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

Issue 5845069: [pph] Add support to re-play actions on types

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years ago by Diego Novillo
Modified:
12 years 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 (+75 lines, -14 lines) Patch
M gcc/cp/ChangeLog.pph View 1 chunk +27 lines, -0 lines 0 comments Download
M gcc/cp/Make-lang.in View 1 chunk +1 line, -1 line 0 comments Download
M gcc/cp/class.c View 2 chunks +4 lines, -0 lines 0 comments Download
M gcc/cp/pph.h View 2 chunks +6 lines, -2 lines 0 comments Download
M gcc/cp/pph-in.c View 3 chunks +16 lines, -10 lines 0 comments Download
M gcc/cp/pph-out.c View 2 chunks +21 lines, -1 line 0 comments Download

Messages

Total messages: 1
Diego Novillo
12 years ago (2012-03-19 19:21:17 UTC) #1
Add support to re-play actions on types as well as symbols.

When declaring class types, the parser calls finish_struct_methods to perform
things like sorting the method vector for the class.  This needs
to be done at reading time, because the sorting is done based on
the pointer values of the entries in the method vector.

We were eagerly doing this for *all* class types we read from PPH
images, but this is not applicable to all class types.  Using the
symtab to replay this action allows us to do it exactly on the
same classes done during the original parse.

The symbol table needs renaming now.  Done in a subsequent patch.

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

	* Make-lang.in (cp/class.o): Add dependency on PPH_H.
	* class.c (finish_struct_methods): If pph_writer_enabled_p
	returns true, call pph_add_type_to_symtab.
	* pph-in.c (pph_in_tcc_type): Do not call finish_struct_methods.
	(pph_in_symtab_action): Handle PPH_SYMTAB_FINISH_STRUCT_METHODS.
	(pph_in_symtab): Likewise.
	* pph-out.c (pph_out_symtab_action): Likewise.
	(pph_add_type_to_symtab): New.
	* pph.h (enum pph_symtab_action): Add PPH_SYMTAB_FINISH_STRUCT_METHODS.
	(pph_add_type_to_symtab): Declare.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/pph@185537
138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/cp/ChangeLog.pph |   27 +++++++++++++++++++++++++++
 gcc/cp/Make-lang.in  |    2 +-
 gcc/cp/class.c       |    4 ++++
 gcc/cp/pph-in.c      |   26 ++++++++++++++++----------
 gcc/cp/pph-out.c     |   22 +++++++++++++++++++++-
 gcc/cp/pph.h         |    7 ++++++-
 6 files changed, 75 insertions(+), 13 deletions(-)

diff --git a/gcc/cp/ChangeLog.pph b/gcc/cp/ChangeLog.pph
index c596b18..1cbf859 100644
--- a/gcc/cp/ChangeLog.pph
+++ b/gcc/cp/ChangeLog.pph
@@ -1,3 +1,30 @@
+2012-03-19   Diego Novillo  <dnovillo@google.com>
+
+	* Make-lang.in (cp/class.o): Add dependency on PPH_H.
+	* class.c (finish_struct_methods): If pph_writer_enabled_p
+	returns true, call pph_add_type_to_symtab.
+	* pph-in.c (pph_in_tcc_type): Do not call finish_struct_methods.
+	(pph_in_symtab_action): Handle PPH_SYMTAB_FINISH_STRUCT_METHODS.
+	(pph_in_symtab): Likewise.
+	* pph-out.c (pph_out_symtab_action): Likewise.
+	(pph_add_type_to_symtab): New.
+	* pph.h (enum pph_symtab_action): Add PPH_SYMTAB_FINISH_STRUCT_METHODS.
+	(pph_add_type_to_symtab): Declare.
+
+2012-03-19   Diego Novillo  <dnovillo@google.com>
+
+	* pph-streamer.h (struct pph_replay_entry): Rename from
+	pph_symtab_entry.
+	Rename field DECL to TO_REPLAY.
+	Update all users.
+	(struct pph_replay): Rename from pph_symtab.
+	(enum pph_replay_action): Rename from pph_symtab_action.
+
+2012-03-17   Diego Novillo  <dnovillo@google.com>
+
+	* parser.c (cp_lexer_print_token): Protect against NULL
+	values in CPP_NAME tokens.
+
 2012-03-16   Lawrence Crowl  <crowl@google.com>
 
 	* cp-tree.h (make_anon_name): Add location parameter.
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index 4968367..78328f9 100644
--- a/gcc/cp/Make-lang.in
+++ b/gcc/cp/Make-lang.in
@@ -298,7 +298,7 @@ cp/typeck.o: cp/typeck.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) \
   output.h c-family/c-objc.h
 cp/class.o: cp/class.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h \
   $(TARGET_H) convert.h $(CGRAPH_H) $(TREE_DUMP_H) gt-cp-class.h \
-  $(SPLAY_TREE_H) pointer-set.h
+  $(SPLAY_TREE_H) pointer-set.h $(PPH_H)
 cp/call.o: cp/call.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h \
   $(DIAGNOSTIC_CORE_H) intl.h gt-cp-call.h convert.h $(TARGET_H) langhooks.h \
   $(TIMEVAR_H) c-family/c-objc.h
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index a601df6..3a94bb2 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -38,6 +38,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-dump.h"
 #include "splay-tree.h"
 #include "pointer-set.h"
+#include "pph.h"
 
 /* The number of nested classes being processed.  If we are not in the
    scope of any class, this is zero.  */
@@ -1863,6 +1864,9 @@ finish_struct_methods (tree t)
   if (!method_vec)
     return;
 
+  if (pph_writer_enabled_p ())
+    pph_add_type_to_symtab (t, PPH_SYMTAB_FINISH_STRUCT_METHODS);
+
   len = VEC_length (tree, method_vec);
 
   /* Clear DECL_IN_AGGR_P for all functions.  */
diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c
index ba89aa4..ee72d77 100644
--- a/gcc/cp/pph-in.c
+++ b/gcc/cp/pph-in.c
@@ -2003,15 +2003,6 @@ pph_in_tcc_type (pph_stream *stream, tree type)
     default:
       break;
     }
-
-  /* If TYPE has a METHOD_VEC, we need to resort it.  Name lookup in
-     classes relies on the specific ordering of the class method
-     pointers.  Since we generally instantiate them in a different
-     order than the original compile, the pointer values will be
-     different.  This will cause name lookups to fail, unless we
-     resort the vector.  */
-  if (CLASS_TYPE_P (type) && CLASSTYPE_METHOD_VEC (type))
-    finish_struct_methods (type);
 }
 
 
@@ -2845,7 +2836,10 @@ static inline enum pph_symtab_action
 pph_in_symtab_action (pph_stream *stream)
 {
   enum pph_symtab_action m = (enum pph_symtab_action) pph_in_uchar (stream);
-  gcc_assert (m == PPH_SYMTAB_DECLARE || m == PPH_SYMTAB_EXPAND);
+  gcc_assert (m == PPH_SYMTAB_DECLARE
+	      || m == PPH_SYMTAB_EXPAND
+	      || m == PPH_SYMTAB_EXPAND_1
+	      || m == PPH_SYMTAB_FINISH_STRUCT_METHODS);
   return m;
 }
 
@@ -2963,6 +2957,18 @@ pph_in_symtab (pph_stream *stream)
 	  at_eof = prev_at_eof;
 	  function_depth = prev_function_depth;
 	}
+      else if (entry.action == PPH_SYMTAB_FINISH_STRUCT_METHODS)
+	{
+	  tree type = entry.decl;
+
+	  /* If TYPE has a METHOD_VEC, we need to resort it.  Name
+	     lookup in classes relies on the specific ordering of the
+	     class method pointers.  Since we generally instantiate
+	     them in a different order than the original compile, the
+	     pointer values will be different.  This will cause name
+	     lookups to fail, unless we resort the vector.  */
+	  finish_struct_methods (type);
+	}
       else
 	gcc_unreachable ();
     }
diff --git a/gcc/cp/pph-out.c b/gcc/cp/pph-out.c
index ba24122..751a6f6 100644
--- a/gcc/cp/pph-out.c
+++ b/gcc/cp/pph-out.c
@@ -2430,7 +2430,8 @@ pph_out_symtab_action (pph_stream *stream, enum
pph_symtab_action action)
 {
   gcc_assert ((action == PPH_SYMTAB_DECLARE
 	       || action == PPH_SYMTAB_EXPAND
-	       || action == PPH_SYMTAB_EXPAND_1)
+	       || action == PPH_SYMTAB_EXPAND_1
+	       || action == PPH_SYMTAB_FINISH_STRUCT_METHODS)
               && (enum pph_symtab_action)(unsigned char) action);
   pph_out_uchar (stream, action);
 }
@@ -2469,6 +2470,25 @@ pph_add_decl_to_symtab (tree decl, enum pph_symtab_action
action,
 }
 
 
+/* Add TYPE to the symbol table, to be re-played according to ACTION.  */
+
+void
+pph_add_type_to_symtab (tree type, enum pph_symtab_action action)
+{
+  pph_symtab_entry entry;
+
+  if (pph_out_stream == NULL)
+    return;
+
+  gcc_assert (TYPE_P (type));
+
+  memset (&entry, 0, sizeof (entry));
+  entry.action = action;
+  entry.decl = type;
+  VEC_safe_push (pph_symtab_entry, heap, pph_out_stream->symtab.v, &entry);
+}
+
+
 /* Emit the symbol table for STREAM.  When this image is read into
    another translation unit, we want to guarantee that the IL
    instances taken from this image are instantiated in the same order
diff --git a/gcc/cp/pph.h b/gcc/cp/pph.h
index e4fd009..25b3f84 100644
--- a/gcc/cp/pph.h
+++ b/gcc/cp/pph.h
@@ -42,7 +42,11 @@ enum pph_symtab_action {
   PPH_SYMTAB_EXPAND,
 
   /* Expand this function with expand_or_defer_fn_1.  */
-  PPH_SYMTAB_EXPAND_1
+  PPH_SYMTAB_EXPAND_1,
+
+  /* Layout the method vector for this type with
+     finish_struct_methods.  */
+  PPH_SYMTAB_FINISH_STRUCT_METHODS
 };
 
 /* Record markers.  */
@@ -161,6 +165,7 @@ extern void pph_out_merge_key_tree (pph_stream *, tree,
bool);
 extern void pph_out_record_marker (pph_stream *stream,
 			enum pph_record_marker marker, enum pph_tag tag);
 void pph_add_decl_to_symtab (tree, enum pph_symtab_action, bool, bool);
+void pph_add_type_to_symtab (tree, enum pph_symtab_action);
 
 /* In pph-in.c.  */
 extern unsigned int pph_in_uint (pph_stream *stream);
-- 
1.7.7.3


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

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