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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 bool fill_with_hole, | 583 bool fill_with_hole, |
584 Label* gc_required) { | 584 Label* gc_required) { |
585 Label not_empty, allocated; | 585 Label not_empty, allocated; |
586 | 586 |
587 // Load the initial map from the array function. | 587 // Load the initial map from the array function. |
588 __ movq(elements_array, | 588 __ movq(elements_array, |
589 FieldOperand(array_function, | 589 FieldOperand(array_function, |
590 JSFunction::kPrototypeOrInitialMapOffset)); | 590 JSFunction::kPrototypeOrInitialMapOffset)); |
591 | 591 |
592 // Check whether an empty sized array is requested. | 592 // Check whether an empty sized array is requested. |
| 593 __ SmiToInteger64(array_size, array_size); |
593 __ testq(array_size, array_size); | 594 __ testq(array_size, array_size); |
594 __ j(not_zero, ¬_empty); | 595 __ j(not_zero, ¬_empty); |
595 | 596 |
596 // If an empty array is requested allocate a small elements array anyway. This | 597 // If an empty array is requested allocate a small elements array anyway. This |
597 // keeps the code below free of special casing for the empty array. | 598 // keeps the code below free of special casing for the empty array. |
598 int size = JSArray::kSize + FixedArray::SizeFor(kPreallocatedArrayElements); | 599 int size = JSArray::kSize + FixedArray::SizeFor(kPreallocatedArrayElements); |
599 __ AllocateInNewSpace(size, | 600 __ AllocateInNewSpace(size, |
600 result, | 601 result, |
601 elements_array_end, | 602 elements_array_end, |
602 scratch, | 603 scratch, |
603 gc_required, | 604 gc_required, |
604 TAG_OBJECT); | 605 TAG_OBJECT); |
605 __ jmp(&allocated); | 606 __ jmp(&allocated); |
606 | 607 |
607 // Allocate the JSArray object together with space for a FixedArray with the | 608 // Allocate the JSArray object together with space for a FixedArray with the |
608 // requested elements. | 609 // requested elements. |
609 __ bind(¬_empty); | 610 __ bind(¬_empty); |
610 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); | 611 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); |
611 __ AllocateInNewSpace(JSArray::kSize + FixedArray::kHeaderSize, | 612 __ AllocateInNewSpace(JSArray::kSize + FixedArray::kHeaderSize, |
612 times_half_pointer_size, // array_size is a smi. | 613 times_pointer_size, |
613 array_size, | 614 array_size, |
614 result, | 615 result, |
615 elements_array_end, | 616 elements_array_end, |
616 scratch, | 617 scratch, |
617 gc_required, | 618 gc_required, |
618 TAG_OBJECT); | 619 TAG_OBJECT); |
619 | 620 |
620 // Allocated the JSArray. Now initialize the fields except for the elements | 621 // Allocated the JSArray. Now initialize the fields except for the elements |
621 // array. | 622 // array. |
622 // result: JSObject | 623 // result: JSObject |
623 // elements_array: initial map | 624 // elements_array: initial map |
624 // elements_array_end: start of next object | 625 // elements_array_end: start of next object |
625 // array_size: size of array (smi) | 626 // array_size: size of array |
626 __ bind(&allocated); | 627 __ bind(&allocated); |
627 __ movq(FieldOperand(result, JSObject::kMapOffset), elements_array); | 628 __ movq(FieldOperand(result, JSObject::kMapOffset), elements_array); |
628 __ Move(elements_array, Factory::empty_fixed_array()); | 629 __ Move(elements_array, Factory::empty_fixed_array()); |
629 __ movq(FieldOperand(result, JSArray::kPropertiesOffset), elements_array); | 630 __ movq(FieldOperand(result, JSArray::kPropertiesOffset), elements_array); |
630 // Field JSArray::kElementsOffset is initialized later. | 631 // Field JSArray::kElementsOffset is initialized later. |
631 __ movq(FieldOperand(result, JSArray::kLengthOffset), array_size); | 632 __ Integer32ToSmi(scratch, array_size); |
| 633 __ movq(FieldOperand(result, JSArray::kLengthOffset), scratch); |
632 | 634 |
633 // Calculate the location of the elements array and set elements array member | 635 // Calculate the location of the elements array and set elements array member |
634 // of the JSArray. | 636 // of the JSArray. |
635 // result: JSObject | 637 // result: JSObject |
636 // elements_array_end: start of next object | 638 // elements_array_end: start of next object |
637 // array_size: size of array (smi) | 639 // array_size: size of array |
638 __ lea(elements_array, Operand(result, JSArray::kSize)); | 640 __ lea(elements_array, Operand(result, JSArray::kSize)); |
639 __ movq(FieldOperand(result, JSArray::kElementsOffset), elements_array); | 641 __ movq(FieldOperand(result, JSArray::kElementsOffset), elements_array); |
640 | 642 |
641 // Initialize the fixed array. FixedArray length is not stored as a smi. | 643 // Initialize the fixed array. FixedArray length is not stored as a smi. |
642 // result: JSObject | 644 // result: JSObject |
643 // elements_array: elements array | 645 // elements_array: elements array |
644 // elements_array_end: start of next object | 646 // elements_array_end: start of next object |
645 // array_size: size of array (smi) | 647 // array_size: size of array |
646 ASSERT(kSmiTag == 0); | 648 ASSERT(kSmiTag == 0); |
647 __ SmiToInteger64(array_size, array_size); | |
648 __ Move(FieldOperand(elements_array, JSObject::kMapOffset), | 649 __ Move(FieldOperand(elements_array, JSObject::kMapOffset), |
649 Factory::fixed_array_map()); | 650 Factory::fixed_array_map()); |
650 Label not_empty_2, fill_array; | 651 Label not_empty_2, fill_array; |
651 __ testq(array_size, array_size); | 652 __ testq(array_size, array_size); |
652 __ j(not_zero, ¬_empty_2); | 653 __ j(not_zero, ¬_empty_2); |
653 // Length of the FixedArray is the number of pre-allocated elements even | 654 // Length of the FixedArray is the number of pre-allocated elements even |
654 // though the actual JSArray has length 0. | 655 // though the actual JSArray has length 0. |
655 __ movq(FieldOperand(elements_array, Array::kLengthOffset), | 656 __ movq(FieldOperand(elements_array, Array::kLengthOffset), |
656 Immediate(kPreallocatedArrayElements)); | 657 Immediate(kPreallocatedArrayElements)); |
657 __ jmp(&fill_array); | 658 __ jmp(&fill_array); |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { | 1291 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { |
1291 Generate_JSEntryTrampolineHelper(masm, false); | 1292 Generate_JSEntryTrampolineHelper(masm, false); |
1292 } | 1293 } |
1293 | 1294 |
1294 | 1295 |
1295 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { | 1296 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { |
1296 Generate_JSEntryTrampolineHelper(masm, true); | 1297 Generate_JSEntryTrampolineHelper(masm, true); |
1297 } | 1298 } |
1298 | 1299 |
1299 } } // namespace v8::internal | 1300 } } // namespace v8::internal |
OLD | NEW |