From 474ecd67eae43aa0f2af968547cee1f02543f313 Mon Sep 17 00:00:00 2001 From: epertoso Date: Fri, 11 Dec 2015 02:20:04 -0800 Subject: [PATCH] Revert of Removes the Callee parameter from FunctionCallbackInfo. (patchset #1 id:1 of https://codereview.chromium.org/1510483002/ ) Reason for revert: Need to figure out a better solution for this. Original issue's description: > Removes the Callee parameter from FunctionCallbackInfo. > > This will help us to instantiate AccessorPair's getters and setters only when they are needed. > > BUG= > > Committed: https://crrev.com/2fe34ebdcdee0f21b88daa4098a7918e91abb8fb > Cr-Commit-Position: refs/heads/master@{#32759} TBR=jochen@chromium.org,verwaest@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG= Review URL: https://codereview.chromium.org/1520843002 Cr-Commit-Position: refs/heads/master@{#32787} --- include/v8.h | 13 +++++++++++-- src/arguments.h | 4 ++++ src/arm/code-stubs-arm.cc | 8 ++++++-- src/arm64/code-stubs-arm64.cc | 7 ++++--- src/builtins.cc | 2 ++ src/ia32/code-stubs-ia32.cc | 8 ++++++-- src/mips/code-stubs-mips.cc | 7 ++++--- src/mips64/code-stubs-mips64.cc | 7 ++++--- src/ppc/code-stubs-ppc.cc | 8 ++++++-- src/x64/code-stubs-x64.cc | 8 ++++++-- src/x87/code-stubs-x87.cc | 8 ++++++-- test/cctest/test-api.cc | 2 ++ 12 files changed, 61 insertions(+), 21 deletions(-) diff --git a/include/v8.h b/include/v8.h index 2f80f16d79..8834b49c57 100644 --- a/include/v8.h +++ b/include/v8.h @@ -3142,6 +3142,7 @@ class FunctionCallbackInfo { public: V8_INLINE int Length() const; V8_INLINE Local operator[](int i) const; + V8_INLINE Local Callee() const; V8_INLINE Local This() const; V8_INLINE Local Holder() const; V8_INLINE bool IsConstructCall() const; @@ -3149,7 +3150,7 @@ class FunctionCallbackInfo { V8_INLINE Isolate* GetIsolate() const; V8_INLINE ReturnValue GetReturnValue() const; // This shouldn't be public, but the arm compiler needs it. - static const int kArgsLength = 6; + static const int kArgsLength = 7; protected: friend class internal::FunctionCallbackArguments; @@ -3159,7 +3160,8 @@ class FunctionCallbackInfo { static const int kReturnValueDefaultValueIndex = 2; static const int kReturnValueIndex = 3; static const int kDataIndex = 4; - static const int kContextSaveIndex = 5; + static const int kCalleeIndex = 5; + static const int kContextSaveIndex = 6; V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args, internal::Object** values, @@ -7588,6 +7590,13 @@ Local FunctionCallbackInfo::operator[](int i) const { } +template +Local FunctionCallbackInfo::Callee() const { + return Local(reinterpret_cast( + &implicit_args_[kCalleeIndex])); +} + + template Local FunctionCallbackInfo::This() const { return Local(reinterpret_cast(values_ + 1)); diff --git a/src/arguments.h b/src/arguments.h index 7ee7069ce3..d11a8cd61e 100644 --- a/src/arguments.h +++ b/src/arguments.h @@ -215,10 +215,12 @@ class FunctionCallbackArguments static const int kReturnValueDefaultValueIndex = T::kReturnValueDefaultValueIndex; static const int kIsolateIndex = T::kIsolateIndex; + static const int kCalleeIndex = T::kCalleeIndex; static const int kContextSaveIndex = T::kContextSaveIndex; FunctionCallbackArguments(internal::Isolate* isolate, internal::Object* data, + internal::JSFunction* callee, internal::Object* holder, internal::Object** argv, int argc, @@ -229,6 +231,7 @@ class FunctionCallbackArguments is_construct_call_(is_construct_call) { Object** values = begin(); values[T::kDataIndex] = data; + values[T::kCalleeIndex] = callee; values[T::kHolderIndex] = holder; values[T::kContextSaveIndex] = isolate->heap()->the_hole_value(); values[T::kIsolateIndex] = reinterpret_cast(isolate); @@ -237,6 +240,7 @@ class FunctionCallbackArguments values[T::kReturnValueDefaultValueIndex] = isolate->heap()->the_hole_value(); values[T::kReturnValueIndex] = isolate->heap()->the_hole_value(); + DCHECK(values[T::kCalleeIndex]->IsJSFunction()); DCHECK(values[T::kHolderIndex]->IsHeapObject()); DCHECK(values[T::kIsolateIndex]->IsSmi()); } diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index 344f6db1ae..971e67004e 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -5215,13 +5215,14 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, typedef FunctionCallbackArguments FCA; - STATIC_ASSERT(FCA::kContextSaveIndex == 5); + STATIC_ASSERT(FCA::kContextSaveIndex == 6); + STATIC_ASSERT(FCA::kCalleeIndex == 5); STATIC_ASSERT(FCA::kDataIndex == 4); STATIC_ASSERT(FCA::kReturnValueOffset == 3); STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); STATIC_ASSERT(FCA::kIsolateIndex == 1); STATIC_ASSERT(FCA::kHolderIndex == 0); - STATIC_ASSERT(FCA::kArgsLength == 6); + STATIC_ASSERT(FCA::kArgsLength == 7); DCHECK(argc.is_immediate() || r3.is(argc.reg())); @@ -5230,6 +5231,9 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, // load context from callee __ ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset)); + // callee + __ push(callee); + // call data __ push(call_data); diff --git a/src/arm64/code-stubs-arm64.cc b/src/arm64/code-stubs-arm64.cc index a2d1c034fa..f0bc691e83 100644 --- a/src/arm64/code-stubs-arm64.cc +++ b/src/arm64/code-stubs-arm64.cc @@ -5640,18 +5640,19 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, typedef FunctionCallbackArguments FCA; - STATIC_ASSERT(FCA::kContextSaveIndex == 5); + STATIC_ASSERT(FCA::kContextSaveIndex == 6); + STATIC_ASSERT(FCA::kCalleeIndex == 5); STATIC_ASSERT(FCA::kDataIndex == 4); STATIC_ASSERT(FCA::kReturnValueOffset == 3); STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); STATIC_ASSERT(FCA::kIsolateIndex == 1); STATIC_ASSERT(FCA::kHolderIndex == 0); - STATIC_ASSERT(FCA::kArgsLength == 6); + STATIC_ASSERT(FCA::kArgsLength == 7); DCHECK(argc.is_immediate() || x3.is(argc.reg())); // FunctionCallbackArguments: context, callee and call data. - __ Push(context, call_data); + __ Push(context, callee, call_data); // Load context from callee __ Ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset)); diff --git a/src/builtins.cc b/src/builtins.cc index fcd4575a34..c9f9f69225 100644 --- a/src/builtins.cc +++ b/src/builtins.cc @@ -1903,6 +1903,7 @@ MUST_USE_RESULT MaybeHandle HandleApiCallHelper( FunctionCallbackArguments custom(isolate, data_obj, + *function, raw_holder, &args[0] - 1, args.length() - 1, @@ -2065,6 +2066,7 @@ MUST_USE_RESULT static Object* HandleApiCallAsFunctionOrConstructor( FunctionCallbackArguments custom(isolate, call_data->data(), + constructor, obj, &args[0] - 1, args.length() - 1, diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc index 817b71dc60..6c7420e84f 100644 --- a/src/ia32/code-stubs-ia32.cc +++ b/src/ia32/code-stubs-ia32.cc @@ -5473,13 +5473,14 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, typedef FunctionCallbackArguments FCA; - STATIC_ASSERT(FCA::kContextSaveIndex == 5); + STATIC_ASSERT(FCA::kContextSaveIndex == 6); + STATIC_ASSERT(FCA::kCalleeIndex == 5); STATIC_ASSERT(FCA::kDataIndex == 4); STATIC_ASSERT(FCA::kReturnValueOffset == 3); STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); STATIC_ASSERT(FCA::kIsolateIndex == 1); STATIC_ASSERT(FCA::kHolderIndex == 0); - STATIC_ASSERT(FCA::kArgsLength == 6); + STATIC_ASSERT(FCA::kArgsLength == 7); DCHECK(argc.is_immediate() || eax.is(argc.reg())); @@ -5493,6 +5494,9 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, return_address = context; } + // callee + __ push(callee); + // call data __ push(call_data); diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc index 1921f7a6b8..476f82eaf8 100644 --- a/src/mips/code-stubs-mips.cc +++ b/src/mips/code-stubs-mips.cc @@ -5425,18 +5425,19 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, typedef FunctionCallbackArguments FCA; - STATIC_ASSERT(FCA::kContextSaveIndex == 5); + STATIC_ASSERT(FCA::kContextSaveIndex == 6); + STATIC_ASSERT(FCA::kCalleeIndex == 5); STATIC_ASSERT(FCA::kDataIndex == 4); STATIC_ASSERT(FCA::kReturnValueOffset == 3); STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); STATIC_ASSERT(FCA::kIsolateIndex == 1); STATIC_ASSERT(FCA::kHolderIndex == 0); - STATIC_ASSERT(FCA::kArgsLength == 6); + STATIC_ASSERT(FCA::kArgsLength == 7); DCHECK(argc.is_immediate() || a3.is(argc.reg())); // Save context, callee and call data. - __ Push(context, call_data); + __ Push(context, callee, call_data); // Load context from callee. __ lw(context, FieldMemOperand(callee, JSFunction::kContextOffset)); diff --git a/src/mips64/code-stubs-mips64.cc b/src/mips64/code-stubs-mips64.cc index 55ccc5f2e8..9649e420d8 100644 --- a/src/mips64/code-stubs-mips64.cc +++ b/src/mips64/code-stubs-mips64.cc @@ -5451,18 +5451,19 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, typedef FunctionCallbackArguments FCA; - STATIC_ASSERT(FCA::kContextSaveIndex == 5); + STATIC_ASSERT(FCA::kContextSaveIndex == 6); + STATIC_ASSERT(FCA::kCalleeIndex == 5); STATIC_ASSERT(FCA::kDataIndex == 4); STATIC_ASSERT(FCA::kReturnValueOffset == 3); STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); STATIC_ASSERT(FCA::kIsolateIndex == 1); STATIC_ASSERT(FCA::kHolderIndex == 0); - STATIC_ASSERT(FCA::kArgsLength == 6); + STATIC_ASSERT(FCA::kArgsLength == 7); DCHECK(argc.is_immediate() || a3.is(argc.reg())); // Save context, callee and call data. - __ Push(context, call_data); + __ Push(context, callee, call_data); // Load context from callee. __ ld(context, FieldMemOperand(callee, JSFunction::kContextOffset)); diff --git a/src/ppc/code-stubs-ppc.cc b/src/ppc/code-stubs-ppc.cc index 788818068a..a835d572dd 100644 --- a/src/ppc/code-stubs-ppc.cc +++ b/src/ppc/code-stubs-ppc.cc @@ -5454,13 +5454,14 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, typedef FunctionCallbackArguments FCA; - STATIC_ASSERT(FCA::kContextSaveIndex == 5); + STATIC_ASSERT(FCA::kContextSaveIndex == 6); + STATIC_ASSERT(FCA::kCalleeIndex == 5); STATIC_ASSERT(FCA::kDataIndex == 4); STATIC_ASSERT(FCA::kReturnValueOffset == 3); STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); STATIC_ASSERT(FCA::kIsolateIndex == 1); STATIC_ASSERT(FCA::kHolderIndex == 0); - STATIC_ASSERT(FCA::kArgsLength == 6); + STATIC_ASSERT(FCA::kArgsLength == 7); DCHECK(argc.is_immediate() || r3.is(argc.reg())); @@ -5469,6 +5470,9 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, // load context from callee __ LoadP(context, FieldMemOperand(callee, JSFunction::kContextOffset)); + // callee + __ push(callee); + // call data __ push(call_data); diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc index 080c89c109..a97e7ecaae 100644 --- a/src/x64/code-stubs-x64.cc +++ b/src/x64/code-stubs-x64.cc @@ -5210,13 +5210,14 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, typedef FunctionCallbackArguments FCA; - STATIC_ASSERT(FCA::kContextSaveIndex == 5); + STATIC_ASSERT(FCA::kContextSaveIndex == 6); + STATIC_ASSERT(FCA::kCalleeIndex == 5); STATIC_ASSERT(FCA::kDataIndex == 4); STATIC_ASSERT(FCA::kReturnValueOffset == 3); STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); STATIC_ASSERT(FCA::kIsolateIndex == 1); STATIC_ASSERT(FCA::kHolderIndex == 0); - STATIC_ASSERT(FCA::kArgsLength == 6); + STATIC_ASSERT(FCA::kArgsLength == 7); DCHECK(argc.is_immediate() || rax.is(argc.reg())); @@ -5225,6 +5226,9 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, // context save __ Push(context); + // callee + __ Push(callee); + // call data __ Push(call_data); Register scratch = call_data; diff --git a/src/x87/code-stubs-x87.cc b/src/x87/code-stubs-x87.cc index 47d6c7dc83..8bc78fd9bd 100644 --- a/src/x87/code-stubs-x87.cc +++ b/src/x87/code-stubs-x87.cc @@ -5155,13 +5155,14 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, typedef FunctionCallbackArguments FCA; - STATIC_ASSERT(FCA::kContextSaveIndex == 5); + STATIC_ASSERT(FCA::kContextSaveIndex == 6); + STATIC_ASSERT(FCA::kCalleeIndex == 5); STATIC_ASSERT(FCA::kDataIndex == 4); STATIC_ASSERT(FCA::kReturnValueOffset == 3); STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); STATIC_ASSERT(FCA::kIsolateIndex == 1); STATIC_ASSERT(FCA::kHolderIndex == 0); - STATIC_ASSERT(FCA::kArgsLength == 6); + STATIC_ASSERT(FCA::kArgsLength == 7); DCHECK(argc.is_immediate() || eax.is(argc.reg())); @@ -5175,6 +5176,9 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, return_address = context; } + // callee + __ push(callee); + // call data __ push(call_data); diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 4886db5736..9b9823d9da 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -7682,6 +7682,7 @@ static void ArgumentsTestCallback( ApiTestFuzzer::Fuzz(); v8::Isolate* isolate = args.GetIsolate(); Local context = isolate->GetCurrentContext(); + CHECK(args_fun->Equals(context, args.Callee()).FromJust()); CHECK_EQ(3, args.Length()); CHECK(v8::Integer::New(isolate, 1)->Equals(context, args[0]).FromJust()); CHECK(v8::Integer::New(isolate, 2)->Equals(context, args[1]).FromJust()); @@ -21757,6 +21758,7 @@ class ApiCallOptimizationChecker { static void OptimizationCallback( const v8::FunctionCallbackInfo& info) { + CHECK(callee == info.Callee()); CHECK(data == info.Data()); CHECK(receiver == info.This()); if (info.Length() == 1) {