Title: [189819] trunk/Source/_javascript_Core
Revision
189819
Author
commit-qu...@webkit.org
Date
2015-09-15 12:26:45 -0700 (Tue, 15 Sep 2015)

Log Message

functions that use try/catch will allocate a top level JSLexicalEnvironment even when it is not necessary
https://bugs.webkit.org/show_bug.cgi?id=148169

Patch by Saam barati <sbar...@apple.com> on 2015-09-15
Reviewed by Geoffrey Garen.

We used to do this before we had proper lexical scoping
in the bytecode generator. There is absolutely no reason
why need to allocate a top-level "var" activation when a
function/program uses a "catch" block.

* parser/ASTBuilder.h:
(JSC::ASTBuilder::createTryStatement):
(JSC::ASTBuilder::incConstants):
(JSC::ASTBuilder::usesThis):
(JSC::ASTBuilder::usesArguments):
(JSC::ASTBuilder::usesWith):
(JSC::ASTBuilder::usesEval):
(JSC::ASTBuilder::usesCatch): Deleted.
* parser/Nodes.h:
(JSC::ScopeNode::isStrictMode):
(JSC::ScopeNode::setUsesArguments):
(JSC::ScopeNode::usesThis):
(JSC::ScopeNode::needsActivation):
(JSC::ScopeNode::hasCapturedVariables):
(JSC::ScopeNode::captures):
(JSC::ScopeNode::needsActivationForMoreThanVariables): Deleted.
* parser/ParserModes.h:
* runtime/Executable.h:
(JSC::ScriptExecutable::usesEval):
(JSC::ScriptExecutable::usesArguments):
(JSC::ScriptExecutable::needsActivation):
(JSC::ScriptExecutable::isStrictMode):
(JSC::ScriptExecutable::ecmaMode):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (189818 => 189819)


--- trunk/Source/_javascript_Core/ChangeLog	2015-09-15 19:00:13 UTC (rev 189818)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-09-15 19:26:45 UTC (rev 189819)
@@ -1,3 +1,39 @@
+2015-09-15  Saam barati  <sbar...@apple.com>
+
+        functions that use try/catch will allocate a top level JSLexicalEnvironment even when it is not necessary
+        https://bugs.webkit.org/show_bug.cgi?id=148169
+
+        Reviewed by Geoffrey Garen.
+
+        We used to do this before we had proper lexical scoping
+        in the bytecode generator. There is absolutely no reason
+        why need to allocate a top-level "var" activation when a
+        function/program uses a "catch" block.
+
+        * parser/ASTBuilder.h:
+        (JSC::ASTBuilder::createTryStatement):
+        (JSC::ASTBuilder::incConstants):
+        (JSC::ASTBuilder::usesThis):
+        (JSC::ASTBuilder::usesArguments):
+        (JSC::ASTBuilder::usesWith):
+        (JSC::ASTBuilder::usesEval):
+        (JSC::ASTBuilder::usesCatch): Deleted.
+        * parser/Nodes.h:
+        (JSC::ScopeNode::isStrictMode):
+        (JSC::ScopeNode::setUsesArguments):
+        (JSC::ScopeNode::usesThis):
+        (JSC::ScopeNode::needsActivation):
+        (JSC::ScopeNode::hasCapturedVariables):
+        (JSC::ScopeNode::captures):
+        (JSC::ScopeNode::needsActivationForMoreThanVariables): Deleted.
+        * parser/ParserModes.h:
+        * runtime/Executable.h:
+        (JSC::ScriptExecutable::usesEval):
+        (JSC::ScriptExecutable::usesArguments):
+        (JSC::ScriptExecutable::needsActivation):
+        (JSC::ScriptExecutable::isStrictMode):
+        (JSC::ScriptExecutable::ecmaMode):
+
 2015-09-15  Michael Saboff  <msab...@apple.com>
 
         REGRESSION(r189774): CLoop doesn't build after r189774

Modified: trunk/Source/_javascript_Core/parser/ASTBuilder.h (189818 => 189819)


--- trunk/Source/_javascript_Core/parser/ASTBuilder.h	2015-09-15 19:00:13 UTC (rev 189818)
+++ trunk/Source/_javascript_Core/parser/ASTBuilder.h	2015-09-15 19:26:45 UTC (rev 189819)
@@ -571,8 +571,6 @@
     StatementNode* createTryStatement(const JSTokenLocation& location, StatementNode* tryBlock, const Identifier* ident, StatementNode* catchBlock, StatementNode* finallyBlock, int startLine, int endLine, VariableEnvironment& catchEnvironment)
     {
         TryNode* result = new (m_parserArena) TryNode(location, tryBlock, *ident, catchBlock, catchEnvironment, finallyBlock);
-        if (catchBlock)
-            usesCatch();
         result->setLoc(startLine, endLine, location.startOffset, location.lineStartOffset);
         return result;
     }
@@ -878,7 +876,6 @@
 
     void incConstants() { m_scope.m_numConstants++; }
     void usesThis() { m_scope.m_features |= ThisFeature; }
-    void usesCatch() { m_scope.m_features |= CatchFeature; }
     void usesArguments() { m_scope.m_features |= ArgumentsFeature; }
     void usesWith() { m_scope.m_features |= WithFeature; }
     void usesEval() 

Modified: trunk/Source/_javascript_Core/parser/Nodes.h (189818 => 189819)


--- trunk/Source/_javascript_Core/parser/Nodes.h	2015-09-15 19:00:13 UTC (rev 189818)
+++ trunk/Source/_javascript_Core/parser/Nodes.h	2015-09-15 19:26:45 UTC (rev 189819)
@@ -1554,8 +1554,7 @@
         bool isStrictMode() const { return m_features & StrictModeFeature; }
         void setUsesArguments() { m_features |= ArgumentsFeature; }
         bool usesThis() const { return m_features & ThisFeature; }
-        bool needsActivationForMoreThanVariables() const { return m_features & (EvalFeature | WithFeature | CatchFeature); }
-        bool needsActivation() const { return (hasCapturedVariables()) || (m_features & (EvalFeature | WithFeature | CatchFeature)); }
+        bool needsActivation() const { return (hasCapturedVariables()) || (m_features & (EvalFeature | WithFeature)); }
         bool hasCapturedVariables() const { return m_varDeclarations.hasCapturedVariables(); }
         bool captures(UniquedStringImpl* uid) { return m_varDeclarations.captures(uid); }
         bool captures(const Identifier& ident) { return captures(ident.impl()); }

Modified: trunk/Source/_javascript_Core/parser/ParserModes.h (189818 => 189819)


--- trunk/Source/_javascript_Core/parser/ParserModes.h	2015-09-15 19:00:13 UTC (rev 189818)
+++ trunk/Source/_javascript_Core/parser/ParserModes.h	2015-09-15 19:26:45 UTC (rev 189819)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2013, 2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -139,18 +139,17 @@
 
 typedef unsigned CodeFeatures;
 
-const CodeFeatures NoFeatures = 0;
-const CodeFeatures EvalFeature = 1 << 0;
-const CodeFeatures ArgumentsFeature = 1 << 1;
-const CodeFeatures WithFeature = 1 << 2;
-const CodeFeatures CatchFeature = 1 << 3;
-const CodeFeatures ThisFeature = 1 << 4;
-const CodeFeatures StrictModeFeature = 1 << 5;
-const CodeFeatures ShadowsArgumentsFeature = 1 << 6;
-const CodeFeatures ModifiedParameterFeature = 1 << 7;
-const CodeFeatures ModifiedArgumentsFeature = 1 << 8;
+const CodeFeatures NoFeatures =                    0;
+const CodeFeatures EvalFeature =              1 << 0;
+const CodeFeatures ArgumentsFeature =         1 << 1;
+const CodeFeatures WithFeature =              1 << 2;
+const CodeFeatures ThisFeature =              1 << 3;
+const CodeFeatures StrictModeFeature =        1 << 4;
+const CodeFeatures ShadowsArgumentsFeature =  1 << 5;
+const CodeFeatures ModifiedParameterFeature = 1 << 6;
+const CodeFeatures ModifiedArgumentsFeature = 1 << 7;
 
-const CodeFeatures AllFeatures = EvalFeature | ArgumentsFeature | WithFeature | CatchFeature | ThisFeature | StrictModeFeature | ShadowsArgumentsFeature | ModifiedParameterFeature;
+const CodeFeatures AllFeatures = EvalFeature | ArgumentsFeature | WithFeature | ThisFeature | StrictModeFeature | ShadowsArgumentsFeature | ModifiedParameterFeature;
 
 } // namespace JSC
 

Modified: trunk/Source/_javascript_Core/runtime/Executable.h (189818 => 189819)


--- trunk/Source/_javascript_Core/runtime/Executable.h	2015-09-15 19:00:13 UTC (rev 189818)
+++ trunk/Source/_javascript_Core/runtime/Executable.h	2015-09-15 19:26:45 UTC (rev 189819)
@@ -388,7 +388,7 @@
 
     bool usesEval() const { return m_features & EvalFeature; }
     bool usesArguments() const { return m_features & ArgumentsFeature; }
-    bool needsActivation() const { return m_hasCapturedVariables || m_features & (EvalFeature | WithFeature | CatchFeature); }
+    bool needsActivation() const { return m_hasCapturedVariables || m_features & (EvalFeature | WithFeature); }
     bool isStrictMode() const { return m_features & StrictModeFeature; }
     ECMAMode ecmaMode() const { return isStrictMode() ? StrictMode : NotStrictMode; }
         
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to