OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 __ cmp(r3, Operand(JS_BUILTINS_OBJECT_TYPE)); | 84 __ cmp(r3, Operand(JS_BUILTINS_OBJECT_TYPE)); |
85 __ b(eq, miss); | 85 __ b(eq, miss); |
86 | 86 |
87 // Check that the properties array is a dictionary. | 87 // Check that the properties array is a dictionary. |
88 __ ldr(t0, FieldMemOperand(t1, JSObject::kPropertiesOffset)); | 88 __ ldr(t0, FieldMemOperand(t1, JSObject::kPropertiesOffset)); |
89 __ ldr(r3, FieldMemOperand(t0, HeapObject::kMapOffset)); | 89 __ ldr(r3, FieldMemOperand(t0, HeapObject::kMapOffset)); |
90 __ cmp(r3, Operand(Factory::hash_table_map())); | 90 __ cmp(r3, Operand(Factory::hash_table_map())); |
91 __ b(ne, miss); | 91 __ b(ne, miss); |
92 | 92 |
93 // Compute the capacity mask. | 93 // Compute the capacity mask. |
94 const int kCapacityOffset = | 94 const int kCapacityOffset = StringDictionary::kHeaderSize + |
95 Array::kHeaderSize + StringDictionary::kCapacityIndex * kPointerSize; | 95 StringDictionary::kCapacityIndex * kPointerSize; |
96 __ ldr(r3, FieldMemOperand(t0, kCapacityOffset)); | 96 __ ldr(r3, FieldMemOperand(t0, kCapacityOffset)); |
97 __ mov(r3, Operand(r3, ASR, kSmiTagSize)); // convert smi to int | 97 __ mov(r3, Operand(r3, ASR, kSmiTagSize)); // convert smi to int |
98 __ sub(r3, r3, Operand(1)); | 98 __ sub(r3, r3, Operand(1)); |
99 | 99 |
100 const int kElementsStartOffset = | 100 const int kElementsStartOffset = StringDictionary::kHeaderSize + |
101 Array::kHeaderSize + StringDictionary::kElementsStartIndex * kPointerSize; | 101 StringDictionary::kElementsStartIndex * kPointerSize; |
102 | 102 |
103 // Generate an unrolled loop that performs a few probes before | 103 // Generate an unrolled loop that performs a few probes before |
104 // giving up. Measurements done on Gmail indicate that 2 probes | 104 // giving up. Measurements done on Gmail indicate that 2 probes |
105 // cover ~93% of loads from dictionaries. | 105 // cover ~93% of loads from dictionaries. |
106 static const int kProbes = 4; | 106 static const int kProbes = 4; |
107 for (int i = 0; i < kProbes; i++) { | 107 for (int i = 0; i < kProbes; i++) { |
108 // Compute the masked index: (hash + i + i * i) & mask. | 108 // Compute the masked index: (hash + i + i * i) & mask. |
109 __ ldr(t1, FieldMemOperand(r2, String::kLengthOffset)); | 109 __ ldr(t1, FieldMemOperand(r2, String::kLengthOffset)); |
110 __ mov(t1, Operand(t1, LSR, String::kHashShift)); | 110 __ mov(t1, Operand(t1, LSR, String::kHashShift)); |
111 if (i > 0) { | 111 if (i > 0) { |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 // Slow case: Push extra copies of the arguments (2). | 592 // Slow case: Push extra copies of the arguments (2). |
593 __ bind(&slow); | 593 __ bind(&slow); |
594 __ IncrementCounter(&Counters::keyed_load_generic_slow, 1, r0, r1); | 594 __ IncrementCounter(&Counters::keyed_load_generic_slow, 1, r0, r1); |
595 __ ldm(ia, sp, r0.bit() | r1.bit()); | 595 __ ldm(ia, sp, r0.bit() | r1.bit()); |
596 __ stm(db_w, sp, r0.bit() | r1.bit()); | 596 __ stm(db_w, sp, r0.bit() | r1.bit()); |
597 // Do tail-call to runtime routine. | 597 // Do tail-call to runtime routine. |
598 __ TailCallRuntime(ExternalReference(Runtime::kGetProperty), 2); | 598 __ TailCallRuntime(ExternalReference(Runtime::kGetProperty), 2); |
599 | 599 |
600 // Fast case: Do the load. | 600 // Fast case: Do the load. |
601 __ bind(&fast); | 601 __ bind(&fast); |
602 __ add(r3, r1, Operand(Array::kHeaderSize - kHeapObjectTag)); | 602 __ add(r3, r1, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
603 __ ldr(r0, MemOperand(r3, r0, LSL, kPointerSizeLog2)); | 603 __ ldr(r0, MemOperand(r3, r0, LSL, kPointerSizeLog2)); |
604 __ cmp(r0, Operand(Factory::the_hole_value())); | 604 __ cmp(r0, Operand(Factory::the_hole_value())); |
605 // In case the loaded value is the_hole we have to consult GetProperty | 605 // In case the loaded value is the_hole we have to consult GetProperty |
606 // to ensure the prototype chain is searched. | 606 // to ensure the prototype chain is searched. |
607 __ b(eq, &slow); | 607 __ b(eq, &slow); |
608 | 608 |
609 __ Ret(); | 609 __ Ret(); |
610 } | 610 } |
611 | 611 |
612 | 612 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 | 659 |
660 // Object case: Check key against length in the elements array. | 660 // Object case: Check key against length in the elements array. |
661 __ ldr(r3, FieldMemOperand(r3, JSObject::kElementsOffset)); | 661 __ ldr(r3, FieldMemOperand(r3, JSObject::kElementsOffset)); |
662 // Check that the object is in fast mode (not dictionary). | 662 // Check that the object is in fast mode (not dictionary). |
663 __ ldr(r2, FieldMemOperand(r3, HeapObject::kMapOffset)); | 663 __ ldr(r2, FieldMemOperand(r3, HeapObject::kMapOffset)); |
664 __ cmp(r2, Operand(Factory::hash_table_map())); | 664 __ cmp(r2, Operand(Factory::hash_table_map())); |
665 __ b(eq, &slow); | 665 __ b(eq, &slow); |
666 // Untag the key (for checking against untagged length in the fixed array). | 666 // Untag the key (for checking against untagged length in the fixed array). |
667 __ mov(r1, Operand(r1, ASR, kSmiTagSize)); | 667 __ mov(r1, Operand(r1, ASR, kSmiTagSize)); |
668 // Compute address to store into and check array bounds. | 668 // Compute address to store into and check array bounds. |
669 __ add(r2, r3, Operand(Array::kHeaderSize - kHeapObjectTag)); | 669 __ add(r2, r3, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
670 __ add(r2, r2, Operand(r1, LSL, kPointerSizeLog2)); | 670 __ add(r2, r2, Operand(r1, LSL, kPointerSizeLog2)); |
671 __ ldr(ip, FieldMemOperand(r3, Array::kLengthOffset)); | 671 __ ldr(ip, FieldMemOperand(r3, FixedArray::kLengthOffset)); |
672 __ cmp(r1, Operand(ip)); | 672 __ cmp(r1, Operand(ip)); |
673 __ b(lo, &fast); | 673 __ b(lo, &fast); |
674 | 674 |
675 | 675 |
676 // Slow case: Push extra copies of the arguments (3). | 676 // Slow case: Push extra copies of the arguments (3). |
677 __ bind(&slow); | 677 __ bind(&slow); |
678 __ ldm(ia, sp, r1.bit() | r3.bit()); // r0 == value, r1 == key, r3 == object | 678 __ ldm(ia, sp, r1.bit() | r3.bit()); // r0 == value, r1 == key, r3 == object |
679 __ stm(db_w, sp, r0.bit() | r1.bit() | r3.bit()); | 679 __ stm(db_w, sp, r0.bit() | r1.bit() | r3.bit()); |
680 // Do tail-call to runtime routine. | 680 // Do tail-call to runtime routine. |
681 __ TailCallRuntime(ExternalReference(Runtime::kSetProperty), 3); | 681 __ TailCallRuntime(ExternalReference(Runtime::kSetProperty), 3); |
682 | 682 |
683 // Extra capacity case: Check if there is extra capacity to | 683 // Extra capacity case: Check if there is extra capacity to |
684 // perform the store and update the length. Used for adding one | 684 // perform the store and update the length. Used for adding one |
685 // element to the array by writing to array[array.length]. | 685 // element to the array by writing to array[array.length]. |
686 // r0 == value, r1 == key, r2 == elements, r3 == object | 686 // r0 == value, r1 == key, r2 == elements, r3 == object |
687 __ bind(&extra); | 687 __ bind(&extra); |
688 __ b(ne, &slow); // do not leave holes in the array | 688 __ b(ne, &slow); // do not leave holes in the array |
689 __ mov(r1, Operand(r1, ASR, kSmiTagSize)); // untag | 689 __ mov(r1, Operand(r1, ASR, kSmiTagSize)); // untag |
690 __ ldr(ip, FieldMemOperand(r2, Array::kLengthOffset)); | 690 __ ldr(ip, FieldMemOperand(r2, Array::kLengthOffset)); |
691 __ cmp(r1, Operand(ip)); | 691 __ cmp(r1, Operand(ip)); |
692 __ b(hs, &slow); | 692 __ b(hs, &slow); |
693 __ mov(r1, Operand(r1, LSL, kSmiTagSize)); // restore tag | 693 __ mov(r1, Operand(r1, LSL, kSmiTagSize)); // restore tag |
694 __ add(r1, r1, Operand(1 << kSmiTagSize)); // and increment | 694 __ add(r1, r1, Operand(1 << kSmiTagSize)); // and increment |
695 __ str(r1, FieldMemOperand(r3, JSArray::kLengthOffset)); | 695 __ str(r1, FieldMemOperand(r3, JSArray::kLengthOffset)); |
696 __ mov(r3, Operand(r2)); | 696 __ mov(r3, Operand(r2)); |
697 // NOTE: Computing the address to store into must take the fact | 697 // NOTE: Computing the address to store into must take the fact |
698 // that the key has been incremented into account. | 698 // that the key has been incremented into account. |
699 int displacement = Array::kHeaderSize - kHeapObjectTag - | 699 int displacement = FixedArray::kHeaderSize - kHeapObjectTag - |
700 ((1 << kSmiTagSize) * 2); | 700 ((1 << kSmiTagSize) * 2); |
701 __ add(r2, r2, Operand(displacement)); | 701 __ add(r2, r2, Operand(displacement)); |
702 __ add(r2, r2, Operand(r1, LSL, kPointerSizeLog2 - kSmiTagSize)); | 702 __ add(r2, r2, Operand(r1, LSL, kPointerSizeLog2 - kSmiTagSize)); |
703 __ b(&fast); | 703 __ b(&fast); |
704 | 704 |
705 | 705 |
706 // Array case: Get the length and the elements array from the JS | 706 // Array case: Get the length and the elements array from the JS |
707 // array. Check that the array is in fast mode; if it is the | 707 // array. Check that the array is in fast mode; if it is the |
708 // length is always a smi. | 708 // length is always a smi. |
709 // r0 == value, r3 == object | 709 // r0 == value, r3 == object |
710 __ bind(&array); | 710 __ bind(&array); |
711 __ ldr(r2, FieldMemOperand(r3, JSObject::kElementsOffset)); | 711 __ ldr(r2, FieldMemOperand(r3, JSObject::kElementsOffset)); |
712 __ ldr(r1, FieldMemOperand(r2, HeapObject::kMapOffset)); | 712 __ ldr(r1, FieldMemOperand(r2, HeapObject::kMapOffset)); |
713 __ cmp(r1, Operand(Factory::hash_table_map())); | 713 __ cmp(r1, Operand(Factory::hash_table_map())); |
714 __ b(eq, &slow); | 714 __ b(eq, &slow); |
715 | 715 |
716 // Check the key against the length in the array, compute the | 716 // Check the key against the length in the array, compute the |
717 // address to store into and fall through to fast case. | 717 // address to store into and fall through to fast case. |
718 __ ldr(r1, MemOperand(sp)); // restore key | 718 __ ldr(r1, MemOperand(sp)); // restore key |
719 // r0 == value, r1 == key, r2 == elements, r3 == object. | 719 // r0 == value, r1 == key, r2 == elements, r3 == object. |
720 __ ldr(ip, FieldMemOperand(r3, JSArray::kLengthOffset)); | 720 __ ldr(ip, FieldMemOperand(r3, JSArray::kLengthOffset)); |
721 __ cmp(r1, Operand(ip)); | 721 __ cmp(r1, Operand(ip)); |
722 __ b(hs, &extra); | 722 __ b(hs, &extra); |
723 __ mov(r3, Operand(r2)); | 723 __ mov(r3, Operand(r2)); |
724 __ add(r2, r2, Operand(Array::kHeaderSize - kHeapObjectTag)); | 724 __ add(r2, r2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
725 __ add(r2, r2, Operand(r1, LSL, kPointerSizeLog2 - kSmiTagSize)); | 725 __ add(r2, r2, Operand(r1, LSL, kPointerSizeLog2 - kSmiTagSize)); |
726 | 726 |
727 | 727 |
728 // Fast case: Do the store. | 728 // Fast case: Do the store. |
729 // r0 == value, r2 == address to store into, r3 == elements | 729 // r0 == value, r2 == address to store into, r3 == elements |
730 __ bind(&fast); | 730 __ bind(&fast); |
731 __ str(r0, MemOperand(r2)); | 731 __ str(r0, MemOperand(r2)); |
732 // Skip write barrier if the written value is a smi. | 732 // Skip write barrier if the written value is a smi. |
733 __ tst(r0, Operand(kSmiTagMask)); | 733 __ tst(r0, Operand(kSmiTagMask)); |
734 __ b(eq, &exit); | 734 __ b(eq, &exit); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 | 808 |
809 // Perform tail call to the entry. | 809 // Perform tail call to the entry. |
810 __ TailCallRuntime(f, 3); | 810 __ TailCallRuntime(f, 3); |
811 } | 811 } |
812 | 812 |
813 | 813 |
814 #undef __ | 814 #undef __ |
815 | 815 |
816 | 816 |
817 } } // namespace v8::internal | 817 } } // namespace v8::internal |
OLD | NEW |