OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 // Load the initial map from the array function. | 484 // Load the initial map from the array function. |
485 __ movq(scratch1, FieldOperand(array_function, | 485 __ movq(scratch1, FieldOperand(array_function, |
486 JSFunction::kPrototypeOrInitialMapOffset)); | 486 JSFunction::kPrototypeOrInitialMapOffset)); |
487 | 487 |
488 // Allocate the JSArray object together with space for a fixed array with the | 488 // Allocate the JSArray object together with space for a fixed array with the |
489 // requested elements. | 489 // requested elements. |
490 int size = JSArray::kSize; | 490 int size = JSArray::kSize; |
491 if (initial_capacity > 0) { | 491 if (initial_capacity > 0) { |
492 size += FixedArray::SizeFor(initial_capacity); | 492 size += FixedArray::SizeFor(initial_capacity); |
493 } | 493 } |
494 __ AllocateObjectInNewSpace(size, | 494 __ AllocateInNewSpace(size, |
495 result, | 495 result, |
496 scratch2, | 496 scratch2, |
497 scratch3, | 497 scratch3, |
498 gc_required, | 498 gc_required, |
499 TAG_OBJECT); | 499 TAG_OBJECT); |
500 | 500 |
501 // Allocated the JSArray. Now initialize the fields except for the elements | 501 // Allocated the JSArray. Now initialize the fields except for the elements |
502 // array. | 502 // array. |
503 // result: JSObject | 503 // result: JSObject |
504 // scratch1: initial map | 504 // scratch1: initial map |
505 // scratch2: start of next object | 505 // scratch2: start of next object |
506 __ movq(FieldOperand(result, JSObject::kMapOffset), scratch1); | 506 __ movq(FieldOperand(result, JSObject::kMapOffset), scratch1); |
507 __ Move(FieldOperand(result, JSArray::kPropertiesOffset), | 507 __ Move(FieldOperand(result, JSArray::kPropertiesOffset), |
508 Factory::empty_fixed_array()); | 508 Factory::empty_fixed_array()); |
509 // Field JSArray::kElementsOffset is initialized later. | 509 // Field JSArray::kElementsOffset is initialized later. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 FieldOperand(array_function, | 585 FieldOperand(array_function, |
586 JSFunction::kPrototypeOrInitialMapOffset)); | 586 JSFunction::kPrototypeOrInitialMapOffset)); |
587 | 587 |
588 // Check whether an empty sized array is requested. | 588 // Check whether an empty sized array is requested. |
589 __ testq(array_size, array_size); | 589 __ testq(array_size, array_size); |
590 __ j(not_zero, ¬_empty); | 590 __ j(not_zero, ¬_empty); |
591 | 591 |
592 // If an empty array is requested allocate a small elements array anyway. This | 592 // If an empty array is requested allocate a small elements array anyway. This |
593 // keeps the code below free of special casing for the empty array. | 593 // keeps the code below free of special casing for the empty array. |
594 int size = JSArray::kSize + FixedArray::SizeFor(kPreallocatedArrayElements); | 594 int size = JSArray::kSize + FixedArray::SizeFor(kPreallocatedArrayElements); |
595 __ AllocateObjectInNewSpace(size, | 595 __ AllocateInNewSpace(size, |
596 result, | 596 result, |
597 elements_array_end, | 597 elements_array_end, |
598 scratch, | 598 scratch, |
599 gc_required, | 599 gc_required, |
600 TAG_OBJECT); | 600 TAG_OBJECT); |
601 __ jmp(&allocated); | 601 __ jmp(&allocated); |
602 | 602 |
603 // Allocate the JSArray object together with space for a FixedArray with the | 603 // Allocate the JSArray object together with space for a FixedArray with the |
604 // requested elements. | 604 // requested elements. |
605 __ bind(¬_empty); | 605 __ bind(¬_empty); |
606 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); | 606 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); |
607 __ AllocateObjectInNewSpace(JSArray::kSize + FixedArray::kHeaderSize, | 607 __ AllocateInNewSpace(JSArray::kSize + FixedArray::kHeaderSize, |
608 times_half_pointer_size, // array_size is a smi. | 608 times_half_pointer_size, // array_size is a smi. |
609 array_size, | 609 array_size, |
610 result, | 610 result, |
611 elements_array_end, | 611 elements_array_end, |
612 scratch, | 612 scratch, |
613 gc_required, | 613 gc_required, |
614 TAG_OBJECT); | 614 TAG_OBJECT); |
615 | 615 |
616 // Allocated the JSArray. Now initialize the fields except for the elements | 616 // Allocated the JSArray. Now initialize the fields except for the elements |
617 // array. | 617 // array. |
618 // result: JSObject | 618 // result: JSObject |
619 // elements_array: initial map | 619 // elements_array: initial map |
620 // elements_array_end: start of next object | 620 // elements_array_end: start of next object |
621 // array_size: size of array (smi) | 621 // array_size: size of array (smi) |
622 __ bind(&allocated); | 622 __ bind(&allocated); |
623 __ movq(FieldOperand(result, JSObject::kMapOffset), elements_array); | 623 __ movq(FieldOperand(result, JSObject::kMapOffset), elements_array); |
624 __ Move(elements_array, Factory::empty_fixed_array()); | 624 __ Move(elements_array, Factory::empty_fixed_array()); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 // instance type would be JS_FUNCTION_TYPE. | 953 // instance type would be JS_FUNCTION_TYPE. |
954 // rdi: constructor | 954 // rdi: constructor |
955 // rax: initial map | 955 // rax: initial map |
956 __ CmpInstanceType(rax, JS_FUNCTION_TYPE); | 956 __ CmpInstanceType(rax, JS_FUNCTION_TYPE); |
957 __ j(equal, &rt_call); | 957 __ j(equal, &rt_call); |
958 | 958 |
959 // Now allocate the JSObject on the heap. | 959 // Now allocate the JSObject on the heap. |
960 __ movzxbq(rdi, FieldOperand(rax, Map::kInstanceSizeOffset)); | 960 __ movzxbq(rdi, FieldOperand(rax, Map::kInstanceSizeOffset)); |
961 __ shl(rdi, Immediate(kPointerSizeLog2)); | 961 __ shl(rdi, Immediate(kPointerSizeLog2)); |
962 // rdi: size of new object | 962 // rdi: size of new object |
963 __ AllocateObjectInNewSpace(rdi, | 963 __ AllocateInNewSpace(rdi, |
964 rbx, | 964 rbx, |
965 rdi, | 965 rdi, |
966 no_reg, | 966 no_reg, |
967 &rt_call, | 967 &rt_call, |
968 NO_ALLOCATION_FLAGS); | 968 NO_ALLOCATION_FLAGS); |
969 // Allocated the JSObject, now initialize the fields. | 969 // Allocated the JSObject, now initialize the fields. |
970 // rax: initial map | 970 // rax: initial map |
971 // rbx: JSObject (not HeapObject tagged - the actual address). | 971 // rbx: JSObject (not HeapObject tagged - the actual address). |
972 // rdi: start of next object | 972 // rdi: start of next object |
973 __ movq(Operand(rbx, JSObject::kMapOffset), rax); | 973 __ movq(Operand(rbx, JSObject::kMapOffset), rax); |
974 __ LoadRoot(rcx, Heap::kEmptyFixedArrayRootIndex); | 974 __ LoadRoot(rcx, Heap::kEmptyFixedArrayRootIndex); |
975 __ movq(Operand(rbx, JSObject::kPropertiesOffset), rcx); | 975 __ movq(Operand(rbx, JSObject::kPropertiesOffset), rcx); |
976 __ movq(Operand(rbx, JSObject::kElementsOffset), rcx); | 976 __ movq(Operand(rbx, JSObject::kElementsOffset), rcx); |
977 // Set extra fields in the newly allocated object. | 977 // Set extra fields in the newly allocated object. |
978 // rax: initial map | 978 // rax: initial map |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 __ subq(rdx, rcx); | 1013 __ subq(rdx, rcx); |
1014 // Done if no extra properties are to be allocated. | 1014 // Done if no extra properties are to be allocated. |
1015 __ j(zero, &allocated); | 1015 __ j(zero, &allocated); |
1016 __ Assert(positive, "Property allocation count failed."); | 1016 __ Assert(positive, "Property allocation count failed."); |
1017 | 1017 |
1018 // Scale the number of elements by pointer size and add the header for | 1018 // Scale the number of elements by pointer size and add the header for |
1019 // FixedArrays to the start of the next object calculation from above. | 1019 // FixedArrays to the start of the next object calculation from above. |
1020 // rbx: JSObject | 1020 // rbx: JSObject |
1021 // rdi: start of next object (will be start of FixedArray) | 1021 // rdi: start of next object (will be start of FixedArray) |
1022 // rdx: number of elements in properties array | 1022 // rdx: number of elements in properties array |
1023 __ AllocateObjectInNewSpace(FixedArray::kHeaderSize, | 1023 __ AllocateInNewSpace(FixedArray::kHeaderSize, |
1024 times_pointer_size, | 1024 times_pointer_size, |
1025 rdx, | 1025 rdx, |
1026 rdi, | 1026 rdi, |
1027 rax, | 1027 rax, |
1028 no_reg, | 1028 no_reg, |
1029 &undo_allocation, | 1029 &undo_allocation, |
1030 RESULT_CONTAINS_TOP); | 1030 RESULT_CONTAINS_TOP); |
1031 | 1031 |
1032 // Initialize the FixedArray. | 1032 // Initialize the FixedArray. |
1033 // rbx: JSObject | 1033 // rbx: JSObject |
1034 // rdi: FixedArray | 1034 // rdi: FixedArray |
1035 // rdx: number of elements | 1035 // rdx: number of elements |
1036 // rax: start of next object | 1036 // rax: start of next object |
1037 __ LoadRoot(rcx, Heap::kFixedArrayMapRootIndex); | 1037 __ LoadRoot(rcx, Heap::kFixedArrayMapRootIndex); |
1038 __ movq(Operand(rdi, JSObject::kMapOffset), rcx); // setup the map | 1038 __ movq(Operand(rdi, JSObject::kMapOffset), rcx); // setup the map |
1039 __ movl(Operand(rdi, FixedArray::kLengthOffset), rdx); // and length | 1039 __ movl(Operand(rdi, FixedArray::kLengthOffset), rdx); // and length |
1040 | 1040 |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { | 1271 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { |
1272 Generate_JSEntryTrampolineHelper(masm, false); | 1272 Generate_JSEntryTrampolineHelper(masm, false); |
1273 } | 1273 } |
1274 | 1274 |
1275 | 1275 |
1276 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { | 1276 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { |
1277 Generate_JSEntryTrampolineHelper(masm, true); | 1277 Generate_JSEntryTrampolineHelper(masm, true); |
1278 } | 1278 } |
1279 | 1279 |
1280 } } // namespace v8::internal | 1280 } } // namespace v8::internal |
OLD | NEW |