Ignore:
Timestamp:
May 19, 2010, 9:57:20 PM (15 years ago)
Author:
[email protected]
Message:

Bug 39399 - Move responsibility for verifying constructors return objects from the caller to the callee.

Reviewed by Geoff Garen.

This is a necessary step to move object creation from caller to callee.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::dump):

  • bytecode/Opcode.h:
  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::emitReturn):
(JSC::BytecodeGenerator::emitConstruct):

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::isConstructor):

  • bytecompiler/NodesCodegen.cpp:

(JSC::FunctionBodyNode::emitBytecode):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::privateExecute):

  • jit/JIT.cpp:

(JSC::JIT::privateCompileMainPass):
(JSC::JIT::privateCompileSlowCases):

  • jit/JIT.h:
  • jit/JITCall.cpp:

(JSC::JIT::emit_op_constructor_ret):

  • jit/JITOpcodes.cpp:

(JSC::JIT::emit_op_constructor_ret):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r59742 r59817  
    366366    ++m_codeBlock->m_numParameters;
    367367
    368     if (functionBody->usesThis() || m_shouldEmitDebugHooks) {
     368    if (!isConstructor() && (functionBody->usesThis() || m_shouldEmitDebugHooks)) {
    369369        emitOpcode(op_convert_this);
    370370        instructions().append(m_thisRegister.index());
     
    15421542    }
    15431543
     1544    // Constructors use op_constructor_ret to check the result is an
     1545    // object, unless we can trivially determine the check is not
     1546    // necessary (currently, if the return value is 'this').
     1547    if (isConstructor() && (src->index() != m_thisRegister.index())) {
     1548        emitOpcode(op_constructor_ret);
     1549        instructions().append(src->index());
     1550        instructions().append(m_thisRegister.index());
     1551        return src;
     1552    }
    15441553    return emitUnaryNoDstOp(op_ret, src);
    15451554}
     
    16071616    instructions().append(funcProto->index()); // proto
    16081617    instructions().append(argv[0]->index()); // thisRegister
    1609 
    1610     emitOpcode(op_construct_verify);
    1611     instructions().append(dst->index());
    1612     instructions().append(argv[0]->index());
    16131618
    16141619    if (m_shouldEmitProfileHooks) {
Note: See TracChangeset for help on using the changeset viewer.