Changeset 174478 in webkit for trunk/Source/JavaScriptCore


Ignore:
Timestamp:
Oct 8, 2014, 1:54:24 PM (11 years ago)
Author:
[email protected]
Message:

Make sure arguments tearoff is performed through the environment record if necessary
https://bugs.webkit.org/show_bug.cgi?id=137538

Reviewed by Michael Saboff.

Fairly simple change. If we have a lexical record we need to pull the unmodified
arguments object from the record and then use the standard op_tear_off_arguments
instruction on the temporary.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitGetOwnScope):
(JSC::BytecodeGenerator::emitReturn):

  • bytecompiler/BytecodeGenerator.h:
Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r174473 r174478  
     12014-10-08  Oliver Hunt  <[email protected]>
     2
     3        Make sure arguments tearoff is performed through the environment record if necessary
     4        https://bugs.webkit.org/show_bug.cgi?id=137538
     5
     6        Reviewed by Michael Saboff.
     7
     8        Fairly simple change.  If we have a lexical record we need to pull the unmodified
     9        arguments object from the record and then use the standard op_tear_off_arguments
     10        instruction on the temporary.
     11
     12        * bytecompiler/BytecodeGenerator.cpp:
     13        (JSC::BytecodeGenerator::emitGetOwnScope):
     14        (JSC::BytecodeGenerator::emitReturn):
     15        * bytecompiler/BytecodeGenerator.h:
     16
    1172014-10-08  [email protected]  <[email protected]>
    218
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r174401 r174478  
    13001300}
    13011301
     1302
     1303RegisterID* BytecodeGenerator::emitGetOwnScope(RegisterID* dst, const Identifier& identifier, OwnScopeLookupRules)
     1304{
     1305    emitOpcode(op_resolve_scope);
     1306    instructions().append(kill(dst));
     1307    instructions().append(addConstant(identifier));
     1308    instructions().append(LocalClosureVar);
     1309    // This should be m_localScopeDepth if we aren't doing
     1310    // resolution during emitReturn()
     1311    instructions().append(0);
     1312    instructions().append(0);
     1313    return dst;
     1314}
     1315
    13021316RegisterID* BytecodeGenerator::emitResolveConstantLocal(RegisterID* dst, const Identifier& identifier, ResolveScopeInfo& info)
    13031317{
     
    19071921{
    19081922    if (m_codeBlock->usesArguments() && m_codeBlock->numParameters() != 1 && !isStrictMode()) {
     1923        RefPtr<RegisterID> scratchRegister;
     1924        int argumentsIndex = unmodifiedArgumentsRegister(m_codeBlock->argumentsRegister()).offset();
     1925        if (m_lexicalEnvironmentRegister && m_codeType == FunctionCode) {
     1926            scratchRegister = newTemporary();
     1927            emitGetOwnScope(scratchRegister.get(), propertyNames().arguments, OwnScopeForReturn);
     1928            ResolveScopeInfo scopeInfo(unmodifiedArgumentsRegister(m_codeBlock->argumentsRegister()).offset());
     1929            emitGetFromScope(scratchRegister.get(), scratchRegister.get(), propertyNames().arguments, ThrowIfNotFound, scopeInfo);
     1930            argumentsIndex = scratchRegister->index();
     1931        }
    19091932        emitOpcode(op_tear_off_arguments);
    1910         instructions().append(unmodifiedArgumentsRegister(m_codeBlock->argumentsRegister()).offset());
     1933        instructions().append(argumentsIndex);
    19111934        instructions().append(m_lexicalEnvironmentRegister ? m_lexicalEnvironmentRegister->index() : emitLoad(0, JSValue())->index());
    19121935    }
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r174401 r174478  
    660660        RegisterID* initializeCapturedVariable(RegisterID* dst, const Identifier&, RegisterID*);
    661661
     662        // We'll may want a non-return mode in future, but currently
     663        // this is only used during emitReturn(). emitReturn() occurs
     664        // with the novel state of having popped off all the local scope
     665        // nodes, but not actually modify any internal stack depth tracking.
     666        enum OwnScopeLookupRules { OwnScopeForReturn };
     667        RegisterID* emitGetOwnScope(RegisterID* dst, const Identifier&, OwnScopeLookupRules);
     668
    662669    public:
    663670        JSString* addStringConstant(const Identifier&);
Note: See TracChangeset for help on using the changeset viewer.