From bc42d95cc357f880f58c88f1b7b4a793ebabb07c Mon Sep 17 00:00:00 2001 From: "serya@chromium.org" Date: Fri, 19 Nov 2010 09:06:00 +0000 Subject: [PATCH] Avoiding repacking payload for v8::Arguments and v8::AccessorInfo (arm) Review URL: http://codereview.chromium.org/5107002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5859 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/apiutils.h | 3 +++ src/arm/stub-cache-arm.cc | 33 ++++++++++++++++----------------- src/builtins.cc | 21 +++++++-------------- src/ia32/stub-cache-ia32.cc | 8 ++++---- src/stub-cache.cc | 7 ++----- src/x64/stub-cache-x64.cc | 2 +- test/cctest/test-api.cc | 8 +++++--- 7 files changed, 38 insertions(+), 44 deletions(-) diff --git a/src/apiutils.h b/src/apiutils.h index 1313dda..9683aa4 100644 --- a/src/apiutils.h +++ b/src/apiutils.h @@ -58,6 +58,9 @@ class ImplementationUtilities { static v8::Arguments NewArguments(internal::Object** implicit_args, internal::Object** argv, int argc, bool is_construct_call) { + ASSERT(implicit_args[v8::Arguments::kCalleeIndex]->IsJSFunction()); + ASSERT(implicit_args[v8::Arguments::kHolderIndex]->IsHeapObject()); + return v8::Arguments(implicit_args, argv, argc, is_construct_call); } diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc index 957bb3c..f3f7a5d 100644 --- a/src/arm/stub-cache-arm.cc +++ b/src/arm/stub-cache-arm.cc @@ -598,8 +598,8 @@ static void GenerateFastApiCall(MacroAssembler* masm, int argc) { // Get the function and setup the context. JSFunction* function = optimization.constant_function(); - __ mov(r7, Operand(Handle(function))); - __ ldr(cp, FieldMemOperand(r7, JSFunction::kContextOffset)); + __ mov(r5, Operand(Handle(function))); + __ ldr(cp, FieldMemOperand(r5, JSFunction::kContextOffset)); // Pass the additional arguments FastHandleApiCall expects. bool info_loaded = false; @@ -607,18 +607,18 @@ static void GenerateFastApiCall(MacroAssembler* masm, if (Heap::InNewSpace(callback)) { info_loaded = true; __ Move(r0, Handle(optimization.api_call_info())); - __ ldr(r6, FieldMemOperand(r0, CallHandlerInfo::kCallbackOffset)); + __ ldr(r7, FieldMemOperand(r0, CallHandlerInfo::kCallbackOffset)); } else { - __ Move(r6, Handle(callback)); + __ Move(r7, Handle(callback)); } Object* call_data = optimization.api_call_info()->data(); if (Heap::InNewSpace(call_data)) { if (!info_loaded) { __ Move(r0, Handle(optimization.api_call_info())); } - __ ldr(r5, FieldMemOperand(r0, CallHandlerInfo::kDataOffset)); + __ ldr(r6, FieldMemOperand(r0, CallHandlerInfo::kDataOffset)); } else { - __ Move(r5, Handle(call_data)); + __ Move(r6, Handle(call_data)); } __ add(sp, sp, Operand(1 * kPointerSize)); @@ -1082,10 +1082,9 @@ bool StubCompiler::GenerateLoadCallback(JSObject* object, // Push the arguments on the JS stack of the caller. __ push(receiver); // Receiver. - __ push(reg); // Holder. - __ mov(ip, Operand(Handle(callback))); // callback data - __ ldr(reg, FieldMemOperand(ip, AccessorInfo::kDataOffset)); - __ Push(ip, reg, name_reg); + __ mov(scratch3, Operand(Handle(callback))); // callback data + __ ldr(ip, FieldMemOperand(scratch3, AccessorInfo::kDataOffset)); + __ Push(reg, ip, scratch3, name_reg); // Do tail-call to the runtime system. ExternalReference load_callback_property = @@ -1208,15 +1207,15 @@ void StubCompiler::GenerateLoadInterceptor(JSObject* object, // holder_reg is either receiver or scratch1. if (!receiver.is(holder_reg)) { ASSERT(scratch1.is(holder_reg)); - __ Push(receiver, holder_reg, scratch2); - __ ldr(scratch1, - FieldMemOperand(holder_reg, AccessorInfo::kDataOffset)); - __ Push(scratch1, name_reg); + __ Push(receiver, holder_reg); + __ ldr(scratch3, + FieldMemOperand(scratch2, AccessorInfo::kDataOffset)); + __ Push(scratch3, scratch2, name_reg); } else { __ push(receiver); - __ ldr(scratch1, - FieldMemOperand(holder_reg, AccessorInfo::kDataOffset)); - __ Push(holder_reg, scratch2, scratch1, name_reg); + __ ldr(scratch3, + FieldMemOperand(scratch2, AccessorInfo::kDataOffset)); + __ Push(holder_reg, scratch3, scratch2, name_reg); } ExternalReference ref = diff --git a/src/builtins.cc b/src/builtins.cc index aede302..e88ef6f 100644 --- a/src/builtins.cc +++ b/src/builtins.cc @@ -1081,29 +1081,22 @@ BUILTIN(FastHandleApiCall) { ASSERT(!CalledAsConstructor()); const bool is_construct = false; - // We expect four more arguments: function, callback, call data, and holder. + // We expect four more arguments: callback, function, call data, and holder. const int args_length = args.length() - 4; ASSERT(args_length >= 0); - Handle function = args.at(args_length); - Object* callback_obj = args[args_length + 1]; - Handle data = args.at(args_length + 2); - Handle checked_holder = args.at(args_length + 3); - -#ifdef DEBUG - VerifyTypeCheck(checked_holder, function); -#endif - - CustomArguments custom; - v8::ImplementationUtilities::PrepareArgumentsData(custom.end(), - *data, *function, *checked_holder); + Object* callback_obj = args[args_length]; v8::Arguments new_args = v8::ImplementationUtilities::NewArguments( - custom.end(), + &args[args_length + 1], &args[0] - 1, args_length - 1, is_construct); +#ifdef DEBUG + VerifyTypeCheck(Utils::OpenHandle(*new_args.Holder()), + Utils::OpenHandle(*new_args.Callee())); +#endif HandleScope scope; Object* result; v8::Handle value; diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc index 6bfa6b9..011390c 100644 --- a/src/ia32/stub-cache-ia32.cc +++ b/src/ia32/stub-cache-ia32.cc @@ -417,7 +417,7 @@ static void CompileCallLoadPropertyWithInterceptor(MacroAssembler* masm, static const int kFastApiCallArguments = 3; -// Reserves space for the extra arguments to FastHandleApiCall in the +// Reserves space for the extra arguments to API function in the // caller's frame. // // These arguments are set by CheckPrototypes and GenerateFastApiCall. @@ -450,7 +450,7 @@ static void FreeSpaceForFastApiCall(MacroAssembler* masm, Register scratch) { } -// Generates call to FastHandleApiCall builtin. +// Generates call to API function. static bool GenerateFastApiCall(MacroAssembler* masm, const CallOptimization& optimization, int argc, @@ -473,7 +473,7 @@ static bool GenerateFastApiCall(MacroAssembler* masm, __ mov(edi, Immediate(Handle(function))); __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); - // Pass the additional arguments FastHandleApiCall expects. + // Pass the additional arguments. __ mov(Operand(esp, 2 * kPointerSize), edi); Object* call_data = optimization.api_call_info()->data(); Handle api_call_info_handle(optimization.api_call_info()); @@ -1263,8 +1263,8 @@ void StubCompiler::GenerateLoadInterceptor(JSObject* object, __ push(receiver); __ push(holder_reg); __ mov(holder_reg, Immediate(Handle(callback))); - __ push(holder_reg); __ push(FieldOperand(holder_reg, AccessorInfo::kDataOffset)); + __ push(holder_reg); __ push(name_reg); __ push(scratch2); // restore return address diff --git a/src/stub-cache.cc b/src/stub-cache.cc index b7c769c..5cc009f 100644 --- a/src/stub-cache.cc +++ b/src/stub-cache.cc @@ -960,14 +960,11 @@ void StubCache::Clear() { MaybeObject* LoadCallbackProperty(Arguments args) { ASSERT(args[0]->IsJSObject()); ASSERT(args[1]->IsJSObject()); - AccessorInfo* callback = AccessorInfo::cast(args[2]); + AccessorInfo* callback = AccessorInfo::cast(args[3]); Address getter_address = v8::ToCData
(callback->getter()); v8::AccessorGetter fun = FUNCTION_CAST(getter_address); ASSERT(fun != NULL); - CustomArguments custom_args(callback->data(), - JSObject::cast(args[0]), - JSObject::cast(args[1])); - v8::AccessorInfo info(custom_args.end()); + v8::AccessorInfo info(&args[0]); HandleScope scope; v8::Handle result; { diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc index 2e60dd5..dbf93f5 100644 --- a/src/x64/stub-cache-x64.cc +++ b/src/x64/stub-cache-x64.cc @@ -2588,8 +2588,8 @@ void StubCompiler::GenerateLoadInterceptor(JSObject* object, __ push(receiver); __ push(holder_reg); __ Move(holder_reg, Handle(callback)); - __ push(holder_reg); __ push(FieldOperand(holder_reg, AccessorInfo::kDataOffset)); + __ push(holder_reg); __ push(name_reg); __ push(scratch2); // restore return address diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index b4f6914..5322314 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -6324,7 +6324,7 @@ static void CheckInterceptorLoadIC(NamedPropertyGetter getter, int expected) { v8::HandleScope scope; v8::Handle templ = ObjectTemplate::New(); - templ->SetNamedPropertyHandler(getter); + templ->SetNamedPropertyHandler(getter, 0, 0, 0, 0, v8_str("data")); LocalContext context; context->Global()->Set(v8_str("o"), templ->NewInstance()); v8::Handle value = CompileRun(source); @@ -6335,7 +6335,8 @@ static void CheckInterceptorLoadIC(NamedPropertyGetter getter, static v8::Handle InterceptorLoadICGetter(Local name, const AccessorInfo& info) { ApiTestFuzzer::Fuzz(); - CHECK(v8_str("x")->Equals(name)); + CHECK_EQ(v8_str("data"), info.Data()); + CHECK_EQ(v8_str("x"), name); return v8::Integer::New(42); } @@ -6733,7 +6734,8 @@ THREADED_TEST(InterceptorStoreIC) { v8::HandleScope scope; v8::Handle templ = ObjectTemplate::New(); templ->SetNamedPropertyHandler(InterceptorLoadICGetter, - InterceptorStoreICSetter); + InterceptorStoreICSetter, + 0, 0, 0, v8_str("data")); LocalContext context; context->Global()->Set(v8_str("o"), templ->NewInstance()); v8::Handle value = CompileRun( -- 2.7.4