]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Decrease stack usage in lexer.
authorVladimir Serbinenko <phcoder@gmail.com>
Sat, 16 Nov 2013 15:37:59 +0000 (16:37 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Sat, 16 Nov 2013 15:37:59 +0000 (16:37 +0100)
We have only 92K of stack and using over 4K per frame is wasteful

* grub-core/script/yylex.l (yyalloc), (yyfree), (yyrealloc): Declare
as macros so that compiler would remove useless structure on stack.
Better solution would be to fix flex not to put this structure on
the stack but flex is external program.

ChangeLog
grub-core/script/yylex.l

index acf26a955f0ef87ce68d078bc3ef09fb147f8ad1..7b5a8125bde07e4e5b18f9f807c2d1fee5725fbf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2013-11-16  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Decrease stack usage in lexer.
+
+       We have only 92K of stack and using over 4K per frame is wasteful
+
+       * grub-core/script/yylex.l (yyalloc), (yyfree), (yyrealloc): Declare
+       as macros so that compiler would remove useless structure on stack.
+       Better solution would be to fix flex not to put this structure on
+       the stack but flex is external program.
+
 2013-11-16  Vladimir Serbinenko  <phcoder@gmail.com>
 
        Decrease stack usage in signature verification.
index 6c61f855f12ccbf7a434cd1bab79f0424583ee0f..9c2cfe11531d055278efdd71c2bf4a18adf6cc4f 100644 (file)
@@ -31,9 +31,9 @@
 #pragma GCC diagnostic ignored "-Wunused-function"
 #pragma GCC diagnostic ignored "-Wsign-compare"
 
-#define yyfree    grub_lexer_yyfree
-#define yyalloc   grub_lexer_yyalloc
-#define yyrealloc grub_lexer_yyrealloc
+#define yyalloc(size, scanner)   (grub_malloc((size)))
+#define yyfree(ptr, scanner)   (grub_free((ptr)))
+#define yyrealloc(ptr, size, scanner) (grub_realloc((ptr), (size)))
 
 /* 
  * As we don't have access to yyscanner, we cannot do much except to
@@ -68,9 +68,6 @@
 static int grub_lexer_unput (const char *input, yyscan_t yyscanner);
 static int grub_lexer_resplit (const char *input, yyscan_t yyscanner);
 
-static void  grub_lexer_yyfree (void *, yyscan_t yyscanner);
-static void* grub_lexer_yyalloc (yy_size_t, yyscan_t yyscanner);
-static void* grub_lexer_yyrealloc (void*, yy_size_t, yyscan_t yyscanner);
 static void  copy_string (struct grub_parser_param *, const char *,
                           unsigned hint);
 
@@ -339,25 +336,6 @@ yywrap (yyscan_t yyscanner)
   return grub_script_lexer_yywrap (yyget_extra (yyscanner), 0);
 }
 
-static void
-grub_lexer_yyfree (void *ptr, yyscan_t yyscanner __attribute__ ((unused)))
-{
-  grub_free(ptr);
-}
-
-static void*
-grub_lexer_yyalloc (yy_size_t size, yyscan_t yyscanner __attribute__ ((unused)))
-{
-  return grub_malloc (size);
-}
-
-static void*
-grub_lexer_yyrealloc (void *ptr, yy_size_t size,
-                      yyscan_t yyscanner __attribute__ ((unused)))
-{
-  return grub_realloc (ptr, size);
-}
-
 static void copy_string (struct grub_parser_param *parser, const char *str, unsigned hint)
 {
   grub_size_t size;