| Index: src/arm/code-stubs-arm.cc
|
| diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc
|
| index 1179aacfcef7598a6e1d0026b57c54a60becf471..b5af11c74fc8f66c2e6635f622c4253ceb353854 100644
|
| --- a/src/arm/code-stubs-arm.cc
|
| +++ b/src/arm/code-stubs-arm.cc
|
| @@ -5973,6 +5973,237 @@ void DirectCEntryStub::GenerateCall(MacroAssembler* masm,
|
| }
|
|
|
|
|
| +void StringDictionaryLookupStub::GenerateNegativeLookup(MacroAssembler* masm,
|
| + Label* miss,
|
| + Label* done,
|
| + Register receiver,
|
| + Register properties,
|
| + String* name,
|
| + Register scratch0) {
|
| + // If names of slots in range from 1 to kProbes - 1 for the hash value are
|
| + // not equal to the name and kProbes-th slot is not used (its name is the
|
| + // undefined value), it guarantees the hash table doesn't contain the
|
| + // property. It's true even if some slots represent deleted properties
|
| + // (their names are the null value).
|
| + for (int i = 0; i < kInlinedProbes; i++) {
|
| + // scratch0 points to properties hash.
|
| + // Compute the masked index: (hash + i + i * i) & mask.
|
| + Register index = scratch0;
|
| + // Capacity is smi 2^n.
|
| + __ ldr(index, FieldMemOperand(properties, kCapacityOffset));
|
| + __ sub(index, index, Operand(1));
|
| + __ and_(index, index, Operand(
|
| + Smi::FromInt(name->Hash() + StringDictionary::GetProbeOffset(i))));
|
| +
|
| + // Scale the index by multiplying by the entry size.
|
| + ASSERT(StringDictionary::kEntrySize == 3);
|
| + __ add(index, index, Operand(index, LSL, 1)); // index *= 3.
|
| +
|
| + Register entity_name = scratch0;
|
| + // Having undefined at this place means the name is not contained.
|
| + ASSERT_EQ(kSmiTagSize, 1);
|
| + Register tmp = properties;
|
| + __ add(tmp, properties, Operand(index, LSL, 1));
|
| + __ ldr(entity_name, FieldMemOperand(tmp, kElementsStartOffset));
|
| +
|
| + ASSERT(!tmp.is(entity_name));
|
| + __ LoadRoot(tmp, Heap::kUndefinedValueRootIndex);
|
| + __ cmp(entity_name, tmp);
|
| + __ b(eq, done);
|
| +
|
| + if (i != kInlinedProbes - 1) {
|
| + // Stop if found the property.
|
| + __ cmp(entity_name, Operand(Handle<String>(name)));
|
| + __ b(eq, miss);
|
| +
|
| + // Check if the entry name is not a symbol.
|
| + __ ldr(entity_name, FieldMemOperand(entity_name, HeapObject::kMapOffset));
|
| + __ ldrb(entity_name,
|
| + FieldMemOperand(entity_name, Map::kInstanceTypeOffset));
|
| + __ tst(entity_name, Operand(kIsSymbolMask));
|
| + __ b(eq, miss);
|
| +
|
| + // Restore the properties.
|
| + __ ldr(properties,
|
| + FieldMemOperand(receiver, JSObject::kPropertiesOffset));
|
| + }
|
| + }
|
| +
|
| + const int spill_mask =
|
| + (lr.bit() | r6.bit() | r5.bit() | r4.bit() | r3.bit() |
|
| + r2.bit() | r1.bit() | r0.bit());
|
| +
|
| + __ stm(db_w, sp, spill_mask);
|
| + __ ldr(r0, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
|
| + __ mov(r1, Operand(Handle<String>(name)));
|
| + StringDictionaryLookupStub stub(NEGATIVE_LOOKUP);
|
| + __ CallStub(&stub);
|
| + __ tst(r0, Operand(r0));
|
| + __ ldm(ia_w, sp, spill_mask);
|
| +
|
| + __ b(eq, done);
|
| + __ b(ne, miss);
|
| +}
|
| +
|
| +
|
| +// Probe the string dictionary in the |elements| register. Jump to the
|
| +// |done| label if a property with the given name is found. Jump to
|
| +// the |miss| label otherwise.
|
| +// If lookup was successful |scratch2| will be equal to elements + 4 * index.
|
| +void StringDictionaryLookupStub::GeneratePositiveLookup(MacroAssembler* masm,
|
| + Label* miss,
|
| + Label* done,
|
| + Register elements,
|
| + Register name,
|
| + Register scratch1,
|
| + Register scratch2) {
|
| + // Assert that name contains a string.
|
| + if (FLAG_debug_code) __ AbortIfNotString(name);
|
| +
|
| + // Compute the capacity mask.
|
| + __ ldr(scratch1, FieldMemOperand(elements, kCapacityOffset));
|
| + __ mov(scratch1, Operand(scratch1, ASR, kSmiTagSize)); // convert smi to int
|
| + __ sub(scratch1, scratch1, Operand(1));
|
| +
|
| + // Generate an unrolled loop that performs a few probes before
|
| + // giving up. Measurements done on Gmail indicate that 2 probes
|
| + // cover ~93% of loads from dictionaries.
|
| + for (int i = 0; i < kInlinedProbes; i++) {
|
| + // Compute the masked index: (hash + i + i * i) & mask.
|
| + __ ldr(scratch2, FieldMemOperand(name, String::kHashFieldOffset));
|
| + if (i > 0) {
|
| + // Add the probe offset (i + i * i) left shifted to avoid right shifting
|
| + // the hash in a separate instruction. The value hash + i + i * i is right
|
| + // shifted in the following and instruction.
|
| + ASSERT(StringDictionary::GetProbeOffset(i) <
|
| + 1 << (32 - String::kHashFieldOffset));
|
| + __ add(scratch2, scratch2, Operand(
|
| + StringDictionary::GetProbeOffset(i) << String::kHashShift));
|
| + }
|
| + __ and_(scratch2, scratch1, Operand(scratch2, LSR, String::kHashShift));
|
| +
|
| + // Scale the index by multiplying by the element size.
|
| + ASSERT(StringDictionary::kEntrySize == 3);
|
| + // scratch2 = scratch2 * 3.
|
| + __ add(scratch2, scratch2, Operand(scratch2, LSL, 1));
|
| +
|
| + // Check if the key is identical to the name.
|
| + __ add(scratch2, elements, Operand(scratch2, LSL, 2));
|
| + __ ldr(ip, FieldMemOperand(scratch2, kElementsStartOffset));
|
| + __ cmp(name, Operand(ip));
|
| + __ b(eq, done);
|
| + }
|
| +
|
| + const int spill_mask =
|
| + (lr.bit() | r6.bit() | r5.bit() | r4.bit() |
|
| + r3.bit() | r2.bit() | r1.bit() | r0.bit()) &
|
| + ~(scratch1.bit() | scratch2.bit());
|
| +
|
| + __ stm(db_w, sp, spill_mask);
|
| + __ Move(r0, elements);
|
| + __ Move(r1, name);
|
| + StringDictionaryLookupStub stub(POSITIVE_LOOKUP);
|
| + __ CallStub(&stub);
|
| + __ tst(r0, Operand(r0));
|
| + __ mov(scratch2, Operand(r2));
|
| + __ ldm(ia_w, sp, spill_mask);
|
| +
|
| + __ b(ne, done);
|
| + __ b(eq, miss);
|
| +}
|
| +
|
| +
|
| +void StringDictionaryLookupStub::Generate(MacroAssembler* masm) {
|
| + // Registers:
|
| + // result: StringDictionary to probe
|
| + // r1: key
|
| + // : StringDictionary to probe.
|
| + // index_: will hold an index of entry if lookup is successful.
|
| + // might alias with result_.
|
| + // Returns:
|
| + // result_ is zero if lookup failed, non zero otherwise.
|
| +
|
| + Register result = r0;
|
| + Register dictionary = r0;
|
| + Register key = r1;
|
| + Register index = r2;
|
| + Register mask = r3;
|
| + Register hash = r4;
|
| + Register undefined = r5;
|
| + Register entry_key = r6;
|
| +
|
| + Label in_dictionary, maybe_in_dictionary, not_in_dictionary;
|
| +
|
| + __ ldr(mask, FieldMemOperand(dictionary, kCapacityOffset));
|
| + __ mov(mask, Operand(mask, ASR, kSmiTagSize));
|
| + __ sub(mask, mask, Operand(1));
|
| +
|
| + __ ldr(hash, FieldMemOperand(key, String::kHashFieldOffset));
|
| +
|
| + __ LoadRoot(undefined, Heap::kUndefinedValueRootIndex);
|
| +
|
| + for (int i = kInlinedProbes; i < kTotalProbes; i++) {
|
| + // Compute the masked index: (hash + i + i * i) & mask.
|
| + // Capacity is smi 2^n.
|
| + if (i > 0) {
|
| + // Add the probe offset (i + i * i) left shifted to avoid right shifting
|
| + // the hash in a separate instruction. The value hash + i + i * i is right
|
| + // shifted in the following and instruction.
|
| + ASSERT(StringDictionary::GetProbeOffset(i) <
|
| + 1 << (32 - String::kHashFieldOffset));
|
| + __ add(index, hash, Operand(
|
| + StringDictionary::GetProbeOffset(i) << String::kHashShift));
|
| + } else {
|
| + __ mov(index, Operand(hash));
|
| + }
|
| + __ and_(index, mask, Operand(index, LSR, String::kHashShift));
|
| +
|
| + // Scale the index by multiplying by the entry size.
|
| + ASSERT(StringDictionary::kEntrySize == 3);
|
| + __ add(index, index, Operand(index, LSL, 1)); // index *= 3.
|
| +
|
| + ASSERT_EQ(kSmiTagSize, 1);
|
| + __ add(index, dictionary, Operand(index, LSL, 2));
|
| + __ ldr(entry_key, FieldMemOperand(index, kElementsStartOffset));
|
| +
|
| + // Having undefined at this place means the name is not contained.
|
| + __ cmp(entry_key, Operand(undefined));
|
| + __ b(eq, ¬_in_dictionary);
|
| +
|
| + // Stop if found the property.
|
| + __ cmp(entry_key, Operand(key));
|
| + __ b(eq, &in_dictionary);
|
| +
|
| + if (i != kTotalProbes - 1 && mode_ == NEGATIVE_LOOKUP) {
|
| + // Check if the entry name is not a symbol.
|
| + __ ldr(entry_key, FieldMemOperand(entry_key, HeapObject::kMapOffset));
|
| + __ ldrb(entry_key,
|
| + FieldMemOperand(entry_key, Map::kInstanceTypeOffset));
|
| + __ tst(entry_key, Operand(kIsSymbolMask));
|
| + __ b(eq, &maybe_in_dictionary);
|
| + }
|
| + }
|
| +
|
| + __ bind(&maybe_in_dictionary);
|
| + // If we are doing negative lookup then probing failure should be
|
| + // treated as a lookup success. For positive lookup probing failure
|
| + // should be treated as lookup failure.
|
| + if (mode_ == POSITIVE_LOOKUP) {
|
| + __ mov(result, Operand(0));
|
| + __ Ret();
|
| + }
|
| +
|
| + __ bind(&in_dictionary);
|
| + __ mov(result, Operand(1));
|
| + __ Ret();
|
| +
|
| + __ bind(¬_in_dictionary);
|
| + __ mov(result, Operand(0));
|
| + __ Ret();
|
| +
|
| +}
|
| +
|
| +
|
| #undef __
|
|
|
| } } // namespace v8::internal
|
|
|