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

Unified Diff: src/x64/code-stubs-x64.cc

Issue 1032163002: Vector-ICs - speed towards the monomorphic exit as quickly as possible. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Turn off flag. Created 5 years, 8 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/arm64/code-stubs-arm64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/code-stubs-x64.cc
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc
index 215f6263bb0b5db1f84385c411fedde19d52db6a..b25cf79ee5ab0118df6b29875345e8ad85600971 100644
--- a/src/x64/code-stubs-x64.cc
+++ b/src/x64/code-stubs-x64.cc
@@ -4351,24 +4351,18 @@ void KeyedLoadICTrampolineStub::Generate(MacroAssembler* masm) {
static void HandleArrayCases(MacroAssembler* masm, Register receiver,
Register key, Register vector, Register slot,
- Register feedback, Register scratch1,
- Register scratch2, Register scratch3,
- Register scratch4, bool is_polymorphic,
+ Register feedback, Register receiver_map,
+ Register scratch1, Register scratch2,
+ Register scratch3, bool is_polymorphic,
Label* miss) {
// feedback initially contains the feedback array
Label next_loop, prepare_next;
- Label load_smi_map, compare_map;
Label start_polymorphic;
- Register receiver_map = scratch1;
- Register counter = scratch2;
- Register length = scratch3;
- Register cached_map = scratch4;
+ Register counter = scratch1;
+ Register length = scratch2;
+ Register cached_map = scratch3;
- // Receiver might not be a heap object.
- __ JumpIfSmi(receiver, &load_smi_map);
- __ movp(receiver_map, FieldOperand(receiver, 0));
- __ bind(&compare_map);
__ movp(cached_map, FieldOperand(feedback, FixedArray::OffsetOfElementAt(0)));
__ cmpp(receiver_map, FieldOperand(cached_map, WeakCell::kValueOffset));
__ j(not_equal, &start_polymorphic);
@@ -4407,39 +4401,21 @@ static void HandleArrayCases(MacroAssembler* masm, Register receiver,
// We exhausted our array of map handler pairs.
__ jmp(miss);
-
- __ bind(&load_smi_map);
- __ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex);
- __ jmp(&compare_map);
}
static void HandleMonomorphicCase(MacroAssembler* masm, Register receiver,
- Register key, Register vector, Register slot,
- Register weak_cell, Register integer_slot,
- Label* miss) {
- // feedback initially contains the feedback array
- Label compare_smi_map;
-
- // Move the weak map into the weak_cell register.
- Register ic_map = weak_cell;
- __ movp(ic_map, FieldOperand(weak_cell, WeakCell::kValueOffset));
-
- // Receiver might not be a heap object.
- __ JumpIfSmi(receiver, &compare_smi_map);
- __ cmpp(ic_map, FieldOperand(receiver, 0));
- __ j(not_equal, miss);
- Register handler = weak_cell;
- __ movp(handler, FieldOperand(vector, integer_slot, times_pointer_size,
- FixedArray::kHeaderSize + kPointerSize));
- __ leap(handler, FieldOperand(handler, Code::kHeaderSize));
- __ jmp(handler);
+ Register receiver_map, Register feedback,
+ Register vector, Register integer_slot,
+ Label* compare_map, Label* load_smi_map,
+ Label* try_array) {
+ __ JumpIfSmi(receiver, load_smi_map);
+ __ movp(receiver_map, FieldOperand(receiver, 0));
- // In microbenchmarks, it made sense to unroll this code so that the call to
- // the handler is duplicated for a HeapObject receiver and a Smi receiver.
- __ bind(&compare_smi_map);
- __ CompareRoot(ic_map, Heap::kHeapNumberMapRootIndex);
- __ j(not_equal, miss);
+ __ bind(compare_map);
+ __ cmpp(receiver_map, FieldOperand(feedback, WeakCell::kValueOffset));
+ __ j(not_equal, try_array);
+ Register handler = feedback;
__ movp(handler, FieldOperand(vector, integer_slot, times_pointer_size,
FixedArray::kHeaderSize + kPointerSize));
__ leap(handler, FieldOperand(handler, Code::kHeaderSize));
@@ -4464,25 +4440,26 @@ void VectorRawLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
Register slot = VectorLoadICDescriptor::SlotRegister(); // rax
Register feedback = rdi;
Register integer_slot = r8;
+ Register receiver_map = r9;
__ SmiToInteger32(integer_slot, slot);
__ movp(feedback, FieldOperand(vector, integer_slot, times_pointer_size,
FixedArray::kHeaderSize));
- // Is it a weak cell?
- Label try_array;
- Label not_array, smi_key, key_okay, miss;
- __ CompareRoot(FieldOperand(feedback, 0), Heap::kWeakCellMapRootIndex);
- __ j(not_equal, &try_array);
- HandleMonomorphicCase(masm, receiver, name, vector, slot, feedback,
- integer_slot, &miss);
+ // Try to quickly handle the monomorphic case without knowing for sure
+ // if we have a weak cell in feedback. We do know it's safe to look
+ // at WeakCell::kValueOffset.
+ Label try_array, load_smi_map, compare_map;
+ Label not_array, miss;
+ HandleMonomorphicCase(masm, receiver, receiver_map, feedback, vector,
+ integer_slot, &compare_map, &load_smi_map, &try_array);
// Is it a fixed array?
__ bind(&try_array);
__ CompareRoot(FieldOperand(feedback, 0), Heap::kFixedArrayMapRootIndex);
__ j(not_equal, &not_array);
- HandleArrayCases(masm, receiver, name, vector, slot, feedback, integer_slot,
- r9, r11, r15, true, &miss);
+ HandleArrayCases(masm, receiver, name, vector, slot, feedback, receiver_map,
+ integer_slot, r11, r15, true, &miss);
__ bind(&not_array);
__ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex);
@@ -4494,6 +4471,10 @@ void VectorRawLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
__ bind(&miss);
LoadIC::GenerateMiss(masm);
+
+ __ bind(&load_smi_map);
+ __ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex);
+ __ jmp(&compare_map);
}
@@ -4514,18 +4495,19 @@ void VectorRawKeyedLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
Register slot = VectorLoadICDescriptor::SlotRegister(); // rax
Register feedback = rdi;
Register integer_slot = r8;
+ Register receiver_map = r9;
__ SmiToInteger32(integer_slot, slot);
__ movp(feedback, FieldOperand(vector, integer_slot, times_pointer_size,
FixedArray::kHeaderSize));
- // Is it a weak cell?
- Label try_array;
- Label not_array, smi_key, key_okay, miss;
- __ CompareRoot(FieldOperand(feedback, 0), Heap::kWeakCellMapRootIndex);
- __ j(not_equal, &try_array);
- HandleMonomorphicCase(masm, receiver, key, vector, slot, feedback,
- integer_slot, &miss);
+ // Try to quickly handle the monomorphic case without knowing for sure
+ // if we have a weak cell in feedback. We do know it's safe to look
+ // at WeakCell::kValueOffset.
+ Label try_array, load_smi_map, compare_map;
+ Label not_array, miss;
+ HandleMonomorphicCase(masm, receiver, receiver_map, feedback, vector,
+ integer_slot, &compare_map, &load_smi_map, &try_array);
__ bind(&try_array);
// Is it a fixed array?
@@ -4535,8 +4517,8 @@ void VectorRawKeyedLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
// We have a polymorphic element handler.
Label polymorphic, try_poly_name;
__ bind(&polymorphic);
- HandleArrayCases(masm, receiver, key, vector, slot, feedback, integer_slot,
- r9, r11, r15, true, &miss);
+ HandleArrayCases(masm, receiver, key, vector, slot, feedback, receiver_map,
+ integer_slot, r11, r15, true, &miss);
__ bind(&not_array);
// Is it generic?
@@ -4554,11 +4536,15 @@ void VectorRawKeyedLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
// at least one map/handler pair.
__ movp(feedback, FieldOperand(vector, integer_slot, times_pointer_size,
FixedArray::kHeaderSize + kPointerSize));
- HandleArrayCases(masm, receiver, key, vector, slot, feedback, integer_slot,
- r9, r11, r15, false, &miss);
+ HandleArrayCases(masm, receiver, key, vector, slot, feedback, receiver_map,
+ integer_slot, r11, r15, false, &miss);
__ bind(&miss);
KeyedLoadIC::GenerateMiss(masm);
+
+ __ bind(&load_smi_map);
+ __ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex);
+ __ jmp(&compare_map);
}
« no previous file with comments | « src/arm64/code-stubs-arm64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698