Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(733)

Side by Side Diff: runtime/vm/stub_code_arm64.cc

Issue 578443003: Support old-space allocation in generated code (bump block only for now). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)). 649 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)).
650 // Assert that length is a Smi. 650 // Assert that length is a Smi.
651 __ tsti(R2, kSmiTagMask); 651 __ tsti(R2, kSmiTagMask);
652 if (FLAG_use_slow_path) { 652 if (FLAG_use_slow_path) {
653 __ b(&slow_case); 653 __ b(&slow_case);
654 } else { 654 } else {
655 __ b(&slow_case, NE); 655 __ b(&slow_case, NE);
656 } 656 }
657 __ cmp(R2, Operand(0)); 657 __ cmp(R2, Operand(0));
658 __ b(&slow_case, LT); 658 __ b(&slow_case, LT);
659 __ LoadImmediate(R8, Isolate::CurrentAddress(), kNoPP); 659
660 __ LoadFromOffset(R8, R8, Isolate::heap_offset(), kNoPP); 660 Isolate* isolate = Isolate::Current();
661 __ LoadFromOffset(R8, R8, Heap::new_space_offset(), kNoPP); 661 Heap* heap = isolate->heap();
662 const intptr_t cid = kArrayCid;
663 Heap::Space space = heap->SpaceForAllocation(cid);
664 const uword top_address = heap->TopAddress(space);
665 __ LoadImmediate(R8, top_address, kNoPP);
666 const uword end_address = heap->EndAddress(space);
667 ASSERT(top_address < end_address);
668 const uword top_offset = 0;
669 const uword end_offset = end_address - top_address;
662 670
663 // Calculate and align allocation size. 671 // Calculate and align allocation size.
664 // Load new object start and calculate next object start. 672 // Load new object start and calculate next object start.
665 // R1: array element type. 673 // R1: array element type.
666 // R2: array length as Smi. 674 // R2: array length as Smi.
667 // R8: points to new space object. 675 // R8: points to new space object.
668 __ LoadFromOffset(R0, R8, Scavenger::top_offset(), kNoPP); 676 __ LoadFromOffset(R0, R8, top_offset, kNoPP);
669 intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; 677 intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
670 __ LoadImmediate(R3, fixed_size, kNoPP); 678 __ LoadImmediate(R3, fixed_size, kNoPP);
671 __ add(R3, R3, Operand(R2, LSL, 2)); // R2 is Smi. 679 __ add(R3, R3, Operand(R2, LSL, 2)); // R2 is Smi.
672 ASSERT(kSmiTagShift == 1); 680 ASSERT(kSmiTagShift == 1);
673 __ andi(R3, R3, ~(kObjectAlignment - 1)); 681 __ andi(R3, R3, ~(kObjectAlignment - 1));
674 __ adds(R7, R3, Operand(R0)); 682 __ adds(R7, R3, Operand(R0));
675 __ b(&slow_case, VS); 683 __ b(&slow_case, VS);
676 684
677 // Check if the allocation fits into the remaining space. 685 // Check if the allocation fits into the remaining space.
678 // R0: potential new object start. 686 // R0: potential new object start.
679 // R1: array element type. 687 // R1: array element type.
680 // R2: array length as Smi. 688 // R2: array length as Smi.
681 // R3: array size. 689 // R3: array size.
682 // R7: potential next object start. 690 // R7: potential next object start.
683 // R8: points to new space object. 691 // R8: points to new space object.
684 __ LoadFromOffset(TMP, R8, Scavenger::end_offset(), kNoPP); 692 __ LoadFromOffset(TMP, R8, end_offset, kNoPP);
685 __ CompareRegisters(R7, TMP); 693 __ CompareRegisters(R7, TMP);
686 __ b(&slow_case, CS); // Branch if unsigned higher or equal. 694 __ b(&slow_case, CS); // Branch if unsigned higher or equal.
687 695
688 // Successfully allocated the object(s), now update top to point to 696 // Successfully allocated the object(s), now update top to point to
689 // next object start and initialize the object. 697 // next object start and initialize the object.
690 // R0: potential new object start. 698 // R0: potential new object start.
691 // R3: array size. 699 // R3: array size.
692 // R7: potential next object start. 700 // R7: potential next object start.
693 // R8: Points to new space object. 701 // R8: Points to new space object.
694 __ StoreToOffset(R7, R8, Scavenger::top_offset(), kNoPP); 702 __ StoreToOffset(R7, R8, top_offset, kNoPP);
695 __ add(R0, R0, Operand(kHeapObjectTag)); 703 __ add(R0, R0, Operand(kHeapObjectTag));
696 __ UpdateAllocationStatsWithSize(kArrayCid, R3, kNoPP); 704 __ UpdateAllocationStatsWithSize(cid, R3, kNoPP, space);
697 705
698 // R0: new object start as a tagged pointer. 706 // R0: new object start as a tagged pointer.
699 // R1: array element type. 707 // R1: array element type.
700 // R2: array length as Smi. 708 // R2: array length as Smi.
701 // R3: array size. 709 // R3: array size.
702 // R7: new object end address. 710 // R7: new object end address.
703 711
704 // Store the type argument field. 712 // Store the type argument field.
705 __ StoreIntoObjectOffsetNoBarrier( 713 __ StoreIntoObjectOffsetNoBarrier(
706 R0, Array::type_arguments_offset(), R1, PP); 714 R0, Array::type_arguments_offset(), R1, PP);
707 715
708 // Set the length field. 716 // Set the length field.
709 __ StoreIntoObjectOffsetNoBarrier(R0, Array::length_offset(), R2, PP); 717 __ StoreIntoObjectOffsetNoBarrier(R0, Array::length_offset(), R2, PP);
710 718
711 // Calculate the size tag. 719 // Calculate the size tag.
712 // R0: new object start as a tagged pointer. 720 // R0: new object start as a tagged pointer.
713 // R2: array length as Smi. 721 // R2: array length as Smi.
714 // R3: array size. 722 // R3: array size.
715 // R7: new object end address. 723 // R7: new object end address.
716 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2; 724 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2;
717 __ CompareImmediate(R3, RawObject::SizeTag::kMaxSizeTag, kNoPP); 725 __ CompareImmediate(R3, RawObject::SizeTag::kMaxSizeTag, kNoPP);
718 // If no size tag overflow, shift R1 left, else set R1 to zero. 726 // If no size tag overflow, shift R1 left, else set R1 to zero.
719 __ LslImmediate(TMP, R3, shift); 727 __ LslImmediate(TMP, R3, shift);
720 __ csel(R1, TMP, R1, LS); 728 __ csel(R1, TMP, R1, LS);
721 __ csel(R1, ZR, R1, HI); 729 __ csel(R1, ZR, R1, HI);
722 730
723 // Get the class index and insert it into the tags. 731 // Get the class index and insert it into the tags.
724 __ LoadImmediate(TMP, RawObject::ClassIdTag::encode(kArrayCid), kNoPP); 732 __ LoadImmediate(TMP, RawObject::ClassIdTag::encode(cid), kNoPP);
725 __ orr(R1, R1, Operand(TMP)); 733 __ orr(R1, R1, Operand(TMP));
726 __ StoreFieldToOffset(R1, R0, Array::tags_offset(), kNoPP); 734 __ StoreFieldToOffset(R1, R0, Array::tags_offset(), kNoPP);
727 735
728 // Initialize all array elements to raw_null. 736 // Initialize all array elements to raw_null.
729 // R0: new object start as a tagged pointer. 737 // R0: new object start as a tagged pointer.
730 // R7: new object end address. 738 // R7: new object end address.
731 // R2: array length as Smi. 739 // R2: array length as Smi.
732 __ AddImmediate(R1, R0, Array::data_offset() - kHeapObjectTag, kNoPP); 740 __ AddImmediate(R1, R0, Array::data_offset() - kHeapObjectTag, kNoPP);
733 // R1: iterator which initially points to the start of the variable 741 // R1: iterator which initially points to the start of the variable
734 // data area to be initialized. 742 // data area to be initialized.
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 // R1: number of context variables. 967 // R1: number of context variables.
960 intptr_t fixed_size = sizeof(RawContext) + kObjectAlignment - 1; 968 intptr_t fixed_size = sizeof(RawContext) + kObjectAlignment - 1;
961 __ LoadImmediate(R2, fixed_size, kNoPP); 969 __ LoadImmediate(R2, fixed_size, kNoPP);
962 __ add(R2, R2, Operand(R1, LSL, 3)); 970 __ add(R2, R2, Operand(R1, LSL, 3));
963 ASSERT(kSmiTagShift == 1); 971 ASSERT(kSmiTagShift == 1);
964 __ andi(R2, R2, ~(kObjectAlignment - 1)); 972 __ andi(R2, R2, ~(kObjectAlignment - 1));
965 973
966 // Now allocate the object. 974 // Now allocate the object.
967 // R1: number of context variables. 975 // R1: number of context variables.
968 // R2: object size. 976 // R2: object size.
969 __ LoadImmediate(R5, heap->TopAddress(), kNoPP); 977 intptr_t cid = context_class.id();
978 Heap::Space space = heap->SpaceForAllocation(cid);
979 __ LoadImmediate(R5, heap->TopAddress(space), kNoPP);
970 __ ldr(R0, Address(R5)); 980 __ ldr(R0, Address(R5));
971 __ add(R3, R2, Operand(R0)); 981 __ add(R3, R2, Operand(R0));
972 // Check if the allocation fits into the remaining space. 982 // Check if the allocation fits into the remaining space.
973 // R0: potential new object. 983 // R0: potential new object.
974 // R1: number of context variables. 984 // R1: number of context variables.
975 // R2: object size. 985 // R2: object size.
976 // R3: potential next object start. 986 // R3: potential next object start.
977 __ LoadImmediate(TMP, heap->EndAddress(), kNoPP); 987 __ LoadImmediate(TMP, heap->EndAddress(space), kNoPP);
978 __ ldr(TMP, Address(TMP)); 988 __ ldr(TMP, Address(TMP));
979 __ CompareRegisters(R3, TMP); 989 __ CompareRegisters(R3, TMP);
980 if (FLAG_use_slow_path) { 990 if (FLAG_use_slow_path) {
981 __ b(&slow_case); 991 __ b(&slow_case);
982 } else { 992 } else {
983 __ b(&slow_case, CS); // Branch if unsigned higher or equal. 993 __ b(&slow_case, CS); // Branch if unsigned higher or equal.
984 } 994 }
985 995
986 // Successfully allocated the object, now update top to point to 996 // Successfully allocated the object, now update top to point to
987 // next object start and initialize the object. 997 // next object start and initialize the object.
988 // R0: new object. 998 // R0: new object.
989 // R1: number of context variables. 999 // R1: number of context variables.
990 // R2: object size. 1000 // R2: object size.
991 // R3: next object start. 1001 // R3: next object start.
992 __ str(R3, Address(R5)); 1002 __ str(R3, Address(R5));
993 __ add(R0, R0, Operand(kHeapObjectTag)); 1003 __ add(R0, R0, Operand(kHeapObjectTag));
994 __ UpdateAllocationStatsWithSize(context_class.id(), R2, kNoPP); 1004 __ UpdateAllocationStatsWithSize(cid, R2, kNoPP, space);
995 1005
996 // Calculate the size tag. 1006 // Calculate the size tag.
997 // R0: new object. 1007 // R0: new object.
998 // R1: number of context variables. 1008 // R1: number of context variables.
999 // R2: object size. 1009 // R2: object size.
1000 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2; 1010 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2;
1001 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag, kNoPP); 1011 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag, kNoPP);
1002 // If no size tag overflow, shift R2 left, else set R2 to zero. 1012 // If no size tag overflow, shift R2 left, else set R2 to zero.
1003 __ LslImmediate(TMP, R2, shift); 1013 __ LslImmediate(TMP, R2, shift);
1004 __ csel(R2, TMP, R2, LS); 1014 __ csel(R2, TMP, R2, LS);
1005 __ csel(R2, ZR, R2, HI); 1015 __ csel(R2, ZR, R2, HI);
1006 1016
1007 // Get the class index and insert it into the tags. 1017 // Get the class index and insert it into the tags.
1008 // R2: size and bit tags. 1018 // R2: size and bit tags.
1009 __ LoadImmediate( 1019 __ LoadImmediate(
1010 TMP, RawObject::ClassIdTag::encode(context_class.id()), kNoPP); 1020 TMP, RawObject::ClassIdTag::encode(cid), kNoPP);
1011 __ orr(R2, R2, Operand(TMP)); 1021 __ orr(R2, R2, Operand(TMP));
1012 __ StoreFieldToOffset(R2, R0, Context::tags_offset(), kNoPP); 1022 __ StoreFieldToOffset(R2, R0, Context::tags_offset(), kNoPP);
1013 1023
1014 // Setup up number of context variables field. 1024 // Setup up number of context variables field.
1015 // R0: new object. 1025 // R0: new object.
1016 // R1: number of context variables as integer value (not object). 1026 // R1: number of context variables as integer value (not object).
1017 __ StoreFieldToOffset(R1, R0, Context::num_variables_offset(), kNoPP); 1027 __ StoreFieldToOffset(R1, R0, Context::num_variables_offset(), kNoPP);
1018 1028
1019 // Setup isolate field. 1029 // Setup isolate field.
1020 // Load Isolate pointer into R2. 1030 // Load Isolate pointer into R2.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 if (is_cls_parameterized) { 1163 if (is_cls_parameterized) {
1154 __ ldr(R1, Address(SP)); 1164 __ ldr(R1, Address(SP));
1155 // R1: instantiated type arguments. 1165 // R1: instantiated type arguments.
1156 } 1166 }
1157 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size)) { 1167 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size)) {
1158 Label slow_case; 1168 Label slow_case;
1159 // Allocate the object and update top to point to 1169 // Allocate the object and update top to point to
1160 // next object start and initialize the allocated object. 1170 // next object start and initialize the allocated object.
1161 // R1: instantiated type arguments (if is_cls_parameterized). 1171 // R1: instantiated type arguments (if is_cls_parameterized).
1162 Heap* heap = Isolate::Current()->heap(); 1172 Heap* heap = Isolate::Current()->heap();
1163 __ LoadImmediate(R5, heap->TopAddress(), kNoPP); 1173 Heap::Space space = heap->SpaceForAllocation(cls.id());
1174 __ LoadImmediate(R5, heap->TopAddress(space), kNoPP);
1164 __ ldr(R2, Address(R5)); 1175 __ ldr(R2, Address(R5));
1165 __ AddImmediate(R3, R2, instance_size, kNoPP); 1176 __ AddImmediate(R3, R2, instance_size, kNoPP);
1166 // Check if the allocation fits into the remaining space. 1177 // Check if the allocation fits into the remaining space.
1167 // R2: potential new object start. 1178 // R2: potential new object start.
1168 // R3: potential next object start. 1179 // R3: potential next object start.
1169 __ LoadImmediate(TMP, heap->EndAddress(), kNoPP); 1180 __ LoadImmediate(TMP, heap->EndAddress(space), kNoPP);
1170 __ ldr(TMP, Address(TMP)); 1181 __ ldr(TMP, Address(TMP));
1171 __ CompareRegisters(R3, TMP); 1182 __ CompareRegisters(R3, TMP);
1172 if (FLAG_use_slow_path) { 1183 if (FLAG_use_slow_path) {
1173 __ b(&slow_case); 1184 __ b(&slow_case);
1174 } else { 1185 } else {
1175 __ b(&slow_case, CS); // Unsigned higher or equal. 1186 __ b(&slow_case, CS); // Unsigned higher or equal.
1176 } 1187 }
1177 __ str(R3, Address(R5)); 1188 __ str(R3, Address(R5));
1178 __ UpdateAllocationStats(cls.id(), kNoPP); 1189 __ UpdateAllocationStats(cls.id(), kNoPP, space);
1179 1190
1180 // R2: new object start. 1191 // R2: new object start.
1181 // R3: next object start. 1192 // R3: next object start.
1182 // R1: new object type arguments (if is_cls_parameterized). 1193 // R1: new object type arguments (if is_cls_parameterized).
1183 // Set the tags. 1194 // Set the tags.
1184 uword tags = 0; 1195 uword tags = 0;
1185 tags = RawObject::SizeTag::update(instance_size, tags); 1196 tags = RawObject::SizeTag::update(instance_size, tags);
1186 ASSERT(cls.id() != kIllegalCid); 1197 ASSERT(cls.id() != kIllegalCid);
1187 tags = RawObject::ClassIdTag::update(cls.id(), tags); 1198 tags = RawObject::ClassIdTag::update(cls.id(), tags);
1188 __ LoadImmediate(R0, tags, kNoPP); 1199 __ LoadImmediate(R0, tags, kNoPP);
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
2083 const Register right = R0; 2094 const Register right = R0;
2084 __ LoadFromOffset(left, SP, 1 * kWordSize, kNoPP); 2095 __ LoadFromOffset(left, SP, 1 * kWordSize, kNoPP);
2085 __ LoadFromOffset(right, SP, 0 * kWordSize, kNoPP); 2096 __ LoadFromOffset(right, SP, 0 * kWordSize, kNoPP);
2086 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); 2097 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp);
2087 __ ret(); 2098 __ ret();
2088 } 2099 }
2089 2100
2090 } // namespace dart 2101 } // namespace dart
2091 2102
2092 #endif // defined TARGET_ARCH_ARM64 2103 #endif // defined TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698