| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 const int kValueOffset = kElementsStartOffset + kPointerSize; | 205 const int kValueOffset = kElementsStartOffset + kPointerSize; |
| 206 __ add(scratch2, scratch2, Operand(kValueOffset - kHeapObjectTag)); | 206 __ add(scratch2, scratch2, Operand(kValueOffset - kHeapObjectTag)); |
| 207 __ str(value, MemOperand(scratch2)); | 207 __ str(value, MemOperand(scratch2)); |
| 208 | 208 |
| 209 // Update the write barrier. Make sure not to clobber the value. | 209 // Update the write barrier. Make sure not to clobber the value. |
| 210 __ mov(scratch1, value); | 210 __ mov(scratch1, value); |
| 211 __ RecordWrite(elements, scratch2, scratch1); | 211 __ RecordWrite(elements, scratch2, scratch1); |
| 212 } | 212 } |
| 213 | 213 |
| 214 | 214 |
| 215 static void GenerateNumberDictionaryLoad(MacroAssembler* masm, | |
| 216 Label* miss, | |
| 217 Register elements, | |
| 218 Register key, | |
| 219 Register result, | |
| 220 Register t0, | |
| 221 Register t1, | |
| 222 Register t2) { | |
| 223 // Register use: | |
| 224 // | |
| 225 // elements - holds the slow-case elements of the receiver on entry. | |
| 226 // Unchanged unless 'result' is the same register. | |
| 227 // | |
| 228 // key - holds the smi key on entry. | |
| 229 // Unchanged unless 'result' is the same register. | |
| 230 // | |
| 231 // result - holds the result on exit if the load succeeded. | |
| 232 // Allowed to be the same as 'key' or 'result'. | |
| 233 // Unchanged on bailout so 'key' or 'result' can be used | |
| 234 // in further computation. | |
| 235 // | |
| 236 // Scratch registers: | |
| 237 // | |
| 238 // t0 - holds the untagged key on entry and holds the hash once computed. | |
| 239 // | |
| 240 // t1 - used to hold the capacity mask of the dictionary | |
| 241 // | |
| 242 // t2 - used for the index into the dictionary. | |
| 243 Label done; | |
| 244 | |
| 245 // Compute the hash code from the untagged key. This must be kept in sync | |
| 246 // with ComputeIntegerHash in utils.h. | |
| 247 // | |
| 248 // hash = ~hash + (hash << 15); | |
| 249 __ mvn(t1, Operand(t0)); | |
| 250 __ add(t0, t1, Operand(t0, LSL, 15)); | |
| 251 // hash = hash ^ (hash >> 12); | |
| 252 __ eor(t0, t0, Operand(t0, LSR, 12)); | |
| 253 // hash = hash + (hash << 2); | |
| 254 __ add(t0, t0, Operand(t0, LSL, 2)); | |
| 255 // hash = hash ^ (hash >> 4); | |
| 256 __ eor(t0, t0, Operand(t0, LSR, 4)); | |
| 257 // hash = hash * 2057; | |
| 258 __ mov(t1, Operand(2057)); | |
| 259 __ mul(t0, t0, t1); | |
| 260 // hash = hash ^ (hash >> 16); | |
| 261 __ eor(t0, t0, Operand(t0, LSR, 16)); | |
| 262 | |
| 263 // Compute the capacity mask. | |
| 264 __ ldr(t1, FieldMemOperand(elements, NumberDictionary::kCapacityOffset)); | |
| 265 __ mov(t1, Operand(t1, ASR, kSmiTagSize)); // convert smi to int | |
| 266 __ sub(t1, t1, Operand(1)); | |
| 267 | |
| 268 // Generate an unrolled loop that performs a few probes before giving up. | |
| 269 static const int kProbes = 4; | |
| 270 for (int i = 0; i < kProbes; i++) { | |
| 271 // Use t2 for index calculations and keep the hash intact in t0. | |
| 272 __ mov(t2, t0); | |
| 273 // Compute the masked index: (hash + i + i * i) & mask. | |
| 274 if (i > 0) { | |
| 275 __ add(t2, t2, Operand(NumberDictionary::GetProbeOffset(i))); | |
| 276 } | |
| 277 __ and_(t2, t2, Operand(t1)); | |
| 278 | |
| 279 // Scale the index by multiplying by the element size. | |
| 280 ASSERT(NumberDictionary::kEntrySize == 3); | |
| 281 __ add(t2, t2, Operand(t2, LSL, 1)); // t2 = t2 * 3 | |
| 282 | |
| 283 // Check if the key is identical to the name. | |
| 284 __ add(t2, elements, Operand(t2, LSL, kPointerSizeLog2)); | |
| 285 __ ldr(ip, FieldMemOperand(t2, NumberDictionary::kElementsStartOffset)); | |
| 286 __ cmp(key, Operand(ip)); | |
| 287 if (i != kProbes - 1) { | |
| 288 __ b(eq, &done); | |
| 289 } else { | |
| 290 __ b(ne, miss); | |
| 291 } | |
| 292 } | |
| 293 | |
| 294 __ bind(&done); | |
| 295 // Check that the value is a normal property. | |
| 296 // t2: elements + (index * kPointerSize) | |
| 297 const int kDetailsOffset = | |
| 298 NumberDictionary::kElementsStartOffset + 2 * kPointerSize; | |
| 299 __ ldr(t1, FieldMemOperand(t2, kDetailsOffset)); | |
| 300 __ tst(t1, Operand(Smi::FromInt(PropertyDetails::TypeField::mask()))); | |
| 301 __ b(ne, miss); | |
| 302 | |
| 303 // Get the value at the masked, scaled index and return. | |
| 304 const int kValueOffset = | |
| 305 NumberDictionary::kElementsStartOffset + kPointerSize; | |
| 306 __ ldr(result, FieldMemOperand(t2, kValueOffset)); | |
| 307 } | |
| 308 | |
| 309 | |
| 310 void LoadIC::GenerateArrayLength(MacroAssembler* masm) { | 215 void LoadIC::GenerateArrayLength(MacroAssembler* masm) { |
| 311 // ----------- S t a t e ------------- | 216 // ----------- S t a t e ------------- |
| 312 // -- r2 : name | 217 // -- r2 : name |
| 313 // -- lr : return address | 218 // -- lr : return address |
| 314 // -- r0 : receiver | 219 // -- r0 : receiver |
| 315 // -- sp[0] : receiver | 220 // -- sp[0] : receiver |
| 316 // ----------------------------------- | 221 // ----------------------------------- |
| 317 Label miss; | 222 Label miss; |
| 318 | 223 |
| 319 StubCompiler::GenerateLoadArrayLength(masm, r0, r3, &miss); | 224 StubCompiler::GenerateLoadArrayLength(masm, r0, r3, &miss); |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 __ bind(&check_number_dictionary); | 636 __ bind(&check_number_dictionary); |
| 732 // r2: key | 637 // r2: key |
| 733 // r3: elements map | 638 // r3: elements map |
| 734 // r4: elements | 639 // r4: elements |
| 735 // Check whether the elements is a number dictionary. | 640 // Check whether the elements is a number dictionary. |
| 736 __ LoadRoot(ip, Heap::kHashTableMapRootIndex); | 641 __ LoadRoot(ip, Heap::kHashTableMapRootIndex); |
| 737 __ cmp(r3, ip); | 642 __ cmp(r3, ip); |
| 738 __ b(ne, &slow_load); | 643 __ b(ne, &slow_load); |
| 739 __ mov(r0, Operand(r2, ASR, kSmiTagSize)); | 644 __ mov(r0, Operand(r2, ASR, kSmiTagSize)); |
| 740 // r0: untagged index | 645 // r0: untagged index |
| 741 GenerateNumberDictionaryLoad(masm, &slow_load, r4, r2, r1, r0, r3, r5); | 646 __ LoadFromNumberDictionary(&slow_load, r4, r2, r1, r0, r3, r5); |
| 742 __ IncrementCounter(counters->keyed_call_generic_smi_dict(), 1, r0, r3); | 647 __ IncrementCounter(counters->keyed_call_generic_smi_dict(), 1, r0, r3); |
| 743 __ jmp(&do_call); | 648 __ jmp(&do_call); |
| 744 | 649 |
| 745 __ bind(&slow_load); | 650 __ bind(&slow_load); |
| 746 // This branch is taken when calling KeyedCallIC_Miss is neither required | 651 // This branch is taken when calling KeyedCallIC_Miss is neither required |
| 747 // nor beneficial. | 652 // nor beneficial. |
| 748 __ IncrementCounter(counters->keyed_call_generic_slow_load(), 1, r0, r3); | 653 __ IncrementCounter(counters->keyed_call_generic_slow_load(), 1, r0, r3); |
| 749 __ EnterInternalFrame(); | 654 __ EnterInternalFrame(); |
| 750 __ push(r2); // save the key | 655 __ push(r2); // save the key |
| 751 __ Push(r1, r2); // pass the receiver and the key | 656 __ Push(r1, r2); // pass the receiver and the key |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 __ ldr(r3, FieldMemOperand(r4, JSObject::kMapOffset)); | 1025 __ ldr(r3, FieldMemOperand(r4, JSObject::kMapOffset)); |
| 1121 | 1026 |
| 1122 // Check whether the elements is a number dictionary. | 1027 // Check whether the elements is a number dictionary. |
| 1123 // r0: key | 1028 // r0: key |
| 1124 // r3: elements map | 1029 // r3: elements map |
| 1125 // r4: elements | 1030 // r4: elements |
| 1126 __ LoadRoot(ip, Heap::kHashTableMapRootIndex); | 1031 __ LoadRoot(ip, Heap::kHashTableMapRootIndex); |
| 1127 __ cmp(r3, ip); | 1032 __ cmp(r3, ip); |
| 1128 __ b(ne, &slow); | 1033 __ b(ne, &slow); |
| 1129 __ mov(r2, Operand(r0, ASR, kSmiTagSize)); | 1034 __ mov(r2, Operand(r0, ASR, kSmiTagSize)); |
| 1130 GenerateNumberDictionaryLoad(masm, &slow, r4, r0, r0, r2, r3, r5); | 1035 __ LoadFromNumberDictionary(&slow, r4, r0, r0, r2, r3, r5); |
| 1131 __ Ret(); | 1036 __ Ret(); |
| 1132 | 1037 |
| 1133 // Slow case, key and receiver still in r0 and r1. | 1038 // Slow case, key and receiver still in r0 and r1. |
| 1134 __ bind(&slow); | 1039 __ bind(&slow); |
| 1135 __ IncrementCounter(isolate->counters()->keyed_load_generic_slow(), | 1040 __ IncrementCounter(isolate->counters()->keyed_load_generic_slow(), |
| 1136 1, r2, r3); | 1041 1, r2, r3); |
| 1137 GenerateRuntimeGetProperty(masm); | 1042 GenerateRuntimeGetProperty(masm); |
| 1138 | 1043 |
| 1139 __ bind(&check_string); | 1044 __ bind(&check_string); |
| 1140 GenerateKeyStringCheck(masm, key, r2, r3, &index_string, &slow); | 1045 GenerateKeyStringCheck(masm, key, r2, r3, &index_string, &slow); |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1716 Register reg = Assembler::GetRn(instr_at_patch); | 1621 Register reg = Assembler::GetRn(instr_at_patch); |
| 1717 patcher.masm()->tst(reg, Operand(kSmiTagMask)); | 1622 patcher.masm()->tst(reg, Operand(kSmiTagMask)); |
| 1718 patcher.EmitCondition(eq); | 1623 patcher.EmitCondition(eq); |
| 1719 } | 1624 } |
| 1720 } | 1625 } |
| 1721 | 1626 |
| 1722 | 1627 |
| 1723 } } // namespace v8::internal | 1628 } } // namespace v8::internal |
| 1724 | 1629 |
| 1725 #endif // V8_TARGET_ARCH_ARM | 1630 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |