Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(898)

Unified Diff: src/arm/stub-cache-arm.cc

Issue 144143002: Revert "Unify calling to GenerateFastApiCallBody before stubbing it" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/ia32/stub-cache-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/arm/stub-cache-arm.cc
diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc
index 987437bbd7bd60163f17c9d828fad46951f0c6fc..8625ed6f35c33c51f191b57567ccae2fa83c2597 100644
--- a/src/arm/stub-cache-arm.cc
+++ b/src/arm/stub-cache-arm.cc
@@ -779,72 +779,64 @@ static void CompileCallLoadPropertyWithInterceptor(
static const int kFastApiCallArguments = FunctionCallbackArguments::kArgsLength;
+// Reserves space for the extra arguments to API function in the
+// caller's frame.
+//
+// These arguments are set by CheckPrototypes and GenerateFastApiDirectCall.
+static void ReserveSpaceForFastApiCall(MacroAssembler* masm,
+ Register scratch) {
+ __ mov(scratch, Operand(Smi::FromInt(0)));
+ for (int i = 0; i < kFastApiCallArguments; i++) {
+ __ push(scratch);
+ }
+}
+
-static void GenerateFastApiCallBody(MacroAssembler* masm,
- const CallOptimization& optimization,
- int argc,
- Register holder,
- Register scratch1,
- Register scratch2,
- Register scratch3,
- bool restore_context) {
+// Undoes the effects of ReserveSpaceForFastApiCall.
+static void FreeSpaceForFastApiCall(MacroAssembler* masm) {
+ __ Drop(kFastApiCallArguments);
+}
+
+
+static void GenerateFastApiDirectCall(MacroAssembler* masm,
+ const CallOptimization& optimization,
+ int argc,
+ bool restore_context) {
// ----------- S t a t e -------------
- // -- sp[0] : last JS argument
+ // -- sp[0] - sp[24] : FunctionCallbackInfo, incl.
+ // : holder (set by CheckPrototypes)
+ // -- sp[28] : last JS argument
// -- ...
- // -- sp[(argc - 1) * 4] : first JS argument
- // -- sp[argc * 4] : receiver
+ // -- sp[(argc + 6) * 4] : first JS argument
+ // -- sp[(argc + 7) * 4] : receiver
// -----------------------------------
- ASSERT(optimization.is_simple_api_call());
-
typedef FunctionCallbackArguments FCA;
-
- STATIC_ASSERT(FCA::kHolderIndex == 0);
- STATIC_ASSERT(FCA::kIsolateIndex == 1);
- STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
- STATIC_ASSERT(FCA::kReturnValueOffset == 3);
- STATIC_ASSERT(FCA::kDataIndex == 4);
- STATIC_ASSERT(FCA::kCalleeIndex == 5);
- STATIC_ASSERT(FCA::kContextSaveIndex == 6);
- STATIC_ASSERT(FCA::kArgsLength == 7);
-
- ASSERT(!holder.is(cp));
-
// Save calling context.
- __ push(cp);
+ __ str(cp, MemOperand(sp, FCA::kContextSaveIndex * kPointerSize));
// Get the function and setup the context.
Handle<JSFunction> function = optimization.constant_function();
- __ Move(scratch1, function);
- __ ldr(cp, FieldMemOperand(scratch1, JSFunction::kContextOffset));
- __ push(scratch1);
+ __ Move(r5, function);
+ __ ldr(cp, FieldMemOperand(r5, JSFunction::kContextOffset));
+ __ str(r5, MemOperand(sp, FCA::kCalleeIndex * kPointerSize));
// Construct the FunctionCallbackInfo.
Handle<CallHandlerInfo> api_call_info = optimization.api_call_info();
Handle<Object> call_data(api_call_info->data(), masm->isolate());
- bool call_data_undefined = false;
if (masm->isolate()->heap()->InNewSpace(*call_data)) {
- __ Move(scratch1, api_call_info);
- __ ldr(scratch1, FieldMemOperand(scratch1, CallHandlerInfo::kDataOffset));
- } else if (call_data->IsUndefined()) {
- call_data_undefined = true;
- __ LoadRoot(scratch3, Heap::kUndefinedValueRootIndex);
+ __ Move(r0, api_call_info);
+ __ ldr(r6, FieldMemOperand(r0, CallHandlerInfo::kDataOffset));
} else {
- __ Move(scratch1, call_data);
+ __ Move(r6, call_data);
}
// Store call data.
- __ push(scratch1);
- if (!call_data_undefined) {
- __ LoadRoot(scratch1, Heap::kUndefinedValueRootIndex);
- }
- // Store ReturnValue default and ReturnValue.
- __ LoadRoot(scratch1, Heap::kUndefinedValueRootIndex);
- __ push(scratch1);
- __ push(scratch1);
+ __ str(r6, MemOperand(sp, FCA::kDataIndex * kPointerSize));
// Store isolate.
- __ mov(scratch1,
- Operand(ExternalReference::isolate_address(masm->isolate())));
- __ push(scratch1);
- // holder
- __ push(holder);
+ __ mov(r5, Operand(ExternalReference::isolate_address(masm->isolate())));
+ __ str(r5, MemOperand(sp, FCA::kIsolateIndex * kPointerSize));
+ // Store ReturnValue default and ReturnValue.
+ __ LoadRoot(r5, Heap::kUndefinedValueRootIndex);
+ __ str(r5, MemOperand(sp, FCA::kReturnValueOffset * kPointerSize));
+ __ str(r5, MemOperand(sp, FCA::kReturnValueDefaultValueIndex * kPointerSize));
// Prepare arguments.
__ mov(r2, sp);
@@ -901,50 +893,6 @@ static void GenerateFastApiCallBody(MacroAssembler* masm,
}
-// Generates call to API function.
-static void GenerateFastApiCall(MacroAssembler* masm,
- const CallOptimization& optimization,
- int argc,
- Handle<Map> map_to_holder,
- CallOptimization::HolderLookup holder_lookup) {
- Counters* counters = masm->isolate()->counters();
- __ IncrementCounter(counters->call_const_fast_api(), 1, r0, r1);
-
- // Move holder to a register
- Register holder_reg = r0;
- switch (holder_lookup) {
- case CallOptimization::kHolderIsReceiver:
- {
- ASSERT(map_to_holder.is_null());
- __ ldr(holder_reg, MemOperand(sp, argc * kPointerSize));
- }
- break;
- case CallOptimization::kHolderIsPrototypeOfMap:
- {
- Handle<JSObject> holder(JSObject::cast(map_to_holder->prototype()));
- if (!masm->isolate()->heap()->InNewSpace(*holder)) {
- __ Move(holder_reg, holder);
- } else {
- __ Move(holder_reg, map_to_holder);
- __ ldr(holder_reg,
- FieldMemOperand(holder_reg, Map::kPrototypeOffset));
- }
- }
- break;
- case CallOptimization::kHolderNotFound:
- UNREACHABLE();
- }
- GenerateFastApiCallBody(masm,
- optimization,
- argc,
- holder_reg,
- r1,
- r2,
- r3,
- false);
-}
-
-
// Generate call to api function.
static void GenerateFastApiCall(MacroAssembler* masm,
const CallOptimization& optimization,
@@ -952,31 +900,26 @@ static void GenerateFastApiCall(MacroAssembler* masm,
Register scratch,
int argc,
Register* values) {
+ ASSERT(optimization.is_simple_api_call());
ASSERT(!receiver.is(scratch));
- __ push(receiver);
+
+ typedef FunctionCallbackArguments FCA;
+ const int stack_space = kFastApiCallArguments + argc + 1;
+ // Assign stack space for the call arguments.
+ __ sub(sp, sp, Operand(stack_space * kPointerSize));
+ // Write holder to stack frame.
+ __ str(receiver, MemOperand(sp, FCA::kHolderIndex * kPointerSize));
+ // Write receiver to stack frame.
+ int index = stack_space - 1;
+ __ str(receiver, MemOperand(sp, index-- * kPointerSize));
// Write the arguments to stack frame.
for (int i = 0; i < argc; i++) {
- Register arg = values[argc-1-i];
- ASSERT(!receiver.is(arg));
- ASSERT(!scratch.is(arg));
- __ push(arg);
- }
- Register scratch1 = r0;
- Register scratch2 = r1;
- Register scratch3 = r2;
- if (!r3.is(receiver)) {
- __ mov(r3, receiver);
- receiver = r3;
+ ASSERT(!receiver.is(values[i]));
+ ASSERT(!scratch.is(values[i]));
+ __ str(values[i], MemOperand(sp, index-- * kPointerSize));
}
- // Stack now matches JSFunction abi.
- GenerateFastApiCallBody(masm,
- optimization,
- argc,
- receiver,
- scratch1,
- scratch2,
- scratch3,
- true);
+
+ GenerateFastApiDirectCall(masm, optimization, argc, true);
}
@@ -1029,17 +972,39 @@ class CallInterceptorCompiler BASE_EMBEDDED {
ASSERT(optimization.is_constant_call());
ASSERT(!lookup->holder()->IsGlobalObject());
Counters* counters = masm->isolate()->counters();
+ int depth1 = kInvalidProtoDepth;
+ int depth2 = kInvalidProtoDepth;
+ bool can_do_fast_api_call = false;
+ if (optimization.is_simple_api_call() &&
+ !lookup->holder()->IsGlobalObject()) {
+ depth1 = optimization.GetPrototypeDepthOfExpectedType(
+ object, interceptor_holder);
+ if (depth1 == kInvalidProtoDepth) {
+ depth2 = optimization.GetPrototypeDepthOfExpectedType(
+ interceptor_holder, Handle<JSObject>(lookup->holder()));
+ }
+ can_do_fast_api_call =
+ depth1 != kInvalidProtoDepth || depth2 != kInvalidProtoDepth;
+ }
+
__ IncrementCounter(counters->call_const_interceptor(), 1,
scratch1, scratch2);
+ if (can_do_fast_api_call) {
+ __ IncrementCounter(counters->call_const_interceptor_fast_api(), 1,
+ scratch1, scratch2);
+ ReserveSpaceForFastApiCall(masm, scratch1);
+ }
+
// Check that the maps from receiver to interceptor's holder
// haven't changed and thus we can invoke interceptor.
Label miss_cleanup;
+ Label* miss = can_do_fast_api_call ? &miss_cleanup : miss_label;
Register holder =
stub_compiler_->CheckPrototypes(
IC::CurrentTypeOf(object, masm->isolate()), receiver,
interceptor_holder, scratch1, scratch2, scratch3,
- name, miss_label);
+ name, depth1, miss);
// Invoke an interceptor and if it provides a value,
// branch to |regular_invoke|.
@@ -1056,42 +1021,37 @@ class CallInterceptorCompiler BASE_EMBEDDED {
stub_compiler_->CheckPrototypes(
IC::CurrentTypeOf(interceptor_holder, masm->isolate()), holder,
handle(lookup->holder()), scratch1, scratch2, scratch3,
- name, miss_label);
- }
-
- Handle<Map> lookup_map;
- CallOptimization::HolderLookup holder_lookup =
- CallOptimization::kHolderNotFound;
- if (optimization.is_simple_api_call() &&
- !lookup->holder()->IsGlobalObject()) {
- lookup_map = optimization.LookupHolderOfExpectedType(
- object, object, interceptor_holder, &holder_lookup);
- if (holder_lookup == CallOptimization::kHolderNotFound) {
- lookup_map =
- optimization.LookupHolderOfExpectedType(
- object,
- interceptor_holder,
- Handle<JSObject>(lookup->holder()),
- &holder_lookup);
- }
+ name, depth2, miss);
+ } else {
+ // CheckPrototypes has a side effect of fetching a 'holder'
+ // for API (object which is instanceof for the signature). It's
+ // safe to omit it here, as if present, it should be fetched
+ // by the previous CheckPrototypes.
+ ASSERT(depth2 == kInvalidProtoDepth);
}
// Invoke function.
- if (holder_lookup != CallOptimization::kHolderNotFound) {
- int argc = arguments_.immediate();
- GenerateFastApiCall(masm,
- optimization,
- argc,
- lookup_map,
- holder_lookup);
+ if (can_do_fast_api_call) {
+ GenerateFastApiDirectCall(
+ masm, optimization, arguments_.immediate(), false);
} else {
Handle<JSFunction> function = optimization.constant_function();
__ Move(r0, receiver);
stub_compiler_->GenerateJumpFunction(object, function);
}
+ // Deferred code for fast API call case---clean preallocated space.
+ if (can_do_fast_api_call) {
+ __ bind(&miss_cleanup);
+ FreeSpaceForFastApiCall(masm);
+ __ b(miss_label);
+ }
+
// Invoke a regular function.
__ bind(&regular_invoke);
+ if (can_do_fast_api_call) {
+ FreeSpaceForFastApiCall(masm);
+ }
}
void CompileRegular(MacroAssembler* masm,
@@ -1167,6 +1127,7 @@ Register StubCompiler::CheckPrototypes(Handle<HeapType> type,
Register scratch1,
Register scratch2,
Handle<Name> name,
+ int save_at_depth,
Label* miss,
PrototypeCheckType check) {
Handle<Map> receiver_map(IC::TypeToMap(*type, isolate()));
@@ -1183,6 +1144,11 @@ Register StubCompiler::CheckPrototypes(Handle<HeapType> type,
Register reg = object_reg;
int depth = 0;
+ typedef FunctionCallbackArguments FCA;
+ if (save_at_depth == depth) {
+ __ str(reg, MemOperand(sp, FCA::kHolderIndex * kPointerSize));
+ }
+
Handle<JSObject> current = Handle<JSObject>::null();
if (type->IsConstant()) current = Handle<JSObject>::cast(type->AsConstant());
Handle<JSObject> prototype = Handle<JSObject>::null();
@@ -1248,6 +1214,10 @@ Register StubCompiler::CheckPrototypes(Handle<HeapType> type,
}
}
+ if (save_at_depth == depth) {
+ __ str(reg, MemOperand(sp, FCA::kHolderIndex * kPointerSize));
+ }
+
// Go to the next object in the prototype chain.
current = prototype;
current_map = handle(current->map());
@@ -1616,36 +1586,36 @@ Handle<Code> CallStubCompiler::CompileFastApiCall(
if (object->IsGlobalObject()) return Handle<Code>::null();
if (!cell.is_null()) return Handle<Code>::null();
if (!object->IsJSObject()) return Handle<Code>::null();
- Handle<JSObject> receiver = Handle<JSObject>::cast(object);
- CallOptimization::HolderLookup holder_lookup =
- CallOptimization::kHolderNotFound;
- Handle<Map> lookup_map = optimization.LookupHolderOfExpectedType(
- receiver, receiver, holder, &holder_lookup);
- if (holder_lookup == CallOptimization::kHolderNotFound) {
- return Handle<Code>::null();
- }
+ int depth = optimization.GetPrototypeDepthOfExpectedType(
+ Handle<JSObject>::cast(object), holder);
+ if (depth == kInvalidProtoDepth) return Handle<Code>::null();
- Label miss;
- GenerateNameCheck(name, &miss);
+ Label miss, miss_before_stack_reserved;
+ GenerateNameCheck(name, &miss_before_stack_reserved);
// Get the receiver from the stack.
const int argc = arguments().immediate();
__ ldr(r1, MemOperand(sp, argc * kPointerSize));
// Check that the receiver isn't a smi.
- __ JumpIfSmi(r1, &miss);
+ __ JumpIfSmi(r1, &miss_before_stack_reserved);
__ IncrementCounter(counters->call_const(), 1, r0, r3);
+ __ IncrementCounter(counters->call_const_fast_api(), 1, r0, r3);
+
+ ReserveSpaceForFastApiCall(masm(), r0);
// Check that the maps haven't changed and find a Holder as a side effect.
CheckPrototypes(
IC::CurrentTypeOf(object, isolate()),
- r1, holder, r0, r3, r4, name, &miss);
+ r1, holder, r0, r3, r4, name, depth, &miss);
- GenerateFastApiCall(
- masm(), optimization, argc, lookup_map, holder_lookup);
+ GenerateFastApiDirectCall(masm(), optimization, argc, false);
- HandlerFrontendFooter(&miss);
+ __ bind(&miss);
+ FreeSpaceForFastApiCall(masm());
+
+ HandlerFrontendFooter(&miss_before_stack_reserved);
// Return the generated code.
return GetCode(function);
« no previous file with comments | « no previous file | src/ia32/stub-cache-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698