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

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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)). 650 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)).
651 // Assert that length is a Smi. 651 // Assert that length is a Smi.
652 __ tsti(R2, kSmiTagMask); 652 __ tsti(R2, kSmiTagMask);
653 if (FLAG_use_slow_path) { 653 if (FLAG_use_slow_path) {
654 __ b(&slow_case); 654 __ b(&slow_case);
655 } else { 655 } else {
656 __ b(&slow_case, NE); 656 __ b(&slow_case, NE);
657 } 657 }
658 __ cmp(R2, Operand(0)); 658 __ cmp(R2, Operand(0));
659 __ b(&slow_case, LT); 659 __ b(&slow_case, LT);
660 __ LoadFieldFromOffset(R8, CTX, Context::isolate_offset(), kNoPP); 660 Isolate* isolate = Isolate::Current();
661 __ LoadFromOffset(R8, R8, Isolate::heap_offset(), kNoPP); 661 Heap* heap = isolate->heap();
662 __ LoadFromOffset(R8, R8, Heap::new_space_offset(), kNoPP); 662 Heap::Space space = heap->SpaceForAllocation(kArrayCid);
663 const uword top_address = heap->TopAddress(space);
664 __ LoadImmediate(R8, top_address, kNoPP);
665 const uword end_address = heap->EndAddress(space);
666 ASSERT(top_address < end_address);
667 const uword top_offset = 0;
668 const uword end_offset = end_address - top_address;
663 669
664 // Calculate and align allocation size. 670 // Calculate and align allocation size.
665 // Load new object start and calculate next object start. 671 // Load new object start and calculate next object start.
666 // R1: array element type. 672 // R1: array element type.
667 // R2: array length as Smi. 673 // R2: array length as Smi.
668 // R8: points to new space object. 674 // R8: points to new space object.
669 __ LoadFromOffset(R0, R8, Scavenger::top_offset(), kNoPP); 675 __ LoadFromOffset(R0, R8, top_offset, kNoPP);
670 intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; 676 intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
671 __ LoadImmediate(R3, fixed_size, kNoPP); 677 __ LoadImmediate(R3, fixed_size, kNoPP);
672 __ add(R3, R3, Operand(R2, LSL, 2)); // R2 is Smi. 678 __ add(R3, R3, Operand(R2, LSL, 2)); // R2 is Smi.
673 ASSERT(kSmiTagShift == 1); 679 ASSERT(kSmiTagShift == 1);
674 __ andi(R3, R3, ~(kObjectAlignment - 1)); 680 __ andi(R3, R3, ~(kObjectAlignment - 1));
675 __ adds(R7, R3, Operand(R0)); 681 __ adds(R7, R3, Operand(R0));
676 __ b(&slow_case, VS); 682 __ b(&slow_case, VS);
677 683
678 // Check if the allocation fits into the remaining space. 684 // Check if the allocation fits into the remaining space.
679 // R0: potential new object start. 685 // R0: potential new object start.
680 // R1: array element type. 686 // R1: array element type.
681 // R2: array length as Smi. 687 // R2: array length as Smi.
682 // R3: array size. 688 // R3: array size.
683 // R7: potential next object start. 689 // R7: potential next object start.
684 // R8: points to new space object. 690 // R8: points to new space object.
685 __ LoadFromOffset(TMP, R8, Scavenger::end_offset(), kNoPP); 691 __ LoadFromOffset(TMP, R8, end_offset, kNoPP);
686 __ CompareRegisters(R7, TMP); 692 __ CompareRegisters(R7, TMP);
687 __ b(&slow_case, CS); // Branch if unsigned higher or equal. 693 __ b(&slow_case, CS); // Branch if unsigned higher or equal.
688 694
689 // Successfully allocated the object(s), now update top to point to 695 // Successfully allocated the object(s), now update top to point to
690 // next object start and initialize the object. 696 // next object start and initialize the object.
691 // R0: potential new object start. 697 // R0: potential new object start.
692 // R3: array size. 698 // R3: array size.
693 // R7: potential next object start. 699 // R7: potential next object start.
694 // R8: Points to new space object. 700 // R8: Points to new space object.
695 __ StoreToOffset(R7, R8, Scavenger::top_offset(), kNoPP); 701 __ StoreToOffset(R7, R8, top_offset, kNoPP);
696 __ add(R0, R0, Operand(kHeapObjectTag)); 702 __ add(R0, R0, Operand(kHeapObjectTag));
697 __ UpdateAllocationStatsWithSize(kArrayCid, R3, kNoPP); 703 __ UpdateAllocationStatsWithSize(kArrayCid, R3, kNoPP, space);
698 704
699 // R0: new object start as a tagged pointer. 705 // R0: new object start as a tagged pointer.
700 // R1: array element type. 706 // R1: array element type.
701 // R2: array length as Smi. 707 // R2: array length as Smi.
702 // R3: array size. 708 // R3: array size.
703 // R7: new object end address. 709 // R7: new object end address.
704 710
705 // Store the type argument field. 711 // Store the type argument field.
706 __ StoreIntoObjectOffsetNoBarrier( 712 __ StoreIntoObjectOffsetNoBarrier(
707 R0, Array::type_arguments_offset(), R1, PP); 713 R0, Array::type_arguments_offset(), R1, PP);
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 // R1: number of context variables. 960 // R1: number of context variables.
955 intptr_t fixed_size = sizeof(RawContext) + kObjectAlignment - 1; 961 intptr_t fixed_size = sizeof(RawContext) + kObjectAlignment - 1;
956 __ LoadImmediate(R2, fixed_size, kNoPP); 962 __ LoadImmediate(R2, fixed_size, kNoPP);
957 __ add(R2, R2, Operand(R1, LSL, 3)); 963 __ add(R2, R2, Operand(R1, LSL, 3));
958 ASSERT(kSmiTagShift == 1); 964 ASSERT(kSmiTagShift == 1);
959 __ andi(R2, R2, ~(kObjectAlignment - 1)); 965 __ andi(R2, R2, ~(kObjectAlignment - 1));
960 966
961 // Now allocate the object. 967 // Now allocate the object.
962 // R1: number of context variables. 968 // R1: number of context variables.
963 // R2: object size. 969 // R2: object size.
964 __ LoadImmediate(R5, heap->TopAddress(), kNoPP); 970 intptr_t cid = context_class.id();
971 Heap::Space space = heap->SpaceForAllocation(cid);
972 __ LoadImmediate(R5, heap->TopAddress(space), kNoPP);
965 __ ldr(R0, Address(R5)); 973 __ ldr(R0, Address(R5));
966 __ add(R3, R2, Operand(R0)); 974 __ add(R3, R2, Operand(R0));
967 // Check if the allocation fits into the remaining space. 975 // Check if the allocation fits into the remaining space.
968 // R0: potential new object. 976 // R0: potential new object.
969 // R1: number of context variables. 977 // R1: number of context variables.
970 // R2: object size. 978 // R2: object size.
971 // R3: potential next object start. 979 // R3: potential next object start.
972 __ LoadImmediate(TMP, heap->EndAddress(), kNoPP); 980 __ LoadImmediate(TMP, heap->EndAddress(space), kNoPP);
973 __ ldr(TMP, Address(TMP)); 981 __ ldr(TMP, Address(TMP));
974 __ CompareRegisters(R3, TMP); 982 __ CompareRegisters(R3, TMP);
975 if (FLAG_use_slow_path) { 983 if (FLAG_use_slow_path) {
976 __ b(&slow_case); 984 __ b(&slow_case);
977 } else { 985 } else {
978 __ b(&slow_case, CS); // Branch if unsigned higher or equal. 986 __ b(&slow_case, CS); // Branch if unsigned higher or equal.
979 } 987 }
980 988
981 // Successfully allocated the object, now update top to point to 989 // Successfully allocated the object, now update top to point to
982 // next object start and initialize the object. 990 // next object start and initialize the object.
983 // R0: new object. 991 // R0: new object.
984 // R1: number of context variables. 992 // R1: number of context variables.
985 // R2: object size. 993 // R2: object size.
986 // R3: next object start. 994 // R3: next object start.
987 __ str(R3, Address(R5)); 995 __ str(R3, Address(R5));
988 __ add(R0, R0, Operand(kHeapObjectTag)); 996 __ add(R0, R0, Operand(kHeapObjectTag));
989 __ UpdateAllocationStatsWithSize(context_class.id(), R2, kNoPP); 997 __ UpdateAllocationStatsWithSize(cid, R2, kNoPP, space);
990 998
991 // Calculate the size tag. 999 // Calculate the size tag.
992 // R0: new object. 1000 // R0: new object.
993 // R1: number of context variables. 1001 // R1: number of context variables.
994 // R2: object size. 1002 // R2: object size.
995 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2; 1003 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2;
996 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag, kNoPP); 1004 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag, kNoPP);
997 // If no size tag overflow, shift R2 left, else set R2 to zero. 1005 // If no size tag overflow, shift R2 left, else set R2 to zero.
998 __ Lsl(TMP, R2, shift); 1006 __ Lsl(TMP, R2, shift);
999 __ csel(R2, TMP, R2, LS); 1007 __ csel(R2, TMP, R2, LS);
1000 __ csel(R2, ZR, R2, HI); 1008 __ csel(R2, ZR, R2, HI);
1001 1009
1002 // Get the class index and insert it into the tags. 1010 // Get the class index and insert it into the tags.
1003 // R2: size and bit tags. 1011 // R2: size and bit tags.
1004 __ LoadImmediate( 1012 __ LoadImmediate(
1005 TMP, RawObject::ClassIdTag::encode(context_class.id()), kNoPP); 1013 TMP, RawObject::ClassIdTag::encode(cid), kNoPP);
1006 __ orr(R2, R2, Operand(TMP)); 1014 __ orr(R2, R2, Operand(TMP));
1007 __ StoreFieldToOffset(R2, R0, Context::tags_offset(), kNoPP); 1015 __ StoreFieldToOffset(R2, R0, Context::tags_offset(), kNoPP);
1008 1016
1009 // Setup up number of context variables field. 1017 // Setup up number of context variables field.
1010 // R0: new object. 1018 // R0: new object.
1011 // R1: number of context variables as integer value (not object). 1019 // R1: number of context variables as integer value (not object).
1012 __ StoreFieldToOffset(R1, R0, Context::num_variables_offset(), kNoPP); 1020 __ StoreFieldToOffset(R1, R0, Context::num_variables_offset(), kNoPP);
1013 1021
1014 // Setup isolate field. 1022 // Setup isolate field.
1015 // Load Isolate pointer from Context structure into R2. 1023 // Load Isolate pointer from Context structure into R2.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 if (is_cls_parameterized) { 1154 if (is_cls_parameterized) {
1147 __ ldr(R1, Address(SP)); 1155 __ ldr(R1, Address(SP));
1148 // R1: instantiated type arguments. 1156 // R1: instantiated type arguments.
1149 } 1157 }
1150 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size)) { 1158 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size)) {
1151 Label slow_case; 1159 Label slow_case;
1152 // Allocate the object and update top to point to 1160 // Allocate the object and update top to point to
1153 // next object start and initialize the allocated object. 1161 // next object start and initialize the allocated object.
1154 // R1: instantiated type arguments (if is_cls_parameterized). 1162 // R1: instantiated type arguments (if is_cls_parameterized).
1155 Heap* heap = Isolate::Current()->heap(); 1163 Heap* heap = Isolate::Current()->heap();
1156 __ LoadImmediate(R5, heap->TopAddress(), kNoPP); 1164 Heap::Space space = heap->SpaceForAllocation(cls.id());
1165 __ LoadImmediate(R5, heap->TopAddress(space), kNoPP);
1157 __ ldr(R2, Address(R5)); 1166 __ ldr(R2, Address(R5));
1158 __ AddImmediate(R3, R2, instance_size, kNoPP); 1167 __ AddImmediate(R3, R2, instance_size, kNoPP);
1159 // Check if the allocation fits into the remaining space. 1168 // Check if the allocation fits into the remaining space.
1160 // R2: potential new object start. 1169 // R2: potential new object start.
1161 // R3: potential next object start. 1170 // R3: potential next object start.
1162 __ LoadImmediate(TMP, heap->EndAddress(), kNoPP); 1171 __ LoadImmediate(TMP, heap->EndAddress(space), kNoPP);
1163 __ ldr(TMP, Address(TMP)); 1172 __ ldr(TMP, Address(TMP));
1164 __ CompareRegisters(R3, TMP); 1173 __ CompareRegisters(R3, TMP);
1165 if (FLAG_use_slow_path) { 1174 if (FLAG_use_slow_path) {
1166 __ b(&slow_case); 1175 __ b(&slow_case);
1167 } else { 1176 } else {
1168 __ b(&slow_case, CS); // Unsigned higher or equal. 1177 __ b(&slow_case, CS); // Unsigned higher or equal.
1169 } 1178 }
1170 __ str(R3, Address(R5)); 1179 __ str(R3, Address(R5));
1171 __ UpdateAllocationStats(cls.id(), kNoPP); 1180 __ UpdateAllocationStats(cls.id(), kNoPP, space);
1172 1181
1173 // R2: new object start. 1182 // R2: new object start.
1174 // R3: next object start. 1183 // R3: next object start.
1175 // R1: new object type arguments (if is_cls_parameterized). 1184 // R1: new object type arguments (if is_cls_parameterized).
1176 // Set the tags. 1185 // Set the tags.
1177 uword tags = 0; 1186 uword tags = 0;
1178 tags = RawObject::SizeTag::update(instance_size, tags); 1187 tags = RawObject::SizeTag::update(instance_size, tags);
1179 ASSERT(cls.id() != kIllegalCid); 1188 ASSERT(cls.id() != kIllegalCid);
1180 tags = RawObject::ClassIdTag::update(cls.id(), tags); 1189 tags = RawObject::ClassIdTag::update(cls.id(), tags);
1181 __ LoadImmediate(R0, tags, kNoPP); 1190 __ LoadImmediate(R0, tags, kNoPP);
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 const Register right = R0; 2086 const Register right = R0;
2078 __ LoadFromOffset(left, SP, 1 * kWordSize, kNoPP); 2087 __ LoadFromOffset(left, SP, 1 * kWordSize, kNoPP);
2079 __ LoadFromOffset(right, SP, 0 * kWordSize, kNoPP); 2088 __ LoadFromOffset(right, SP, 0 * kWordSize, kNoPP);
2080 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); 2089 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp);
2081 __ ret(); 2090 __ ret();
2082 } 2091 }
2083 2092
2084 } // namespace dart 2093 } // namespace dart
2085 2094
2086 #endif // defined TARGET_ARCH_ARM64 2095 #endif // defined TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698