2008-09-30 Maciej Stachowiak <mjs@apple.com>
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Oct 2008 02:57:53 +0000 (02:57 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Oct 2008 02:57:53 +0000 (02:57 +0000)
        Reviewed by Oliver Hunt.

        - track uses of "this", "with" and "catch" in the parser

        Knowing this up front will be useful for future optimizations.

        Perf and correctness remain the same.

        * kjs/NodeInfo.h:
        * kjs/grammar.y:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37132 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/NodeInfo.h
JavaScriptCore/kjs/grammar.y

index 05fd54c797f8ae696bc715d77f9e1112c26eeffb..a79577867454b0915318856fe951efe72a14ad86 100644 (file)
@@ -1,3 +1,16 @@
+2008-09-30  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        - track uses of "this", "with" and "catch" in the parser
+        
+        Knowing this up front will be useful for future optimizations.
+        
+        Perf and correctness remain the same.
+        
+        * kjs/NodeInfo.h:
+        * kjs/grammar.y:
+
 2008-09-30  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Mark Rowe.
index 420e153c623698d8104f4da1d54baeeccddc17d7..35ce0ef3866adb62b342def95d50d8f5c37ef6ca 100644 (file)
@@ -32,6 +32,10 @@ namespace JSC {
     const FeatureInfo ClosureFeature = 1 << 1;
     const FeatureInfo AssignFeature = 1 << 2;
     const FeatureInfo ArgumentsFeature = 1 << 3;
+    const FeatureInfo WithFeature = 1 << 4;
+    const FeatureInfo CatchFeature = 1 << 5;
+    const FeatureInfo ThisFeature = 1 << 6;
+    const FeatureInfo AllFeatures = EvalFeature | ClosureFeature | AssignFeature | ArgumentsFeature | WithFeature | CatchFeature | ThisFeature;
 
     template <typename T> struct NodeFeatureInfo {
         T m_node;
index 39336525f4d3feef304dd32d5a63a5187a3fffac..e791a4201635e87060edd89dfc92f7213814fb8b 100644 (file)
@@ -103,14 +103,14 @@ template <typename T> NodeDeclarationInfo<T> createNodeDeclarationInfo(T node, P
                                                                        FeatureInfo info,
                                                                        int numConstants) 
 {
-    ASSERT((info & ~(EvalFeature | ClosureFeature | AssignFeature | ArgumentsFeature)) == 0);
+    ASSERT((info & ~AllFeatures) == 0);
     NodeDeclarationInfo<T> result = {node, varDecls, funcDecls, info, numConstants};
     return result;
 }
 
 template <typename T> NodeFeatureInfo<T> createNodeFeatureInfo(T node, FeatureInfo info, int numConstants)
 {
-    ASSERT((info & ~(EvalFeature | ClosureFeature | AssignFeature | ArgumentsFeature)) == 0);
+    ASSERT((info & ~AllFeatures) == 0);
     NodeFeatureInfo<T> result = {node, info, numConstants};
     return result;
 }
@@ -337,7 +337,7 @@ PrimaryExpr:
 ;
 
 PrimaryExprNoBrace:
-    THISTOKEN                           { $$ = createNodeFeatureInfo<ExpressionNode*>(new ThisNode(GLOBAL_DATA), 0, 0); }
+    THISTOKEN                           { $$ = createNodeFeatureInfo<ExpressionNode*>(new ThisNode(GLOBAL_DATA), ThisFeature, 0); }
   | Literal
   | ArrayLiteral
   | IDENT                               { $$ = createNodeFeatureInfo<ExpressionNode*>(new ResolveNode(GLOBAL_DATA, *$1, @1.first_column), (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0, 0); }
@@ -1058,7 +1058,7 @@ ReturnStatement:
 
 WithStatement:
     WITH '(' Expr ')' Statement         { $$ = createNodeDeclarationInfo<StatementNode*>(new WithNode(GLOBAL_DATA, $3.m_node, $5.m_node, @3.last_column, @3.last_column - @3.first_column),
-                                                                                         $5.m_varDeclarations, $5.m_funcDeclarations, $3.m_featureInfo | $5.m_featureInfo, $3.m_numConstants + $5.m_numConstants);
+                                                                                         $5.m_varDeclarations, $5.m_funcDeclarations, $3.m_featureInfo | $5.m_featureInfo | WithFeature, $3.m_numConstants + $5.m_numConstants);
                                           DBG($$.m_node, @1, @4); }
 ;
 
@@ -1137,14 +1137,14 @@ TryStatement:
   | TRY Block CATCH '(' IDENT ')' Block { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, $2.m_node, *$5, $7.m_node, 0),
                                                                                          mergeDeclarationLists($2.m_varDeclarations, $7.m_varDeclarations),
                                                                                          mergeDeclarationLists($2.m_funcDeclarations, $7.m_funcDeclarations),
-                                                                                         $2.m_featureInfo | $7.m_featureInfo,
+                                                                                         $2.m_featureInfo | $7.m_featureInfo | CatchFeature,
                                                                                          $2.m_numConstants + $7.m_numConstants);
                                           DBG($$.m_node, @1, @2); }
   | TRY Block CATCH '(' IDENT ')' Block FINALLY Block
                                         { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, $2.m_node, *$5, $7.m_node, $9.m_node),
                                                                                          mergeDeclarationLists(mergeDeclarationLists($2.m_varDeclarations, $7.m_varDeclarations), $9.m_varDeclarations),
                                                                                          mergeDeclarationLists(mergeDeclarationLists($2.m_funcDeclarations, $7.m_funcDeclarations), $9.m_funcDeclarations),
-                                                                                         $2.m_featureInfo | $7.m_featureInfo | $9.m_featureInfo,
+                                                                                         $2.m_featureInfo | $7.m_featureInfo | $9.m_featureInfo | CatchFeature,
                                                                                          $2.m_numConstants + $7.m_numConstants + $9.m_numConstants);
                                           DBG($$.m_node, @1, @2); }
 ;