https://bugs.webkit.org/show_bug.cgi?id=39583
Move creation of 'this' object from caller to callee in construction.
Reviewed by Sam Weinig.
Presently the caller of a constructor is responsible for providing a this
object. Instead, move the object creation into a new op_create_this opcode,
planted in the head of the contructor bytecode for a function. Since the
prototype for the object is provided by performing a get_by_id on the callee,
also add a new get_callee opcode (this is used to get the callee JSFunction
into a register so that a normal get_by_id can be used).
Currently the caller is also responsible for detecting when op_construct is
performed on a JSFunction representing a host function, in which case an
exception is thrown – and this check currently takes place when constructing
the this object. Instead, mirroring the recent changes for non-host functions,
add a parallel code-path for native constructors to follow, with a thunk for
invoking native constructors provided by JITStubs, and a constructor-specific
NativeFunction on NativeExecutable. Provide an implementation of a host
constructor which will throw an exception.
(JSC::CodeBlock::dump):
(JSC::CodeBlock::getByIdExceptionInfoForBytecodeOffset):
- bytecode/CodeBlock.h:
- bytecode/Opcode.h:
- bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::emitConstruct):
- bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::emitGetByIdExceptionInfo):
- interpreter/Interpreter.cpp:
(JSC::Interpreter::privateExecute):
(JSC::JIT::privateCompileMainPass):
- jit/JIT.h:
- jit/JITCall.cpp:
(JSC::JIT::compileOpCall):
(JSC::JIT::compileOpCallSlowCase):
(JSC::JIT::compileOpCall):
(JSC::JIT::compileOpCallSlowCase):
(JSC::JIT::privateCompileCTIMachineTrampolines):
(JSC::JIT::privateCompileCTINativeCall):
(JSC::JIT::emit_op_neq_null):
(JSC::JIT::emit_op_convert_this):
(JSC::JIT::emit_op_get_callee):
(JSC::JIT::emit_op_create_this):
(JSC::JIT::privateCompileCTIMachineTrampolines):
(JSC::JIT::privateCompileCTINativeCall):
(JSC::JIT::emit_op_get_callee):
(JSC::JIT::emit_op_create_this):
(JSC::DEFINE_STUB_FUNCTION):
(JSC::JITThunks::hostFunctionStub):
(JSC::JITThunks::ctiNativeConstruct):
(JSC::):
- runtime/ExceptionHelpers.cpp:
(JSC::createNotAnObjectError):
(JSC::NativeExecutable::create):
(JSC::NativeExecutable::NativeExecutable):
(JSC::callHostFunctionAsConstructor):