Ignore:
Timestamp:
Jun 20, 2012, 6:38:49 PM (13 years ago)
Author:
[email protected]
Message:

DFG should optimize ResolveGlobal
https://bugs.webkit.org/show_bug.cgi?id=89617

Reviewed by Oliver Hunt.

This adds inlining of ResolveGlobal accesses that are known monomorphic. It also
adds the specific function optimization to ResolveGlobal, when it is inlined. And,
it makes internal functions act like specific functions, since that will be the
most common use-case of this optimization.

This is only a slighy speed-up (sub 1%), since we don't yet do the obvious thing
with this optimization, which is to completely inline common "globally resolved"
function and constructor calls, like "new Array()".

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Target.pri:
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::globalResolveInfoForBytecodeOffset):

  • bytecode/CodeBlock.h:

(CodeBlock):
(JSC::CodeBlock::numberOfGlobalResolveInfos):

  • bytecode/GlobalResolveInfo.h:

(JSC::getGlobalResolveInfoBytecodeOffset):
(JSC):

  • bytecode/ResolveGlobalStatus.cpp: Added.

(JSC):
(JSC::computeForStructure):
(JSC::computeForLLInt):
(JSC::ResolveGlobalStatus::computeFor):

  • bytecode/ResolveGlobalStatus.h: Added.

(JSC):
(ResolveGlobalStatus):
(JSC::ResolveGlobalStatus::ResolveGlobalStatus):
(JSC::ResolveGlobalStatus::state):
(JSC::ResolveGlobalStatus::isSet):
(JSC::ResolveGlobalStatus::operator!):
(JSC::ResolveGlobalStatus::isSimple):
(JSC::ResolveGlobalStatus::takesSlowPath):
(JSC::ResolveGlobalStatus::structure):
(JSC::ResolveGlobalStatus::offset):
(JSC::ResolveGlobalStatus::specificValue):

  • dfg/DFGByteCodeParser.cpp:

(ByteCodeParser):
(JSC::DFG::ByteCodeParser::handleGetByOffset):
(DFG):
(JSC::DFG::ByteCodeParser::handleGetById):
(JSC::DFG::ByteCodeParser::parseBlock):

  • runtime/JSObject.cpp:

(JSC::getCallableObjectSlow):
(JSC):
(JSC::JSObject::put):
(JSC::JSObject::putDirectVirtual):
(JSC::JSObject::putDirectAccessor):

  • runtime/JSObject.h:

(JSC):
(JSC::getCallableObject):
(JSC::JSObject::putOwnDataProperty):
(JSC::JSObject::putDirect):
(JSC::JSObject::putDirectWithoutTransition):

File:
1 edited

Legend:

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

    r120244 r120897  
    4444namespace JSC {
    4545
     46JSCell* getCallableObjectSlow(JSCell* cell)
     47{
     48    Structure* structure = cell->structure();
     49    if (structure->typeInfo().type() == JSFunctionType)
     50        return cell;
     51    if (structure->classInfo()->isSubClassOf(&InternalFunction::s_info))
     52        return cell;
     53    return 0;
     54}
     55
    4656ASSERT_CLASS_FITS_IN_CELL(JSObject);
    4757ASSERT_CLASS_FITS_IN_CELL(JSNonFinalObject);
     
    134144            prototype = obj->prototype();
    135145            if (prototype.isNull()) {
    136                 if (!thisObject->putDirectInternal<PutModePut>(globalData, propertyName, value, 0, slot, getJSFunction(value)) && slot.isStrictMode())
     146                if (!thisObject->putDirectInternal<PutModePut>(globalData, propertyName, value, 0, slot, getCallableObject(value)) && slot.isStrictMode())
    137147                    throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
    138148                return;
     
    181191    }
    182192   
    183     if (!thisObject->putDirectInternal<PutModePut>(globalData, propertyName, value, 0, slot, getJSFunction(value)) && slot.isStrictMode())
     193    if (!thisObject->putDirectInternal<PutModePut>(globalData, propertyName, value, 0, slot, getCallableObject(value)) && slot.isStrictMode())
    184194        throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
    185195    return;
     
    197207    ASSERT(!value.isGetterSetter() && !(attributes & Accessor));
    198208    PutPropertySlot slot;
    199     object->putDirectInternal<PutModeDefineOwnProperty>(exec->globalData(), propertyName, value, attributes, slot, getJSFunction(value));
     209    object->putDirectInternal<PutModeDefineOwnProperty>(exec->globalData(), propertyName, value, attributes, slot, getCallableObject(value));
    200210}
    201211
     
    227237
    228238    PutPropertySlot slot;
    229     putDirectInternal<PutModeDefineOwnProperty>(globalData, propertyName, value, attributes, slot, getJSFunction(value));
     239    putDirectInternal<PutModeDefineOwnProperty>(globalData, propertyName, value, attributes, slot, getCallableObject(value));
    230240
    231241    // putDirect will change our Structure if we add a new property. For
Note: See TracChangeset for help on using the changeset viewer.