Changeset 58986 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
May 7, 2010, 5:05:00 PM (15 years ago)
Author:
[email protected]
Message:

2010-05-07 Oliver Hunt <[email protected]>

Reviewed by Geoffrey Garen.

Optimize access to the global object from a function that uses eval
https://bugs.webkit.org/show_bug.cgi?id=38644

Add op_resolve_global_dynamic, a variant of op_resolve_global that
checks each node in the scope chain for dynamically inserted properties
and falls back to the normal resolve logic in that case.

  • JavaScriptCore.exp:
  • bytecode/CodeBlock.cpp: (JSC::isGlobalResolve): (JSC::CodeBlock::printStructures): (JSC::CodeBlock::dump): (JSC::CodeBlock::derefStructures):
  • bytecode/Opcode.h:
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::findScopedProperty):

Now take an additional reference parameter to used to indicate that
there were nodes that may gain dynamic properties

(JSC::BytecodeGenerator::emitResolve):
(JSC::BytecodeGenerator::emitResolveBase):
(JSC::BytecodeGenerator::emitResolveWithBase):

deal with additional argument to findScopedProperty

  • bytecompiler/BytecodeGenerator.h:
  • bytecompiler/NodesCodegen.cpp: (JSC::FunctionCallResolveNode::emitBytecode): (JSC::PostfixResolveNode::emitBytecode): (JSC::PrefixResolveNode::emitBytecode): (JSC::ReadModifyResolveNode::emitBytecode): (JSC::AssignResolveNode::emitBytecode):

These functions use findScopedProperty directly in order to
optimise lookup. They cannot trivially handle any degree of
dynamism in the lookup so we just give up in such case.

  • interpreter/Interpreter.cpp: (JSC::Interpreter::resolveGlobalDynamic): (JSC::Interpreter::execute): (JSC::Interpreter::privateExecute):
  • interpreter/Interpreter.h:
  • jit/JIT.cpp: (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileSlowCases):
  • jit/JIT.h:
  • jit/JITOpcodes.cpp: (JSC::JIT::emit_op_resolve_global): (JSC::JIT::emit_op_resolve_global_dynamic): (JSC::JIT::emitSlow_op_resolve_global): (JSC::JIT::emitSlow_op_resolve_global_dynamic):

Happily resolve_global_dynamic can share the slow case!

  • jit/JITStubs.h: (JSC::):
  • runtime/JSActivation.cpp: (JSC::JSActivation::isDynamicScope):
  • runtime/JSActivation.h:
  • runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::isDynamicScope):
  • runtime/JSGlobalObject.h:
  • runtime/JSStaticScopeObject.cpp: (JSC::JSStaticScopeObject::isDynamicScope):
  • runtime/JSStaticScopeObject.h:
  • runtime/JSVariableObject.h:
Location:
trunk/JavaScriptCore/runtime
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/JSActivation.cpp

    r55401 r58986  
    135135}
    136136
    137 bool JSActivation::isDynamicScope() const
     137bool JSActivation::isDynamicScope(bool& requiresDynamicChecks) const
    138138{
    139     return d()->functionExecutable->usesEval();
     139    requiresDynamicChecks = d()->functionExecutable->usesEval();
     140    return false;
    140141}
    141142
  • trunk/JavaScriptCore/runtime/JSActivation.h

    r58267 r58986  
    4848        virtual void markChildren(MarkStack&);
    4949
    50         virtual bool isDynamicScope() const;
     50        virtual bool isDynamicScope(bool& requiresDynamicChecks) const;
    5151
    5252        virtual bool isActivationObject() const { return true; }
  • trunk/JavaScriptCore/runtime/JSGlobalObject.cpp

    r58267 r58986  
    427427}
    428428
    429 bool JSGlobalObject::isDynamicScope() const
     429bool JSGlobalObject::isDynamicScope(bool&) const
    430430{
    431431    return true;
  • trunk/JavaScriptCore/runtime/JSGlobalObject.h

    r57120 r58986  
    257257        virtual bool allowsAccessFrom(const JSGlobalObject*) const { return true; }
    258258
    259         virtual bool isDynamicScope() const;
     259        virtual bool isDynamicScope(bool& requiresDynamicChecks) const;
    260260
    261261        HashSet<GlobalCodeBlock*>& codeBlocks() { return d()->codeBlocks; }
  • trunk/JavaScriptCore/runtime/JSStaticScopeObject.cpp

    r47022 r58986  
    5959}
    6060
    61 bool JSStaticScopeObject::isDynamicScope() const
     61bool JSStaticScopeObject::isDynamicScope(bool&) const
    6262{
    6363    return false;
  • trunk/JavaScriptCore/runtime/JSStaticScopeObject.h

    r54022 r58986  
    5252        virtual ~JSStaticScopeObject();
    5353        virtual void markChildren(MarkStack&);
    54         bool isDynamicScope() const;
     54        bool isDynamicScope(bool& requiresDynamicChecks) const;
    5555        virtual JSObject* toThisObject(ExecState*) const;
    5656        virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
  • trunk/JavaScriptCore/runtime/JSVariableObject.h

    r54022 r58986  
    5353       
    5454        virtual bool isVariableObject() const;
    55         virtual bool isDynamicScope() const = 0;
     55        virtual bool isDynamicScope(bool& requiresDynamicChecks) const = 0;
    5656
    5757        Register& registerAt(int index) const { return d->registers[index]; }
Note: See TracChangeset for help on using the changeset viewer.