Index: src/x64/code-stubs-x64.cc |
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc |
index 075964bcee36299c5d80825ea1f2d7592c3637b7..0637bd2fb928ac1d0f4bea03afab158eedf85d4e 100644 |
--- a/src/x64/code-stubs-x64.cc |
+++ b/src/x64/code-stubs-x64.cc |
@@ -106,8 +106,8 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor( |
void CreateAllocationSiteStub::InitializeInterfaceDescriptor( |
Isolate* isolate, |
CodeStubInterfaceDescriptor* descriptor) { |
- static Register registers[] = { rbx }; |
- descriptor->register_param_count_ = 1; |
+ static Register registers[] = { rbx, rdx }; |
+ descriptor->register_param_count_ = 2; |
descriptor->register_params_ = registers; |
descriptor->deoptimization_handler_ = NULL; |
} |
@@ -2161,28 +2161,32 @@ void ICCompareStub::GenerateGeneric(MacroAssembler* masm) { |
static void GenerateRecordCallTarget(MacroAssembler* masm) { |
- // Cache the called function in a global property cell. Cache states |
+ // Cache the called function in a feedback vector slot. Cache states |
// are uninitialized, monomorphic (indicated by a JSFunction), and |
// megamorphic. |
// rax : number of arguments to the construct function |
- // rbx : cache cell for call target |
+ // rbx : Feedback vector |
+ // rdx : slot in feedback vector (Smi) |
// rdi : the function to call |
Isolate* isolate = masm->isolate(); |
- Label initialize, done, miss, megamorphic, not_array_function; |
+ Label initialize, done, miss, megamorphic, not_array_function, |
+ done_no_smi_convert; |
// Load the cache state into rcx. |
- __ movp(rcx, FieldOperand(rbx, Cell::kValueOffset)); |
+ __ SmiToInteger32(rdx, rdx); |
+ __ movp(rcx, FieldOperand(rbx, rdx, times_pointer_size, |
+ FixedArray::kHeaderSize)); |
// A monomorphic cache hit or an already megamorphic state: invoke the |
// function without changing the state. |
__ cmpq(rcx, rdi); |
__ j(equal, &done); |
- __ Cmp(rcx, TypeFeedbackCells::MegamorphicSentinel(isolate)); |
+ __ Cmp(rcx, TypeFeedbackInfo::MegamorphicSentinel(isolate)); |
__ j(equal, &done); |
// If we came here, we need to see if we are the array function. |
// If we didn't have a matching function, and we didn't find the megamorph |
- // sentinel, then we have in the cell either some other function or an |
+ // sentinel, then we have in the slot either some other function or an |
// AllocationSite. Do a map check on the object in rcx. |
Handle<Map> allocation_site_map = |
masm->isolate()->factory()->allocation_site_map(); |
@@ -2199,13 +2203,13 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) { |
// A monomorphic miss (i.e, here the cache is not uninitialized) goes |
// megamorphic. |
- __ Cmp(rcx, TypeFeedbackCells::UninitializedSentinel(isolate)); |
+ __ Cmp(rcx, TypeFeedbackInfo::UninitializedSentinel(isolate)); |
__ j(equal, &initialize); |
// MegamorphicSentinel is an immortal immovable object (undefined) so no |
// write-barrier is needed. |
__ bind(&megamorphic); |
- __ Move(FieldOperand(rbx, Cell::kValueOffset), |
- TypeFeedbackCells::MegamorphicSentinel(isolate)); |
+ __ Move(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize), |
+ TypeFeedbackInfo::MegamorphicSentinel(isolate)); |
__ jmp(&done); |
// An uninitialized cache is patched with the function or sentinel to |
@@ -2217,7 +2221,7 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) { |
__ j(not_equal, ¬_array_function); |
// The target function is the Array constructor, |
- // Create an AllocationSite if we don't already have it, store it in the cell |
+ // Create an AllocationSite if we don't already have it, store it in the slot. |
{ |
FrameScope scope(masm, StackFrame::INTERNAL); |
@@ -2225,28 +2229,45 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) { |
__ Integer32ToSmi(rax, rax); |
__ push(rax); |
__ push(rdi); |
+ __ Integer32ToSmi(rdx, rdx); |
+ __ push(rdx); |
__ push(rbx); |
CreateAllocationSiteStub create_stub; |
__ CallStub(&create_stub); |
__ pop(rbx); |
+ __ pop(rdx); |
__ pop(rdi); |
__ pop(rax); |
__ SmiToInteger32(rax, rax); |
} |
- __ jmp(&done); |
+ __ jmp(&done_no_smi_convert); |
__ bind(¬_array_function); |
- __ movp(FieldOperand(rbx, Cell::kValueOffset), rdi); |
- // No need for a write barrier here - cells are rescanned. |
+ __ movp(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize), |
+ rdi); |
+ |
+ // We won't need rdx or rbx anymore, just save rdi |
+ __ push(rdi); |
+ __ push(rbx); |
+ __ push(rdx); |
+ __ RecordWriteArray(rbx, rdi, rdx, kDontSaveFPRegs, |
+ EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
+ __ pop(rdx); |
+ __ pop(rbx); |
+ __ pop(rdi); |
__ bind(&done); |
+ __ Integer32ToSmi(rdx, rdx); |
+ |
+ __ bind(&done_no_smi_convert); |
} |
void CallFunctionStub::Generate(MacroAssembler* masm) { |
- // rbx : cache cell for call target |
+ // rbx : feedback vector |
+ // rdx : (only if rbx is not undefined) slot in feedback vector (Smi) |
// rdi : the function to call |
Isolate* isolate = masm->isolate(); |
Label slow, non_function, wrap, cont; |
@@ -2283,6 +2304,7 @@ void CallFunctionStub::Generate(MacroAssembler* masm) { |
__ j(not_equal, &cont); |
} |
+ |
// Load the receiver from the stack. |
__ movp(rax, args.GetReceiverOperand()); |
@@ -2306,8 +2328,11 @@ void CallFunctionStub::Generate(MacroAssembler* masm) { |
// If there is a call target cache, mark it megamorphic in the |
// non-function case. MegamorphicSentinel is an immortal immovable |
// object (undefined) so no write barrier is needed. |
- __ Move(FieldOperand(rbx, Cell::kValueOffset), |
- TypeFeedbackCells::MegamorphicSentinel(isolate)); |
+ __ SmiToInteger32(rdx, rdx); |
+ __ Move(FieldOperand(rbx, rdx, times_pointer_size, |
+ FixedArray::kHeaderSize), |
+ TypeFeedbackInfo::MegamorphicSentinel(isolate)); |
+ __ Integer32ToSmi(rdx, rdx); |
} |
// Check for function proxy. |
__ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); |
@@ -2353,7 +2378,8 @@ void CallFunctionStub::Generate(MacroAssembler* masm) { |
void CallConstructStub::Generate(MacroAssembler* masm) { |
// rax : number of arguments |
- // rbx : cache cell for call target |
+ // rbx : feedback vector |
+ // rdx : (only if rbx is not undefined) slot in feedback vector (Smi) |
// rdi : constructor function |
Label slow, non_function_call; |
@@ -4867,7 +4893,7 @@ static void CreateArrayDispatchOneArgument(MacroAssembler* masm, |
__ TailCallStub(&stub); |
} else if (mode == DONT_OVERRIDE) { |
// We are going to create a holey array, but our kind is non-holey. |
- // Fix kind and retry (only if we have an allocation site in the cell). |
+ // Fix kind and retry (only if we have an allocation site in the slot). |
__ incl(rdx); |
if (FLAG_debug_code) { |
@@ -4977,7 +5003,8 @@ void ArrayConstructorStub::GenerateDispatchToArrayStub( |
void ArrayConstructorStub::Generate(MacroAssembler* masm) { |
// ----------- S t a t e ------------- |
// -- rax : argc |
- // -- rbx : type info cell |
+ // -- rbx : feedback vector (fixed array or undefined) |
+ // -- rdx : slot index (if ebx is fixed array) |
// -- rdi : constructor |
// -- rsp[0] : return address |
// -- rsp[8] : last argument |
@@ -4999,22 +5026,29 @@ void ArrayConstructorStub::Generate(MacroAssembler* masm) { |
__ CmpObjectType(rcx, MAP_TYPE, rcx); |
__ Check(equal, kUnexpectedInitialMapForArrayFunction); |
- // We should either have undefined in rbx or a valid cell |
+ // We should either have undefined in rbx or a valid fixed array. |
Label okay_here; |
- Handle<Map> cell_map = masm->isolate()->factory()->cell_map(); |
+ Handle<Map> fixed_array_map = masm->isolate()->factory()->fixed_array_map(); |
__ Cmp(rbx, undefined_sentinel); |
__ j(equal, &okay_here); |
- __ Cmp(FieldOperand(rbx, 0), cell_map); |
- __ Assert(equal, kExpectedPropertyCellInRegisterRbx); |
+ __ Cmp(FieldOperand(rbx, 0), fixed_array_map); |
+ __ Assert(equal, kExpectedFixedArrayInRegisterRbx); |
+ |
+ // rdx should be a smi if we don't have undefined in rbx. |
+ __ AssertSmi(rdx); |
+ |
__ bind(&okay_here); |
} |
Label no_info; |
- // If the type cell is undefined, or contains anything other than an |
+ // If the feedback slot is undefined, or contains anything other than an |
// AllocationSite, call an array constructor that doesn't use AllocationSites. |
__ Cmp(rbx, undefined_sentinel); |
__ j(equal, &no_info); |
- __ movp(rbx, FieldOperand(rbx, Cell::kValueOffset)); |
+ __ SmiToInteger32(rdx, rdx); |
+ __ movp(rbx, FieldOperand(rbx, rdx, times_pointer_size, |
+ FixedArray::kHeaderSize)); |
+ __ Integer32ToSmi(rdx, rdx); |
__ Cmp(FieldOperand(rbx, 0), |
masm->isolate()->factory()->allocation_site_map()); |
__ j(not_equal, &no_info); |
@@ -5071,7 +5105,6 @@ void InternalArrayConstructorStub::GenerateCase( |
void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { |
// ----------- S t a t e ------------- |
// -- rax : argc |
- // -- rbx : type info cell |
// -- rdi : constructor |
// -- rsp[0] : return address |
// -- rsp[8] : last argument |