DFG should inline code blocks that use scoped variable access
[WebKit-https.git] / Source / JavaScriptCore / dfg / DFGCSEPhase.cpp
index 828a31125ae493171b50a74da001f71272c352fe..b914ee10c7100ae31e47c4833d5bae29d93ab05a 100644 (file)
@@ -236,6 +236,13 @@ private:
                     return node.child3().index();
                 break;
             }
+            case SetLocal: {
+                VariableAccessData* variableAccessData = node.variableAccessData();
+                if (variableAccessData->isCaptured()
+                    && variableAccessData->local() == static_cast<VirtualRegister>(varNumber))
+                    return NoNode;
+                break;
+            }
             default:
                 break;
             }
@@ -318,6 +325,14 @@ private:
                     return NoNode;
                 break;
             }
+                
+            case GetLocal: {
+                VariableAccessData* variableAccessData = node.variableAccessData();
+                if (variableAccessData->isCaptured()
+                    && variableAccessData->local() == static_cast<VirtualRegister>(varNumber))
+                    return NoNode;
+                break;
+            }
 
             default:
                 break;
@@ -830,6 +845,11 @@ private:
                 }
                 break;
                 
+            case PutScopedVar:
+                if (static_cast<VirtualRegister>(node.varNumber()) == local)
+                    return NoNode;
+                break;
+                
             default:
                 if (careAboutClobbering && m_graph.clobbersWorld(index))
                     return NoNode;
@@ -882,9 +902,13 @@ private:
                 return result;
             }
                 
+            case GetScopedVar:
+                if (static_cast<VirtualRegister>(node.varNumber()) == local)
+                    result.mayBeAccessed = true;
+                break;
+                
             case GetMyScope:
             case SkipTopScope:
-            case GetScopeRegisters:
                 if (m_graph.uncheckedActivationRegisterFor(node.codeOrigin) == local)
                     result.mayBeAccessed = true;
                 break;