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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 __ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset)); | 531 __ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset)); |
532 __ mov(ecx, ebx); | 532 __ mov(ecx, ebx); |
533 __ shr(ecx, KeyedLookupCache::kMapHashShift); | 533 __ shr(ecx, KeyedLookupCache::kMapHashShift); |
534 __ mov(edi, FieldOperand(eax, String::kHashFieldOffset)); | 534 __ mov(edi, FieldOperand(eax, String::kHashFieldOffset)); |
535 __ shr(edi, String::kHashShift); | 535 __ shr(edi, String::kHashShift); |
536 __ xor_(ecx, edi); | 536 __ xor_(ecx, edi); |
537 __ and_(ecx, KeyedLookupCache::kCapacityMask & KeyedLookupCache::kHashMask); | 537 __ and_(ecx, KeyedLookupCache::kCapacityMask & KeyedLookupCache::kHashMask); |
538 | 538 |
539 // Load the key (consisting of map and symbol) from the cache and | 539 // Load the key (consisting of map and symbol) from the cache and |
540 // check for match. | 540 // check for match. |
541 Label try_second_entry, hit_on_first_entry, load_in_object_property; | 541 Label load_in_object_property; |
| 542 static const int kEntriesPerBucket = KeyedLookupCache::kEntriesPerBucket; |
| 543 Label hit_on_nth_entry[kEntriesPerBucket]; |
542 ExternalReference cache_keys = | 544 ExternalReference cache_keys = |
543 ExternalReference::keyed_lookup_cache_keys(masm->isolate()); | 545 ExternalReference::keyed_lookup_cache_keys(masm->isolate()); |
544 __ mov(edi, ecx); | |
545 __ shl(edi, kPointerSizeLog2 + 1); | |
546 __ cmp(ebx, Operand::StaticArray(edi, times_1, cache_keys)); | |
547 __ j(not_equal, &try_second_entry); | |
548 __ add(edi, Immediate(kPointerSize)); | |
549 __ cmp(eax, Operand::StaticArray(edi, times_1, cache_keys)); | |
550 __ j(equal, &hit_on_first_entry); | |
551 | 546 |
552 __ bind(&try_second_entry); | 547 for (int i = 0; i < kEntriesPerBucket - 1; i++) { |
| 548 Label try_next_entry; |
| 549 __ mov(edi, ecx); |
| 550 __ shl(edi, kPointerSizeLog2 + 1); |
| 551 if (i != 0) { |
| 552 __ add(edi, Immediate(kPointerSize * i * 2)); |
| 553 } |
| 554 __ cmp(ebx, Operand::StaticArray(edi, times_1, cache_keys)); |
| 555 __ j(not_equal, &try_next_entry); |
| 556 __ add(edi, Immediate(kPointerSize)); |
| 557 __ cmp(eax, Operand::StaticArray(edi, times_1, cache_keys)); |
| 558 __ j(equal, &hit_on_nth_entry[i]); |
| 559 __ bind(&try_next_entry); |
| 560 } |
| 561 |
553 __ lea(edi, Operand(ecx, 1)); | 562 __ lea(edi, Operand(ecx, 1)); |
554 __ shl(edi, kPointerSizeLog2 + 1); | 563 __ shl(edi, kPointerSizeLog2 + 1); |
| 564 __ add(edi, Immediate(kPointerSize * (kEntriesPerBucket - 1) * 2)); |
555 __ cmp(ebx, Operand::StaticArray(edi, times_1, cache_keys)); | 565 __ cmp(ebx, Operand::StaticArray(edi, times_1, cache_keys)); |
556 __ j(not_equal, &slow); | 566 __ j(not_equal, &slow); |
557 __ add(edi, Immediate(kPointerSize)); | 567 __ add(edi, Immediate(kPointerSize)); |
558 __ cmp(eax, Operand::StaticArray(edi, times_1, cache_keys)); | 568 __ cmp(eax, Operand::StaticArray(edi, times_1, cache_keys)); |
559 __ j(not_equal, &slow); | 569 __ j(not_equal, &slow); |
560 | 570 |
561 // Get field offset. | 571 // Get field offset. |
562 // edx : receiver | 572 // edx : receiver |
563 // ebx : receiver's map | 573 // ebx : receiver's map |
564 // eax : key | 574 // eax : key |
565 // ecx : lookup cache index | 575 // ecx : lookup cache index |
566 ExternalReference cache_field_offsets = | 576 ExternalReference cache_field_offsets = |
567 ExternalReference::keyed_lookup_cache_field_offsets(masm->isolate()); | 577 ExternalReference::keyed_lookup_cache_field_offsets(masm->isolate()); |
568 | 578 |
569 // Hit on second entry. | 579 // Hit on nth entry. |
570 __ add(ecx, Immediate(1)); | 580 for (int i = kEntriesPerBucket - 1; i >= 0; i--) { |
571 __ mov(edi, | 581 __ bind(&hit_on_nth_entry[i]); |
572 Operand::StaticArray(ecx, times_pointer_size, cache_field_offsets)); | 582 if (i != 0) { |
573 __ movzx_b(ecx, FieldOperand(ebx, Map::kInObjectPropertiesOffset)); | 583 __ add(ecx, Immediate(i)); |
574 __ sub(edi, ecx); | 584 } |
575 __ j(above_equal, &property_array_property); | 585 __ mov(edi, |
576 __ jmp(&load_in_object_property); | 586 Operand::StaticArray(ecx, times_pointer_size, cache_field_offsets)); |
577 | 587 __ movzx_b(ecx, FieldOperand(ebx, Map::kInObjectPropertiesOffset)); |
578 // Hit on first entry. | 588 __ sub(edi, ecx); |
579 __ bind(&hit_on_first_entry); | 589 __ j(above_equal, &property_array_property); |
580 __ mov(edi, | 590 if (i != 0) { |
581 Operand::StaticArray(ecx, times_pointer_size, cache_field_offsets)); | 591 __ jmp(&load_in_object_property); |
582 __ movzx_b(ecx, FieldOperand(ebx, Map::kInObjectPropertiesOffset)); | 592 } |
583 __ sub(edi, ecx); | 593 } |
584 __ j(above_equal, &property_array_property); | |
585 | 594 |
586 // Load in-object property. | 595 // Load in-object property. |
587 __ bind(&load_in_object_property); | 596 __ bind(&load_in_object_property); |
588 __ movzx_b(ecx, FieldOperand(ebx, Map::kInstanceSizeOffset)); | 597 __ movzx_b(ecx, FieldOperand(ebx, Map::kInstanceSizeOffset)); |
589 __ add(ecx, edi); | 598 __ add(ecx, edi); |
590 __ mov(eax, FieldOperand(edx, ecx, times_pointer_size, 0)); | 599 __ mov(eax, FieldOperand(edx, ecx, times_pointer_size, 0)); |
591 __ IncrementCounter(counters->keyed_load_generic_lookup_cache(), 1); | 600 __ IncrementCounter(counters->keyed_load_generic_lookup_cache(), 1); |
592 __ ret(0); | 601 __ ret(0); |
593 | 602 |
594 // Load property array property. | 603 // Load property array property. |
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1706 Condition cc = *jmp_address == Assembler::kJncShortOpcode | 1715 Condition cc = *jmp_address == Assembler::kJncShortOpcode |
1707 ? not_zero | 1716 ? not_zero |
1708 : zero; | 1717 : zero; |
1709 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); | 1718 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); |
1710 } | 1719 } |
1711 | 1720 |
1712 | 1721 |
1713 } } // namespace v8::internal | 1722 } } // namespace v8::internal |
1714 | 1723 |
1715 #endif // V8_TARGET_ARCH_IA32 | 1724 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |