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

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

Issue 148343005: A64: Synchronize with r18147. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | « src/mips/macro-assembler-mips.cc ('k') | src/object-observe.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mips/stub-cache-mips.cc
diff --git a/src/mips/stub-cache-mips.cc b/src/mips/stub-cache-mips.cc
index e7437015b036315733e29056b2d7227637ea4d1d..4190e628c0d6c084b6c8788a48b48994cb1d7748 100644
--- a/src/mips/stub-cache-mips.cc
+++ b/src/mips/stub-cache-mips.cc
@@ -732,35 +732,6 @@ void StoreStubCompiler::GenerateRestoreName(MacroAssembler* masm,
}
-static void GenerateCallFunction(MacroAssembler* masm,
- Handle<Object> object,
- const ParameterCount& arguments,
- Label* miss,
- Code::ExtraICState extra_ic_state) {
- // ----------- S t a t e -------------
- // -- a0: receiver
- // -- a1: function to call
- // -----------------------------------
- // Check that the function really is a function.
- __ JumpIfSmi(a1, miss);
- __ GetObjectType(a1, a3, a3);
- __ Branch(miss, ne, a3, Operand(JS_FUNCTION_TYPE));
-
- // Patch the receiver on the stack with the global proxy if
- // necessary.
- if (object->IsGlobalObject()) {
- __ lw(a3, FieldMemOperand(a0, GlobalObject::kGlobalReceiverOffset));
- __ sw(a3, MemOperand(sp, arguments.immediate() * kPointerSize));
- }
-
- // Invoke the function.
- CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state)
- ? CALL_AS_FUNCTION
- : CALL_AS_METHOD;
- __ InvokeFunction(a1, arguments, JUMP_FUNCTION, NullCallWrapper(), call_kind);
-}
-
-
static void PushInterceptorArguments(MacroAssembler* masm,
Register receiver,
Register holder,
@@ -942,10 +913,10 @@ static void GenerateFastApiCall(MacroAssembler* masm,
class CallInterceptorCompiler BASE_EMBEDDED {
public:
- CallInterceptorCompiler(StubCompiler* stub_compiler,
+ CallInterceptorCompiler(CallStubCompiler* stub_compiler,
const ParameterCount& arguments,
Register name,
- Code::ExtraICState extra_ic_state)
+ ExtraICState extra_ic_state)
: stub_compiler_(stub_compiler),
arguments_(arguments),
name_(name),
@@ -1054,13 +1025,8 @@ class CallInterceptorCompiler BASE_EMBEDDED {
GenerateFastApiDirectCall(
masm, optimization, arguments_.immediate(), false);
} else {
- CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state_)
- ? CALL_AS_FUNCTION
- : CALL_AS_METHOD;
Handle<JSFunction> function = optimization.constant_function();
- ParameterCount expected(function);
- __ InvokeFunction(function, expected, arguments_,
- JUMP_FUNCTION, NullCallWrapper(), call_kind);
+ stub_compiler_->GenerateJumpFunction(object, function);
}
// Deferred code for fast API call case---clean preallocated space.
@@ -1126,10 +1092,10 @@ class CallInterceptorCompiler BASE_EMBEDDED {
__ Branch(interceptor_succeeded, ne, v0, Operand(scratch));
}
- StubCompiler* stub_compiler_;
+ CallStubCompiler* stub_compiler_;
const ParameterCount& arguments_;
Register name_;
- Code::ExtraICState extra_ic_state_;
+ ExtraICState extra_ic_state_;
};
@@ -1527,22 +1493,12 @@ void CallStubCompiler::GenerateNameCheck(Handle<Name> name, Label* miss) {
}
-void CallStubCompiler::GenerateGlobalReceiverCheck(Handle<JSObject> object,
- Handle<JSObject> holder,
- Handle<Name> name,
- Label* miss) {
- ASSERT(holder->IsGlobalObject());
-
- // Get the number of arguments.
- const int argc = arguments().immediate();
-
- // Get the receiver from the stack.
- __ lw(a0, MemOperand(sp, argc * kPointerSize));
-
- // Check that the maps haven't changed.
- __ JumpIfSmi(a0, miss);
- CheckPrototypes(
- IC::CurrentTypeOf(object, isolate()), a0, holder, a3, a1, t0, name, miss);
+void CallStubCompiler::GenerateFunctionCheck(Register function,
+ Register scratch,
+ Label* miss) {
+ __ JumpIfSmi(function, miss);
+ __ GetObjectType(function, scratch, scratch);
+ __ Branch(miss, ne, scratch, Operand(JS_FUNCTION_TYPE));
}
@@ -1561,9 +1517,7 @@ void CallStubCompiler::GenerateLoadFunctionFromCell(
// the nice side effect that multiple closures based on the same
// function can all use this call IC. Before we load through the
// function, we have to verify that it still is a function.
- __ JumpIfSmi(a1, miss);
- __ GetObjectType(a1, a3, a3);
- __ Branch(miss, ne, a3, Operand(JS_FUNCTION_TYPE));
+ GenerateFunctionCheck(a1, a3, miss);
// Check the shared function info. Make sure it hasn't changed.
__ li(a3, Handle<SharedFunctionInfo>(function->shared()));
@@ -1588,33 +1542,15 @@ Handle<Code> CallStubCompiler::CompileCallField(Handle<JSObject> object,
Handle<JSObject> holder,
PropertyIndex index,
Handle<Name> name) {
- // ----------- S t a t e -------------
- // -- a2 : name
- // -- ra : return address
- // -----------------------------------
Label miss;
- GenerateNameCheck(name, &miss);
-
- const int argc = arguments().immediate();
-
- // Get the receiver of the function from the stack into a0.
- __ lw(a0, MemOperand(sp, argc * kPointerSize));
- // Check that the receiver isn't a smi.
- __ JumpIfSmi(a0, &miss, t0);
-
- // Do the right check and compute the holder register.
- Register reg = CheckPrototypes(
- IC::CurrentTypeOf(object, isolate()),
- a0, holder, a1, a3, t0, name, &miss);
+ Register reg = HandlerFrontendHeader(
+ object, holder, name, RECEIVER_MAP_CHECK, &miss);
GenerateFastPropertyLoad(masm(), a1, reg, index.is_inobject(holder),
index.translate(holder), Representation::Tagged());
+ GenerateJumpFunction(object, a1, &miss);
- GenerateCallFunction(masm(), object, arguments(), &miss, extra_state_);
-
- // Handle call cache miss.
- __ bind(&miss);
- GenerateMissBranch();
+ HandlerFrontendFooter(&miss);
// Return the generated code.
return GetCode(Code::FAST, name);
@@ -1630,31 +1566,16 @@ Handle<Code> CallStubCompiler::CompileArrayCodeCall(
Code::StubType type) {
Label miss;
- // Check that function is still array.
- const int argc = arguments().immediate();
- GenerateNameCheck(name, &miss);
- Register receiver = a1;
-
- if (cell.is_null()) {
- __ lw(receiver, MemOperand(sp, argc * kPointerSize));
-
- // Check that the receiver isn't a smi.
- __ JumpIfSmi(receiver, &miss);
-
- // Check that the maps haven't changed.
- CheckPrototypes(
- IC::CurrentTypeOf(object, isolate()), receiver, holder,
- a3, a0, t0, name, &miss);
- } else {
+ HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
+ if (!cell.is_null()) {
ASSERT(cell->value() == *function);
- GenerateGlobalReceiverCheck(Handle<JSObject>::cast(object), holder, name,
- &miss);
GenerateLoadFunctionFromCell(cell, function, &miss);
}
Handle<AllocationSite> site = isolate()->factory()->NewAllocationSite();
site->SetElementsKind(GetInitialFastElementsKind());
Handle<Cell> site_feedback_cell = isolate()->factory()->NewCell(site);
+ const int argc = arguments().immediate();
__ li(a0, Operand(argc));
__ li(a2, Operand(site_feedback_cell));
__ li(a1, Operand(function));
@@ -1662,8 +1583,7 @@ Handle<Code> CallStubCompiler::CompileArrayCodeCall(
ArrayConstructorStub stub(isolate());
__ TailCallStub(&stub);
- __ bind(&miss);
- GenerateMissBranch();
+ HandlerFrontendFooter(&miss);
// Return the generated code.
return GetCode(type, name);
@@ -1677,14 +1597,6 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
Handle<JSFunction> function,
Handle<String> name,
Code::StubType type) {
- // ----------- S t a t e -------------
- // -- a2 : name
- // -- ra : return address
- // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based)
- // -- ...
- // -- sp[argc * 4] : receiver
- // -----------------------------------
-
// If object is not an array or is observed, bail out to regular call.
if (!object->IsJSArray() ||
!cell.is_null() ||
@@ -1693,22 +1605,11 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
}
Label miss;
+ HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
+ Register receiver = a0;
+ Register scratch = a1;
- GenerateNameCheck(name, &miss);
-
- Register receiver = a1;
-
- // Get the receiver from the stack.
const int argc = arguments().immediate();
- __ lw(receiver, MemOperand(sp, argc * kPointerSize));
-
- // Check that the receiver isn't a smi.
- __ JumpIfSmi(receiver, &miss);
-
- // Check that the maps haven't changed.
- CheckPrototypes(
- IC::CurrentTypeOf(object, isolate()), receiver, holder,
- a3, v0, t0, name, &miss);
if (argc == 0) {
// Nothing to do, just return the length.
@@ -1726,34 +1627,34 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
// Check that the elements are in fast mode and writable.
__ CheckMap(elements,
- v0,
+ scratch,
Heap::kFixedArrayMapRootIndex,
&check_double,
DONT_DO_SMI_CHECK);
- // Get the array's length into v0 and calculate new length.
- __ lw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset));
+ // Get the array's length into scratch and calculate new length.
+ __ lw(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
STATIC_ASSERT(kSmiTagSize == 1);
STATIC_ASSERT(kSmiTag == 0);
- __ Addu(v0, v0, Operand(Smi::FromInt(argc)));
+ __ Addu(scratch, scratch, Operand(Smi::FromInt(argc)));
// Get the elements' length.
__ lw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset));
// Check if we could survive without allocation.
- __ Branch(&attempt_to_grow_elements, gt, v0, Operand(t0));
+ __ Branch(&attempt_to_grow_elements, gt, scratch, Operand(t0));
// Check if value is a smi.
__ lw(t0, MemOperand(sp, (argc - 1) * kPointerSize));
__ JumpIfNotSmi(t0, &with_write_barrier);
// Save new length.
- __ sw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset));
+ __ sw(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
// Store the value.
// We may need a register containing the address end_elements below,
// so write back the value in end_elements.
- __ sll(end_elements, v0, kPointerSizeLog2 - kSmiTagSize);
+ __ sll(end_elements, scratch, kPointerSizeLog2 - kSmiTagSize);
__ Addu(end_elements, elements, end_elements);
const int kEndElementsOffset =
FixedArray::kHeaderSize - kHeapObjectTag - argc * kPointerSize;
@@ -1761,38 +1662,39 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
__ sw(t0, MemOperand(end_elements));
// Check for a smi.
+ __ mov(v0, scratch);
__ DropAndRet(argc + 1);
__ bind(&check_double);
// Check that the elements are in fast mode and writable.
__ CheckMap(elements,
- a0,
+ scratch,
Heap::kFixedDoubleArrayMapRootIndex,
&call_builtin,
DONT_DO_SMI_CHECK);
- // Get the array's length into v0 and calculate new length.
- __ lw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset));
+ // Get the array's length into scratch and calculate new length.
+ __ lw(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
STATIC_ASSERT(kSmiTagSize == 1);
STATIC_ASSERT(kSmiTag == 0);
- __ Addu(v0, v0, Operand(Smi::FromInt(argc)));
+ __ Addu(scratch, scratch, Operand(Smi::FromInt(argc)));
// Get the elements' length.
__ lw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset));
// Check if we could survive without allocation.
- __ Branch(&call_builtin, gt, v0, Operand(t0));
+ __ Branch(&call_builtin, gt, scratch, Operand(t0));
__ lw(t0, MemOperand(sp, (argc - 1) * kPointerSize));
__ StoreNumberToDoubleElements(
- t0, v0, elements, a3, t1, a2,
+ t0, scratch, elements, a3, t1, a2,
&call_builtin, argc * kDoubleSize);
// Save new length.
- __ sw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset));
+ __ sw(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
- // Check for a smi.
+ __ mov(v0, scratch);
__ DropAndRet(argc + 1);
__ bind(&with_write_barrier);
@@ -1842,12 +1744,12 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
}
// Save new length.
- __ sw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset));
+ __ sw(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
// Store the value.
// We may need a register containing the address end_elements below,
// so write back the value in end_elements.
- __ sll(end_elements, v0, kPointerSizeLog2 - kSmiTagSize);
+ __ sll(end_elements, scratch, kPointerSizeLog2 - kSmiTagSize);
__ Addu(end_elements, elements, end_elements);
__ Addu(end_elements, end_elements, kEndElementsOffset);
__ sw(t0, MemOperand(end_elements));
@@ -1859,10 +1761,11 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
kDontSaveFPRegs,
EMIT_REMEMBERED_SET,
OMIT_SMI_CHECK);
+ __ mov(v0, scratch);
__ DropAndRet(argc + 1);
__ bind(&attempt_to_grow_elements);
- // v0: array's length + 1.
+ // scratch: array's length + 1.
// t0: elements' length.
if (!FLAG_inline_new) {
@@ -1885,7 +1788,7 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
const int kAllocationDelta = 4;
// Load top and check if it is the end of elements.
- __ sll(end_elements, v0, kPointerSizeLog2 - kSmiTagSize);
+ __ sll(end_elements, scratch, kPointerSizeLog2 - kSmiTagSize);
__ Addu(end_elements, elements, end_elements);
__ Addu(end_elements, end_elements, Operand(kEndElementsOffset));
__ li(t3, Operand(new_space_allocation_top));
@@ -1909,11 +1812,12 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
}
// Update elements' and array's sizes.
- __ sw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset));
+ __ sw(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
__ Addu(t0, t0, Operand(Smi::FromInt(kAllocationDelta)));
__ sw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset));
// Elements are in new space, so write barrier is not required.
+ __ mov(v0, scratch);
__ DropAndRet(argc + 1);
}
__ bind(&call_builtin);
@@ -1921,9 +1825,7 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
ExternalReference(Builtins::c_ArrayPush, isolate()), argc + 1, 1);
}
- // Handle call cache miss.
- __ bind(&miss);
- GenerateMissBranch();
+ HandlerFrontendFooter(&miss);
// Return the generated code.
return GetCode(type, name);
@@ -1937,14 +1839,6 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall(
Handle<JSFunction> function,
Handle<String> name,
Code::StubType type) {
- // ----------- S t a t e -------------
- // -- a2 : name
- // -- ra : return address
- // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based)
- // -- ...
- // -- sp[argc * 4] : receiver
- // -----------------------------------
-
// If object is not an array or is observed, bail out to regular call.
if (!object->IsJSArray() ||
!cell.is_null() ||
@@ -1953,27 +1847,17 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall(
}
Label miss, return_undefined, call_builtin;
- Register receiver = a1;
+ Register receiver = a0;
+ Register scratch = a1;
Register elements = a3;
- GenerateNameCheck(name, &miss);
-
- // Get the receiver from the stack.
- const int argc = arguments().immediate();
- __ lw(receiver, MemOperand(sp, argc * kPointerSize));
- // Check that the receiver isn't a smi.
- __ JumpIfSmi(receiver, &miss);
-
- // Check that the maps haven't changed.
- CheckPrototypes(
- IC::CurrentTypeOf(object, isolate()), receiver, holder,
- elements, t0, v0, name, &miss);
+ HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
// Get the elements array of the object.
__ lw(elements, FieldMemOperand(receiver, JSArray::kElementsOffset));
// Check that the elements are in fast mode and writable.
__ CheckMap(elements,
- v0,
+ scratch,
Heap::kFixedArrayMapRootIndex,
&call_builtin,
DONT_DO_SMI_CHECK);
@@ -1991,14 +1875,16 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall(
// expensive shift first, and use an offset later on.
__ sll(t1, t0, kPointerSizeLog2 - kSmiTagSize);
__ Addu(elements, elements, t1);
- __ lw(v0, FieldMemOperand(elements, FixedArray::kHeaderSize));
- __ Branch(&call_builtin, eq, v0, Operand(t2));
+ __ lw(scratch, FieldMemOperand(elements, FixedArray::kHeaderSize));
+ __ Branch(&call_builtin, eq, scratch, Operand(t2));
// Set the array's length.
__ sw(t0, FieldMemOperand(receiver, JSArray::kLengthOffset));
// Fill with the hole.
__ sw(t2, FieldMemOperand(elements, FixedArray::kHeaderSize));
+ const int argc = arguments().immediate();
+ __ mov(v0, scratch);
__ DropAndRet(argc + 1);
__ bind(&return_undefined);
@@ -2009,9 +1895,7 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall(
__ TailCallExternalReference(
ExternalReference(Builtins::c_ArrayPop, isolate()), argc + 1, 1);
- // Handle call cache miss.
- __ bind(&miss);
- GenerateMissBranch();
+ HandlerFrontendFooter(&miss);
// Return the generated code.
return GetCode(type, name);
@@ -2025,18 +1909,9 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall(
Handle<JSFunction> function,
Handle<String> name,
Code::StubType type) {
- // ----------- S t a t e -------------
- // -- a2 : function name
- // -- ra : return address
- // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based)
- // -- ...
- // -- sp[argc * 4] : receiver
- // -----------------------------------
-
// If object is not a string, bail out to regular call.
if (!object->IsString() || !cell.is_null()) return Handle<Code>::null();
- const int argc = arguments().immediate();
Label miss;
Label name_miss;
Label index_out_of_range;
@@ -2049,22 +1924,12 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall(
index_out_of_range_label = &miss;
}
- GenerateNameCheck(name, &name_miss);
+ HandlerFrontendHeader(object, holder, name, STRING_CHECK, &name_miss);
- // Check that the maps starting from the prototype haven't changed.
- GenerateDirectLoadGlobalFunctionPrototype(masm(),
- Context::STRING_FUNCTION_INDEX,
- v0,
- &miss);
- ASSERT(!object.is_identical_to(holder));
- Handle<JSObject> prototype(JSObject::cast(object->GetPrototype(isolate())));
- CheckPrototypes(
- IC::CurrentTypeOf(prototype, isolate()),
- v0, holder, a1, a3, t0, name, &miss);
-
- Register receiver = a1;
+ Register receiver = a0;
Register index = t1;
- Register result = v0;
+ Register result = a1;
+ const int argc = arguments().immediate();
__ lw(receiver, MemOperand(sp, argc * kPointerSize));
if (argc > 0) {
__ lw(index, MemOperand(sp, (argc - 1) * kPointerSize));
@@ -2080,6 +1945,7 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall(
index_out_of_range_label,
STRING_INDEX_IS_NUMBER);
generator.GenerateFast(masm());
+ __ mov(v0, result);
__ DropAndRet(argc + 1);
StubRuntimeCallHelper call_helper;
@@ -2094,8 +1960,7 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall(
__ bind(&miss);
// Restore function name in a2.
__ li(a2, name);
- __ bind(&name_miss);
- GenerateMissBranch();
+ HandlerFrontendFooter(&name_miss);
// Return the generated code.
return GetCode(type, name);
@@ -2109,14 +1974,6 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall(
Handle<JSFunction> function,
Handle<String> name,
Code::StubType type) {
- // ----------- S t a t e -------------
- // -- a2 : function name
- // -- ra : return address
- // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based)
- // -- ...
- // -- sp[argc * 4] : receiver
- // -----------------------------------
-
// If object is not a string, bail out to regular call.
if (!object->IsString() || !cell.is_null()) return Handle<Code>::null();
@@ -2130,24 +1987,13 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall(
DEFAULT_STRING_STUB)) {
index_out_of_range_label = &miss;
}
- GenerateNameCheck(name, &name_miss);
-
- // Check that the maps starting from the prototype haven't changed.
- GenerateDirectLoadGlobalFunctionPrototype(masm(),
- Context::STRING_FUNCTION_INDEX,
- v0,
- &miss);
- ASSERT(!object.is_identical_to(holder));
- Handle<JSObject> prototype(JSObject::cast(object->GetPrototype(isolate())));
- CheckPrototypes(
- IC::CurrentTypeOf(prototype, isolate()),
- v0, holder, a1, a3, t0, name, &miss);
- Register receiver = v0;
+ HandlerFrontendHeader(object, holder, name, STRING_CHECK, &name_miss);
+
+ Register receiver = a0;
Register index = t1;
Register scratch = a3;
- Register result = v0;
- __ lw(receiver, MemOperand(sp, argc * kPointerSize));
+ Register result = a1;
if (argc > 0) {
__ lw(index, MemOperand(sp, (argc - 1) * kPointerSize));
} else {
@@ -2163,6 +2009,7 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall(
index_out_of_range_label,
STRING_INDEX_IS_NUMBER);
generator.GenerateFast(masm());
+ __ mov(v0, result);
__ DropAndRet(argc + 1);
StubRuntimeCallHelper call_helper;
@@ -2177,8 +2024,7 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall(
__ bind(&miss);
// Restore function name in a2.
__ li(a2, name);
- __ bind(&name_miss);
- GenerateMissBranch();
+ HandlerFrontendFooter(&name_miss);
// Return the generated code.
return GetCode(type, name);
@@ -2192,14 +2038,6 @@ Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall(
Handle<JSFunction> function,
Handle<String> name,
Code::StubType type) {
- // ----------- S t a t e -------------
- // -- a2 : function name
- // -- ra : return address
- // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based)
- // -- ...
- // -- sp[argc * 4] : receiver
- // -----------------------------------
-
const int argc = arguments().immediate();
// If the object is not a JSObject or we got an unexpected number of
@@ -2207,21 +2045,9 @@ Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall(
if (!object->IsJSObject() || argc != 1) return Handle<Code>::null();
Label miss;
- GenerateNameCheck(name, &miss);
-
- if (cell.is_null()) {
- __ lw(a1, MemOperand(sp, 1 * kPointerSize));
-
- STATIC_ASSERT(kSmiTag == 0);
- __ JumpIfSmi(a1, &miss);
-
- CheckPrototypes(
- IC::CurrentTypeOf(object, isolate()),
- a1, holder, v0, a3, t0, name, &miss);
- } else {
+ HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
+ if (!cell.is_null()) {
ASSERT(cell->value() == *function);
- GenerateGlobalReceiverCheck(Handle<JSObject>::cast(object), holder, name,
- &miss);
GenerateLoadFunctionFromCell(cell, function, &miss);
}
@@ -2244,16 +2070,12 @@ Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall(
StubRuntimeCallHelper call_helper;
generator.GenerateSlow(masm(), call_helper);
- // Tail call the full function. We do not have to patch the receiver
- // because the function makes no use of it.
__ bind(&slow);
- ParameterCount expected(function);
- __ InvokeFunction(function, expected, arguments(),
- JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD);
+ // We do not have to patch the receiver because the function makes no use of
+ // it.
+ GenerateJumpFunctionIgnoreReceiver(function);
- __ bind(&miss);
- // a2: function name.
- GenerateMissBranch();
+ HandlerFrontendFooter(&miss);
// Return the generated code.
return GetCode(type, name);
@@ -2267,34 +2089,15 @@ Handle<Code> CallStubCompiler::CompileMathFloorCall(
Handle<JSFunction> function,
Handle<String> name,
Code::StubType type) {
- // ----------- S t a t e -------------
- // -- a2 : function name
- // -- ra : return address
- // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based)
- // -- ...
- // -- sp[argc * 4] : receiver
- // -----------------------------------
-
-
const int argc = arguments().immediate();
// If the object is not a JSObject or we got an unexpected number of
// arguments, bail out to the regular call.
if (!object->IsJSObject() || argc != 1) return Handle<Code>::null();
Label miss, slow;
- GenerateNameCheck(name, &miss);
-
- if (cell.is_null()) {
- __ lw(a1, MemOperand(sp, 1 * kPointerSize));
- STATIC_ASSERT(kSmiTag == 0);
- __ JumpIfSmi(a1, &miss);
- CheckPrototypes(
- IC::CurrentTypeOf(object, isolate()),
- a1, holder, a0, a3, t0, name, &miss);
- } else {
+ HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
+ if (!cell.is_null()) {
ASSERT(cell->value() == *function);
- GenerateGlobalReceiverCheck(Handle<JSObject>::cast(object), holder, name,
- &miss);
GenerateLoadFunctionFromCell(cell, function, &miss);
}
@@ -2376,15 +2179,11 @@ Handle<Code> CallStubCompiler::CompileMathFloorCall(
__ ctc1(a3, FCSR);
__ bind(&slow);
- // Tail call the full function. We do not have to patch the receiver
- // because the function makes no use of it.
- ParameterCount expected(function);
- __ InvokeFunction(function, expected, arguments(),
- JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD);
+ // We do not have to patch the receiver because the function makes no use of
+ // it.
+ GenerateJumpFunctionIgnoreReceiver(function);
- __ bind(&miss);
- // a2: function name.
- GenerateMissBranch();
+ HandlerFrontendFooter(&miss);
// Return the generated code.
return GetCode(type, name);
@@ -2398,14 +2197,6 @@ Handle<Code> CallStubCompiler::CompileMathAbsCall(
Handle<JSFunction> function,
Handle<String> name,
Code::StubType type) {
- // ----------- S t a t e -------------
- // -- a2 : function name
- // -- ra : return address
- // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based)
- // -- ...
- // -- sp[argc * 4] : receiver
- // -----------------------------------
-
const int argc = arguments().immediate();
// If the object is not a JSObject or we got an unexpected number of
// arguments, bail out to the regular call.
@@ -2413,18 +2204,9 @@ Handle<Code> CallStubCompiler::CompileMathAbsCall(
Label miss;
- GenerateNameCheck(name, &miss);
- if (cell.is_null()) {
- __ lw(a1, MemOperand(sp, 1 * kPointerSize));
- STATIC_ASSERT(kSmiTag == 0);
- __ JumpIfSmi(a1, &miss);
- CheckPrototypes(
- IC::CurrentTypeOf(object, isolate()),
- a1, holder, v0, a3, t0, name, &miss);
- } else {
+ HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
+ if (!cell.is_null()) {
ASSERT(cell->value() == *function);
- GenerateGlobalReceiverCheck(Handle<JSObject>::cast(object), holder, name,
- &miss);
GenerateLoadFunctionFromCell(cell, function, &miss);
}
@@ -2476,16 +2258,12 @@ Handle<Code> CallStubCompiler::CompileMathAbsCall(
__ sw(a3, FieldMemOperand(v0, HeapNumber::kMantissaOffset));
__ DropAndRet(argc + 1);
- // Tail call the full function. We do not have to patch the receiver
- // because the function makes no use of it.
__ bind(&slow);
- ParameterCount expected(function);
- __ InvokeFunction(function, expected, arguments(),
- JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD);
+ // We do not have to patch the receiver because the function makes no use of
+ // it.
+ GenerateJumpFunctionIgnoreReceiver(function);
- __ bind(&miss);
- // a2: function name.
- GenerateMissBranch();
+ HandlerFrontendFooter(&miss);
// Return the generated code.
return GetCode(type, name);
@@ -2538,8 +2316,7 @@ Handle<Code> CallStubCompiler::CompileFastApiCall(
__ bind(&miss);
FreeSpaceForFastApiCall(masm());
- __ bind(&miss_before_stack_reserved);
- GenerateMissBranch();
+ HandlerFrontendFooter(&miss_before_stack_reserved);
// Return the generated code.
return GetCode(function);
@@ -2557,24 +2334,37 @@ void StubCompiler::GenerateBooleanCheck(Register object, Label* miss) {
}
-void CallStubCompiler::CompileHandlerFrontend(Handle<Object> object,
- Handle<JSObject> holder,
- Handle<Name> name,
- CheckType check) {
+void CallStubCompiler::PatchGlobalProxy(Handle<Object> object) {
+ if (!object.is_null() && object->IsGlobalObject()) {
+ const int argc = arguments().immediate();
+ const int receiver_offset = argc * kPointerSize;
+ __ lw(a3, FieldMemOperand(a0, GlobalObject::kGlobalReceiverOffset));
+ __ sw(a3, MemOperand(sp, receiver_offset));
+ }
+}
+
+
+Register CallStubCompiler::HandlerFrontendHeader(Handle<Object> object,
+ Handle<JSObject> holder,
+ Handle<Name> name,
+ CheckType check,
+ Label* miss) {
// ----------- S t a t e -------------
// -- a2 : name
// -- ra : return address
// -----------------------------------
- Label miss;
- GenerateNameCheck(name, &miss);
+ GenerateNameCheck(name, miss);
+
+ Register reg = a0;
// Get the receiver from the stack.
const int argc = arguments().immediate();
- __ lw(a1, MemOperand(sp, argc * kPointerSize));
+ const int receiver_offset = argc * kPointerSize;
+ __ lw(a0, MemOperand(sp, receiver_offset));
// Check that the receiver isn't a smi.
if (check != NUMBER_CHECK) {
- __ JumpIfSmi(a1, &miss);
+ __ JumpIfSmi(a0, miss);
}
// Make sure that it's okay not to patch the on stack receiver
@@ -2582,130 +2372,82 @@ void CallStubCompiler::CompileHandlerFrontend(Handle<Object> object,
ASSERT(!object->IsGlobalObject() || check == RECEIVER_MAP_CHECK);
switch (check) {
case RECEIVER_MAP_CHECK:
- __ IncrementCounter(isolate()->counters()->call_const(), 1, a0, a3);
+ __ IncrementCounter(isolate()->counters()->call_const(), 1, a1, a3);
// Check that the maps haven't changed.
- CheckPrototypes(
+ reg = CheckPrototypes(
IC::CurrentTypeOf(object, isolate()),
- a1, holder, a0, a3, t0, name, &miss);
-
- // Patch the receiver on the stack with the global proxy if
- // necessary.
- if (object->IsGlobalObject()) {
- __ lw(a3, FieldMemOperand(a1, GlobalObject::kGlobalReceiverOffset));
- __ sw(a3, MemOperand(sp, argc * kPointerSize));
- }
+ reg, holder, a1, a3, t0, name, miss);
break;
case STRING_CHECK: {
// Check that the object is a string.
- __ GetObjectType(a1, a3, a3);
- __ Branch(&miss, Ugreater_equal, a3, Operand(FIRST_NONSTRING_TYPE));
+ __ GetObjectType(reg, a3, a3);
+ __ Branch(miss, Ugreater_equal, a3, Operand(FIRST_NONSTRING_TYPE));
// Check that the maps starting from the prototype haven't changed.
GenerateDirectLoadGlobalFunctionPrototype(
- masm(), Context::STRING_FUNCTION_INDEX, a0, &miss);
- Handle<Object> prototype(object->GetPrototype(isolate()), isolate());
- CheckPrototypes(
- IC::CurrentTypeOf(prototype, isolate()),
- a0, holder, a3, a1, t0, name, &miss);
+ masm(), Context::STRING_FUNCTION_INDEX, a1, miss);
break;
}
case SYMBOL_CHECK: {
// Check that the object is a symbol.
- __ GetObjectType(a1, a1, a3);
- __ Branch(&miss, ne, a3, Operand(SYMBOL_TYPE));
+ __ GetObjectType(reg, a1, a3);
+ __ Branch(miss, ne, a3, Operand(SYMBOL_TYPE));
// Check that the maps starting from the prototype haven't changed.
GenerateDirectLoadGlobalFunctionPrototype(
- masm(), Context::SYMBOL_FUNCTION_INDEX, a0, &miss);
- Handle<Object> prototype(object->GetPrototype(isolate()), isolate());
- CheckPrototypes(
- IC::CurrentTypeOf(prototype, isolate()),
- a0, holder, a3, a1, t0, name, &miss);
+ masm(), Context::SYMBOL_FUNCTION_INDEX, a1, miss);
break;
}
case NUMBER_CHECK: {
Label fast;
// Check that the object is a smi or a heap number.
- __ JumpIfSmi(a1, &fast);
- __ GetObjectType(a1, a0, a0);
- __ Branch(&miss, ne, a0, Operand(HEAP_NUMBER_TYPE));
+ __ JumpIfSmi(reg, &fast);
+ __ GetObjectType(reg, a3, a3);
+ __ Branch(miss, ne, a3, Operand(HEAP_NUMBER_TYPE));
__ bind(&fast);
// Check that the maps starting from the prototype haven't changed.
GenerateDirectLoadGlobalFunctionPrototype(
- masm(), Context::NUMBER_FUNCTION_INDEX, a0, &miss);
- Handle<Object> prototype(object->GetPrototype(isolate()), isolate());
- CheckPrototypes(
- IC::CurrentTypeOf(prototype, isolate()),
- a0, holder, a3, a1, t0, name, &miss);
+ masm(), Context::NUMBER_FUNCTION_INDEX, a1, miss);
break;
}
case BOOLEAN_CHECK: {
- GenerateBooleanCheck(a1, &miss);
+ GenerateBooleanCheck(reg, miss);
// Check that the maps starting from the prototype haven't changed.
GenerateDirectLoadGlobalFunctionPrototype(
- masm(), Context::BOOLEAN_FUNCTION_INDEX, a0, &miss);
- Handle<Object> prototype(object->GetPrototype(isolate()), isolate());
- CheckPrototypes(
- IC::CurrentTypeOf(prototype, isolate()),
- a0, holder, a3, a1, t0, name, &miss);
+ masm(), Context::BOOLEAN_FUNCTION_INDEX, a1, miss);
break;
}
}
- Label success;
- __ Branch(&success);
-
- // Handle call cache miss.
- __ bind(&miss);
-
- GenerateMissBranch();
-
- __ bind(&success);
-}
-
+ if (check != RECEIVER_MAP_CHECK) {
+ Handle<Object> prototype(object->GetPrototype(isolate()), isolate());
+ reg = CheckPrototypes(
+ IC::CurrentTypeOf(prototype, isolate()),
+ a1, holder, a1, a3, t0, name, miss);
+ }
-void CallStubCompiler::CompileHandlerBackend(Handle<JSFunction> function) {
- CallKind call_kind = CallICBase::Contextual::decode(extra_state_)
- ? CALL_AS_FUNCTION
- : CALL_AS_METHOD;
- ParameterCount expected(function);
- __ InvokeFunction(function, expected, arguments(),
- JUMP_FUNCTION, NullCallWrapper(), call_kind);
+ return reg;
}
-Handle<Code> CallStubCompiler::CompileCallConstant(
- Handle<Object> object,
- Handle<JSObject> holder,
- Handle<Name> name,
- CheckType check,
- Handle<JSFunction> function) {
- if (HasCustomCallGenerator(function)) {
- Handle<Code> code = CompileCustomCall(object, holder,
- Handle<Cell>::null(),
- function, Handle<String>::cast(name),
- Code::FAST);
- // A null handle means bail out to the regular compiler code below.
- if (!code.is_null()) return code;
- }
-
- CompileHandlerFrontend(object, holder, name, check);
- CompileHandlerBackend(function);
-
- // Return the generated code.
- return GetCode(function);
+void CallStubCompiler::GenerateJumpFunction(Handle<Object> object,
+ Register function,
+ Label* miss) {
+ ASSERT(function.is(a1));
+ // Check that the function really is a function.
+ GenerateFunctionCheck(function, a3, miss);
+ if (!function.is(a1)) __ mov(a1, function);
+ PatchGlobalProxy(object);
+ // Invoke the function.
+ __ InvokeFunction(a1, arguments(), JUMP_FUNCTION,
+ NullCallWrapper(), call_kind());
}
Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object,
Handle<JSObject> holder,
Handle<Name> name) {
- // ----------- S t a t e -------------
- // -- a2 : name
- // -- ra : return address
- // -----------------------------------
-
Label miss;
GenerateNameCheck(name, &miss);
@@ -2727,11 +2469,9 @@ Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object,
// Restore receiver.
__ lw(a0, MemOperand(sp, argc * kPointerSize));
- GenerateCallFunction(masm(), object, arguments(), &miss, extra_state_);
+ GenerateJumpFunction(object, a1, &miss);
- // Handle call cache miss.
- __ bind(&miss);
- GenerateMissBranch();
+ HandlerFrontendFooter(&miss);
// Return the generated code.
return GetCode(Code::FAST, name);
@@ -2744,11 +2484,6 @@ Handle<Code> CallStubCompiler::CompileCallGlobal(
Handle<PropertyCell> cell,
Handle<JSFunction> function,
Handle<Name> name) {
- // ----------- S t a t e -------------
- // -- a2 : name
- // -- ra : return address
- // -----------------------------------
-
if (HasCustomCallGenerator(function)) {
Handle<Code> code = CompileCustomCall(
object, holder, cell, function, Handle<String>::cast(name),
@@ -2758,41 +2493,14 @@ Handle<Code> CallStubCompiler::CompileCallGlobal(
}
Label miss;
- GenerateNameCheck(name, &miss);
-
- // Get the number of arguments.
- const int argc = arguments().immediate();
- GenerateGlobalReceiverCheck(object, holder, name, &miss);
+ HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
+ // Potentially loads a closure that matches the shared function info of the
+ // function, rather than function.
GenerateLoadFunctionFromCell(cell, function, &miss);
-
- // Patch the receiver on the stack with the global proxy if
- // necessary.
- if (object->IsGlobalObject()) {
- __ lw(a3, FieldMemOperand(a0, GlobalObject::kGlobalReceiverOffset));
- __ sw(a3, MemOperand(sp, argc * kPointerSize));
- }
-
- // Set up the context (function already in r1).
- __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
-
- // Jump to the cached code (tail call).
Counters* counters = isolate()->counters();
__ IncrementCounter(counters->call_global_inline(), 1, a3, t0);
- ParameterCount expected(function->shared()->formal_parameter_count());
- CallKind call_kind = CallICBase::Contextual::decode(extra_state_)
- ? CALL_AS_FUNCTION
- : CALL_AS_METHOD;
- // We call indirectly through the code field in the function to
- // allow recompilation to take effect without changing any of the
- // call sites.
- __ lw(a3, FieldMemOperand(a1, JSFunction::kCodeEntryOffset));
- __ InvokeCode(a3, expected, arguments(), JUMP_FUNCTION,
- NullCallWrapper(), call_kind);
-
- // Handle call cache miss.
- __ bind(&miss);
- __ IncrementCounter(counters->call_global_inline_miss(), 1, a1, a3);
- GenerateMissBranch();
+ GenerateJumpFunction(object, a1, function);
+ HandlerFrontendFooter(&miss);
// Return the generated code.
return GetCode(Code::NORMAL, name);
@@ -2911,13 +2619,10 @@ Handle<Code> StoreStubCompiler::CompileStoreInterceptor(
__ Push(receiver(), this->name(), value());
- __ li(scratch1(), Operand(Smi::FromInt(strict_mode())));
- __ push(scratch1()); // strict mode
-
// Do tail-call to the runtime system.
ExternalReference store_ic_property =
ExternalReference(IC_Utility(IC::kStoreInterceptorProperty), isolate());
- __ TailCallExternalReference(store_ic_property, 4, 1);
+ __ TailCallExternalReference(store_ic_property, 3, 1);
// Handle store cache miss.
__ bind(&miss);
« no previous file with comments | « src/mips/macro-assembler-mips.cc ('k') | src/object-observe.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698