mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
deps: back-port 306c412c from v8 upstream
The patch has been modified to maintain ABI compatibility. The original
change removes the v8::FunctionCallbackInfo<T>::is_construct_call_ field
from deps/v8/include/v8.h. The field is set directly by JIT-ted code so
the removal of those code paths has been backed out as well.
Original commit message:
[api] Expose FunctionCallbackInfo::NewTarget
This is needed by Blink to implement the Custom Elements spec.
BUG=v8:4261
LOG=y
Review-Url: https://codereview.chromium.org/1910253005
Cr-Commit-Position: refs/heads/master@{#35833}
Fixes: https://github.com/nodejs/node/issues/9288
PR-URL: https://github.com/nodejs/node/pull/9293
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
This commit is contained in:
1 parent
fd1ffe4f5a
commit
e774de1685
23 files changed
+167
-150
No files matched your search
Vendored
+8
-1
@@ -3177,12 +3177,13 @@ class FunctionCallbackInfo {
|
||||
Local<Function> Callee() const);
|
||||
V8_INLINE Local<Object> This() const;
|
||||
V8_INLINE Local<Object> Holder() const;
|
||||
V8_INLINE Local<Value> NewTarget() const;
|
||||
V8_INLINE bool IsConstructCall() const;
|
||||
V8_INLINE Local<Value> Data() const;
|
||||
V8_INLINE Isolate* GetIsolate() const;
|
||||
V8_INLINE ReturnValue<T> GetReturnValue() const;
|
||||
// This shouldn't be public, but the arm compiler needs it.
|
||||
static const int kArgsLength = 7;
|
||||
static const int kArgsLength = 8;
|
||||
|
||||
protected:
|
||||
friend class internal::FunctionCallbackArguments;
|
||||
@@ -3194,6 +3195,7 @@ class FunctionCallbackInfo {
|
||||
static const int kDataIndex = 4;
|
||||
static const int kCalleeIndex = 5;
|
||||
static const int kContextSaveIndex = 6;
|
||||
static const int kNewTargetIndex = 7;
|
||||
|
||||
V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args,
|
||||
internal::Object** values,
|
||||
@@ -7902,6 +7904,11 @@ Local<Object> FunctionCallbackInfo<T>::Holder() const {
|
||||
&implicit_args_[kHolderIndex]));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Local<Value> FunctionCallbackInfo<T>::NewTarget() const {
|
||||
return Local<Value>(
|
||||
reinterpret_cast<Value*>(&implicit_args_[kNewTargetIndex]));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Local<Value> FunctionCallbackInfo<T>::Data() const {
|
||||
|
||||
Vendored
+6
-3
@@ -206,19 +206,22 @@ class FunctionCallbackArguments
|
||||
static const int kIsolateIndex = T::kIsolateIndex;
|
||||
static const int kCalleeIndex = T::kCalleeIndex;
|
||||
static const int kContextSaveIndex = T::kContextSaveIndex;
|
||||
static const int kNewTargetIndex = T::kNewTargetIndex;
|
||||
|
||||
FunctionCallbackArguments(internal::Isolate* isolate, internal::Object* data,
|
||||
internal::HeapObject* callee,
|
||||
internal::Object* holder, internal::Object** argv,
|
||||
int argc, bool is_construct_call)
|
||||
internal::Object* holder,
|
||||
internal::HeapObject* new_target,
|
||||
internal::Object** argv, int argc)
|
||||
: Super(isolate),
|
||||
argv_(argv),
|
||||
argc_(argc),
|
||||
is_construct_call_(is_construct_call) {
|
||||
is_construct_call_(!new_target->IsUndefined()) {
|
||||
Object** values = begin();
|
||||
values[T::kDataIndex] = data;
|
||||
values[T::kCalleeIndex] = callee;
|
||||
values[T::kHolderIndex] = holder;
|
||||
values[T::kNewTargetIndex] = new_target;
|
||||
values[T::kContextSaveIndex] = isolate->heap()->the_hole_value();
|
||||
values[T::kIsolateIndex] = reinterpret_cast<internal::Object*>(isolate);
|
||||
// Here the hole is set as default value.
|
||||
|
||||
Vendored
+3
-10
@@ -604,16 +604,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
||||
// r0: number of arguments
|
||||
// r1: constructor function
|
||||
// r3: new target
|
||||
if (is_api_function) {
|
||||
__ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset));
|
||||
Handle<Code> code =
|
||||
masm->isolate()->builtins()->HandleApiCallConstruct();
|
||||
__ Call(code, RelocInfo::CODE_TARGET);
|
||||
} else {
|
||||
ParameterCount actual(r0);
|
||||
__ InvokeFunction(r1, r3, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
}
|
||||
ParameterCount actual(r0);
|
||||
__ InvokeFunction(r1, r3, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
|
||||
// Store offset of return address for deoptimizer.
|
||||
if (create_implicit_receiver && !is_api_function) {
|
||||
|
||||
Vendored
+5
-1
@@ -5423,7 +5423,11 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
|
||||
STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
|
||||
STATIC_ASSERT(FCA::kIsolateIndex == 1);
|
||||
STATIC_ASSERT(FCA::kHolderIndex == 0);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 7);
|
||||
STATIC_ASSERT(FCA::kNewTargetIndex == 7);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 8);
|
||||
|
||||
// new target
|
||||
__ PushRoot(Heap::kUndefinedValueRootIndex);
|
||||
|
||||
// context save
|
||||
__ push(context);
|
||||
|
||||
Vendored
+3
-10
@@ -605,16 +605,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
||||
// x0: number of arguments
|
||||
// x1: constructor function
|
||||
// x3: new target
|
||||
if (is_api_function) {
|
||||
__ Ldr(cp, FieldMemOperand(constructor, JSFunction::kContextOffset));
|
||||
Handle<Code> code =
|
||||
masm->isolate()->builtins()->HandleApiCallConstruct();
|
||||
__ Call(code, RelocInfo::CODE_TARGET);
|
||||
} else {
|
||||
ParameterCount actual(argc);
|
||||
__ InvokeFunction(constructor, new_target, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
}
|
||||
ParameterCount actual(argc);
|
||||
__ InvokeFunction(constructor, new_target, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
|
||||
// Store offset of return address for deoptimizer.
|
||||
if (create_implicit_receiver && !is_api_function) {
|
||||
|
||||
+8
-2
@@ -5807,9 +5807,15 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
|
||||
STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
|
||||
STATIC_ASSERT(FCA::kIsolateIndex == 1);
|
||||
STATIC_ASSERT(FCA::kHolderIndex == 0);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 7);
|
||||
STATIC_ASSERT(FCA::kNewTargetIndex == 7);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 8);
|
||||
|
||||
// FunctionCallbackArguments: context, callee and call data.
|
||||
// FunctionCallbackArguments
|
||||
|
||||
// new target
|
||||
__ PushRoot(Heap::kUndefinedValueRootIndex);
|
||||
|
||||
// context, callee and call data.
|
||||
__ Push(context, callee, call_data);
|
||||
|
||||
if (!is_lazy()) {
|
||||
|
||||
Vendored
+36
-46
@@ -89,17 +89,6 @@ Handle<S> BuiltinArguments<BuiltinExtraArguments::kTarget>::target() {
|
||||
return Arguments::at<S>(Arguments::length() - 1);
|
||||
}
|
||||
|
||||
template <>
|
||||
int BuiltinArguments<BuiltinExtraArguments::kNewTarget>::length() const {
|
||||
return Arguments::length() - 1;
|
||||
}
|
||||
|
||||
template <>
|
||||
Handle<HeapObject>
|
||||
BuiltinArguments<BuiltinExtraArguments::kNewTarget>::new_target() {
|
||||
return Arguments::at<HeapObject>(Arguments::length() - 1);
|
||||
}
|
||||
|
||||
template <>
|
||||
int BuiltinArguments<BuiltinExtraArguments::kTargetAndNewTarget>::length()
|
||||
const {
|
||||
@@ -4247,11 +4236,13 @@ BUILTIN(RestrictedStrictArgumentsPropertiesThrower) {
|
||||
|
||||
namespace {
|
||||
|
||||
template <bool is_construct>
|
||||
MUST_USE_RESULT MaybeHandle<Object> HandleApiCallHelper(
|
||||
Isolate* isolate, BuiltinArguments<BuiltinExtraArguments::kTarget> args) {
|
||||
Isolate* isolate,
|
||||
BuiltinArguments<BuiltinExtraArguments::kTargetAndNewTarget> args) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<HeapObject> function = args.target<HeapObject>();
|
||||
Handle<HeapObject> new_target = args.new_target();
|
||||
bool is_construct = !new_target->IsUndefined();
|
||||
Handle<JSReceiver> receiver;
|
||||
|
||||
DCHECK(function->IsFunctionTemplateInfo() ||
|
||||
@@ -4311,13 +4302,9 @@ MUST_USE_RESULT MaybeHandle<Object> HandleApiCallHelper(
|
||||
LOG(isolate, ApiObjectAccess("call", JSObject::cast(*args.receiver())));
|
||||
DCHECK(raw_holder->IsJSObject());
|
||||
|
||||
FunctionCallbackArguments custom(isolate,
|
||||
data_obj,
|
||||
*function,
|
||||
raw_holder,
|
||||
&args[0] - 1,
|
||||
args.length() - 1,
|
||||
is_construct);
|
||||
FunctionCallbackArguments custom(isolate, data_obj, *function, raw_holder,
|
||||
*new_target, &args[0] - 1,
|
||||
args.length() - 1);
|
||||
|
||||
Handle<Object> result = custom.Call(callback);
|
||||
if (result.is_null()) result = isolate->factory()->undefined_value();
|
||||
@@ -4338,19 +4325,11 @@ BUILTIN(HandleApiCall) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<Object> result;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
|
||||
HandleApiCallHelper<false>(isolate, args));
|
||||
HandleApiCallHelper(isolate, args));
|
||||
return *result;
|
||||
}
|
||||
|
||||
|
||||
BUILTIN(HandleApiCallConstruct) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<Object> result;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
|
||||
HandleApiCallHelper<true>(isolate, args));
|
||||
return *result;
|
||||
}
|
||||
|
||||
Handle<Code> Builtins::CallFunction(ConvertReceiverMode mode,
|
||||
TailCallMode tail_call_mode) {
|
||||
switch (tail_call_mode) {
|
||||
@@ -4432,11 +4411,12 @@ Handle<Code> Builtins::InterpreterPushArgsAndCall(TailCallMode tail_call_mode) {
|
||||
namespace {
|
||||
|
||||
class RelocatableArguments
|
||||
: public BuiltinArguments<BuiltinExtraArguments::kTarget>,
|
||||
: public BuiltinArguments<BuiltinExtraArguments::kTargetAndNewTarget>,
|
||||
public Relocatable {
|
||||
public:
|
||||
RelocatableArguments(Isolate* isolate, int length, Object** arguments)
|
||||
: BuiltinArguments<BuiltinExtraArguments::kTarget>(length, arguments),
|
||||
: BuiltinArguments<BuiltinExtraArguments::kTargetAndNewTarget>(length,
|
||||
arguments),
|
||||
Relocatable(isolate) {}
|
||||
|
||||
virtual inline void IterateInstance(ObjectVisitor* v) {
|
||||
@@ -4468,24 +4448,26 @@ MaybeHandle<Object> Builtins::InvokeApiFunction(Handle<HeapObject> function,
|
||||
}
|
||||
}
|
||||
}
|
||||
// Construct BuiltinArguments object: function, arguments reversed, receiver.
|
||||
// Construct BuiltinArguments object:
|
||||
// new target, function, arguments reversed, receiver.
|
||||
const int kBufferSize = 32;
|
||||
Object* small_argv[kBufferSize];
|
||||
Object** argv;
|
||||
if (argc + 2 <= kBufferSize) {
|
||||
if (argc + 3 <= kBufferSize) {
|
||||
argv = small_argv;
|
||||
} else {
|
||||
argv = new Object* [argc + 2];
|
||||
argv = new Object*[argc + 3];
|
||||
}
|
||||
argv[argc + 1] = *receiver;
|
||||
argv[argc + 2] = *receiver;
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
argv[argc - i] = *args[i];
|
||||
argv[argc - i + 1] = *args[i];
|
||||
}
|
||||
argv[0] = *function;
|
||||
argv[1] = *function;
|
||||
argv[0] = isolate->heap()->undefined_value(); // new target
|
||||
MaybeHandle<Object> result;
|
||||
{
|
||||
RelocatableArguments arguments(isolate, argc + 2, &argv[argc + 1]);
|
||||
result = HandleApiCallHelper<false>(isolate, arguments);
|
||||
RelocatableArguments arguments(isolate, argc + 3, &argv[argc] + 2);
|
||||
result = HandleApiCallHelper(isolate, arguments);
|
||||
}
|
||||
if (argv != small_argv) {
|
||||
delete[] argv;
|
||||
@@ -4505,6 +4487,18 @@ MUST_USE_RESULT static Object* HandleApiCallAsFunctionOrConstructor(
|
||||
// Get the object called.
|
||||
JSObject* obj = JSObject::cast(*receiver);
|
||||
|
||||
// Set the new target.
|
||||
HeapObject* new_target;
|
||||
if (is_construct_call) {
|
||||
// TODO(adamk): This should be passed through in args instead of
|
||||
// being patched in here. We need to set a non-undefined value
|
||||
// for v8::FunctionCallbackInfo::IsConstructCall() to get the
|
||||
// right answer.
|
||||
new_target = obj;
|
||||
} else {
|
||||
new_target = isolate->heap()->undefined_value();
|
||||
}
|
||||
|
||||
// Get the invocation callback from the function descriptor that was
|
||||
// used to create the called object.
|
||||
DCHECK(obj->map()->is_callable());
|
||||
@@ -4527,13 +4521,9 @@ MUST_USE_RESULT static Object* HandleApiCallAsFunctionOrConstructor(
|
||||
HandleScope scope(isolate);
|
||||
LOG(isolate, ApiObjectAccess("call non-function", obj));
|
||||
|
||||
FunctionCallbackArguments custom(isolate,
|
||||
call_data->data(),
|
||||
constructor,
|
||||
obj,
|
||||
&args[0] - 1,
|
||||
args.length() - 1,
|
||||
is_construct_call);
|
||||
FunctionCallbackArguments custom(isolate, call_data->data(), constructor,
|
||||
obj, new_target, &args[0] - 1,
|
||||
args.length() - 1);
|
||||
Handle<Object> result_handle = custom.Call(callback);
|
||||
if (result_handle.is_null()) {
|
||||
result = isolate->heap()->undefined_value();
|
||||
|
||||
Vendored
+1
-2
@@ -166,8 +166,7 @@ inline bool operator&(BuiltinExtraArguments lhs, BuiltinExtraArguments rhs) {
|
||||
V(SymbolConstructor, kNone) \
|
||||
V(SymbolConstructor_ConstructStub, kTarget) \
|
||||
\
|
||||
V(HandleApiCall, kTarget) \
|
||||
V(HandleApiCallConstruct, kTarget) \
|
||||
V(HandleApiCall, kTargetAndNewTarget) \
|
||||
V(HandleApiCallAsFunction, kNone) \
|
||||
V(HandleApiCallAsConstructor, kNone) \
|
||||
\
|
||||
|
||||
Vendored
+3
-10
@@ -186,16 +186,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
||||
__ j(greater_equal, &loop);
|
||||
|
||||
// Call the function.
|
||||
if (is_api_function) {
|
||||
__ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
|
||||
Handle<Code> code =
|
||||
masm->isolate()->builtins()->HandleApiCallConstruct();
|
||||
__ call(code, RelocInfo::CODE_TARGET);
|
||||
} else {
|
||||
ParameterCount actual(eax);
|
||||
__ InvokeFunction(edi, edx, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
}
|
||||
ParameterCount actual(eax);
|
||||
__ InvokeFunction(edi, edx, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
|
||||
// Store offset of return address for deoptimizer.
|
||||
if (create_implicit_receiver && !is_api_function) {
|
||||
|
||||
Vendored
+6
-1
@@ -5686,9 +5686,14 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
|
||||
STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
|
||||
STATIC_ASSERT(FCA::kIsolateIndex == 1);
|
||||
STATIC_ASSERT(FCA::kHolderIndex == 0);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 7);
|
||||
STATIC_ASSERT(FCA::kNewTargetIndex == 7);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 8);
|
||||
|
||||
__ pop(return_address);
|
||||
|
||||
// new target
|
||||
__ PushRoot(Heap::kUndefinedValueRootIndex);
|
||||
|
||||
// context save.
|
||||
__ push(context);
|
||||
|
||||
|
||||
Vendored
+3
-10
@@ -603,16 +603,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
||||
// a0: number of arguments
|
||||
// a1: constructor function
|
||||
// a3: new target
|
||||
if (is_api_function) {
|
||||
__ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
|
||||
Handle<Code> code =
|
||||
masm->isolate()->builtins()->HandleApiCallConstruct();
|
||||
__ Call(code, RelocInfo::CODE_TARGET);
|
||||
} else {
|
||||
ParameterCount actual(a0);
|
||||
__ InvokeFunction(a1, a3, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
}
|
||||
ParameterCount actual(a0);
|
||||
__ InvokeFunction(a1, a3, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
|
||||
// Store offset of return address for deoptimizer.
|
||||
if (create_implicit_receiver && !is_api_function) {
|
||||
|
||||
Vendored
+5
-1
@@ -5608,7 +5608,11 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
|
||||
STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
|
||||
STATIC_ASSERT(FCA::kIsolateIndex == 1);
|
||||
STATIC_ASSERT(FCA::kHolderIndex == 0);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 7);
|
||||
STATIC_ASSERT(FCA::kNewTargetIndex == 7);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 8);
|
||||
|
||||
// new target
|
||||
__ PushRoot(Heap::kUndefinedValueRootIndex);
|
||||
|
||||
// Save context, callee and call data.
|
||||
__ Push(context, callee, call_data);
|
||||
|
||||
+3
-10
@@ -592,16 +592,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
||||
// a0: number of arguments
|
||||
// a1: constructor function
|
||||
// a3: new target
|
||||
if (is_api_function) {
|
||||
__ ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
|
||||
Handle<Code> code =
|
||||
masm->isolate()->builtins()->HandleApiCallConstruct();
|
||||
__ Call(code, RelocInfo::CODE_TARGET);
|
||||
} else {
|
||||
ParameterCount actual(a0);
|
||||
__ InvokeFunction(a1, a3, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
}
|
||||
ParameterCount actual(a0);
|
||||
__ InvokeFunction(a1, a3, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
|
||||
// Store offset of return address for deoptimizer.
|
||||
if (create_implicit_receiver && !is_api_function) {
|
||||
|
||||
+5
-1
@@ -5636,7 +5636,11 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
|
||||
STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
|
||||
STATIC_ASSERT(FCA::kIsolateIndex == 1);
|
||||
STATIC_ASSERT(FCA::kHolderIndex == 0);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 7);
|
||||
STATIC_ASSERT(FCA::kNewTargetIndex == 7);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 8);
|
||||
|
||||
// new target
|
||||
__ PushRoot(Heap::kUndefinedValueRootIndex);
|
||||
|
||||
// Save context, callee and call data.
|
||||
__ Push(context, callee, call_data);
|
||||
|
||||
Vendored
+4
-9
@@ -605,15 +605,10 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
||||
// r3: number of arguments
|
||||
// r4: constructor function
|
||||
// r6: new target
|
||||
if (is_api_function) {
|
||||
__ LoadP(cp, FieldMemOperand(r4, JSFunction::kContextOffset));
|
||||
Handle<Code> code = masm->isolate()->builtins()->HandleApiCallConstruct();
|
||||
__ Call(code, RelocInfo::CODE_TARGET);
|
||||
} else {
|
||||
ParameterCount actual(r3);
|
||||
__ InvokeFunction(r4, r6, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
}
|
||||
|
||||
ParameterCount actual(r3);
|
||||
__ InvokeFunction(r4, r6, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
|
||||
// Store offset of return address for deoptimizer.
|
||||
if (create_implicit_receiver && !is_api_function) {
|
||||
|
||||
Vendored
+5
-1
@@ -5623,7 +5623,11 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
|
||||
STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
|
||||
STATIC_ASSERT(FCA::kIsolateIndex == 1);
|
||||
STATIC_ASSERT(FCA::kHolderIndex == 0);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 7);
|
||||
STATIC_ASSERT(FCA::kNewTargetIndex == 7);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 8);
|
||||
|
||||
// new target
|
||||
__ PushRoot(Heap::kUndefinedValueRootIndex);
|
||||
|
||||
// context save
|
||||
__ push(context);
|
||||
|
||||
Vendored
+4
-9
@@ -596,15 +596,10 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
||||
// r2: number of arguments
|
||||
// r3: constructor function
|
||||
// r5: new target
|
||||
if (is_api_function) {
|
||||
__ LoadP(cp, FieldMemOperand(r3, JSFunction::kContextOffset));
|
||||
Handle<Code> code = masm->isolate()->builtins()->HandleApiCallConstruct();
|
||||
__ Call(code, RelocInfo::CODE_TARGET);
|
||||
} else {
|
||||
ParameterCount actual(r2);
|
||||
__ InvokeFunction(r3, r5, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
}
|
||||
|
||||
ParameterCount actual(r2);
|
||||
__ InvokeFunction(r3, r5, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
|
||||
// Store offset of return address for deoptimizer.
|
||||
if (create_implicit_receiver && !is_api_function) {
|
||||
|
||||
Vendored
+5
-1
@@ -5533,7 +5533,11 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
|
||||
STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
|
||||
STATIC_ASSERT(FCA::kIsolateIndex == 1);
|
||||
STATIC_ASSERT(FCA::kHolderIndex == 0);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 7);
|
||||
STATIC_ASSERT(FCA::kNewTargetIndex == 7);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 8);
|
||||
|
||||
// new target
|
||||
__ PushRoot(Heap::kUndefinedValueRootIndex);
|
||||
|
||||
// context save
|
||||
__ push(context);
|
||||
|
||||
Vendored
+3
-10
@@ -185,16 +185,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
||||
__ j(greater_equal, &loop);
|
||||
|
||||
// Call the function.
|
||||
if (is_api_function) {
|
||||
__ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
|
||||
Handle<Code> code =
|
||||
masm->isolate()->builtins()->HandleApiCallConstruct();
|
||||
__ Call(code, RelocInfo::CODE_TARGET);
|
||||
} else {
|
||||
ParameterCount actual(rax);
|
||||
__ InvokeFunction(rdi, rdx, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
}
|
||||
ParameterCount actual(rax);
|
||||
__ InvokeFunction(rdi, rdx, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
|
||||
// Store offset of return address for deoptimizer.
|
||||
if (create_implicit_receiver && !is_api_function) {
|
||||
|
||||
Vendored
+5
-1
@@ -5404,10 +5404,14 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
|
||||
STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
|
||||
STATIC_ASSERT(FCA::kIsolateIndex == 1);
|
||||
STATIC_ASSERT(FCA::kHolderIndex == 0);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 7);
|
||||
STATIC_ASSERT(FCA::kNewTargetIndex == 7);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 8);
|
||||
|
||||
__ PopReturnAddressTo(return_address);
|
||||
|
||||
// new target
|
||||
__ PushRoot(Heap::kUndefinedValueRootIndex);
|
||||
|
||||
// context save
|
||||
__ Push(context);
|
||||
|
||||
|
||||
Vendored
+3
-10
@@ -186,16 +186,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
||||
__ j(greater_equal, &loop);
|
||||
|
||||
// Call the function.
|
||||
if (is_api_function) {
|
||||
__ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
|
||||
Handle<Code> code =
|
||||
masm->isolate()->builtins()->HandleApiCallConstruct();
|
||||
__ call(code, RelocInfo::CODE_TARGET);
|
||||
} else {
|
||||
ParameterCount actual(eax);
|
||||
__ InvokeFunction(edi, edx, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
}
|
||||
ParameterCount actual(eax);
|
||||
__ InvokeFunction(edi, edx, actual, CALL_FUNCTION,
|
||||
CheckDebugStepCallWrapper());
|
||||
|
||||
// Store offset of return address for deoptimizer.
|
||||
if (create_implicit_receiver && !is_api_function) {
|
||||
|
||||
Vendored
+6
-1
@@ -5354,9 +5354,14 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
|
||||
STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
|
||||
STATIC_ASSERT(FCA::kIsolateIndex == 1);
|
||||
STATIC_ASSERT(FCA::kHolderIndex == 0);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 7);
|
||||
STATIC_ASSERT(FCA::kNewTargetIndex == 7);
|
||||
STATIC_ASSERT(FCA::kArgsLength == 8);
|
||||
|
||||
__ pop(return_address);
|
||||
|
||||
// new target
|
||||
__ PushRoot(Heap::kUndefinedValueRootIndex);
|
||||
|
||||
// context save.
|
||||
__ push(context);
|
||||
|
||||
|
||||
Vendored
+37
@@ -13261,6 +13261,43 @@ THREADED_TEST(IsConstructCall) {
|
||||
CHECK(value->BooleanValue(context.local()).FromJust());
|
||||
}
|
||||
|
||||
static void NewTargetHandler(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
ApiTestFuzzer::Fuzz();
|
||||
args.GetReturnValue().Set(args.NewTarget());
|
||||
}
|
||||
|
||||
THREADED_TEST(NewTargetHandler) {
|
||||
v8::Isolate* isolate = CcTest::isolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
|
||||
// Function template with call handler.
|
||||
Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
|
||||
templ->SetCallHandler(NewTargetHandler);
|
||||
|
||||
LocalContext context;
|
||||
|
||||
Local<Function> function =
|
||||
templ->GetFunction(context.local()).ToLocalChecked();
|
||||
CHECK(context->Global()
|
||||
->Set(context.local(), v8_str("f"), function)
|
||||
.FromJust());
|
||||
Local<Value> value = CompileRun("f()");
|
||||
CHECK(value->IsUndefined());
|
||||
value = CompileRun("new f()");
|
||||
CHECK(value->IsFunction());
|
||||
CHECK(value == function);
|
||||
Local<Value> subclass = CompileRun("var g = class extends f { }; g");
|
||||
CHECK(subclass->IsFunction());
|
||||
value = CompileRun("new g()");
|
||||
CHECK(value->IsFunction());
|
||||
CHECK(value == subclass);
|
||||
value = CompileRun("Reflect.construct(f, [], Array)");
|
||||
CHECK(value->IsFunction());
|
||||
CHECK(value ==
|
||||
context->Global()
|
||||
->Get(context.local(), v8_str("Array"))
|
||||
.ToLocalChecked());
|
||||
}
|
||||
|
||||
THREADED_TEST(ObjectProtoToString) {
|
||||
v8::Isolate* isolate = CcTest::isolate();
|
||||
|
||||
Reference in new issue
Block a user