Ignore:
Timestamp:
Mar 15, 2016, 1:41:00 PM (9 years ago)
Author:
[email protected]
Message:

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<JSGlobalObject*>
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:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp

    r198154 r198228  
    770770    const Identifier& ident = exec->codeBlock()->identifier(pc[3].u.operand);
    771771    JSScope* scope = exec->uncheckedR(pc[2].u.operand).Register::scope();
    772     JSValue resolvedScope = JSScope::resolve(exec, scope, ident);
     772    JSObject* resolvedScope = JSScope::resolve(exec, scope, ident);
    773773
    774774    ResolveType resolveType = static_cast<ResolveType>(pc[4].u.operand);
     
    778778
    779779    if (resolveType == UnresolvedProperty || resolveType == UnresolvedPropertyWithVarInjectionChecks) {
    780         if (JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsDynamicCast<JSGlobalLexicalEnvironment*>(resolvedScope)) {
     780        if (resolvedScope->isGlobalObject()) {
     781            JSGlobalObject* globalObject = jsCast<JSGlobalObject*>(resolvedScope);
     782            if (globalObject->hasProperty(exec, ident)) {
     783                if (resolveType == UnresolvedProperty)
     784                    pc[4].u.operand = GlobalProperty;
     785                else
     786                    pc[4].u.operand = GlobalPropertyWithVarInjectionChecks;
     787
     788                pc[6].u.pointer = globalObject;
     789            }
     790        } else if (resolvedScope->isGlobalLexicalEnvironment()) {
     791            JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsCast<JSGlobalLexicalEnvironment*>(resolvedScope);
    781792            if (resolveType == UnresolvedProperty)
    782793                pc[4].u.operand = GlobalLexicalVar;
     
    784795                pc[4].u.operand = GlobalLexicalVarWithVarInjectionChecks;
    785796            pc[6].u.pointer = globalLexicalEnvironment;
    786         } else if (JSGlobalObject* globalObject = jsDynamicCast<JSGlobalObject*>(resolvedScope)) {
    787             if (globalObject->hasProperty(exec, ident)) {
    788                 if (resolveType == UnresolvedProperty)
    789                     pc[4].u.operand = GlobalProperty;
    790                 else
    791                     pc[4].u.operand = GlobalPropertyWithVarInjectionChecks;
    792 
    793                 pc[6].u.pointer = globalObject;
    794             }
    795797        }
    796798    }
Note: See TracChangeset for help on using the changeset viewer.