Index: src/arm/stub-cache-arm.cc |
diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc |
index 9b2ba53bde0aa1b1f388922db8dac18e42a95a36..4d5f220a2982da97c383aefa7be95fac6cd455ec 100644 |
--- a/src/arm/stub-cache-arm.cc |
+++ b/src/arm/stub-cache-arm.cc |
@@ -757,11 +757,11 @@ static void GenerateCallFunction(MacroAssembler* masm, |
__ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE); |
__ b(ne, miss); |
- // Patch the receiver on the stack with the global proxy if |
- // necessary. |
if (object->IsGlobalObject()) { |
Igor Sheludko
2013/11/28 12:54:27
Looks like PatchGlobalProxy(object);
Why don't mak
|
+ const int argc = arguments.immediate(); |
+ const int receiver_offset = argc * kPointerSize; |
__ ldr(r3, FieldMemOperand(r0, GlobalObject::kGlobalReceiverOffset)); |
- __ str(r3, MemOperand(sp, arguments.immediate() * kPointerSize)); |
+ __ str(r3, MemOperand(sp, receiver_offset)); |
} |
// Invoke the function. |
@@ -1549,25 +1549,6 @@ 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. |
- __ ldr(r0, MemOperand(sp, argc * kPointerSize)); |
- |
- // Check that the maps haven't changed. |
- __ JumpIfSmi(r0, miss); |
- CheckPrototypes( |
- IC::CurrentTypeOf(object, isolate()), r0, holder, r3, r1, r4, name, miss); |
-} |
- |
- |
void CallStubCompiler::GenerateLoadFunctionFromCell( |
Handle<Cell> cell, |
Handle<JSFunction> function, |
@@ -1611,33 +1592,16 @@ Handle<Code> CallStubCompiler::CompileCallField(Handle<JSObject> object, |
Handle<JSObject> holder, |
PropertyIndex index, |
Handle<Name> name) { |
- // ----------- S t a t e ------------- |
- // -- r2 : name |
- // -- lr : return address |
- // ----------------------------------- |
Label miss; |
- GenerateNameCheck(name, &miss); |
- |
- const int argc = arguments().immediate(); |
- |
- // Get the receiver of the function from the stack into r0. |
- __ ldr(r0, MemOperand(sp, argc * kPointerSize)); |
- // Check that the receiver isn't a smi. |
- __ JumpIfSmi(r0, &miss); |
- |
- // Do the right check and compute the holder register. |
- Register reg = CheckPrototypes( |
- IC::CurrentTypeOf(object, isolate()), |
- r0, holder, r1, r3, r4, name, &miss); |
+ Register reg = HandlerFrontendHeader( |
+ object, holder, name, RECEIVER_MAP_CHECK, &miss); |
GenerateFastPropertyLoad(masm(), r1, reg, index.is_inobject(holder), |
index.translate(holder), Representation::Tagged()); |
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); |
@@ -1653,31 +1617,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 = r1; |
- |
- if (cell.is_null()) { |
- __ ldr(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, |
- r3, r0, r4, 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(); |
__ mov(r0, Operand(argc)); |
__ mov(r2, Operand(site_feedback_cell)); |
__ mov(r1, Operand(function)); |
@@ -1685,8 +1634,7 @@ Handle<Code> CallStubCompiler::CompileArrayCodeCall( |
ArrayConstructorStub stub(isolate()); |
__ TailCallStub(&stub); |
- __ bind(&miss); |
- GenerateMissBranch(); |
+ HandlerFrontendFooter(&miss); |
// Return the generated code. |
return GetCode(type, name); |
@@ -1700,14 +1648,6 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall( |
Handle<JSFunction> function, |
Handle<String> name, |
Code::StubType type) { |
- // ----------- S t a t e ------------- |
- // -- r2 : name |
- // -- lr : 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() || |
@@ -1716,21 +1656,12 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall( |
} |
Label miss; |
- GenerateNameCheck(name, &miss); |
- Register receiver = r1; |
- // Get the receiver from the stack |
- const int argc = arguments().immediate(); |
- __ ldr(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, |
- r3, r0, r4, name, &miss); |
+ HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss); |
+ Register receiver = r0; |
+ Register scratch = r1; |
+ const int argc = arguments().immediate(); |
if (argc == 0) { |
// Nothing to do, just return the length. |
__ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
@@ -1749,20 +1680,20 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall( |
// Check that the elements are in fast mode and writable. |
__ CheckMap(elements, |
- r0, |
+ scratch, |
Heap::kFixedArrayMapRootIndex, |
&check_double, |
DONT_DO_SMI_CHECK); |
- // Get the array's length into r0 and calculate new length. |
- __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
- __ add(r0, r0, Operand(Smi::FromInt(argc))); |
+ // Get the array's length into scratch and calculate new length. |
+ __ ldr(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
+ __ add(scratch, scratch, Operand(Smi::FromInt(argc))); |
// Get the elements' length. |
__ ldr(r4, FieldMemOperand(elements, FixedArray::kLengthOffset)); |
// Check if we could survive without allocation. |
- __ cmp(r0, r4); |
+ __ cmp(scratch, r4); |
__ b(gt, &attempt_to_grow_elements); |
// Check if value is a smi. |
@@ -1770,49 +1701,50 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall( |
__ JumpIfNotSmi(r4, &with_write_barrier); |
// Save new length. |
- __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
+ __ str(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. |
- __ add(end_elements, elements, Operand::PointerOffsetFromSmiKey(r0)); |
+ __ add(end_elements, elements, Operand::PointerOffsetFromSmiKey(scratch)); |
const int kEndElementsOffset = |
FixedArray::kHeaderSize - kHeapObjectTag - argc * kPointerSize; |
__ str(r4, MemOperand(end_elements, kEndElementsOffset, PreIndex)); |
// Check for a smi. |
__ Drop(argc + 1); |
+ __ mov(r0, scratch); |
__ Ret(); |
__ bind(&check_double); |
// Check that the elements are in fast mode and writable. |
__ CheckMap(elements, |
- r0, |
+ scratch, |
Heap::kFixedDoubleArrayMapRootIndex, |
&call_builtin, |
DONT_DO_SMI_CHECK); |
- // Get the array's length into r0 and calculate new length. |
- __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
- __ add(r0, r0, Operand(Smi::FromInt(argc))); |
+ // Get the array's length into scratch and calculate new length. |
+ __ ldr(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
+ __ add(scratch, scratch, Operand(Smi::FromInt(argc))); |
// Get the elements' length. |
__ ldr(r4, FieldMemOperand(elements, FixedArray::kLengthOffset)); |
// Check if we could survive without allocation. |
- __ cmp(r0, r4); |
+ __ cmp(scratch, r4); |
__ b(gt, &call_builtin); |
__ ldr(r4, MemOperand(sp, (argc - 1) * kPointerSize)); |
- __ StoreNumberToDoubleElements(r4, r0, elements, r5, d0, |
+ __ StoreNumberToDoubleElements(r4, scratch, elements, r5, d0, |
&call_builtin, argc * kDoubleSize); |
// Save new length. |
- __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
+ __ str(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
- // Check for a smi. |
__ Drop(argc + 1); |
+ __ mov(r0, scratch); |
__ Ret(); |
__ bind(&with_write_barrier); |
@@ -1863,12 +1795,12 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall( |
} |
// Save new length. |
- __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
+ __ str(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. |
- __ add(end_elements, elements, Operand::PointerOffsetFromSmiKey(r0)); |
+ __ add(end_elements, elements, Operand::PointerOffsetFromSmiKey(scratch)); |
__ str(r4, MemOperand(end_elements, kEndElementsOffset, PreIndex)); |
__ RecordWrite(elements, |
@@ -1879,10 +1811,11 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall( |
EMIT_REMEMBERED_SET, |
OMIT_SMI_CHECK); |
__ Drop(argc + 1); |
+ __ mov(r0, scratch); |
__ Ret(); |
__ bind(&attempt_to_grow_elements); |
- // r0: array's length + 1. |
+ // scratch: array's length + 1. |
if (!FLAG_inline_new) { |
__ b(&call_builtin); |
@@ -1904,7 +1837,7 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall( |
const int kAllocationDelta = 4; |
// Load top and check if it is the end of elements. |
- __ add(end_elements, elements, Operand::PointerOffsetFromSmiKey(r0)); |
+ __ add(end_elements, elements, Operand::PointerOffsetFromSmiKey(scratch)); |
__ add(end_elements, end_elements, Operand(kEndElementsOffset)); |
__ mov(r4, Operand(new_space_allocation_top)); |
__ ldr(r3, MemOperand(r4)); |
@@ -1929,13 +1862,14 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall( |
} |
// Update elements' and array's sizes. |
- __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
+ __ str(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
__ ldr(r4, FieldMemOperand(elements, FixedArray::kLengthOffset)); |
__ add(r4, r4, Operand(Smi::FromInt(kAllocationDelta))); |
__ str(r4, FieldMemOperand(elements, FixedArray::kLengthOffset)); |
// Elements are in new space, so write barrier is not required. |
__ Drop(argc + 1); |
+ __ mov(r0, scratch); |
__ Ret(); |
} |
__ bind(&call_builtin); |
@@ -1943,9 +1877,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); |
@@ -1959,14 +1891,6 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall( |
Handle<JSFunction> function, |
Handle<String> name, |
Code::StubType type) { |
- // ----------- S t a t e ------------- |
- // -- r2 : name |
- // -- lr : 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() || |
@@ -1975,26 +1899,18 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall( |
} |
Label miss, return_undefined, call_builtin; |
- Register receiver = r1; |
+ Register receiver = r0; |
+ Register scratch = r1; |
Register elements = r3; |
- GenerateNameCheck(name, &miss); |
- |
- // Get the receiver from the stack |
- const int argc = arguments().immediate(); |
- __ ldr(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, r4, r0, name, &miss); |
+ HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss); |
// Get the elements array of the object. |
__ ldr(elements, FieldMemOperand(receiver, JSArray::kElementsOffset)); |
// Check that the elements are in fast mode and writable. |
__ CheckMap(elements, |
- r0, |
+ scratch, |
Heap::kFixedArrayMapRootIndex, |
&call_builtin, |
DONT_DO_SMI_CHECK); |
@@ -2009,8 +1925,8 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall( |
// We can't address the last element in one operation. Compute the more |
// expensive shift first, and use an offset later on. |
__ add(elements, elements, Operand::PointerOffsetFromSmiKey(r4)); |
- __ ldr(r0, FieldMemOperand(elements, FixedArray::kHeaderSize)); |
- __ cmp(r0, r6); |
+ __ ldr(scratch, FieldMemOperand(elements, FixedArray::kHeaderSize)); |
+ __ cmp(scratch, r6); |
__ b(eq, &call_builtin); |
// Set the array's length. |
@@ -2018,7 +1934,9 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall( |
// Fill with the hole. |
__ str(r6, FieldMemOperand(elements, FixedArray::kHeaderSize)); |
+ const int argc = arguments().immediate(); |
__ Drop(argc + 1); |
+ __ mov(r0, scratch); |
__ Ret(); |
__ bind(&return_undefined); |
@@ -2030,9 +1948,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); |
@@ -2046,18 +1962,9 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall( |
Handle<JSFunction> function, |
Handle<String> name, |
Code::StubType type) { |
- // ----------- S t a t e ------------- |
- // -- r2 : function name |
- // -- lr : 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; |
@@ -2068,22 +1975,13 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall( |
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, |
- r0, |
- &miss); |
- ASSERT(!object.is_identical_to(holder)); |
- Handle<JSObject> prototype(JSObject::cast(object->GetPrototype(isolate()))); |
- CheckPrototypes( |
- IC::CurrentTypeOf(prototype, isolate()), |
- r0, holder, r1, r3, r4, name, &miss); |
- Register receiver = r1; |
+ HandlerFrontendHeader(object, holder, name, STRING_CHECK, &name_miss); |
+ |
+ Register receiver = r0; |
Register index = r4; |
- Register result = r0; |
+ Register result = r1; |
+ const int argc = arguments().immediate(); |
__ ldr(receiver, MemOperand(sp, argc * kPointerSize)); |
if (argc > 0) { |
__ ldr(index, MemOperand(sp, (argc - 1) * kPointerSize)); |
@@ -2100,6 +1998,7 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall( |
STRING_INDEX_IS_NUMBER); |
generator.GenerateFast(masm()); |
__ Drop(argc + 1); |
+ __ mov(r0, result); |
__ Ret(); |
StubRuntimeCallHelper call_helper; |
@@ -2130,14 +2029,6 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall( |
Handle<JSFunction> function, |
Handle<String> name, |
Code::StubType type) { |
- // ----------- S t a t e ------------- |
- // -- r2 : function name |
- // -- lr : 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(); |
@@ -2151,24 +2042,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, |
- r0, |
- &miss); |
- ASSERT(!object.is_identical_to(holder)); |
- Handle<JSObject> prototype(JSObject::cast(object->GetPrototype(isolate()))); |
- CheckPrototypes( |
- IC::CurrentTypeOf(prototype, isolate()), |
- r0, holder, r1, r3, r4, name, &miss); |
+ |
+ HandlerFrontendHeader(object, holder, name, STRING_CHECK, &name_miss); |
Register receiver = r0; |
Register index = r4; |
Register scratch = r3; |
- Register result = r0; |
- __ ldr(receiver, MemOperand(sp, argc * kPointerSize)); |
+ Register result = r1; |
if (argc > 0) { |
__ ldr(index, MemOperand(sp, (argc - 1) * kPointerSize)); |
} else { |
@@ -2185,6 +2065,7 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall( |
STRING_INDEX_IS_NUMBER); |
generator.GenerateFast(masm()); |
__ Drop(argc + 1); |
+ __ mov(r0, result); |
__ Ret(); |
StubRuntimeCallHelper call_helper; |
@@ -2215,14 +2096,6 @@ Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall( |
Handle<JSFunction> function, |
Handle<String> name, |
Code::StubType type) { |
- // ----------- S t a t e ------------- |
- // -- r2 : function name |
- // -- lr : 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 |
@@ -2230,20 +2103,10 @@ Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall( |
if (!object->IsJSObject() || argc != 1) return Handle<Code>::null(); |
Label miss; |
- GenerateNameCheck(name, &miss); |
- |
- if (cell.is_null()) { |
- __ ldr(r1, MemOperand(sp, 1 * kPointerSize)); |
- |
- __ JumpIfSmi(r1, &miss); |
- CheckPrototypes( |
- IC::CurrentTypeOf(object, isolate()), |
- r1, holder, r0, r3, r4, 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); |
} |
@@ -2273,9 +2136,7 @@ Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall( |
__ InvokeFunction(function, expected, arguments(), |
JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD); |
- __ bind(&miss); |
- // r2: function name. |
- GenerateMissBranch(); |
+ HandlerFrontendFooter(&miss); |
// Return the generated code. |
return GetCode(type, name); |
@@ -2289,32 +2150,16 @@ Handle<Code> CallStubCompiler::CompileMathFloorCall( |
Handle<JSFunction> function, |
Handle<String> name, |
Code::StubType type) { |
- // ----------- S t a t e ------------- |
- // -- r2 : function name |
- // -- lr : 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()) { |
- __ ldr(r1, MemOperand(sp, 1 * kPointerSize)); |
- __ JumpIfSmi(r1, &miss); |
- CheckPrototypes( |
- IC::CurrentTypeOf(object, isolate()), |
- r1, holder, r0, r3, r4, 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); |
} |
@@ -2383,9 +2228,7 @@ Handle<Code> CallStubCompiler::CompileMathFloorCall( |
__ InvokeFunction(function, expected, arguments(), |
JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD); |
- __ bind(&miss); |
- // r2: function name. |
- GenerateMissBranch(); |
+ HandlerFrontendFooter(&miss); |
// Return the generated code. |
return GetCode(type, name); |
@@ -2399,31 +2242,16 @@ Handle<Code> CallStubCompiler::CompileMathAbsCall( |
Handle<JSFunction> function, |
Handle<String> name, |
Code::StubType type) { |
- // ----------- S t a t e ------------- |
- // -- r2 : function name |
- // -- lr : 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; |
- GenerateNameCheck(name, &miss); |
- if (cell.is_null()) { |
- __ ldr(r1, MemOperand(sp, 1 * kPointerSize)); |
- __ JumpIfSmi(r1, &miss); |
- CheckPrototypes( |
- IC::CurrentTypeOf(object, isolate()), |
- r1, holder, r0, r3, r4, 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); |
} |
@@ -2483,9 +2311,7 @@ Handle<Code> CallStubCompiler::CompileMathAbsCall( |
__ InvokeFunction(function, expected, arguments(), |
JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD); |
- __ bind(&miss); |
- // r2: function name. |
- GenerateMissBranch(); |
+ HandlerFrontendFooter(&miss); |
// Return the generated code. |
return GetCode(type, name); |
@@ -2557,24 +2383,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->IsGlobalObject()) { |
+ const int argc = arguments().immediate(); |
+ const int receiver_offset = argc * kPointerSize; |
+ __ ldr(r3, FieldMemOperand(r0, GlobalObject::kGlobalReceiverOffset)); |
+ __ str(r3, 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 ------------- |
// -- r2 : name |
// -- lr : return address |
// ----------------------------------- |
- Label miss; |
- GenerateNameCheck(name, &miss); |
+ GenerateNameCheck(name, miss); |
+ |
+ Register reg = r0; |
// Get the receiver from the stack |
const int argc = arguments().immediate(); |
- __ ldr(r1, MemOperand(sp, argc * kPointerSize)); |
+ const int receiver_offset = argc * kPointerSize; |
+ __ ldr(r0, MemOperand(sp, receiver_offset)); |
// Check that the receiver isn't a smi. |
if (check != NUMBER_CHECK) { |
- __ JumpIfSmi(r1, &miss); |
+ __ JumpIfSmi(r0, miss); |
} |
// Make sure that it's okay not to patch the on stack receiver |
@@ -2582,85 +2421,62 @@ 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, r0, r3); |
+ __ IncrementCounter(isolate()->counters()->call_const(), 1, r1, r3); |
// Check that the maps haven't changed. |
- CheckPrototypes( |
+ reg = CheckPrototypes( |
IC::CurrentTypeOf(object, isolate()), |
- r1, holder, r0, r3, r4, name, &miss); |
- |
- // Patch the receiver on the stack with the global proxy if |
- // necessary. |
- if (object->IsGlobalObject()) { |
- __ ldr(r3, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset)); |
- __ str(r3, MemOperand(sp, argc * kPointerSize)); |
- } |
+ reg, holder, r1, r3, r4, name, miss); |
break; |
case STRING_CHECK: { |
// Check that the object is a string. |
- __ CompareObjectType(r1, r3, r3, FIRST_NONSTRING_TYPE); |
- __ b(ge, &miss); |
+ __ CompareObjectType(reg, r3, r3, FIRST_NONSTRING_TYPE); |
+ __ b(ge, miss); |
// Check that the maps starting from the prototype haven't changed. |
GenerateDirectLoadGlobalFunctionPrototype( |
- masm(), Context::STRING_FUNCTION_INDEX, r0, &miss); |
- Handle<Object> prototype(object->GetPrototype(isolate()), isolate()); |
- CheckPrototypes( |
- IC::CurrentTypeOf(prototype, isolate()), |
- r0, holder, r3, r1, r4, name, &miss); |
+ masm(), Context::STRING_FUNCTION_INDEX, r1, miss); |
break; |
} |
case SYMBOL_CHECK: { |
// Check that the object is a symbol. |
- __ CompareObjectType(r1, r1, r3, SYMBOL_TYPE); |
- __ b(ne, &miss); |
+ __ CompareObjectType(reg, r3, r3, SYMBOL_TYPE); |
+ __ b(ne, miss); |
// Check that the maps starting from the prototype haven't changed. |
GenerateDirectLoadGlobalFunctionPrototype( |
- masm(), Context::SYMBOL_FUNCTION_INDEX, r0, &miss); |
- Handle<Object> prototype(object->GetPrototype(isolate()), isolate()); |
- CheckPrototypes( |
- IC::CurrentTypeOf(prototype, isolate()), |
- r0, holder, r3, r1, r4, name, &miss); |
+ masm(), Context::SYMBOL_FUNCTION_INDEX, r1, miss); |
break; |
} |
case NUMBER_CHECK: { |
Label fast; |
// Check that the object is a smi or a heap number. |
- __ JumpIfSmi(r1, &fast); |
- __ CompareObjectType(r1, r0, r0, HEAP_NUMBER_TYPE); |
- __ b(ne, &miss); |
+ __ JumpIfSmi(reg, &fast); |
+ __ CompareObjectType(reg, r3, r3, HEAP_NUMBER_TYPE); |
+ __ b(ne, miss); |
__ bind(&fast); |
// Check that the maps starting from the prototype haven't changed. |
GenerateDirectLoadGlobalFunctionPrototype( |
- masm(), Context::NUMBER_FUNCTION_INDEX, r0, &miss); |
- Handle<Object> prototype(object->GetPrototype(isolate()), isolate()); |
- CheckPrototypes( |
- IC::CurrentTypeOf(prototype, isolate()), |
- r0, holder, r3, r1, r4, name, &miss); |
+ masm(), Context::NUMBER_FUNCTION_INDEX, r1, miss); |
break; |
} |
case BOOLEAN_CHECK: { |
- GenerateBooleanCheck(r1, &miss); |
+ GenerateBooleanCheck(reg, miss); |
// Check that the maps starting from the prototype haven't changed. |
GenerateDirectLoadGlobalFunctionPrototype( |
- masm(), Context::BOOLEAN_FUNCTION_INDEX, r0, &miss); |
- Handle<Object> prototype(object->GetPrototype(isolate()), isolate()); |
- CheckPrototypes( |
- IC::CurrentTypeOf(prototype, isolate()), |
- r0, holder, r3, r1, r4, name, &miss); |
+ masm(), Context::BOOLEAN_FUNCTION_INDEX, r1, miss); |
break; |
} |
} |
- Label success; |
- __ b(&success); |
- |
- // Handle call cache miss. |
- __ bind(&miss); |
- GenerateMissBranch(); |
+ if (check != RECEIVER_MAP_CHECK) { |
+ Handle<Object> prototype(object->GetPrototype(isolate()), isolate()); |
+ reg = CheckPrototypes( |
+ IC::CurrentTypeOf(prototype, isolate()), |
+ r1, holder, r1, r3, r4, name, miss); |
+ } |
- __ bind(&success); |
+ return reg; |
} |
@@ -2689,8 +2505,11 @@ Handle<Code> CallStubCompiler::CompileCallConstant( |
if (!code.is_null()) return code; |
} |
- CompileHandlerFrontend(object, holder, name, check); |
+ Label miss; |
+ HandlerFrontendHeader(object, holder, name, check, &miss); |
+ PatchGlobalProxy(object); |
CompileHandlerBackend(function); |
+ HandlerFrontendFooter(&miss); |
// Return the generated code. |
return GetCode(function); |
@@ -2700,10 +2519,6 @@ Handle<Code> CallStubCompiler::CompileCallConstant( |
Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object, |
Handle<JSObject> holder, |
Handle<Name> name) { |
- // ----------- S t a t e ------------- |
- // -- r2 : name |
- // -- lr : return address |
- // ----------------------------------- |
Label miss; |
GenerateNameCheck(name, &miss); |
@@ -2741,10 +2556,6 @@ Handle<Code> CallStubCompiler::CompileCallGlobal( |
Handle<PropertyCell> cell, |
Handle<JSFunction> function, |
Handle<Name> name) { |
- // ----------- S t a t e ------------- |
- // -- r2 : name |
- // -- lr : return address |
- // ----------------------------------- |
if (HasCustomCallGenerator(function)) { |
Handle<Code> code = CompileCustomCall( |
object, holder, cell, function, Handle<String>::cast(name), |
@@ -2754,19 +2565,9 @@ 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); |
GenerateLoadFunctionFromCell(cell, function, &miss); |
- |
- // Patch the receiver on the stack with the global proxy if |
- // necessary. |
- if (object->IsGlobalObject()) { |
- __ ldr(r3, FieldMemOperand(r0, GlobalObject::kGlobalReceiverOffset)); |
- __ str(r3, MemOperand(sp, argc * kPointerSize)); |
- } |
+ PatchGlobalProxy(object); |
// Set up the context (function already in r1). |
__ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
@@ -2785,10 +2586,7 @@ Handle<Code> CallStubCompiler::CompileCallGlobal( |
__ InvokeCode(r3, expected, arguments(), JUMP_FUNCTION, |
NullCallWrapper(), call_kind); |
- // Handle call cache miss. |
- __ bind(&miss); |
- __ IncrementCounter(counters->call_global_inline_miss(), 1, r1, r3); |
- GenerateMissBranch(); |
+ HandlerFrontendFooter(&miss); |
// Return the generated code. |
return GetCode(Code::NORMAL, name); |