summaryrefslogtreecommitdiff
path: root/deps/v8/src/ic/mips/ic-mips.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/ic/mips/ic-mips.cc')
-rw-r--r--deps/v8/src/ic/mips/ic-mips.cc174
1 files changed, 68 insertions, 106 deletions
diff --git a/deps/v8/src/ic/mips/ic-mips.cc b/deps/v8/src/ic/mips/ic-mips.cc
index 7c8a5eacab..33b78cec58 100644
--- a/deps/v8/src/ic/mips/ic-mips.cc
+++ b/deps/v8/src/ic/mips/ic-mips.cc
@@ -160,12 +160,10 @@ static void GenerateKeyedLoadReceiverCheck(MacroAssembler* masm,
// Loads an indexed element from a fast case array.
-// If not_fast_array is NULL, doesn't perform the elements map check.
static void GenerateFastArrayLoad(MacroAssembler* masm, Register receiver,
Register key, Register elements,
Register scratch1, Register scratch2,
- Register result, Label* not_fast_array,
- Label* out_of_range) {
+ Register result, Label* slow) {
// Register use:
//
// receiver - holds the receiver on entry.
@@ -174,8 +172,6 @@ static void GenerateFastArrayLoad(MacroAssembler* masm, Register receiver,
// key - holds the smi key on entry.
// Unchanged unless 'result' is the same register.
//
- // elements - holds the elements of the receiver on exit.
- //
// result - holds the result on exit if the load succeeded.
// Allowed to be the the same as 'receiver' or 'key'.
// Unchanged on bailout so 'receiver' and 'key' can be safely
@@ -183,25 +179,50 @@ static void GenerateFastArrayLoad(MacroAssembler* masm, Register receiver,
//
// Scratch registers:
//
- // scratch1 - used to hold elements map and elements length.
- // Holds the elements map if not_fast_array branch is taken.
+ // elements - holds the elements of the receiver and its prototypes.
+ //
+ // scratch1 - used to hold elements length, bit fields, base addresses.
//
- // scratch2 - used to hold the loaded value.
+ // scratch2 - used to hold maps, prototypes, and the loaded value.
+ Label check_prototypes, check_next_prototype;
+ Label done, in_bounds, return_undefined;
__ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
- if (not_fast_array != NULL) {
- // Check that the object is in fast mode (not dictionary).
- __ lw(scratch1, FieldMemOperand(elements, HeapObject::kMapOffset));
- __ LoadRoot(at, Heap::kFixedArrayMapRootIndex);
- __ Branch(not_fast_array, ne, scratch1, Operand(at));
- } else {
- __ AssertFastElements(elements);
- }
+ __ AssertFastElements(elements);
// Check that the key (index) is within bounds.
__ lw(scratch1, FieldMemOperand(elements, FixedArray::kLengthOffset));
- __ Branch(out_of_range, hs, key, Operand(scratch1));
+ __ Branch(&in_bounds, lo, key, Operand(scratch1));
+ // Out-of-bounds. Check the prototype chain to see if we can just return
+ // 'undefined'.
+ // Negative keys can't take the fast OOB path.
+ __ Branch(slow, lt, key, Operand(zero_reg));
+ __ bind(&check_prototypes);
+ __ lw(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset));
+ __ bind(&check_next_prototype);
+ __ lw(scratch2, FieldMemOperand(scratch2, Map::kPrototypeOffset));
+ // scratch2: current prototype
+ __ LoadRoot(at, Heap::kNullValueRootIndex);
+ __ Branch(&return_undefined, eq, scratch2, Operand(at));
+ __ lw(elements, FieldMemOperand(scratch2, JSObject::kElementsOffset));
+ __ lw(scratch2, FieldMemOperand(scratch2, HeapObject::kMapOffset));
+ // elements: elements of current prototype
+ // scratch2: map of current prototype
+ __ lbu(scratch1, FieldMemOperand(scratch2, Map::kInstanceTypeOffset));
+ __ Branch(slow, lo, scratch1, Operand(JS_OBJECT_TYPE));
+ __ lbu(scratch1, FieldMemOperand(scratch2, Map::kBitFieldOffset));
+ __ And(at, scratch1, Operand((1 << Map::kIsAccessCheckNeeded) |
+ (1 << Map::kHasIndexedInterceptor)));
+ __ Branch(slow, ne, at, Operand(zero_reg));
+ __ LoadRoot(at, Heap::kEmptyFixedArrayRootIndex);
+ __ Branch(slow, ne, elements, Operand(at));
+ __ Branch(&check_next_prototype);
+ __ bind(&return_undefined);
+ __ LoadRoot(result, Heap::kUndefinedValueRootIndex);
+ __ Branch(&done);
+
+ __ bind(&in_bounds);
// Fast case: Do the load.
__ Addu(scratch1, elements,
Operand(FixedArray::kHeaderSize - kHeapObjectTag));
@@ -212,10 +233,10 @@ static void GenerateFastArrayLoad(MacroAssembler* masm, Register receiver,
__ lw(scratch2, MemOperand(at));
__ LoadRoot(at, Heap::kTheHoleValueRootIndex);
- // In case the loaded value is the_hole we have to consult GetProperty
- // to ensure the prototype chain is searched.
- __ Branch(out_of_range, eq, scratch2, Operand(at));
- __ mov(result, scratch2);
+ // In case the loaded value is the_hole we have to check the prototype chain.
+ __ Branch(&check_prototypes, eq, scratch2, Operand(at));
+ __ Move(result, scratch2);
+ __ bind(&done);
}
@@ -454,7 +475,7 @@ void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) {
}
-void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
+void KeyedLoadIC::GenerateMegamorphic(MacroAssembler* masm) {
// The return address is in ra.
Label slow, check_name, index_smi, index_name, property_array_property;
Label probe_dictionary, check_number_dictionary;
@@ -478,7 +499,7 @@ void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
// Check the receiver's map to see if it has fast elements.
__ CheckFastElements(a0, a3, &check_number_dictionary);
- GenerateFastArrayLoad(masm, receiver, key, a0, a3, t0, v0, NULL, &slow);
+ GenerateFastArrayLoad(masm, receiver, key, a0, a3, t0, v0, &slow);
__ IncrementCounter(isolate->counters()->keyed_load_generic_smi(), 1, t0, a3);
__ Ret();
@@ -508,92 +529,33 @@ void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
Map::kHasNamedInterceptor, &slow);
- // If the receiver is a fast-case object, check the keyed lookup
- // cache. Otherwise probe the dictionary.
+ // If the receiver is a fast-case object, check the stub cache. Otherwise
+ // probe the dictionary.
__ lw(a3, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
__ lw(t0, FieldMemOperand(a3, HeapObject::kMapOffset));
__ LoadRoot(at, Heap::kHashTableMapRootIndex);
__ Branch(&probe_dictionary, eq, t0, Operand(at));
- // Load the map of the receiver, compute the keyed lookup cache hash
- // based on 32 bits of the map pointer and the name hash.
- __ lw(a0, FieldMemOperand(receiver, HeapObject::kMapOffset));
- __ sra(a3, a0, KeyedLookupCache::kMapHashShift);
- __ lw(t0, FieldMemOperand(key, Name::kHashFieldOffset));
- __ sra(at, t0, Name::kHashShift);
- __ xor_(a3, a3, at);
- int mask = KeyedLookupCache::kCapacityMask & KeyedLookupCache::kHashMask;
- __ And(a3, a3, Operand(mask));
-
- // Load the key (consisting of map and unique name) from the cache and
- // check for match.
- Label load_in_object_property;
- static const int kEntriesPerBucket = KeyedLookupCache::kEntriesPerBucket;
- Label hit_on_nth_entry[kEntriesPerBucket];
- ExternalReference cache_keys =
- ExternalReference::keyed_lookup_cache_keys(isolate);
- __ li(t0, Operand(cache_keys));
- __ sll(at, a3, kPointerSizeLog2 + 1);
- __ addu(t0, t0, at);
-
- for (int i = 0; i < kEntriesPerBucket - 1; i++) {
- Label try_next_entry;
- __ lw(t1, MemOperand(t0, kPointerSize * i * 2));
- __ Branch(&try_next_entry, ne, a0, Operand(t1));
- __ lw(t1, MemOperand(t0, kPointerSize * (i * 2 + 1)));
- __ Branch(&hit_on_nth_entry[i], eq, key, Operand(t1));
- __ bind(&try_next_entry);
- }
-
- __ lw(t1, MemOperand(t0, kPointerSize * (kEntriesPerBucket - 1) * 2));
- __ Branch(&slow, ne, a0, Operand(t1));
- __ lw(t1, MemOperand(t0, kPointerSize * ((kEntriesPerBucket - 1) * 2 + 1)));
- __ Branch(&slow, ne, key, Operand(t1));
-
- // Get field offset.
- // a0 : receiver's map
- // a3 : lookup cache index
- ExternalReference cache_field_offsets =
- ExternalReference::keyed_lookup_cache_field_offsets(isolate);
-
- // Hit on nth entry.
- for (int i = kEntriesPerBucket - 1; i >= 0; i--) {
- __ bind(&hit_on_nth_entry[i]);
- __ li(t0, Operand(cache_field_offsets));
- __ sll(at, a3, kPointerSizeLog2);
- __ addu(at, t0, at);
- __ lw(t1, MemOperand(at, kPointerSize * i));
- __ lbu(t2, FieldMemOperand(a0, Map::kInObjectPropertiesOffset));
- __ Subu(t1, t1, t2);
- __ Branch(&property_array_property, ge, t1, Operand(zero_reg));
- if (i != 0) {
- __ Branch(&load_in_object_property);
- }
+ if (FLAG_vector_ics) {
+ // When vector ics are in use, the handlers in the stub cache expect a
+ // vector and slot. Since we won't change the IC from any downstream
+ // misses, a dummy vector can be used.
+ Register vector = VectorLoadICDescriptor::VectorRegister();
+ Register slot = VectorLoadICDescriptor::SlotRegister();
+ DCHECK(!AreAliased(vector, slot, t0, t1, t2, t5));
+ Handle<TypeFeedbackVector> dummy_vector = Handle<TypeFeedbackVector>::cast(
+ masm->isolate()->factory()->keyed_load_dummy_vector());
+ int int_slot = dummy_vector->GetIndex(FeedbackVectorICSlot(0));
+ __ LoadRoot(vector, Heap::kKeyedLoadDummyVectorRootIndex);
+ __ li(slot, Operand(Smi::FromInt(int_slot)));
}
- // Load in-object property.
- __ bind(&load_in_object_property);
- __ lbu(t2, FieldMemOperand(a0, Map::kInstanceSizeOffset));
- __ addu(t2, t2, t1); // Index from start of object.
- __ Subu(receiver, receiver, Operand(kHeapObjectTag)); // Remove the heap tag.
- __ sll(at, t2, kPointerSizeLog2);
- __ addu(at, receiver, at);
- __ lw(v0, MemOperand(at));
- __ IncrementCounter(isolate->counters()->keyed_load_generic_lookup_cache(), 1,
- t0, a3);
- __ Ret();
-
- // Load property array property.
- __ bind(&property_array_property);
- __ lw(receiver, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
- __ Addu(receiver, receiver, FixedArray::kHeaderSize - kHeapObjectTag);
- __ sll(v0, t1, kPointerSizeLog2);
- __ Addu(v0, v0, receiver);
- __ lw(v0, MemOperand(v0));
- __ IncrementCounter(isolate->counters()->keyed_load_generic_lookup_cache(), 1,
- t0, a3);
- __ Ret();
-
+ Code::Flags flags = Code::RemoveTypeAndHolderFromFlags(
+ Code::ComputeHandlerFlags(Code::LOAD_IC));
+ masm->isolate()->stub_cache()->GenerateProbe(
+ masm, Code::LOAD_IC, flags, false, receiver, key, t0, t1, t2, t5);
+ // Cache miss.
+ GenerateMiss(masm);
// Do a quick inline probe of the receiver's dictionary, if it
// exists.
@@ -762,7 +724,7 @@ static void KeyedStoreGenerateMegamorphicHelper(
void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm,
- StrictMode strict_mode) {
+ LanguageMode language_mode) {
// ---------- S t a t e --------------
// -- a0 : value
// -- a1 : key
@@ -813,7 +775,7 @@ void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm,
// a0: value.
// a1: key.
// a2: receiver.
- PropertyICCompiler::GenerateRuntimeSetProperty(masm, strict_mode);
+ PropertyICCompiler::GenerateRuntimeSetProperty(masm, language_mode);
// Never returns to here.
__ bind(&maybe_name_key);
@@ -1013,10 +975,10 @@ void PatchInlinedSmiCode(Address address, InlinedSmiCheck check) {
Register reg = Register::from_code(Assembler::GetRs(instr_at_patch));
if (check == ENABLE_INLINED_SMI_CHECK) {
DCHECK(Assembler::IsAndImmediate(instr_at_patch));
- DCHECK_EQ(0, Assembler::GetImmediate16(instr_at_patch));
+ DCHECK_EQ(0u, Assembler::GetImmediate16(instr_at_patch));
patcher.masm()->andi(at, reg, kSmiTagMask);
} else {
- DCHECK(check == DISABLE_INLINED_SMI_CHECK);
+ DCHECK_EQ(check, DISABLE_INLINED_SMI_CHECK);
DCHECK(Assembler::IsAndImmediate(instr_at_patch));
patcher.masm()->andi(at, reg, 0);
}