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/interpreter/Interpreter.cpp

    r59811 r59817  
    38413841        NEXT_INSTRUCTION();
    38423842    }
     3843    DEFINE_OPCODE(op_constructor_ret) {
     3844        /* ret result(r)
     3845           
     3846           Return register result as the return value of the current
     3847           function call, writing it into the caller's expected return
     3848           value register. In addition, unwind one call frame and
     3849           restore the scope chain, code block instruction pointer and
     3850           register base to those of the calling function.
     3851        */
     3852
     3853        int result = vPC[1].u.operand;
     3854
     3855        if (callFrame->codeBlock()->needsFullScopeChain())
     3856            callFrame->scopeChain()->deref();
     3857
     3858        JSValue returnValue = callFrame->r(result).jsValue();
     3859
     3860        if (UNLIKELY(!returnValue.isObject()))
     3861            returnValue = callFrame->r(vPC[2].u.operand).jsValue();
     3862
     3863        vPC = callFrame->returnPC();
     3864        int dst = callFrame->returnValueRegister();
     3865        callFrame = callFrame->callerFrame();
     3866       
     3867        if (callFrame->hasHostCallFrameFlag())
     3868            return returnValue;
     3869
     3870        callFrame->r(dst) = returnValue;
     3871
     3872        NEXT_INSTRUCTION();
     3873    }
    38433874    DEFINE_OPCODE(op_enter) {
    38443875        /* enter
     
    40174048        exceptionValue = createNotAConstructorError(callFrame, v, vPC - callFrame->codeBlock()->instructions().begin(), callFrame->codeBlock());
    40184049        goto vm_throw;
    4019     }
    4020     DEFINE_OPCODE(op_construct_verify) {
    4021         /* construct_verify dst(r) override(r)
    4022 
    4023            Verifies that register dst holds an object. If not, moves
    4024            the object in register override to register dst.
    4025         */
    4026 
    4027         int dst = vPC[1].u.operand;
    4028         if (LIKELY(callFrame->r(dst).jsValue().isObject())) {
    4029             vPC += OPCODE_LENGTH(op_construct_verify);
    4030             NEXT_INSTRUCTION();
    4031         }
    4032 
    4033         int override = vPC[2].u.operand;
    4034         callFrame->r(dst) = callFrame->r(override);
    4035 
    4036         vPC += OPCODE_LENGTH(op_construct_verify);
    4037         NEXT_INSTRUCTION();
    40384050    }
    40394051    DEFINE_OPCODE(op_strcat) {
Note: See TracChangeset for help on using the changeset viewer.