<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[198228] trunk/Source/JavaScriptCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/198228">198228</a></dd>
<dt>Author</dt> <dd>sbarati@apple.com</dd>
<dt>Date</dt> <dd>2016-03-15 13:41:00 -0700 (Tue, 15 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>We should have different JSTypes for JSGlobalLexicalEnvironment and JSLexicalEnvironment and JSModuleEnvironment
https://bugs.webkit.org/show_bug.cgi?id=152406

Reviewed by Mark Lam.

This makes testing for a JSGlobalLexicalEnvironment faster
because we can just check the Cell's type instead of using
jsDynamicCast. I also changed code that does jsDynamicCast&lt;JSGlobalObject*&gt;
instead of isGlobalObject().

* interpreter/Interpreter.cpp:
(JSC::Interpreter::execute):
* jit/JITOperations.cpp:
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
* runtime/CommonSlowPaths.cpp:
(JSC::SLOW_PATH_DECL):
* runtime/CommonSlowPaths.h:
(JSC::CommonSlowPaths::tryCachePutToScopeGlobal):
(JSC::CommonSlowPaths::tryCacheGetFromScopeGlobal):
* runtime/JSGlobalLexicalEnvironment.h:
(JSC::JSGlobalLexicalEnvironment::createStructure):
* runtime/JSLexicalEnvironment.h:
(JSC::JSLexicalEnvironment::createStructure):
(JSC::JSLexicalEnvironment::JSLexicalEnvironment):
* runtime/JSModuleEnvironment.h:
(JSC::JSModuleEnvironment::createStructure):
(JSC::JSModuleEnvironment::offsetOfModuleRecord):
* runtime/JSObject.h:
(JSC::JSObject::isGlobalObject):
(JSC::JSObject::isJSLexicalEnvironment):
(JSC::JSObject::isGlobalLexicalEnvironment):
(JSC::JSObject::isErrorInstance):
* runtime/JSScope.cpp:
(JSC::abstractAccess):
(JSC::isUnscopable):
(JSC::JSScope::resolve):
(JSC::JSScope::collectVariablesUnderTDZ):
(JSC::JSScope::isVarScope):
(JSC::JSScope::isLexicalScope):
(JSC::JSScope::isModuleScope):
(JSC::JSScope::isCatchScope):
(JSC::JSScope::isFunctionNameScopeObject):
(JSC::JSScope::isNestedLexicalScope):
(JSC::JSScope::constantScopeForCodeBlock):
(JSC::isScopeType): Deleted.
(JSC::JSScope::isGlobalLexicalEnvironment): Deleted.
* runtime/JSScope.h:
* runtime/JSType.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinterpreterInterpretercpp">trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITOperationscpp">trunk/Source/JavaScriptCore/jit/JITOperations.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorellintLLIntSlowPathscpp">trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCommonSlowPathscpp">trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCommonSlowPathsh">trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalLexicalEnvironmenth">trunk/Source/JavaScriptCore/runtime/JSGlobalLexicalEnvironment.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSLexicalEnvironmenth">trunk/Source/JavaScriptCore/runtime/JSLexicalEnvironment.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSModuleEnvironmenth">trunk/Source/JavaScriptCore/runtime/JSModuleEnvironment.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSObjecth">trunk/Source/JavaScriptCore/runtime/JSObject.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSScopecpp">trunk/Source/JavaScriptCore/runtime/JSScope.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSScopeh">trunk/Source/JavaScriptCore/runtime/JSScope.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSTypeh">trunk/Source/JavaScriptCore/runtime/JSType.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (198227 => 198228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-03-15 20:41:00 UTC (rev 198228)
</span><span class="lines">@@ -1,3 +1,55 @@
</span><ins>+2016-03-15  Saam Barati  &lt;sbarati@apple.com&gt;
+
+        We should have different JSTypes for JSGlobalLexicalEnvironment and JSLexicalEnvironment and JSModuleEnvironment
+        https://bugs.webkit.org/show_bug.cgi?id=152406
+
+        Reviewed by Mark Lam.
+
+        This makes testing for a JSGlobalLexicalEnvironment faster
+        because we can just check the Cell's type instead of using
+        jsDynamicCast. I also changed code that does jsDynamicCast&lt;JSGlobalObject*&gt;
+        instead of isGlobalObject().
+
+        * interpreter/Interpreter.cpp:
+        (JSC::Interpreter::execute):
+        * jit/JITOperations.cpp:
+        * llint/LLIntSlowPaths.cpp:
+        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
+        * runtime/CommonSlowPaths.cpp:
+        (JSC::SLOW_PATH_DECL):
+        * runtime/CommonSlowPaths.h:
+        (JSC::CommonSlowPaths::tryCachePutToScopeGlobal):
+        (JSC::CommonSlowPaths::tryCacheGetFromScopeGlobal):
+        * runtime/JSGlobalLexicalEnvironment.h:
+        (JSC::JSGlobalLexicalEnvironment::createStructure):
+        * runtime/JSLexicalEnvironment.h:
+        (JSC::JSLexicalEnvironment::createStructure):
+        (JSC::JSLexicalEnvironment::JSLexicalEnvironment):
+        * runtime/JSModuleEnvironment.h:
+        (JSC::JSModuleEnvironment::createStructure):
+        (JSC::JSModuleEnvironment::offsetOfModuleRecord):
+        * runtime/JSObject.h:
+        (JSC::JSObject::isGlobalObject):
+        (JSC::JSObject::isJSLexicalEnvironment):
+        (JSC::JSObject::isGlobalLexicalEnvironment):
+        (JSC::JSObject::isErrorInstance):
+        * runtime/JSScope.cpp:
+        (JSC::abstractAccess):
+        (JSC::isUnscopable):
+        (JSC::JSScope::resolve):
+        (JSC::JSScope::collectVariablesUnderTDZ):
+        (JSC::JSScope::isVarScope):
+        (JSC::JSScope::isLexicalScope):
+        (JSC::JSScope::isModuleScope):
+        (JSC::JSScope::isCatchScope):
+        (JSC::JSScope::isFunctionNameScopeObject):
+        (JSC::JSScope::isNestedLexicalScope):
+        (JSC::JSScope::constantScopeForCodeBlock):
+        (JSC::isScopeType): Deleted.
+        (JSC::JSScope::isGlobalLexicalEnvironment): Deleted.
+        * runtime/JSScope.h:
+        * runtime/JSType.h:
+
</ins><span class="cx"> 2016-03-15  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove the Baker barrier from JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinterpreterInterpretercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp (198227 => 198228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp        2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp        2016-03-15 20:41:00 UTC (rev 198228)
</span><span class="lines">@@ -1202,7 +1202,8 @@
</span><span class="cx">                 variableObject = node;
</span><span class="cx">                 break;
</span><span class="cx">             } 
</span><del>-            if (JSLexicalEnvironment* lexicalEnvironment = jsDynamicCast&lt;JSLexicalEnvironment*&gt;(node)) {
</del><ins>+            if (node-&gt;isJSLexicalEnvironment()) {
+                JSLexicalEnvironment* lexicalEnvironment = jsCast&lt;JSLexicalEnvironment*&gt;(node);
</ins><span class="cx">                 if (lexicalEnvironment-&gt;symbolTable()-&gt;scopeType() == SymbolTable::ScopeType::VarScope) {
</span><span class="cx">                     variableObject = node;
</span><span class="cx">                     break;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITOperationscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITOperations.cpp (198227 => 198228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITOperations.cpp        2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/JavaScriptCore/jit/JITOperations.cpp        2016-03-15 20:41:00 UTC (rev 198228)
</span><span class="lines">@@ -1891,7 +1891,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     JSValue result = JSValue();
</span><del>-    if (jsDynamicCast&lt;JSGlobalLexicalEnvironment*&gt;(scope)) {
</del><ins>+    if (scope-&gt;isGlobalLexicalEnvironment()) {
</ins><span class="cx">         // When we can't statically prove we need a TDZ check, we must perform the check on the slow path.
</span><span class="cx">         result = slot.getValue(exec, ident);
</span><span class="cx">         if (result == jsTDZValue()) {
</span><span class="lines">@@ -1932,7 +1932,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool hasProperty = scope-&gt;hasProperty(exec, ident);
</span><span class="cx">     if (hasProperty
</span><del>-        &amp;&amp; jsDynamicCast&lt;JSGlobalLexicalEnvironment*&gt;(scope)
</del><ins>+        &amp;&amp; scope-&gt;isGlobalLexicalEnvironment()
</ins><span class="cx">         &amp;&amp; getPutInfo.initializationMode() != Initialization) {
</span><span class="cx">         // When we can't statically prove we need a TDZ check, we must perform the check on the slow path.
</span><span class="cx">         PropertySlot slot(scope, PropertySlot::InternalMethodType::Get);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorellintLLIntSlowPathscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp (198227 => 198228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp        2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp        2016-03-15 20:41:00 UTC (rev 198228)
</span><span class="lines">@@ -1422,7 +1422,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     JSValue result = JSValue();
</span><del>-    if (jsDynamicCast&lt;JSGlobalLexicalEnvironment*&gt;(scope)) {
</del><ins>+    if (scope-&gt;isGlobalLexicalEnvironment()) {
</ins><span class="cx">         // When we can't statically prove we need a TDZ check, we must perform the check on the slow path.
</span><span class="cx">         result = slot.getValue(exec, ident);
</span><span class="cx">         if (result == jsTDZValue())
</span><span class="lines">@@ -1459,7 +1459,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool hasProperty = scope-&gt;hasProperty(exec, ident);
</span><span class="cx">     if (hasProperty
</span><del>-        &amp;&amp; jsDynamicCast&lt;JSGlobalLexicalEnvironment*&gt;(scope)
</del><ins>+        &amp;&amp; scope-&gt;isGlobalLexicalEnvironment()
</ins><span class="cx">         &amp;&amp; getPutInfo.initializationMode() != Initialization) {
</span><span class="cx">         // When we can't statically prove we need a TDZ check, we must perform the check on the slow path.
</span><span class="cx">         PropertySlot slot(scope, PropertySlot::InternalMethodType::Get);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCommonSlowPathscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp (198227 => 198228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp        2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp        2016-03-15 20:41:00 UTC (rev 198228)
</span><span class="lines">@@ -769,7 +769,7 @@
</span><span class="cx">     BEGIN();
</span><span class="cx">     const Identifier&amp; ident = exec-&gt;codeBlock()-&gt;identifier(pc[3].u.operand);
</span><span class="cx">     JSScope* scope = exec-&gt;uncheckedR(pc[2].u.operand).Register::scope();
</span><del>-    JSValue resolvedScope = JSScope::resolve(exec, scope, ident);
</del><ins>+    JSObject* resolvedScope = JSScope::resolve(exec, scope, ident);
</ins><span class="cx"> 
</span><span class="cx">     ResolveType resolveType = static_cast&lt;ResolveType&gt;(pc[4].u.operand);
</span><span class="cx"> 
</span><span class="lines">@@ -777,13 +777,8 @@
</span><span class="cx">     ASSERT(resolveType != ModuleVar);
</span><span class="cx"> 
</span><span class="cx">     if (resolveType == UnresolvedProperty || resolveType == UnresolvedPropertyWithVarInjectionChecks) {
</span><del>-        if (JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsDynamicCast&lt;JSGlobalLexicalEnvironment*&gt;(resolvedScope)) {
-            if (resolveType == UnresolvedProperty)
-                pc[4].u.operand = GlobalLexicalVar;
-            else
-                pc[4].u.operand = GlobalLexicalVarWithVarInjectionChecks;
-            pc[6].u.pointer = globalLexicalEnvironment;
-        } else if (JSGlobalObject* globalObject = jsDynamicCast&lt;JSGlobalObject*&gt;(resolvedScope)) {
</del><ins>+        if (resolvedScope-&gt;isGlobalObject()) {
+            JSGlobalObject* globalObject = jsCast&lt;JSGlobalObject*&gt;(resolvedScope);
</ins><span class="cx">             if (globalObject-&gt;hasProperty(exec, ident)) {
</span><span class="cx">                 if (resolveType == UnresolvedProperty)
</span><span class="cx">                     pc[4].u.operand = GlobalProperty;
</span><span class="lines">@@ -792,6 +787,13 @@
</span><span class="cx"> 
</span><span class="cx">                 pc[6].u.pointer = globalObject;
</span><span class="cx">             }
</span><ins>+        } else if (resolvedScope-&gt;isGlobalLexicalEnvironment()) {
+            JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsCast&lt;JSGlobalLexicalEnvironment*&gt;(resolvedScope);
+            if (resolveType == UnresolvedProperty)
+                pc[4].u.operand = GlobalLexicalVar;
+            else
+                pc[4].u.operand = GlobalLexicalVarWithVarInjectionChecks;
+            pc[6].u.pointer = globalLexicalEnvironment;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCommonSlowPathsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.h (198227 => 198228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.h        2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.h        2016-03-15 20:41:00 UTC (rev 198228)
</span><span class="lines">@@ -100,18 +100,19 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (resolveType == UnresolvedProperty || resolveType == UnresolvedPropertyWithVarInjectionChecks) {
</span><del>-        if (JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsDynamicCast&lt;JSGlobalLexicalEnvironment*&gt;(scope)) {
</del><ins>+        if (scope-&gt;isGlobalObject()) {
+            ResolveType newResolveType = resolveType == UnresolvedProperty ? GlobalProperty : GlobalPropertyWithVarInjectionChecks;
+            resolveType = newResolveType;
+            getPutInfo = GetPutInfo(getPutInfo.resolveMode(), newResolveType, getPutInfo.initializationMode());
+            pc[4].u.operand = getPutInfo.operand();
+        } else if (scope-&gt;isGlobalLexicalEnvironment()) {
+            JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsCast&lt;JSGlobalLexicalEnvironment*&gt;(scope);
</ins><span class="cx">             ResolveType newResolveType = resolveType == UnresolvedProperty ? GlobalLexicalVar : GlobalLexicalVarWithVarInjectionChecks;
</span><span class="cx">             pc[4].u.operand = GetPutInfo(getPutInfo.resolveMode(), newResolveType, getPutInfo.initializationMode()).operand();
</span><span class="cx">             SymbolTableEntry entry = globalLexicalEnvironment-&gt;symbolTable()-&gt;get(ident.impl());
</span><span class="cx">             ASSERT(!entry.isNull());
</span><span class="cx">             pc[5].u.watchpointSet = entry.watchpointSet();
</span><span class="cx">             pc[6].u.pointer = static_cast&lt;void*&gt;(globalLexicalEnvironment-&gt;variableAt(entry.scopeOffset()).slot());
</span><del>-        } else if (jsDynamicCast&lt;JSGlobalObject*&gt;(scope)) {
-            ResolveType newResolveType = resolveType == UnresolvedProperty ? GlobalProperty : GlobalPropertyWithVarInjectionChecks;
-            resolveType = newResolveType;
-            getPutInfo = GetPutInfo(getPutInfo.resolveMode(), newResolveType, getPutInfo.initializationMode());
-            pc[4].u.operand = getPutInfo.operand();
</del><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="lines">@@ -142,17 +143,18 @@
</span><span class="cx">     ResolveType resolveType = getPutInfo.resolveType();
</span><span class="cx"> 
</span><span class="cx">     if (resolveType == UnresolvedProperty || resolveType == UnresolvedPropertyWithVarInjectionChecks) {
</span><del>-        if (JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsDynamicCast&lt;JSGlobalLexicalEnvironment*&gt;(scope)) {
</del><ins>+        if (scope-&gt;isGlobalObject()) {
+            ResolveType newResolveType = resolveType == UnresolvedProperty ? GlobalProperty : GlobalPropertyWithVarInjectionChecks;
+            resolveType = newResolveType; // Allow below caching mechanism to kick in.
+            pc[4].u.operand = GetPutInfo(getPutInfo.resolveMode(), newResolveType, getPutInfo.initializationMode()).operand();
+        } else if (scope-&gt;isGlobalLexicalEnvironment()) {
+            JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsCast&lt;JSGlobalLexicalEnvironment*&gt;(scope);
</ins><span class="cx">             ResolveType newResolveType = resolveType == UnresolvedProperty ? GlobalLexicalVar : GlobalLexicalVarWithVarInjectionChecks;
</span><span class="cx">             pc[4].u.operand = GetPutInfo(getPutInfo.resolveMode(), newResolveType, getPutInfo.initializationMode()).operand();
</span><span class="cx">             SymbolTableEntry entry = globalLexicalEnvironment-&gt;symbolTable()-&gt;get(ident.impl());
</span><span class="cx">             ASSERT(!entry.isNull());
</span><span class="cx">             pc[5].u.watchpointSet = entry.watchpointSet();
</span><span class="cx">             pc[6].u.pointer = static_cast&lt;void*&gt;(globalLexicalEnvironment-&gt;variableAt(entry.scopeOffset()).slot());
</span><del>-        } else if (jsDynamicCast&lt;JSGlobalObject*&gt;(scope)) {
-            ResolveType newResolveType = resolveType == UnresolvedProperty ? GlobalProperty : GlobalPropertyWithVarInjectionChecks;
-            resolveType = newResolveType; // Allow below caching mechanism to kick in.
-            pc[4].u.operand = GetPutInfo(getPutInfo.resolveMode(), newResolveType, getPutInfo.initializationMode()).operand();
</del><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalLexicalEnvironmenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalLexicalEnvironment.h (198227 => 198228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalLexicalEnvironment.h        2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalLexicalEnvironment.h        2016-03-15 20:41:00 UTC (rev 198228)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx"> 
</span><span class="cx">     static Structure* createStructure(VM&amp; vm, JSGlobalObject* globalObject)
</span><span class="cx">     {
</span><del>-        return Structure::create(vm, globalObject, jsNull(), TypeInfo(ClosureObjectType, StructureFlags), info());
</del><ins>+        return Structure::create(vm, globalObject, jsNull(), TypeInfo(GlobalLexicalEnvironmentType, StructureFlags), info());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> protected:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSLexicalEnvironmenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSLexicalEnvironment.h (198227 => 198228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSLexicalEnvironment.h        2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/JavaScriptCore/runtime/JSLexicalEnvironment.h        2016-03-15 20:41:00 UTC (rev 198228)
</span><span class="lines">@@ -75,7 +75,7 @@
</span><span class="cx"> 
</span><span class="cx">     DECLARE_INFO;
</span><span class="cx"> 
</span><del>-    static Structure* createStructure(VM&amp; vm, JSGlobalObject* globalObject) { return Structure::create(vm, globalObject, jsNull(), TypeInfo(ClosureObjectType, StructureFlags), info()); }
</del><ins>+    static Structure* createStructure(VM&amp; vm, JSGlobalObject* globalObject) { return Structure::create(vm, globalObject, jsNull(), TypeInfo(LexicalEnvironmentType, StructureFlags), info()); }
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> inline JSLexicalEnvironment::JSLexicalEnvironment(VM&amp; vm, Structure* structure, JSScope* currentScope, SymbolTable* symbolTable)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSModuleEnvironmenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSModuleEnvironment.h (198227 => 198228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSModuleEnvironment.h        2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/JavaScriptCore/runtime/JSModuleEnvironment.h        2016-03-15 20:41:00 UTC (rev 198228)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx"> 
</span><span class="cx">     static Structure* createStructure(VM&amp; vm, JSGlobalObject* globalObject)
</span><span class="cx">     {
</span><del>-        return Structure::create(vm, globalObject, jsNull(), TypeInfo(ObjectType, StructureFlags), info());
</del><ins>+        return Structure::create(vm, globalObject, jsNull(), TypeInfo(ModuleEnvironmentType, StructureFlags), info());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     static size_t offsetOfModuleRecord(SymbolTable* symbolTable)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSObject.h (198227 => 198228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSObject.h        2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/JavaScriptCore/runtime/JSObject.h        2016-03-15 20:41:00 UTC (rev 198228)
</span><span class="lines">@@ -641,6 +641,8 @@
</span><span class="cx">     JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, const PropertyDescriptor&amp;, bool shouldThrow);
</span><span class="cx"> 
</span><span class="cx">     bool isGlobalObject() const;
</span><ins>+    bool isJSLexicalEnvironment() const;
+    bool isGlobalLexicalEnvironment() const;
</ins><span class="cx">     bool isErrorInstance() const;
</span><span class="cx">     bool isWithScope() const;
</span><span class="cx"> 
</span><span class="lines">@@ -1076,6 +1078,16 @@
</span><span class="cx">     return type() == GlobalObjectType;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline bool JSObject::isJSLexicalEnvironment() const
+{
+    return type() == LexicalEnvironmentType || type() == ModuleEnvironmentType;
+}
+
+inline bool JSObject::isGlobalLexicalEnvironment() const
+{
+    return type() == GlobalLexicalEnvironmentType;
+}
+
</ins><span class="cx"> inline bool JSObject::isErrorInstance() const
</span><span class="cx"> {
</span><span class="cx">     return type() == ErrorInstanceType;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSScopecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSScope.cpp (198227 => 198228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSScope.cpp        2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/JavaScriptCore/runtime/JSScope.cpp        2016-03-15 20:41:00 UTC (rev 198228)
</span><span class="lines">@@ -48,7 +48,8 @@
</span><span class="cx"> // Returns true if we found enough information to terminate optimization.
</span><span class="cx"> static inline bool abstractAccess(ExecState* exec, JSScope* scope, const Identifier&amp; ident, GetOrPut getOrPut, size_t depth, bool&amp; needsVarInjectionChecks, ResolveOp&amp; op, InitializationMode initializationMode)
</span><span class="cx"> {
</span><del>-    if (JSLexicalEnvironment* lexicalEnvironment = jsDynamicCast&lt;JSLexicalEnvironment*&gt;(scope)) {
</del><ins>+    if (scope-&gt;isJSLexicalEnvironment()) {
+        JSLexicalEnvironment* lexicalEnvironment = jsCast&lt;JSLexicalEnvironment*&gt;(scope);
</ins><span class="cx">         if (ident == exec-&gt;propertyNames().arguments) {
</span><span class="cx">             // We know the property will be at this lexical environment scope, but we don't know how to cache it.
</span><span class="cx">             op = ResolveOp(Dynamic, 0, 0, 0, 0, 0);
</span><span class="lines">@@ -67,7 +68,8 @@
</span><span class="cx">             return true;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (JSModuleEnvironment* moduleEnvironment = jsDynamicCast&lt;JSModuleEnvironment*&gt;(scope)) {
</del><ins>+        if (scope-&gt;type() == ModuleEnvironmentType) {
+            JSModuleEnvironment* moduleEnvironment = jsCast&lt;JSModuleEnvironment*&gt;(scope);
</ins><span class="cx">             JSModuleRecord* moduleRecord = moduleEnvironment-&gt;moduleRecord();
</span><span class="cx">             JSModuleRecord::Resolution resolution = moduleRecord-&gt;resolveImport(exec, ident);
</span><span class="cx">             if (resolution.type == JSModuleRecord::Resolution::Type::Resolved) {
</span><span class="lines">@@ -85,7 +87,8 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsDynamicCast&lt;JSGlobalLexicalEnvironment*&gt;(scope)) {
</del><ins>+    if (scope-&gt;isGlobalLexicalEnvironment()) {
+        JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsCast&lt;JSGlobalLexicalEnvironment*&gt;(scope);
</ins><span class="cx">         SymbolTableEntry entry = globalLexicalEnvironment-&gt;symbolTable()-&gt;get(ident.impl());
</span><span class="cx">         if (!entry.isNull()) {
</span><span class="cx">             if (getOrPut == Put &amp;&amp; entry.isReadOnly() &amp;&amp; initializationMode != Initialization) {
</span><span class="lines">@@ -112,7 +115,8 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (JSGlobalObject* globalObject = jsDynamicCast&lt;JSGlobalObject*&gt;(scope)) {
</del><ins>+    if (scope-&gt;isGlobalObject()) {
+        JSGlobalObject* globalObject = jsCast&lt;JSGlobalObject*&gt;(scope);
</ins><span class="cx">         SymbolTableEntry entry = globalObject-&gt;symbolTable()-&gt;get(ident.impl());
</span><span class="cx">         if (!entry.isNull()) {
</span><span class="cx">             if (getOrPut == Put &amp;&amp; entry.isReadOnly()) {
</span><span class="lines">@@ -190,7 +194,7 @@
</span><span class="cx">     return blocked.toBoolean(exec);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSValue JSScope::resolve(ExecState* exec, JSScope* scope, const Identifier&amp; ident)
</del><ins>+JSObject* JSScope::resolve(ExecState* exec, JSScope* scope, const Identifier&amp; ident)
</ins><span class="cx"> {
</span><span class="cx">     ScopeChainIterator end = scope-&gt;end();
</span><span class="cx">     ScopeChainIterator it = scope-&gt;begin();
</span><span class="lines">@@ -246,51 +250,44 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-template &lt;typename EnvironmentType, SymbolTable::ScopeType scopeType&gt;
-inline static bool isScopeType(JSScope* scope)
</del><ins>+bool JSScope::isVarScope()
</ins><span class="cx"> {
</span><del>-    EnvironmentType* environment = jsDynamicCast&lt;EnvironmentType*&gt;(scope);
-    if (!environment)
</del><ins>+    if (type() != LexicalEnvironmentType)
</ins><span class="cx">         return false;
</span><del>-
-    return environment-&gt;symbolTable()-&gt;scopeType() == scopeType;
</del><ins>+    return jsCast&lt;JSLexicalEnvironment*&gt;(this)-&gt;symbolTable()-&gt;scopeType() == SymbolTable::ScopeType::VarScope;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool JSScope::isVarScope()
-{
-    return isScopeType&lt;JSLexicalEnvironment, SymbolTable::ScopeType::VarScope&gt;(this);
-}
-
</del><span class="cx"> bool JSScope::isLexicalScope()
</span><span class="cx"> {
</span><del>-    return isScopeType&lt;JSLexicalEnvironment, SymbolTable::ScopeType::LexicalScope&gt;(this);
</del><ins>+    if (!isJSLexicalEnvironment())
+        return false;
+    return jsCast&lt;JSLexicalEnvironment*&gt;(this)-&gt;symbolTable()-&gt;scopeType() == SymbolTable::ScopeType::LexicalScope;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool JSScope::isModuleScope()
</span><span class="cx"> {
</span><del>-    return isScopeType&lt;JSModuleEnvironment, SymbolTable::ScopeType::LexicalScope&gt;(this);
</del><ins>+    return type() == ModuleEnvironmentType;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool JSScope::isCatchScope()
</span><span class="cx"> {
</span><del>-    return isScopeType&lt;JSLexicalEnvironment, SymbolTable::ScopeType::CatchScope&gt;(this);
</del><ins>+    if (type() != LexicalEnvironmentType)
+        return false;
+    return jsCast&lt;JSLexicalEnvironment*&gt;(this)-&gt;symbolTable()-&gt;scopeType() == SymbolTable::ScopeType::CatchScope;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool JSScope::isFunctionNameScopeObject()
</span><span class="cx"> {
</span><del>-    return isScopeType&lt;JSLexicalEnvironment, SymbolTable::ScopeType::FunctionNameScope&gt;(this);
</del><ins>+    if (type() != LexicalEnvironmentType)
+        return false;
+    return jsCast&lt;JSLexicalEnvironment*&gt;(this)-&gt;symbolTable()-&gt;scopeType() == SymbolTable::ScopeType::FunctionNameScope;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool JSScope::isGlobalLexicalEnvironment()
-{
-    return isScopeType&lt;JSGlobalLexicalEnvironment, SymbolTable::ScopeType::GlobalLexicalScope&gt;(this);
-}
-
</del><span class="cx"> bool JSScope::isNestedLexicalScope()
</span><span class="cx"> {
</span><del>-    if (JSLexicalEnvironment* environment = jsDynamicCast&lt;JSLexicalEnvironment*&gt;(this))
-        return environment-&gt;symbolTable()-&gt;isNestedLexicalScope();
-    return false;
</del><ins>+    if (!isJSLexicalEnvironment())
+        return false;
+    return jsCast&lt;JSLexicalEnvironment*&gt;(this)-&gt;symbolTable()-&gt;isNestedLexicalScope();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSScope* JSScope::constantScopeForCodeBlock(ResolveType type, CodeBlock* codeBlock)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSScopeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSScope.h (198227 => 198228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSScope.h        2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/JavaScriptCore/runtime/JSScope.h        2016-03-15 20:41:00 UTC (rev 198228)
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx"> 
</span><span class="cx">     static JSObject* objectAtScope(JSScope*);
</span><span class="cx"> 
</span><del>-    static JSValue resolve(ExecState*, JSScope*, const Identifier&amp;);
</del><ins>+    static JSObject* resolve(ExecState*, JSScope*, const Identifier&amp;);
</ins><span class="cx">     static ResolveOp abstractResolve(ExecState*, size_t depthOffset, JSScope*, const Identifier&amp;, GetOrPut, ResolveType, InitializationMode);
</span><span class="cx"> 
</span><span class="cx">     static bool hasConstantScope(ResolveType);
</span><span class="lines">@@ -58,7 +58,6 @@
</span><span class="cx">     bool isVarScope();
</span><span class="cx">     bool isLexicalScope();
</span><span class="cx">     bool isModuleScope();
</span><del>-    bool isGlobalLexicalEnvironment();
</del><span class="cx">     bool isCatchScope();
</span><span class="cx">     bool isFunctionNameScopeObject();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSTypeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSType.h (198227 => 198228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSType.h        2016-03-15 20:31:33 UTC (rev 198227)
+++ trunk/Source/JavaScriptCore/runtime/JSType.h        2016-03-15 20:41:00 UTC (rev 198228)
</span><span class="lines">@@ -76,7 +76,9 @@
</span><span class="cx">     DataViewType,
</span><span class="cx"> 
</span><span class="cx">     GlobalObjectType,
</span><del>-    ClosureObjectType,
</del><ins>+    LexicalEnvironmentType,
+    GlobalLexicalEnvironmentType,
+    ModuleEnvironmentType,
</ins><span class="cx">     RegExpObjectType,
</span><span class="cx">     ProxyObjectType,
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>