| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 no_reg, | 217 no_reg, |
| 218 &undo_allocation, | 218 &undo_allocation, |
| 219 RESULT_CONTAINS_TOP); | 219 RESULT_CONTAINS_TOP); |
| 220 | 220 |
| 221 // Initialize the FixedArray. | 221 // Initialize the FixedArray. |
| 222 // ebx: JSObject | 222 // ebx: JSObject |
| 223 // edi: FixedArray | 223 // edi: FixedArray |
| 224 // edx: number of elements | 224 // edx: number of elements |
| 225 // ecx: start of next object | 225 // ecx: start of next object |
| 226 __ mov(eax, Factory::fixed_array_map()); | 226 __ mov(eax, Factory::fixed_array_map()); |
| 227 __ mov(Operand(edi, JSObject::kMapOffset), eax); // setup the map | 227 __ mov(Operand(edi, FixedArray::kMapOffset), eax); // setup the map |
| 228 __ mov(Operand(edi, Array::kLengthOffset), edx); // and length | 228 __ SmiTag(edx); |
| 229 __ mov(Operand(edi, FixedArray::kLengthOffset), edx); // and length |
| 229 | 230 |
| 230 // Initialize the fields to undefined. | 231 // Initialize the fields to undefined. |
| 231 // ebx: JSObject | 232 // ebx: JSObject |
| 232 // edi: FixedArray | 233 // edi: FixedArray |
| 233 // ecx: start of next object | 234 // ecx: start of next object |
| 234 { Label loop, entry; | 235 { Label loop, entry; |
| 235 __ mov(edx, Factory::undefined_value()); | 236 __ mov(edx, Factory::undefined_value()); |
| 236 __ lea(eax, Operand(edi, FixedArray::kHeaderSize)); | 237 __ lea(eax, Operand(edi, FixedArray::kHeaderSize)); |
| 237 __ jmp(&entry); | 238 __ jmp(&entry); |
| 238 __ bind(&loop); | 239 __ bind(&loop); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 RelocInfo::CODE_TARGET); | 540 RelocInfo::CODE_TARGET); |
| 540 __ bind(&function); | 541 __ bind(&function); |
| 541 } | 542 } |
| 542 | 543 |
| 543 // 5b. Get the code to call from the function and check that the number of | 544 // 5b. Get the code to call from the function and check that the number of |
| 544 // expected arguments matches what we're providing. If so, jump | 545 // expected arguments matches what we're providing. If so, jump |
| 545 // (tail-call) to the code in register edx without checking arguments. | 546 // (tail-call) to the code in register edx without checking arguments. |
| 546 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 547 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| 547 __ mov(ebx, | 548 __ mov(ebx, |
| 548 FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); | 549 FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 550 __ SmiUntag(ebx); |
| 549 __ mov(edx, FieldOperand(edx, SharedFunctionInfo::kCodeOffset)); | 551 __ mov(edx, FieldOperand(edx, SharedFunctionInfo::kCodeOffset)); |
| 550 __ lea(edx, FieldOperand(edx, Code::kHeaderSize)); | 552 __ lea(edx, FieldOperand(edx, Code::kHeaderSize)); |
| 551 __ cmp(eax, Operand(ebx)); | 553 __ cmp(eax, Operand(ebx)); |
| 552 __ j(not_equal, Handle<Code>(builtin(ArgumentsAdaptorTrampoline))); | 554 __ j(not_equal, Handle<Code>(builtin(ArgumentsAdaptorTrampoline))); |
| 553 | 555 |
| 554 ParameterCount expected(0); | 556 ParameterCount expected(0); |
| 555 __ InvokeCode(Operand(edx), expected, expected, JUMP_FUNCTION); | 557 __ InvokeCode(Operand(edx), expected, expected, JUMP_FUNCTION); |
| 556 } | 558 } |
| 557 | 559 |
| 558 | 560 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 return; | 745 return; |
| 744 } | 746 } |
| 745 | 747 |
| 746 // Calculate the location of the elements array and set elements array member | 748 // Calculate the location of the elements array and set elements array member |
| 747 // of the JSArray. | 749 // of the JSArray. |
| 748 // result: JSObject | 750 // result: JSObject |
| 749 // scratch2: start of next object | 751 // scratch2: start of next object |
| 750 __ lea(scratch1, Operand(result, JSArray::kSize)); | 752 __ lea(scratch1, Operand(result, JSArray::kSize)); |
| 751 __ mov(FieldOperand(result, JSArray::kElementsOffset), scratch1); | 753 __ mov(FieldOperand(result, JSArray::kElementsOffset), scratch1); |
| 752 | 754 |
| 753 // Initialize the FixedArray and fill it with holes. FixedArray length is not | 755 // Initialize the FixedArray and fill it with holes. FixedArray length is |
| 754 // stored as a smi. | 756 // stored as a smi. |
| 755 // result: JSObject | 757 // result: JSObject |
| 756 // scratch1: elements array | 758 // scratch1: elements array |
| 757 // scratch2: start of next object | 759 // scratch2: start of next object |
| 758 __ mov(FieldOperand(scratch1, JSObject::kMapOffset), | 760 __ mov(FieldOperand(scratch1, FixedArray::kMapOffset), |
| 759 Factory::fixed_array_map()); | 761 Factory::fixed_array_map()); |
| 760 __ mov(FieldOperand(scratch1, Array::kLengthOffset), | 762 __ mov(FieldOperand(scratch1, FixedArray::kLengthOffset), |
| 761 Immediate(initial_capacity)); | 763 Immediate(Smi::FromInt(initial_capacity))); |
| 762 | 764 |
| 763 // Fill the FixedArray with the hole value. Inline the code if short. | 765 // Fill the FixedArray with the hole value. Inline the code if short. |
| 764 // Reconsider loop unfolding if kPreallocatedArrayElements gets changed. | 766 // Reconsider loop unfolding if kPreallocatedArrayElements gets changed. |
| 765 static const int kLoopUnfoldLimit = 4; | 767 static const int kLoopUnfoldLimit = 4; |
| 766 ASSERT(kPreallocatedArrayElements <= kLoopUnfoldLimit); | 768 ASSERT(kPreallocatedArrayElements <= kLoopUnfoldLimit); |
| 767 if (initial_capacity <= kLoopUnfoldLimit) { | 769 if (initial_capacity <= kLoopUnfoldLimit) { |
| 768 // Use a scratch register here to have only one reloc info when unfolding | 770 // Use a scratch register here to have only one reloc info when unfolding |
| 769 // the loop. | 771 // the loop. |
| 770 __ mov(scratch3, Factory::the_hole_value()); | 772 __ mov(scratch3, Factory::the_hole_value()); |
| 771 for (int i = 0; i < initial_capacity; i++) { | 773 for (int i = 0; i < initial_capacity; i++) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 __ mov(FieldOperand(result, JSArray::kLengthOffset), array_size); | 839 __ mov(FieldOperand(result, JSArray::kLengthOffset), array_size); |
| 838 | 840 |
| 839 // Calculate the location of the elements array and set elements array member | 841 // Calculate the location of the elements array and set elements array member |
| 840 // of the JSArray. | 842 // of the JSArray. |
| 841 // result: JSObject | 843 // result: JSObject |
| 842 // elements_array_end: start of next object | 844 // elements_array_end: start of next object |
| 843 // array_size: size of array (smi) | 845 // array_size: size of array (smi) |
| 844 __ lea(elements_array, Operand(result, JSArray::kSize)); | 846 __ lea(elements_array, Operand(result, JSArray::kSize)); |
| 845 __ mov(FieldOperand(result, JSArray::kElementsOffset), elements_array); | 847 __ mov(FieldOperand(result, JSArray::kElementsOffset), elements_array); |
| 846 | 848 |
| 847 // Initialize the fixed array. FixedArray length is not stored as a smi. | 849 // Initialize the fixed array. FixedArray length is stored as a smi. |
| 848 // result: JSObject | 850 // result: JSObject |
| 849 // elements_array: elements array | 851 // elements_array: elements array |
| 850 // elements_array_end: start of next object | 852 // elements_array_end: start of next object |
| 851 // array_size: size of array (smi) | 853 // array_size: size of array (smi) |
| 852 ASSERT(kSmiTag == 0); | 854 __ mov(FieldOperand(elements_array, FixedArray::kMapOffset), |
| 853 __ SmiUntag(array_size); // Convert from smi to value. | |
| 854 __ mov(FieldOperand(elements_array, JSObject::kMapOffset), | |
| 855 Factory::fixed_array_map()); | 855 Factory::fixed_array_map()); |
| 856 // For non-empty JSArrays the length of the FixedArray and the JSArray is the | 856 // For non-empty JSArrays the length of the FixedArray and the JSArray is the |
| 857 // same. | 857 // same. |
| 858 __ mov(FieldOperand(elements_array, Array::kLengthOffset), array_size); | 858 __ mov(FieldOperand(elements_array, FixedArray::kLengthOffset), array_size); |
| 859 | 859 |
| 860 // Fill the allocated FixedArray with the hole value if requested. | 860 // Fill the allocated FixedArray with the hole value if requested. |
| 861 // result: JSObject | 861 // result: JSObject |
| 862 // elements_array: elements array | 862 // elements_array: elements array |
| 863 if (fill_with_hole) { | 863 if (fill_with_hole) { |
| 864 __ SmiUntag(array_size); |
| 864 __ lea(edi, Operand(elements_array, | 865 __ lea(edi, Operand(elements_array, |
| 865 FixedArray::kHeaderSize - kHeapObjectTag)); | 866 FixedArray::kHeaderSize - kHeapObjectTag)); |
| 866 | 867 |
| 867 __ push(eax); | 868 __ push(eax); |
| 868 __ mov(eax, Factory::the_hole_value()); | 869 __ mov(eax, Factory::the_hole_value()); |
| 869 | 870 |
| 870 __ cld(); | 871 __ cld(); |
| 871 __ rep_stos(); | 872 __ rep_stos(); |
| 872 | 873 |
| 873 // Restore saved registers. | 874 // Restore saved registers. |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 // Dont adapt arguments. | 1241 // Dont adapt arguments. |
| 1241 // ------------------------------------------- | 1242 // ------------------------------------------- |
| 1242 __ bind(&dont_adapt_arguments); | 1243 __ bind(&dont_adapt_arguments); |
| 1243 __ jmp(Operand(edx)); | 1244 __ jmp(Operand(edx)); |
| 1244 } | 1245 } |
| 1245 | 1246 |
| 1246 | 1247 |
| 1247 #undef __ | 1248 #undef __ |
| 1248 | 1249 |
| 1249 } } // namespace v8::internal | 1250 } } // namespace v8::internal |
| OLD | NEW |