OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/base/division-by-constant.h" | 8 #include "src/base/division-by-constant.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 Register map) { | 803 Register map) { |
804 mov(map, FieldOperand(heap_object, HeapObject::kMapOffset)); | 804 mov(map, FieldOperand(heap_object, HeapObject::kMapOffset)); |
805 CmpInstanceType(map, type); | 805 CmpInstanceType(map, type); |
806 } | 806 } |
807 | 807 |
808 | 808 |
809 void MacroAssembler::CmpInstanceType(Register map, InstanceType type) { | 809 void MacroAssembler::CmpInstanceType(Register map, InstanceType type) { |
810 cmpb(FieldOperand(map, Map::kInstanceTypeOffset), Immediate(type)); | 810 cmpb(FieldOperand(map, Map::kInstanceTypeOffset), Immediate(type)); |
811 } | 811 } |
812 | 812 |
813 | |
814 void MacroAssembler::CheckFastElements(Register map, | |
815 Label* fail, | |
816 Label::Distance distance) { | |
817 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0); | |
818 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1); | |
819 STATIC_ASSERT(FAST_ELEMENTS == 2); | |
820 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3); | |
821 cmpb(FieldOperand(map, Map::kBitField2Offset), | |
822 Immediate(Map::kMaximumBitField2FastHoleyElementValue)); | |
823 j(above, fail, distance); | |
824 } | |
825 | |
826 | |
827 void MacroAssembler::CheckFastObjectElements(Register map, | 813 void MacroAssembler::CheckFastObjectElements(Register map, |
828 Label* fail, | 814 Label* fail, |
829 Label::Distance distance) { | 815 Label::Distance distance) { |
830 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0); | 816 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0); |
831 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1); | 817 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1); |
832 STATIC_ASSERT(FAST_ELEMENTS == 2); | 818 STATIC_ASSERT(FAST_ELEMENTS == 2); |
833 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3); | 819 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3); |
834 cmpb(FieldOperand(map, Map::kBitField2Offset), | 820 cmpb(FieldOperand(map, Map::kBitField2Offset), |
835 Immediate(Map::kMaximumBitField2FastHoleySmiElementValue)); | 821 Immediate(Map::kMaximumBitField2FastHoleySmiElementValue)); |
836 j(below_equal, fail, distance); | 822 j(below_equal, fail, distance); |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 xor_(r0, scratch); | 1392 xor_(r0, scratch); |
1407 // hash = hash * 2057; | 1393 // hash = hash * 2057; |
1408 imul(r0, r0, 2057); | 1394 imul(r0, r0, 2057); |
1409 // hash = hash ^ (hash >> 16); | 1395 // hash = hash ^ (hash >> 16); |
1410 mov(scratch, r0); | 1396 mov(scratch, r0); |
1411 shr(scratch, 16); | 1397 shr(scratch, 16); |
1412 xor_(r0, scratch); | 1398 xor_(r0, scratch); |
1413 and_(r0, 0x3fffffff); | 1399 and_(r0, 0x3fffffff); |
1414 } | 1400 } |
1415 | 1401 |
1416 | |
1417 | |
1418 void MacroAssembler::LoadFromNumberDictionary(Label* miss, | |
1419 Register elements, | |
1420 Register key, | |
1421 Register r0, | |
1422 Register r1, | |
1423 Register r2, | |
1424 Register result) { | |
1425 // Register use: | |
1426 // | |
1427 // elements - holds the slow-case elements of the receiver and is unchanged. | |
1428 // | |
1429 // key - holds the smi key on entry and is unchanged. | |
1430 // | |
1431 // Scratch registers: | |
1432 // | |
1433 // r0 - holds the untagged key on entry and holds the hash once computed. | |
1434 // | |
1435 // r1 - used to hold the capacity mask of the dictionary | |
1436 // | |
1437 // r2 - used for the index into the dictionary. | |
1438 // | |
1439 // result - holds the result on exit if the load succeeds and we fall through. | |
1440 | |
1441 Label done; | |
1442 | |
1443 GetNumberHash(r0, r1); | |
1444 | |
1445 // Compute capacity mask. | |
1446 mov(r1, FieldOperand(elements, SeededNumberDictionary::kCapacityOffset)); | |
1447 shr(r1, kSmiTagSize); // convert smi to int | |
1448 dec(r1); | |
1449 | |
1450 // Generate an unrolled loop that performs a few probes before giving up. | |
1451 for (int i = 0; i < kNumberDictionaryProbes; i++) { | |
1452 // Use r2 for index calculations and keep the hash intact in r0. | |
1453 mov(r2, r0); | |
1454 // Compute the masked index: (hash + i + i * i) & mask. | |
1455 if (i > 0) { | |
1456 add(r2, Immediate(SeededNumberDictionary::GetProbeOffset(i))); | |
1457 } | |
1458 and_(r2, r1); | |
1459 | |
1460 // Scale the index by multiplying by the entry size. | |
1461 DCHECK(SeededNumberDictionary::kEntrySize == 3); | |
1462 lea(r2, Operand(r2, r2, times_2, 0)); // r2 = r2 * 3 | |
1463 | |
1464 // Check if the key matches. | |
1465 cmp(key, FieldOperand(elements, | |
1466 r2, | |
1467 times_pointer_size, | |
1468 SeededNumberDictionary::kElementsStartOffset)); | |
1469 if (i != (kNumberDictionaryProbes - 1)) { | |
1470 j(equal, &done); | |
1471 } else { | |
1472 j(not_equal, miss); | |
1473 } | |
1474 } | |
1475 | |
1476 bind(&done); | |
1477 // Check that the value is a field property. | |
1478 const int kDetailsOffset = | |
1479 SeededNumberDictionary::kElementsStartOffset + 2 * kPointerSize; | |
1480 DCHECK_EQ(DATA, 0); | |
1481 test(FieldOperand(elements, r2, times_pointer_size, kDetailsOffset), | |
1482 Immediate(PropertyDetails::TypeField::kMask << kSmiTagSize)); | |
1483 j(not_zero, miss); | |
1484 | |
1485 // Get the value at the masked, scaled index. | |
1486 const int kValueOffset = | |
1487 SeededNumberDictionary::kElementsStartOffset + kPointerSize; | |
1488 mov(result, FieldOperand(elements, r2, times_pointer_size, kValueOffset)); | |
1489 } | |
1490 | |
1491 | |
1492 void MacroAssembler::LoadAllocationTopHelper(Register result, | 1402 void MacroAssembler::LoadAllocationTopHelper(Register result, |
1493 Register scratch, | 1403 Register scratch, |
1494 AllocationFlags flags) { | 1404 AllocationFlags flags) { |
1495 ExternalReference allocation_top = | 1405 ExternalReference allocation_top = |
1496 AllocationUtils::GetAllocationTopReference(isolate(), flags); | 1406 AllocationUtils::GetAllocationTopReference(isolate(), flags); |
1497 | 1407 |
1498 // Just return if allocation top is already known. | 1408 // Just return if allocation top is already known. |
1499 if ((flags & RESULT_CONTAINS_TOP) != 0) { | 1409 if ((flags & RESULT_CONTAINS_TOP) != 0) { |
1500 // No use of scratch if allocation top is provided. | 1410 // No use of scratch if allocation top is provided. |
1501 DCHECK(scratch.is(no_reg)); | 1411 DCHECK(scratch.is(no_reg)); |
(...skipping 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3457 mov(eax, dividend); | 3367 mov(eax, dividend); |
3458 shr(eax, 31); | 3368 shr(eax, 31); |
3459 add(edx, eax); | 3369 add(edx, eax); |
3460 } | 3370 } |
3461 | 3371 |
3462 | 3372 |
3463 } // namespace internal | 3373 } // namespace internal |
3464 } // namespace v8 | 3374 } // namespace v8 |
3465 | 3375 |
3466 #endif // V8_TARGET_ARCH_IA32 | 3376 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |