Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1128)

Issue 5822055: [pph] Add a GC root for the lexer (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 1 month ago by Diego Novillo
Modified:
12 years, 1 month ago
Reviewers:
CC:
Lawrence Crowl, gcc-patches_gcc.gnu.org
Visibility:
Public.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+10 lines, -1 line) Patch
M gcc/cp/parser.c View 3 chunks +10 lines, -1 line 0 comments Download

Messages

Total messages: 1
Diego Novillo
12 years, 1 month ago (2012-03-14 23:56:06 UTC) #1
Add a GC root for the lexer.

This GC root is required to support running the garbage collector
during lexing.  This happens when the lexer loads pre-parsed headers.
Loading these headers calls into the middle-end, which may run the
garbage collector.

This was triggering in some of the bigger translation units that cause
a lot of GC activity.

2012-03-14   Diego Novillo  <dnovillo@google.com>

	* parser.c (the_lexer): Declare.
	(cp_lexer_new_main): Initialize.
	(c_parse_file): Set to NULL.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 8c231c02..0d87b0f 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -613,6 +613,14 @@ cp_lexer_alloc (void)
 }
 
 
+/* The lexer.   This GC root is required to support running the
+   garbage collector during lexing.  This happens when the lexer loads
+   pre-parsed headers.  Loading these headers calls into the
+   middle-end, which may run the garbage collector.  */
+
+static GTY (()) cp_lexer *the_lexer;
+
+
 /* Create a new main C++ lexer, the lexer that gets tokens from the
    preprocessor.  */
 
@@ -627,7 +635,7 @@ cp_lexer_new_main (void)
      allocating any memory.  */
   cp_parser_initial_pragma (&token);
 
-  lexer = cp_lexer_alloc ();
+  the_lexer = lexer = cp_lexer_alloc ();
 
   /* Put the first token in the buffer.  */
   VEC_quick_push (cp_token, lexer->buffer, &token);
@@ -27497,6 +27505,7 @@ c_parse_file (void)
 				? dk_no_deferred : dk_no_check);
   cp_parser_translation_unit (the_parser);
   the_parser = NULL;
+  the_lexer = NULL;
 
   if (pph_enabled_p ())
     pph_finish ();

--
This patch is available for review at http://codereview.appspot.com/5822055
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b