Revision: 18793
Author: [email protected]
Date: Thu Jan 23 17:24:54 2014 UTC
Log: Merged r18783, r18784 into trunk branch.
MIPS: Reland r18714 'Unify calling to GenerateFastApiCallBody before
stubbing it'.
MIPS: Turn FastNewContextStub into a HydrogenCodeStub.
[email protected], [email protected]
BUG=
Review URL: https://codereview.chromium.org/145853002
http://code.google.com/p/v8/source/detail?r=18793
Modified:
/trunk/src/mips/code-stubs-mips.cc
/trunk/src/mips/full-codegen-mips.cc
/trunk/src/mips/lithium-codegen-mips.cc
/trunk/src/mips/stub-cache-mips.cc
/trunk/src/version.cc
=======================================
--- /trunk/src/mips/code-stubs-mips.cc Thu Jan 23 09:38:20 2014 UTC
+++ /trunk/src/mips/code-stubs-mips.cc Thu Jan 23 17:24:54 2014 UTC
@@ -48,6 +48,16 @@
descriptor->deoptimization_handler_ =
Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry;
}
+
+
+void FastNewContextStub::InitializeInterfaceDescriptor(
+ Isolate* isolate,
+ CodeStubInterfaceDescriptor* descriptor) {
+ static Register registers[] = { a1 };
+ descriptor->register_param_count_ = 1;
+ descriptor->register_params_ = registers;
+ descriptor->deoptimization_handler_ = NULL;
+}
void ToNumberStub::InitializeInterfaceDescriptor(
@@ -451,47 +461,6 @@
__ Ret();
}
-
-
-void FastNewContextStub::Generate(MacroAssembler* masm) {
- // Try to allocate the context in new space.
- Label gc;
- int length = slots_ + Context::MIN_CONTEXT_SLOTS;
-
- // Attempt to allocate the context in new space.
- __ Allocate(FixedArray::SizeFor(length), v0, a1, a2, &gc, TAG_OBJECT);
-
- // Load the function from the stack.
- __ lw(a3, MemOperand(sp, 0));
-
- // Set up the object header.
- __ LoadRoot(a1, Heap::kFunctionContextMapRootIndex);
- __ li(a2, Operand(Smi::FromInt(length)));
- __ sw(a2, FieldMemOperand(v0, FixedArray::kLengthOffset));
- __ sw(a1, FieldMemOperand(v0, HeapObject::kMapOffset));
-
- // Set up the fixed slots, copy the global object from the previous
context.
- __ lw(a2, MemOperand(cp,
Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
- __ li(a1, Operand(Smi::FromInt(0)));
- __ sw(a3, MemOperand(v0, Context::SlotOffset(Context::CLOSURE_INDEX)));
- __ sw(cp, MemOperand(v0, Context::SlotOffset(Context::PREVIOUS_INDEX)));
- __ sw(a1, MemOperand(v0, Context::SlotOffset(Context::EXTENSION_INDEX)));
- __ sw(a2, MemOperand(v0,
Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
-
- // Initialize the rest of the slots to undefined.
- __ LoadRoot(a1, Heap::kUndefinedValueRootIndex);
- for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) {
- __ sw(a1, MemOperand(v0, Context::SlotOffset(i)));
- }
-
- // Remove the on-stack argument and return.
- __ mov(cp, v0);
- __ DropAndRet(1);
-
- // Need to collect. Call into runtime system.
- __ bind(&gc);
- __ TailCallRuntime(Runtime::kNewFunctionContext, 1, 1);
-}
void FastNewBlockContextStub::Generate(MacroAssembler* masm) {
=======================================
--- /trunk/src/mips/full-codegen-mips.cc Thu Jan 23 09:38:20 2014 UTC
+++ /trunk/src/mips/full-codegen-mips.cc Thu Jan 23 17:24:54 2014 UTC
@@ -211,20 +211,22 @@
if (heap_slots > 0) {
Comment cmnt(masm_, "[ Allocate context");
// Argument to NewContext is the function, which is still in a1.
- __ push(a1);
if (FLAG_harmony_scoping && info->scope()->is_global_scope()) {
+ __ push(a1);
__ Push(info->scope()->GetScopeInfo());
__ CallRuntime(Runtime::kNewGlobalContext, 2);
} else if (heap_slots <= FastNewContextStub::kMaximumSlots) {
FastNewContextStub stub(heap_slots);
__ CallStub(&stub);
} else {
+ __ push(a1);
__ CallRuntime(Runtime::kNewFunctionContext, 1);
}
function_in_register = false;
- // Context is returned in both v0 and cp. It replaces the context
- // passed to us. It's saved in the stack and kept live in cp.
- __ sw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+ // Context is returned in v0. It replaces the context passed to us.
+ // It's saved in the stack and kept live in cp.
+ __ mov(cp, v0);
+ __ sw(v0, MemOperand(fp, StandardFrameConstants::kContextOffset));
// Copy any necessary parameters into the context.
int num_parameters = info->scope()->num_parameters();
for (int i = 0; i < num_parameters; i++) {
=======================================
--- /trunk/src/mips/lithium-codegen-mips.cc Thu Jan 23 09:38:20 2014 UTC
+++ /trunk/src/mips/lithium-codegen-mips.cc Thu Jan 23 17:24:54 2014 UTC
@@ -204,17 +204,18 @@
if (heap_slots > 0) {
Comment(";;; Allocate local context");
// Argument to NewContext is the function, which is in a1.
- __ push(a1);
if (heap_slots <= FastNewContextStub::kMaximumSlots) {
FastNewContextStub stub(heap_slots);
__ CallStub(&stub);
} else {
+ __ push(a1);
__ CallRuntime(Runtime::kNewFunctionContext, 1);
}
RecordSafepoint(Safepoint::kNoLazyDeopt);
- // Context is returned in both v0 and cp. It replaces the context
- // passed to us. It's saved in the stack and kept live in cp.
- __ sw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+ // Context is returned in both v0. It replaces the context passed to
us.
+ // It's saved in the stack and kept live in cp.
+ __ mov(cp, v0);
+ __ sw(v0, MemOperand(fp, StandardFrameConstants::kContextOffset));
// Copy any necessary parameters into the context.
int num_parameters = scope()->num_parameters();
for (int i = 0; i < num_parameters; i++) {
=======================================
--- /trunk/src/mips/stub-cache-mips.cc Thu Jan 23 09:38:20 2014 UTC
+++ /trunk/src/mips/stub-cache-mips.cc Thu Jan 23 17:24:54 2014 UTC
@@ -767,64 +767,70 @@
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) {
- ASSERT(Smi::FromInt(0) == 0);
- for (int i = 0; i < kFastApiCallArguments; i++) {
- __ push(zero_reg);
- }
-}
-
-// 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) {
+static void GenerateFastApiCallBody(MacroAssembler* masm,
+ const CallOptimization& optimization,
+ int argc,
+ Register holder,
+ Register scratch1,
+ Register scratch2,
+ Register scratch3,
+ bool restore_context) {
// ----------- S t a t e -------------
- // -- sp[0] - sp[24] : FunctionCallbackInfo, incl.
- // : holder (set by CheckPrototypes)
- // -- sp[28] : last JS argument
+ // -- sp[0] : last JS argument
// -- ...
- // -- sp[(argc + 6) * 4] : first JS argument
- // -- sp[(argc + 7) * 4] : receiver
+ // -- sp[(argc - 1) * 4] : first JS argument
+ // -- sp[argc * 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.
- __ sw(cp, MemOperand(sp, FCA::kContextSaveIndex * kPointerSize));
+ __ push(cp);
// Get the function and setup the context.
Handle<JSFunction> function = optimization.constant_function();
- __ li(t1, function);
- __ lw(cp, FieldMemOperand(t1, JSFunction::kContextOffset));
- __ sw(t1, MemOperand(sp, FCA::kCalleeIndex * kPointerSize));
+ __ li(scratch1, function);
+ __ lw(cp, FieldMemOperand(scratch1, JSFunction::kContextOffset));
+ __ push(scratch1);
// 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)) {
- __ li(a0, api_call_info);
- __ lw(t2, FieldMemOperand(a0, CallHandlerInfo::kDataOffset));
+ __ li(scratch1, api_call_info);
+ __ lw(scratch1, FieldMemOperand(scratch1,
CallHandlerInfo::kDataOffset));
+ } else if (call_data->IsUndefined()) {
+ call_data_undefined = true;
+ __ LoadRoot(scratch3, Heap::kUndefinedValueRootIndex);
} else {
- __ li(t2, call_data);
+ __ li(scratch1, call_data);
}
// Store call data.
- __ sw(t2, MemOperand(sp, FCA::kDataIndex * kPointerSize));
- // Store isolate.
- __ li(t3, Operand(ExternalReference::isolate_address(masm->isolate())));
- __ sw(t3, MemOperand(sp, FCA::kIsolateIndex * kPointerSize));
+ __ push(scratch1);
+ if (!call_data_undefined) {
+ __ LoadRoot(scratch1, Heap::kUndefinedValueRootIndex);
+ }
// Store ReturnValue default and ReturnValue.
- __ LoadRoot(t1, Heap::kUndefinedValueRootIndex);
- __ sw(t1, MemOperand(sp, FCA::kReturnValueOffset * kPointerSize));
- __ sw(t1, MemOperand(sp, FCA::kReturnValueDefaultValueIndex *
kPointerSize));
+ __ LoadRoot(scratch1, Heap::kUndefinedValueRootIndex);
+ __ Push(scratch1, scratch1);
+ // Store isolate.
+ __ li(scratch1,
Operand(ExternalReference::isolate_address(masm->isolate())));
+ __ push(scratch1);
+ // Store holder.
+ __ push(holder);
// Prepare arguments.
__ Move(a2, sp);
@@ -879,6 +885,50 @@
restore_context ?
&context_restore_operand : NULL);
}
+
+
+// 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, a0, a1);
+
+ // Move holder to a register.
+ Register holder_reg = a0;
+ switch (holder_lookup) {
+ case CallOptimization::kHolderIsReceiver:
+ {
+ ASSERT(map_to_holder.is_null());
+ __ lw(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)) {
+ __ li(holder_reg, holder);
+ } else {
+ __ li(holder_reg, map_to_holder);
+ __ lw(holder_reg,
+ FieldMemOperand(holder_reg, Map::kPrototypeOffset));
+ }
+ }
+ break;
+ case CallOptimization::kHolderNotFound:
+ UNREACHABLE();
+ }
+ GenerateFastApiCallBody(masm,
+ optimization,
+ argc,
+ holder_reg,
+ a1,
+ a2,
+ a3,
+ false);
+}
// Generate call to api function.
@@ -888,26 +938,32 @@
Register scratch,
int argc,
Register* values) {
- ASSERT(optimization.is_simple_api_call());
ASSERT(!receiver.is(scratch));
-
- typedef FunctionCallbackArguments FCA;
- const int stack_space = kFastApiCallArguments + argc + 1;
- // Assign stack space for the call arguments.
- __ Subu(sp, sp, Operand(stack_space * kPointerSize));
- // Write holder to stack frame.
- __ sw(receiver, MemOperand(sp, FCA::kHolderIndex * kPointerSize));
- // Write receiver to stack frame.
- int index = stack_space - 1;
- __ sw(receiver, MemOperand(sp, index-- * kPointerSize));
+ __ push(receiver);
// Write the arguments to stack frame.
for (int i = 0; i < argc; i++) {
- ASSERT(!receiver.is(values[i]));
- ASSERT(!scratch.is(values[i]));
- __ sw(values[i], MemOperand(sp, index-- * kPointerSize));
+ Register arg = values[argc-1-i];
+ ASSERT(!receiver.is(arg));
+ ASSERT(!scratch.is(arg));
+ __ push(arg);
}
- GenerateFastApiDirectCall(masm, optimization, argc, true);
+ Register scratch1 = a0;
+ Register scratch2 = a1;
+ Register scratch3 = a2;
+ if (!a3.is(receiver)) {
+ __ mov(a3, receiver);
+ receiver = a3;
+ }
+ // Stack now matches JSFunction abi.
+ GenerateFastApiCallBody(masm,
+ optimization,
+ argc,
+ receiver,
+ scratch1,
+ scratch2,
+ scratch3,
+ true);
}
@@ -960,39 +1016,17 @@
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, depth1, miss);
+ name, miss_label);
// Invoke an interceptor and if it provides a value,
// branch to |regular_invoke|.
@@ -1009,37 +1043,42 @@
stub_compiler_->CheckPrototypes(
IC::CurrentTypeOf(interceptor_holder, masm->isolate()), holder,
handle(lookup->holder()), scratch1, scratch2, scratch3,
- 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);
+ 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);
+ }
}
// Invoke function.
- if (can_do_fast_api_call) {
- GenerateFastApiDirectCall(
- masm, optimization, arguments_.immediate(), false);
+ if (holder_lookup != CallOptimization::kHolderNotFound) {
+ int argc = arguments_.immediate();
+ GenerateFastApiCall(masm,
+ optimization,
+ argc,
+ lookup_map,
+ holder_lookup);
} else {
Handle<JSFunction> function = optimization.constant_function();
__ Move(a0, 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);
- __ Branch(miss_label);
- }
// Invoke a regular function.
__ bind(®ular_invoke);
- if (can_do_fast_api_call) {
- FreeSpaceForFastApiCall(masm);
- }
}
void CompileRegular(MacroAssembler* masm,
@@ -1114,7 +1153,6 @@
Register scratch1,
Register scratch2,
Handle<Name> name,
- int save_at_depth,
Label* miss,
PrototypeCheckType check) {
Handle<Map> receiver_map(IC::TypeToMap(*type, isolate()));
@@ -1130,11 +1168,6 @@
// Keep track of the current object in register reg.
Register reg = object_reg;
int depth = 0;
-
- typedef FunctionCallbackArguments FCA;
- if (save_at_depth == depth) {
- __ sw(reg, MemOperand(sp, FCA::kHolderIndex * kPointerSize));
- }
Handle<JSObject> current = Handle<JSObject>::null();
if (type->IsConstant()) current =
Handle<JSObject>::cast(type->AsConstant());
@@ -1200,10 +1233,6 @@
__ li(reg, Operand(prototype));
}
}
-
- if (save_at_depth == depth) {
- __ sw(reg, MemOperand(sp, FCA::kHolderIndex * kPointerSize));
- }
// Go to the next object in the prototype chain.
current = prototype;
@@ -1572,37 +1601,36 @@
if (object->IsGlobalObject()) return Handle<Code>::null();
if (!cell.is_null()) return Handle<Code>::null();
if (!object->IsJSObject()) return Handle<Code>::null();
- int depth = optimization.GetPrototypeDepthOfExpectedType(
- Handle<JSObject>::cast(object), holder);
- if (depth == kInvalidProtoDepth) 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();
+ }
- Label miss, miss_before_stack_reserved;
-
- GenerateNameCheck(name, &miss_before_stack_reserved);
+ Label miss;
+ GenerateNameCheck(name, &miss);
// Get the receiver from the stack.
const int argc = arguments().immediate();
__ lw(a1, MemOperand(sp, argc * kPointerSize));
// Check that the receiver isn't a smi.
- __ JumpIfSmi(a1, &miss_before_stack_reserved);
+ __ JumpIfSmi(a1, &miss);
__ IncrementCounter(counters->call_const(), 1, a0, a3);
- __ IncrementCounter(counters->call_const_fast_api(), 1, a0, a3);
-
- ReserveSpaceForFastApiCall(masm(), a0);
// Check that the maps haven't changed and find a Holder as a side
effect.
CheckPrototypes(
IC::CurrentTypeOf(object, isolate()),
- a1, holder, a0, a3, t0, name, depth, &miss);
-
- GenerateFastApiDirectCall(masm(), optimization, argc, false);
+ a1, holder, a0, a3, t0, name, &miss);
- __ bind(&miss);
- FreeSpaceForFastApiCall(masm());
+ GenerateFastApiCall(
+ masm(), optimization, argc, lookup_map, holder_lookup);
- HandlerFrontendFooter(&miss_before_stack_reserved);
+ HandlerFrontendFooter(&miss);
// Return the generated code.
return GetCode(function);
=======================================
--- /trunk/src/version.cc Thu Jan 23 09:38:20 2014 UTC
+++ /trunk/src/version.cc Thu Jan 23 17:24:54 2014 UTC
@@ -35,7 +35,7 @@
#define MAJOR_VERSION 3
#define MINOR_VERSION 24
#define BUILD_NUMBER 22
-#define PATCH_LEVEL 0
+#define PATCH_LEVEL 1
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
#define IS_CANDIDATE_VERSION 0
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.