OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 no_reg, | 219 no_reg, |
220 &undo_allocation, | 220 &undo_allocation, |
221 RESULT_CONTAINS_TOP); | 221 RESULT_CONTAINS_TOP); |
222 | 222 |
223 // Initialize the FixedArray. | 223 // Initialize the FixedArray. |
224 // ebx: JSObject | 224 // ebx: JSObject |
225 // edi: FixedArray | 225 // edi: FixedArray |
226 // edx: number of elements | 226 // edx: number of elements |
227 // ecx: start of next object | 227 // ecx: start of next object |
228 __ mov(eax, Factory::fixed_array_map()); | 228 __ mov(eax, Factory::fixed_array_map()); |
229 __ mov(Operand(edi, JSObject::kMapOffset), eax); // setup the map | 229 __ mov(Operand(edi, FixedArray::kMapOffset), eax); // setup the map |
230 __ mov(Operand(edi, Array::kLengthOffset), edx); // and length | 230 __ SmiTag(edx); |
| 231 __ mov(Operand(edi, FixedArray::kLengthOffset), edx); // and length |
231 | 232 |
232 // Initialize the fields to undefined. | 233 // Initialize the fields to undefined. |
233 // ebx: JSObject | 234 // ebx: JSObject |
234 // edi: FixedArray | 235 // edi: FixedArray |
235 // ecx: start of next object | 236 // ecx: start of next object |
236 { Label loop, entry; | 237 { Label loop, entry; |
237 __ mov(edx, Factory::undefined_value()); | 238 __ mov(edx, Factory::undefined_value()); |
238 __ lea(eax, Operand(edi, FixedArray::kHeaderSize)); | 239 __ lea(eax, Operand(edi, FixedArray::kHeaderSize)); |
239 __ jmp(&entry); | 240 __ jmp(&entry); |
240 __ bind(&loop); | 241 __ bind(&loop); |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 RelocInfo::CODE_TARGET); | 542 RelocInfo::CODE_TARGET); |
542 __ bind(&function); | 543 __ bind(&function); |
543 } | 544 } |
544 | 545 |
545 // 5b. Get the code to call from the function and check that the number of | 546 // 5b. Get the code to call from the function and check that the number of |
546 // expected arguments matches what we're providing. If so, jump | 547 // expected arguments matches what we're providing. If so, jump |
547 // (tail-call) to the code in register edx without checking arguments. | 548 // (tail-call) to the code in register edx without checking arguments. |
548 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 549 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
549 __ mov(ebx, | 550 __ mov(ebx, |
550 FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); | 551 FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 552 __ SmiUntag(ebx); |
551 __ mov(edx, FieldOperand(edx, SharedFunctionInfo::kCodeOffset)); | 553 __ mov(edx, FieldOperand(edx, SharedFunctionInfo::kCodeOffset)); |
552 __ lea(edx, FieldOperand(edx, Code::kHeaderSize)); | 554 __ lea(edx, FieldOperand(edx, Code::kHeaderSize)); |
553 __ cmp(eax, Operand(ebx)); | 555 __ cmp(eax, Operand(ebx)); |
554 __ j(not_equal, Handle<Code>(builtin(ArgumentsAdaptorTrampoline))); | 556 __ j(not_equal, Handle<Code>(builtin(ArgumentsAdaptorTrampoline))); |
555 | 557 |
556 ParameterCount expected(0); | 558 ParameterCount expected(0); |
557 __ InvokeCode(Operand(edx), expected, expected, JUMP_FUNCTION); | 559 __ InvokeCode(Operand(edx), expected, expected, JUMP_FUNCTION); |
558 } | 560 } |
559 | 561 |
560 | 562 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 return; | 747 return; |
746 } | 748 } |
747 | 749 |
748 // Calculate the location of the elements array and set elements array member | 750 // Calculate the location of the elements array and set elements array member |
749 // of the JSArray. | 751 // of the JSArray. |
750 // result: JSObject | 752 // result: JSObject |
751 // scratch2: start of next object | 753 // scratch2: start of next object |
752 __ lea(scratch1, Operand(result, JSArray::kSize)); | 754 __ lea(scratch1, Operand(result, JSArray::kSize)); |
753 __ mov(FieldOperand(result, JSArray::kElementsOffset), scratch1); | 755 __ mov(FieldOperand(result, JSArray::kElementsOffset), scratch1); |
754 | 756 |
755 // Initialize the FixedArray and fill it with holes. FixedArray length is not | 757 // Initialize the FixedArray and fill it with holes. FixedArray length is |
756 // stored as a smi. | 758 // stored as a smi. |
757 // result: JSObject | 759 // result: JSObject |
758 // scratch1: elements array | 760 // scratch1: elements array |
759 // scratch2: start of next object | 761 // scratch2: start of next object |
760 __ mov(FieldOperand(scratch1, JSObject::kMapOffset), | 762 __ mov(FieldOperand(scratch1, FixedArray::kMapOffset), |
761 Factory::fixed_array_map()); | 763 Factory::fixed_array_map()); |
762 __ mov(FieldOperand(scratch1, Array::kLengthOffset), | 764 __ mov(FieldOperand(scratch1, FixedArray::kLengthOffset), |
763 Immediate(initial_capacity)); | 765 Immediate(Smi::FromInt(initial_capacity))); |
764 | 766 |
765 // Fill the FixedArray with the hole value. Inline the code if short. | 767 // Fill the FixedArray with the hole value. Inline the code if short. |
766 // Reconsider loop unfolding if kPreallocatedArrayElements gets changed. | 768 // Reconsider loop unfolding if kPreallocatedArrayElements gets changed. |
767 static const int kLoopUnfoldLimit = 4; | 769 static const int kLoopUnfoldLimit = 4; |
768 ASSERT(kPreallocatedArrayElements <= kLoopUnfoldLimit); | 770 ASSERT(kPreallocatedArrayElements <= kLoopUnfoldLimit); |
769 if (initial_capacity <= kLoopUnfoldLimit) { | 771 if (initial_capacity <= kLoopUnfoldLimit) { |
770 // Use a scratch register here to have only one reloc info when unfolding | 772 // Use a scratch register here to have only one reloc info when unfolding |
771 // the loop. | 773 // the loop. |
772 __ mov(scratch3, Factory::the_hole_value()); | 774 __ mov(scratch3, Factory::the_hole_value()); |
773 for (int i = 0; i < initial_capacity; i++) { | 775 for (int i = 0; i < initial_capacity; i++) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 __ mov(FieldOperand(result, JSArray::kLengthOffset), array_size); | 842 __ mov(FieldOperand(result, JSArray::kLengthOffset), array_size); |
841 | 843 |
842 // Calculate the location of the elements array and set elements array member | 844 // Calculate the location of the elements array and set elements array member |
843 // of the JSArray. | 845 // of the JSArray. |
844 // result: JSObject | 846 // result: JSObject |
845 // elements_array_end: start of next object | 847 // elements_array_end: start of next object |
846 // array_size: size of array (smi) | 848 // array_size: size of array (smi) |
847 __ lea(elements_array, Operand(result, JSArray::kSize)); | 849 __ lea(elements_array, Operand(result, JSArray::kSize)); |
848 __ mov(FieldOperand(result, JSArray::kElementsOffset), elements_array); | 850 __ mov(FieldOperand(result, JSArray::kElementsOffset), elements_array); |
849 | 851 |
850 // Initialize the fixed array. FixedArray length is not stored as a smi. | 852 // Initialize the fixed array. FixedArray length is stored as a smi. |
851 // result: JSObject | 853 // result: JSObject |
852 // elements_array: elements array | 854 // elements_array: elements array |
853 // elements_array_end: start of next object | 855 // elements_array_end: start of next object |
854 // array_size: size of array (smi) | 856 // array_size: size of array (smi) |
855 ASSERT(kSmiTag == 0); | 857 __ mov(FieldOperand(elements_array, FixedArray::kMapOffset), |
856 __ SmiUntag(array_size); // Convert from smi to value. | |
857 __ mov(FieldOperand(elements_array, JSObject::kMapOffset), | |
858 Factory::fixed_array_map()); | 858 Factory::fixed_array_map()); |
859 // For non-empty JSArrays the length of the FixedArray and the JSArray is the | 859 // For non-empty JSArrays the length of the FixedArray and the JSArray is the |
860 // same. | 860 // same. |
861 __ mov(FieldOperand(elements_array, Array::kLengthOffset), array_size); | 861 __ mov(FieldOperand(elements_array, FixedArray::kLengthOffset), array_size); |
862 | 862 |
863 // Fill the allocated FixedArray with the hole value if requested. | 863 // Fill the allocated FixedArray with the hole value if requested. |
864 // result: JSObject | 864 // result: JSObject |
865 // elements_array: elements array | 865 // elements_array: elements array |
866 if (fill_with_hole) { | 866 if (fill_with_hole) { |
| 867 __ SmiUntag(array_size); |
867 __ lea(edi, Operand(elements_array, | 868 __ lea(edi, Operand(elements_array, |
868 FixedArray::kHeaderSize - kHeapObjectTag)); | 869 FixedArray::kHeaderSize - kHeapObjectTag)); |
869 __ mov(eax, Factory::the_hole_value()); | 870 __ mov(eax, Factory::the_hole_value()); |
870 __ cld(); | 871 __ cld(); |
871 // Do not use rep stos when filling less than kRepStosThreshold | 872 // Do not use rep stos when filling less than kRepStosThreshold |
872 // words. | 873 // words. |
873 const int kRepStosThreshold = 16; | 874 const int kRepStosThreshold = 16; |
874 Label loop, entry, done; | 875 Label loop, entry, done; |
875 __ cmp(ecx, kRepStosThreshold); | 876 __ cmp(ecx, kRepStosThreshold); |
876 __ j(below, &loop); // Note: ecx > 0. | 877 __ j(below, &loop); // Note: ecx > 0. |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1253 __ bind(&dont_adapt_arguments); | 1254 __ bind(&dont_adapt_arguments); |
1254 __ jmp(Operand(edx)); | 1255 __ jmp(Operand(edx)); |
1255 } | 1256 } |
1256 | 1257 |
1257 | 1258 |
1258 #undef __ | 1259 #undef __ |
1259 | 1260 |
1260 } } // namespace v8::internal | 1261 } } // namespace v8::internal |
1261 | 1262 |
1262 #endif // V8_TARGET_ARCH_IA32 | 1263 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |