Commit 806e57f4 authored by michael_dawson's avatar michael_dawson Committed by Commit bot

PPC: Vector-ICs - speed towards the monomorphic exit as quickly as possible.

Port 35a67b74

Original commit message:
Thanks to some careful assumptions, we can examine the object found at
vector[slot] and trust it's a heap object where the second field is
either a map if it's a WeakCell, or definitely not a map if it's a
Symbol, String or FixedArray. Use this to save a memory read.

R=mbrandy@us.ibm.com

BUG=

Review URL: https://codereview.chromium.org/1059133005

Cr-Commit-Position: refs/heads/master@{#27728}
parent c00de386
......@@ -4602,21 +4602,15 @@ void VectorRawLoadStub::GenerateForTrampoline(MacroAssembler* masm) {
static void HandleArrayCases(MacroAssembler* masm, Register receiver,
Register key, Register vector, Register slot,
Register feedback, Register scratch1,
Register scratch2, Register scratch3,
Register feedback, Register receiver_map,
Register scratch1, Register scratch2,
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 cached_map = scratch2;
Register cached_map = scratch1;
// Receiver might not be a heap object.
__ JumpIfSmi(receiver, &load_smi_map);
__ LoadP(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ bind(&compare_map);
__ LoadP(cached_map,
FieldMemOperand(feedback, FixedArray::OffsetOfElementAt(0)));
__ LoadP(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset));
......@@ -4630,7 +4624,7 @@ static void HandleArrayCases(MacroAssembler* masm, Register receiver,
__ Jump(ip);
Register length = scratch3;
Register length = scratch2;
__ bind(&start_polymorphic);
__ LoadP(length, FieldMemOperand(feedback, FixedArray::kLengthOffset));
if (!is_polymorphic) {
......@@ -4650,9 +4644,9 @@ static void HandleArrayCases(MacroAssembler* masm, Register receiver,
// ^ ^
// | |
// pointer_reg too_far
// aka feedback scratch3
// also need receiver_map (aka scratch1)
// use cached_map (scratch2) to look in the weak map values.
// aka feedback scratch2
// also need receiver_map
// use cached_map (scratch1) to look in the weak map values.
__ SmiToPtrArrayOffset(r0, length);
__ add(too_far, feedback, r0);
__ addi(too_far, too_far, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
......@@ -4675,44 +4669,23 @@ static void HandleArrayCases(MacroAssembler* masm, Register receiver,
// We exhausted our array of map handler pairs.
__ b(miss);
__ bind(&load_smi_map);
__ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex);
__ b(&compare_map);
}
static void HandleMonomorphicCase(MacroAssembler* masm, Register receiver,
Register key, Register vector, Register slot,
Register weak_cell, Register scratch,
Label* miss) {
// feedback initially contains the feedback array
Label compare_smi_map;
Register receiver_map = scratch;
Register cached_map = weak_cell;
// Move the weak map into the weak_cell register.
__ LoadP(cached_map, FieldMemOperand(weak_cell, WeakCell::kValueOffset));
// Receiver might not be a heap object.
__ JumpIfSmi(receiver, &compare_smi_map);
Register receiver_map, Register feedback,
Register vector, Register slot,
Register scratch, Label* compare_map,
Label* load_smi_map, Label* try_array) {
__ JumpIfSmi(receiver, load_smi_map);
__ LoadP(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ bind(compare_map);
Register cached_map = scratch;
// Move the weak map into the weak_cell register.
__ LoadP(cached_map, FieldMemOperand(feedback, WeakCell::kValueOffset));
__ cmp(cached_map, receiver_map);
__ bne(miss);
Register handler = weak_cell;
__ SmiToPtrArrayOffset(r0, slot);
__ add(handler, vector, r0);
__ LoadP(handler,
FieldMemOperand(handler, FixedArray::kHeaderSize + kPointerSize));
__ addi(ip, handler, Operand(Code::kHeaderSize - kHeapObjectTag));
__ Jump(ip);
// 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(weak_cell, Heap::kHeapNumberMapRootIndex);
__ bne(miss);
__ bne(try_array);
Register handler = feedback;
__ SmiToPtrArrayOffset(r0, slot);
__ add(handler, vector, r0);
__ LoadP(handler,
......@@ -4728,27 +4701,28 @@ void VectorRawLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
Register vector = VectorLoadICDescriptor::VectorRegister(); // r6
Register slot = VectorLoadICDescriptor::SlotRegister(); // r3
Register feedback = r7;
Register scratch1 = r8;
Register receiver_map = r8;
Register scratch1 = r9;
__ SmiToPtrArrayOffset(r0, slot);
__ add(feedback, vector, r0);
__ LoadP(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize));
// Is it a weak cell?
Label try_array;
Label not_array, smi_key, key_okay, miss;
__ LoadP(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset));
__ CompareRoot(scratch1, Heap::kWeakCellMapRootIndex);
__ bne(&try_array);
HandleMonomorphicCase(masm, receiver, name, vector, slot, feedback, scratch1,
&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, slot,
scratch1, &compare_map, &load_smi_map, &try_array);
// Is it a fixed array?
__ bind(&try_array);
__ LoadP(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset));
__ CompareRoot(scratch1, Heap::kFixedArrayMapRootIndex);
__ bne(&not_array);
HandleArrayCases(masm, receiver, name, vector, slot, feedback, scratch1, r9,
r10, true, &miss);
HandleArrayCases(masm, receiver, name, vector, slot, feedback, receiver_map,
scratch1, r10, true, &miss);
__ bind(&not_array);
__ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex);
......@@ -4757,10 +4731,14 @@ void VectorRawLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
Code::ComputeHandlerFlags(Code::LOAD_IC));
masm->isolate()->stub_cache()->GenerateProbe(masm, Code::LOAD_IC, code_flags,
false, receiver, name, feedback,
scratch1, r9, r10);
receiver_map, scratch1, r10);
__ bind(&miss);
LoadIC::GenerateMiss(masm);
__ bind(&load_smi_map);
__ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex);
__ b(&compare_map);
}
......@@ -4780,31 +4758,32 @@ void VectorRawKeyedLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
Register vector = VectorLoadICDescriptor::VectorRegister(); // r6
Register slot = VectorLoadICDescriptor::SlotRegister(); // r3
Register feedback = r7;
Register scratch1 = r8;
Register receiver_map = r8;
Register scratch1 = r9;
__ SmiToPtrArrayOffset(r0, slot);
__ add(feedback, vector, r0);
__ LoadP(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize));
// Is it a weak cell?
Label try_array;
Label not_array, smi_key, key_okay, miss;
__ LoadP(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset));
__ CompareRoot(scratch1, Heap::kWeakCellMapRootIndex);
__ bne(&try_array);
HandleMonomorphicCase(masm, receiver, key, vector, slot, feedback, scratch1,
&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, slot,
scratch1, &compare_map, &load_smi_map, &try_array);
__ bind(&try_array);
// Is it a fixed array?
__ LoadP(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset));
__ CompareRoot(scratch1, Heap::kFixedArrayMapRootIndex);
__ bne(&not_array);
// We have a polymorphic element handler.
Label polymorphic, try_poly_name;
__ bind(&polymorphic);
HandleArrayCases(masm, receiver, key, vector, slot, feedback, scratch1, r9,
r10, true, &miss);
HandleArrayCases(masm, receiver, key, vector, slot, feedback, receiver_map,
scratch1, r10, true, &miss);
__ bind(&not_array);
// Is it generic?
......@@ -4824,11 +4803,15 @@ void VectorRawKeyedLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
__ add(feedback, vector, r0);
__ LoadP(feedback,
FieldMemOperand(feedback, FixedArray::kHeaderSize + kPointerSize));
HandleArrayCases(masm, receiver, key, vector, slot, feedback, scratch1, r9,
r10, false, &miss);
HandleArrayCases(masm, receiver, key, vector, slot, feedback, receiver_map,
scratch1, r10, false, &miss);
__ bind(&miss);
KeyedLoadIC::GenerateMiss(masm);
__ bind(&load_smi_map);
__ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex);
__ b(&compare_map);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment