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

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

Issue 163683006: Simplify generated code for object allocation with type arguments. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comments Created 6 years, 10 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
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | runtime/vm/stub_code_ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_ARM) 6 #if defined(TARGET_ARCH_ARM)
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 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 __ CallRuntime(kStoreBufferBlockProcessRuntimeEntry, 1); 1090 __ CallRuntime(kStoreBufferBlockProcessRuntimeEntry, 1);
1091 // Restore callee-saved registers, tear down frame. 1091 // Restore callee-saved registers, tear down frame.
1092 __ LeaveCallRuntimeFrame(); 1092 __ LeaveCallRuntimeFrame();
1093 __ Ret(); 1093 __ Ret();
1094 } 1094 }
1095 1095
1096 1096
1097 // Called for inline allocation of objects. 1097 // Called for inline allocation of objects.
1098 // Input parameters: 1098 // Input parameters:
1099 // LR : return address. 1099 // LR : return address.
1100 // SP + 4 : type arguments object (only if class is parameterized). 1100 // SP + 0 : type arguments object (only if class is parameterized).
1101 // SP + 0 : type arguments of instantiator (only if class is parameterized).
1102 void StubCode::GenerateAllocationStubForClass(Assembler* assembler, 1101 void StubCode::GenerateAllocationStubForClass(Assembler* assembler,
1103 const Class& cls) { 1102 const Class& cls) {
1104 // The generated code is different if the class is parameterized. 1103 // The generated code is different if the class is parameterized.
1105 const bool is_cls_parameterized = cls.NumTypeArguments() > 0; 1104 const bool is_cls_parameterized = cls.NumTypeArguments() > 0;
1106 ASSERT(!is_cls_parameterized || 1105 ASSERT(!is_cls_parameterized ||
1107 (cls.type_arguments_field_offset() != Class::kNoTypeArguments)); 1106 (cls.type_arguments_field_offset() != Class::kNoTypeArguments));
1108 // kInlineInstanceSize is a constant used as a threshold for determining 1107 // kInlineInstanceSize is a constant used as a threshold for determining
1109 // when the object initialization should be done as a loop or as 1108 // when the object initialization should be done as a loop or as
1110 // straight line code. 1109 // straight line code.
1111 const int kInlineInstanceSize = 12; 1110 const int kInlineInstanceSize = 12;
1112 const intptr_t instance_size = cls.instance_size(); 1111 const intptr_t instance_size = cls.instance_size();
1113 ASSERT(instance_size > 0); 1112 ASSERT(instance_size > 0);
1114 Label slow_case_with_type_arguments; 1113 Label slow_case_with_type_arguments;
1115 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size)) { 1114 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size)) {
1116 Label slow_case_reload_type_arguments; 1115 Label slow_case_reload_type_arguments;
1117 if (is_cls_parameterized) { 1116 if (is_cls_parameterized) {
1118 // Instantiation of the type arguments vector is only required if an 1117 __ ldr(R1, Address(SP, 0));
1119 // instantiator is provided (not kNoInstantiator, but may be null).
1120 __ ldm(IA, SP, (1 << R0) | (1 << R1));
1121 // R1: type arguments, instantiated or not.
1122 // R0: instantiator type arguments or kNoInstantiator.
1123 Label type_arguments_ready;
1124 __ CompareImmediate(R0, Smi::RawValue(StubCode::kNoInstantiator));
1125 __ b(&type_arguments_ready, EQ);
1126 // Lookup instantiator R0 in instantiations array of type arguments R1
1127 // and, if found, use cached instantiated type arguments.
1128 __ ldr(R2, FieldAddress(R1, TypeArguments::instantiations_offset()));
1129 __ ldr(R3, FieldAddress(R2, Array::length_offset()));
1130 __ AddImmediate(R2, Array::data_offset() - kHeapObjectTag);
1131 __ add(R3, R2, ShifterOperand(R3, LSL, 1)); // R3 is Smi.
1132 Label loop, found;
1133 __ Bind(&loop);
1134 __ cmp(R2, ShifterOperand(R3));
1135 __ b(&slow_case_reload_type_arguments, CS); // Unsigned higher or equal.
1136 __ ldr(R1, Address(R2, 0 * kWordSize)); // Cached instantiator.
1137 __ cmp(R1, ShifterOperand(R0));
1138 __ b(&found, EQ);
1139 __ CompareImmediate(R1, Smi::RawValue(StubCode::kNoInstantiator));
1140 __ b(&slow_case_reload_type_arguments, EQ);
1141 __ AddImmediate(R2, 2 * kWordSize);
1142 __ b(&loop);
1143 __ Bind(&found);
1144 __ ldr(R1, Address(R2, 1 * kWordSize)); // Cached instantiated args.
1145 __ LoadImmediate(R0, Smi::RawValue(StubCode::kNoInstantiator));
1146 __ Bind(&type_arguments_ready);
1147 // R1: instantiated type arguments. 1118 // R1: instantiated type arguments.
1148 // R0: kNoInstantiator.
1149 } 1119 }
1150 // Allocate the object and update top to point to 1120 // Allocate the object and update top to point to
1151 // next object start and initialize the allocated object. 1121 // next object start and initialize the allocated object.
1152 // R1: instantiated type arguments (if is_cls_parameterized). 1122 // R1: instantiated type arguments (if is_cls_parameterized).
1153 // R0: kNoInstantiator (if is_cls_parameterized).
1154 Heap* heap = Isolate::Current()->heap(); 1123 Heap* heap = Isolate::Current()->heap();
1155 __ LoadImmediate(R5, heap->TopAddress()); 1124 __ LoadImmediate(R5, heap->TopAddress());
1156 __ ldr(R2, Address(R5, 0)); 1125 __ ldr(R2, Address(R5, 0));
1157 __ AddImmediate(R3, R2, instance_size); 1126 __ AddImmediate(R3, R2, instance_size);
1158 // Check if the allocation fits into the remaining space. 1127 // Check if the allocation fits into the remaining space.
1159 // R2: potential new object start. 1128 // R2: potential new object start.
1160 // R3: potential next object start. 1129 // R3: potential next object start.
1161 __ LoadImmediate(IP, heap->EndAddress()); 1130 __ LoadImmediate(IP, heap->EndAddress());
1162 __ ldr(IP, Address(IP, 0)); 1131 __ ldr(IP, Address(IP, 0));
1163 __ cmp(R3, ShifterOperand(IP)); 1132 __ cmp(R3, ShifterOperand(IP));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 } 1190 }
1222 // Done allocating and initializing the instance. 1191 // Done allocating and initializing the instance.
1223 // R2: new object still missing its heap tag. 1192 // R2: new object still missing its heap tag.
1224 __ add(R0, R2, ShifterOperand(kHeapObjectTag)); 1193 __ add(R0, R2, ShifterOperand(kHeapObjectTag));
1225 // R0: new object. 1194 // R0: new object.
1226 __ Ret(); 1195 __ Ret();
1227 1196
1228 __ Bind(&slow_case_reload_type_arguments); 1197 __ Bind(&slow_case_reload_type_arguments);
1229 } 1198 }
1230 if (is_cls_parameterized) { 1199 if (is_cls_parameterized) {
1231 __ ldm(IA, SP, (1 << R0) | (1 << R1)); 1200 __ ldr(R1, Address(SP, 0));
1232 } 1201 }
1233 __ Bind(&slow_case_with_type_arguments); 1202 __ Bind(&slow_case_with_type_arguments);
1234 // If is_cls_parameterized: 1203 // If is_cls_parameterized:
1235 // R1: new object type arguments (instantiated or not). 1204 // R1: new object type arguments.
1236 // R0: instantiator type arguments or kNoInstantiator.
1237 // Create a stub frame as we are pushing some objects on the stack before 1205 // Create a stub frame as we are pushing some objects on the stack before
1238 // calling into the runtime. 1206 // calling into the runtime.
1239 __ EnterStubFrame(true); // Uses pool pointer to pass cls to runtime. 1207 __ EnterStubFrame(true); // Uses pool pointer to pass cls to runtime.
1240 __ LoadImmediate(R2, reinterpret_cast<intptr_t>(Object::null())); 1208 __ LoadImmediate(R2, reinterpret_cast<intptr_t>(Object::null()));
1241 __ Push(R2); // Setup space on stack for return value. 1209 __ Push(R2); // Setup space on stack for return value.
1242 __ PushObject(cls); // Push class of object to be allocated. 1210 __ PushObject(cls); // Push class of object to be allocated.
1243 if (is_cls_parameterized) { 1211 if (is_cls_parameterized) {
1244 // Push type arguments of object to be allocated and of instantiator. 1212 // Push type arguments.
1245 __ PushList((1 << R0) | (1 << R1)); 1213 __ Push(R1);
1246 } else { 1214 } else {
1247 // Push null type arguments and kNoInstantiator. 1215 // Push null type arguments.
1248 __ LoadImmediate(R1, Smi::RawValue(StubCode::kNoInstantiator)); 1216 __ Push(R2);
1249 __ PushList((1 << R1) | (1 << R2));
1250 } 1217 }
1251 __ CallRuntime(kAllocateObjectRuntimeEntry, 3); // Allocate object. 1218 __ CallRuntime(kAllocateObjectRuntimeEntry, 2); // Allocate object.
1252 __ Drop(3); // Pop arguments. 1219 __ Drop(2); // Pop arguments.
1253 __ Pop(R0); // Pop result (newly allocated object). 1220 __ Pop(R0); // Pop result (newly allocated object).
1254 // R0: new object 1221 // R0: new object
1255 // Restore the frame pointer. 1222 // Restore the frame pointer.
1256 __ LeaveStubFrame(); 1223 __ LeaveStubFrame();
1257 __ Ret(); 1224 __ Ret();
1258 } 1225 }
1259 1226
1260 1227
1261 // Called for inline allocation of closures. 1228 // Called for inline allocation of closures.
1262 // Input parameters: 1229 // Input parameters:
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 const Register right = R0; 2098 const Register right = R0;
2132 __ ldr(left, Address(SP, 1 * kWordSize)); 2099 __ ldr(left, Address(SP, 1 * kWordSize));
2133 __ ldr(right, Address(SP, 0 * kWordSize)); 2100 __ ldr(right, Address(SP, 0 * kWordSize));
2134 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); 2101 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp);
2135 __ Ret(); 2102 __ Ret();
2136 } 2103 }
2137 2104
2138 } // namespace dart 2105 } // namespace dart
2139 2106
2140 #endif // defined TARGET_ARCH_ARM 2107 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | runtime/vm/stub_code_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698