Ignore:
Timestamp:
Feb 24, 2015, 4:41:35 PM (10 years ago)
Author:
[email protected]
Message:

Use "this" instead of "callee" to get the constructor
https://bugs.webkit.org/show_bug.cgi?id=141019

Reviewed by Filip Pizlo.

This patch uses "this" register to pass the constructor (newTarget) to op_create_this from
op_construct or op_construct_varargs. This will allow future patches that implement ES6 class
to pass in the most derived class' constructor through "this" argument.

BytecodeGenerator's emitConstruct and emitConstructVarargs now passes thisRegister like
regular calls and emitCreateThis passes in this register to op_create_this as constructor.

The rest of the code change removes the code for special casing "this" register not being used
in call to construct.

  • bytecode/BytecodeUseDef.h:

(JSC::computeUsesForBytecodeOffset):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitCreateThis):
(JSC::BytecodeGenerator::emitConstructVarargs):
(JSC::BytecodeGenerator::emitConstruct):

  • bytecompiler/BytecodeGenerator.h:
  • bytecompiler/NodesCodegen.cpp:

(JSC::NewExprNode::emitBytecode):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::addCallWithoutSettingResult):
(JSC::DFG::ByteCodeParser::handleVarargsCall):
(JSC::DFG::ByteCodeParser::emitArgumentPhantoms):
(JSC::DFG::ByteCodeParser::attemptToInlineCall):
(JSC::DFG::ByteCodeParser::handleInlining):
(JSC::DFG::ByteCodeParser::handleConstantInternalFunction):
(JSC::DFG::ByteCodeParser::parseBlock):

  • dfg/DFGJITCode.cpp:

(JSC::DFG::JITCode::reconstruct):

  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::emitCall):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::emitCall):

  • ftl/FTLJSCallVarargs.cpp:

(JSC::FTL::JSCallVarargs::emit):

  • ftl/FTLLowerDFGToLLVM.cpp:

(JSC::FTL::LowerDFGToLLVM::compileNativeCallOrConstruct):
(JSC::FTL::LowerDFGToLLVM::compileCallOrConstruct):
(JSC::FTL::LowerDFGToLLVM::compileCallOrConstructVarargs):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::executeConstruct):

  • jit/JITOperations.cpp:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGJITCode.cpp

    r164229 r180595  
    8383   
    8484    result = Operands<JSValue>(OperandsLike, recoveries);
    85     for (size_t i = result.size(); i--;) {
    86         int operand = result.operandForIndex(i);
    87        
    88         if (codeOrigin == CodeOrigin(0)
    89             && operandIsArgument(operand)
    90             && !VirtualRegister(operand).toArgument()
    91             && codeBlock->codeType() == FunctionCode
    92             && codeBlock->specializationKind() == CodeForConstruct) {
    93             // Ugh. If we're in a constructor, the 'this' argument may hold garbage. It will
    94             // also never be used. It doesn't matter what we put into the value for this,
    95             // but it has to be an actual value that can be grokked by subsequent DFG passes,
    96             // so we sanitize it here by turning it into Undefined.
    97             result[i] = jsUndefined();
    98             continue;
    99         }
    100        
     85    for (size_t i = result.size(); i--;)
    10186        result[i] = recoveries[i].recover(exec);
    102     }
    10387}
    10488
Note: See TracChangeset for help on using the changeset viewer.