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

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

Issue 356923006: Iterate over PcDescriptors only via iterators, not via an index. (preparation for more compression … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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" // Needed here to get TARGET_ARCH_ARM64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64.
6 #if defined(TARGET_ARCH_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
7 7
8 #include "vm/flow_graph_compiler.h" 8 #include "vm/flow_graph_compiler.h"
9 9
10 #include "vm/ast_printer.h" 10 #include "vm/ast_printer.h"
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 1107
1108 if (is_optimizing()) { 1108 if (is_optimizing()) {
1109 lazy_deopt_pc_offset_ = assembler()->CodeSize(); 1109 lazy_deopt_pc_offset_ = assembler()->CodeSize();
1110 __ BranchPatchable(&StubCode::DeoptimizeLazyLabel()); 1110 __ BranchPatchable(&StubCode::DeoptimizeLazyLabel());
1111 } 1111 }
1112 } 1112 }
1113 1113
1114 1114
1115 void FlowGraphCompiler::GenerateCall(intptr_t token_pos, 1115 void FlowGraphCompiler::GenerateCall(intptr_t token_pos,
1116 const ExternalLabel* label, 1116 const ExternalLabel* label,
1117 PcDescriptors::Kind kind, 1117 RawPcDescriptors::Kind kind,
1118 LocationSummary* locs) { 1118 LocationSummary* locs) {
1119 __ BranchLinkPatchable(label); 1119 __ BranchLinkPatchable(label);
1120 AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos); 1120 AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos);
1121 RecordSafepoint(locs); 1121 RecordSafepoint(locs);
1122 } 1122 }
1123 1123
1124 1124
1125 void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, 1125 void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id,
1126 intptr_t token_pos, 1126 intptr_t token_pos,
1127 const ExternalLabel* label, 1127 const ExternalLabel* label,
1128 PcDescriptors::Kind kind, 1128 RawPcDescriptors::Kind kind,
1129 LocationSummary* locs) { 1129 LocationSummary* locs) {
1130 __ BranchLinkPatchable(label); 1130 __ BranchLinkPatchable(label);
1131 AddCurrentDescriptor(kind, deopt_id, token_pos); 1131 AddCurrentDescriptor(kind, deopt_id, token_pos);
1132 RecordSafepoint(locs); 1132 RecordSafepoint(locs);
1133 // Marks either the continuation point in unoptimized code or the 1133 // Marks either the continuation point in unoptimized code or the
1134 // deoptimization point in optimized code, after call. 1134 // deoptimization point in optimized code, after call.
1135 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); 1135 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
1136 if (is_optimizing()) { 1136 if (is_optimizing()) {
1137 AddDeoptIndexAtCall(deopt_id_after, token_pos); 1137 AddDeoptIndexAtCall(deopt_id_after, token_pos);
1138 } else { 1138 } else {
1139 // Add deoptimization continuation point after the call and before the 1139 // Add deoptimization continuation point after the call and before the
1140 // arguments are removed. 1140 // arguments are removed.
1141 AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); 1141 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos);
1142 } 1142 }
1143 } 1143 }
1144 1144
1145 1145
1146 void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, 1146 void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos,
1147 intptr_t deopt_id, 1147 intptr_t deopt_id,
1148 const RuntimeEntry& entry, 1148 const RuntimeEntry& entry,
1149 intptr_t argument_count, 1149 intptr_t argument_count,
1150 LocationSummary* locs) { 1150 LocationSummary* locs) {
1151 __ CallRuntime(entry, argument_count); 1151 __ CallRuntime(entry, argument_count);
1152 AddCurrentDescriptor(PcDescriptors::kOther, deopt_id, token_pos); 1152 AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id, token_pos);
1153 RecordSafepoint(locs); 1153 RecordSafepoint(locs);
1154 if (deopt_id != Isolate::kNoDeoptId) { 1154 if (deopt_id != Isolate::kNoDeoptId) {
1155 // Marks either the continuation point in unoptimized code or the 1155 // Marks either the continuation point in unoptimized code or the
1156 // deoptimization point in optimized code, after call. 1156 // deoptimization point in optimized code, after call.
1157 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); 1157 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
1158 if (is_optimizing()) { 1158 if (is_optimizing()) {
1159 AddDeoptIndexAtCall(deopt_id_after, token_pos); 1159 AddDeoptIndexAtCall(deopt_id_after, token_pos);
1160 } else { 1160 } else {
1161 // Add deoptimization continuation point after the call and before the 1161 // Add deoptimization continuation point after the call and before the
1162 // arguments are removed. 1162 // arguments are removed.
1163 AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); 1163 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos);
1164 } 1164 }
1165 } 1165 }
1166 } 1166 }
1167 1167
1168 1168
1169 void FlowGraphCompiler::EmitEdgeCounter() { 1169 void FlowGraphCompiler::EmitEdgeCounter() {
1170 // We do not check for overflow when incrementing the edge counter. The 1170 // We do not check for overflow when incrementing the edge counter. The
1171 // function should normally be optimized long before the counter can 1171 // function should normally be optimized long before the counter can
1172 // overflow; and though we do not reset the counters when we optimize or 1172 // overflow; and though we do not reset the counters when we optimize or
1173 // deoptimize, there is a bound on the number of 1173 // deoptimize, there is a bound on the number of
(...skipping 21 matching lines...) Expand all
1195 // to inlining in optimized code, that function may not correspond to the 1195 // to inlining in optimized code, that function may not correspond to the
1196 // top-level function (parsed_function().function()) which could be 1196 // top-level function (parsed_function().function()) which could be
1197 // reoptimized and which counter needs to be incremented. 1197 // reoptimized and which counter needs to be incremented.
1198 // Pass the function explicitly, it is used in IC stub. 1198 // Pass the function explicitly, it is used in IC stub.
1199 1199
1200 __ LoadObject(R6, parsed_function().function(), PP); 1200 __ LoadObject(R6, parsed_function().function(), PP);
1201 __ LoadObject(R5, ic_data, PP); 1201 __ LoadObject(R5, ic_data, PP);
1202 GenerateDartCall(deopt_id, 1202 GenerateDartCall(deopt_id,
1203 token_pos, 1203 token_pos,
1204 target_label, 1204 target_label,
1205 PcDescriptors::kIcCall, 1205 RawPcDescriptors::kIcCall,
1206 locs); 1206 locs);
1207 __ Drop(argument_count); 1207 __ Drop(argument_count);
1208 } 1208 }
1209 1209
1210 1210
1211 void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label, 1211 void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label,
1212 const ICData& ic_data, 1212 const ICData& ic_data,
1213 intptr_t argument_count, 1213 intptr_t argument_count,
1214 intptr_t deopt_id, 1214 intptr_t deopt_id,
1215 intptr_t token_pos, 1215 intptr_t token_pos,
1216 LocationSummary* locs) { 1216 LocationSummary* locs) {
1217 ASSERT(Array::Handle(ic_data.arguments_descriptor()).Length() > 0); 1217 ASSERT(Array::Handle(ic_data.arguments_descriptor()).Length() > 0);
1218 __ LoadImmediate(R4, 0, kNoPP); 1218 __ LoadImmediate(R4, 0, kNoPP);
1219 __ LoadObject(R5, ic_data, PP); 1219 __ LoadObject(R5, ic_data, PP);
1220 GenerateDartCall(deopt_id, 1220 GenerateDartCall(deopt_id,
1221 token_pos, 1221 token_pos,
1222 target_label, 1222 target_label,
1223 PcDescriptors::kIcCall, 1223 RawPcDescriptors::kIcCall,
1224 locs); 1224 locs);
1225 __ Drop(argument_count); 1225 __ Drop(argument_count);
1226 #if defined(DEBUG) 1226 #if defined(DEBUG)
1227 __ LoadImmediate(R4, kInvalidObjectPointer, kNoPP); 1227 __ LoadImmediate(R4, kInvalidObjectPointer, kNoPP);
1228 #endif 1228 #endif
1229 } 1229 }
1230 1230
1231 1231
1232 void FlowGraphCompiler::EmitMegamorphicInstanceCall( 1232 void FlowGraphCompiler::EmitMegamorphicInstanceCall(
1233 const ICData& ic_data, 1233 const ICData& ic_data,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 // proper target for the given name and arguments descriptor. If the 1276 // proper target for the given name and arguments descriptor. If the
1277 // illegal class id was found, the target is a cache miss handler that can 1277 // illegal class id was found, the target is a cache miss handler that can
1278 // be invoked as a normal Dart function. 1278 // be invoked as a normal Dart function.
1279 __ add(TMP, R2, Operand(R3, LSL, 3)); 1279 __ add(TMP, R2, Operand(R3, LSL, 3));
1280 __ LoadFieldFromOffset(R0, TMP, base + kWordSize, PP); 1280 __ LoadFieldFromOffset(R0, TMP, base + kWordSize, PP);
1281 __ LoadFieldFromOffset(R1, R0, Function::instructions_offset(), PP); 1281 __ LoadFieldFromOffset(R1, R0, Function::instructions_offset(), PP);
1282 __ LoadObject(R5, ic_data, PP); 1282 __ LoadObject(R5, ic_data, PP);
1283 __ LoadObject(R4, arguments_descriptor, PP); 1283 __ LoadObject(R4, arguments_descriptor, PP);
1284 __ AddImmediate(R1, R1, Instructions::HeaderSize() - kHeapObjectTag, PP); 1284 __ AddImmediate(R1, R1, Instructions::HeaderSize() - kHeapObjectTag, PP);
1285 __ blr(R1); 1285 __ blr(R1);
1286 AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); 1286 AddCurrentDescriptor(RawPcDescriptors::kOther,
1287 Isolate::kNoDeoptId, token_pos);
1287 RecordSafepoint(locs); 1288 RecordSafepoint(locs);
1288 AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); 1289 AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos);
1289 __ Drop(argument_count); 1290 __ Drop(argument_count);
1290 } 1291 }
1291 1292
1292 1293
1293 void FlowGraphCompiler::EmitUnoptimizedStaticCall( 1294 void FlowGraphCompiler::EmitUnoptimizedStaticCall(
1294 intptr_t argument_count, 1295 intptr_t argument_count,
1295 intptr_t deopt_id, 1296 intptr_t deopt_id,
1296 intptr_t token_pos, 1297 intptr_t token_pos,
1297 LocationSummary* locs, 1298 LocationSummary* locs,
1298 const ICData& ic_data) { 1299 const ICData& ic_data) {
1299 uword label_address = 0; 1300 uword label_address = 0;
1300 if (ic_data.NumArgsTested() == 0) { 1301 if (ic_data.NumArgsTested() == 0) {
1301 label_address = StubCode::ZeroArgsUnoptimizedStaticCallEntryPoint(); 1302 label_address = StubCode::ZeroArgsUnoptimizedStaticCallEntryPoint();
1302 } else if (ic_data.NumArgsTested() == 2) { 1303 } else if (ic_data.NumArgsTested() == 2) {
1303 label_address = StubCode::TwoArgsUnoptimizedStaticCallEntryPoint(); 1304 label_address = StubCode::TwoArgsUnoptimizedStaticCallEntryPoint();
1304 } else { 1305 } else {
1305 UNIMPLEMENTED(); 1306 UNIMPLEMENTED();
1306 } 1307 }
1307 ExternalLabel target_label(label_address); 1308 ExternalLabel target_label(label_address);
1308 __ LoadImmediate(R4, 0, kNoPP); 1309 __ LoadImmediate(R4, 0, kNoPP);
1309 __ LoadObject(R5, ic_data, PP); 1310 __ LoadObject(R5, ic_data, PP);
1310 GenerateDartCall(deopt_id, 1311 GenerateDartCall(deopt_id,
1311 token_pos, 1312 token_pos,
1312 &target_label, 1313 &target_label,
1313 PcDescriptors::kUnoptStaticCall, 1314 RawPcDescriptors::kUnoptStaticCall,
1314 locs); 1315 locs);
1315 #if defined(DEBUG) 1316 #if defined(DEBUG)
1316 __ LoadImmediate(R5, kInvalidObjectPointer, kNoPP); 1317 __ LoadImmediate(R5, kInvalidObjectPointer, kNoPP);
1317 #endif 1318 #endif
1318 __ Drop(argument_count); 1319 __ Drop(argument_count);
1319 } 1320 }
1320 1321
1321 1322
1322 void FlowGraphCompiler::EmitOptimizedStaticCall( 1323 void FlowGraphCompiler::EmitOptimizedStaticCall(
1323 const Function& function, 1324 const Function& function,
1324 const Array& arguments_descriptor, 1325 const Array& arguments_descriptor,
1325 intptr_t argument_count, 1326 intptr_t argument_count,
1326 intptr_t deopt_id, 1327 intptr_t deopt_id,
1327 intptr_t token_pos, 1328 intptr_t token_pos,
1328 LocationSummary* locs) { 1329 LocationSummary* locs) {
1329 __ LoadObject(R4, arguments_descriptor, PP); 1330 __ LoadObject(R4, arguments_descriptor, PP);
1330 // Do not use the code from the function, but let the code be patched so that 1331 // Do not use the code from the function, but let the code be patched so that
1331 // we can record the outgoing edges to other code. 1332 // we can record the outgoing edges to other code.
1332 GenerateDartCall(deopt_id, 1333 GenerateDartCall(deopt_id,
1333 token_pos, 1334 token_pos,
1334 &StubCode::CallStaticFunctionLabel(), 1335 &StubCode::CallStaticFunctionLabel(),
1335 PcDescriptors::kOptStaticCall, 1336 RawPcDescriptors::kOptStaticCall,
1336 locs); 1337 locs);
1337 AddStaticCallTarget(function); 1338 AddStaticCallTarget(function);
1338 __ Drop(argument_count); 1339 __ Drop(argument_count);
1339 } 1340 }
1340 1341
1341 1342
1342 void FlowGraphCompiler::EmitEqualityRegConstCompare(Register reg, 1343 void FlowGraphCompiler::EmitEqualityRegConstCompare(Register reg,
1343 const Object& obj, 1344 const Object& obj,
1344 bool needs_number_check, 1345 bool needs_number_check,
1345 intptr_t token_pos) { 1346 intptr_t token_pos) {
1346 if (needs_number_check) { 1347 if (needs_number_check) {
1347 ASSERT(!obj.IsMint() && !obj.IsDouble() && !obj.IsBigint()); 1348 ASSERT(!obj.IsMint() && !obj.IsDouble() && !obj.IsBigint());
1348 __ Push(reg); 1349 __ Push(reg);
1349 __ PushObject(obj, PP); 1350 __ PushObject(obj, PP);
1350 if (is_optimizing()) { 1351 if (is_optimizing()) {
1351 __ BranchLinkPatchable( 1352 __ BranchLinkPatchable(
1352 &StubCode::OptimizedIdenticalWithNumberCheckLabel()); 1353 &StubCode::OptimizedIdenticalWithNumberCheckLabel());
1353 } else { 1354 } else {
1354 __ BranchLinkPatchable( 1355 __ BranchLinkPatchable(
1355 &StubCode::UnoptimizedIdenticalWithNumberCheckLabel()); 1356 &StubCode::UnoptimizedIdenticalWithNumberCheckLabel());
1356 } 1357 }
1357 if (token_pos != Scanner::kNoSourcePos) { 1358 if (token_pos != Scanner::kNoSourcePos) {
1358 AddCurrentDescriptor(PcDescriptors::kRuntimeCall, 1359 AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall,
1359 Isolate::kNoDeoptId, 1360 Isolate::kNoDeoptId,
1360 token_pos); 1361 token_pos);
1361 } 1362 }
1362 __ Drop(1); // Discard constant. 1363 __ Drop(1); // Discard constant.
1363 __ Pop(reg); // Restore 'reg'. 1364 __ Pop(reg); // Restore 'reg'.
1364 return; 1365 return;
1365 } 1366 }
1366 1367
1367 __ CompareObject(reg, obj, PP); 1368 __ CompareObject(reg, obj, PP);
1368 } 1369 }
1369 1370
1370 1371
1371 void FlowGraphCompiler::EmitEqualityRegRegCompare(Register left, 1372 void FlowGraphCompiler::EmitEqualityRegRegCompare(Register left,
1372 Register right, 1373 Register right,
1373 bool needs_number_check, 1374 bool needs_number_check,
1374 intptr_t token_pos) { 1375 intptr_t token_pos) {
1375 if (needs_number_check) { 1376 if (needs_number_check) {
1376 __ Push(left); 1377 __ Push(left);
1377 __ Push(right); 1378 __ Push(right);
1378 if (is_optimizing()) { 1379 if (is_optimizing()) {
1379 __ BranchLinkPatchable( 1380 __ BranchLinkPatchable(
1380 &StubCode::OptimizedIdenticalWithNumberCheckLabel()); 1381 &StubCode::OptimizedIdenticalWithNumberCheckLabel());
1381 } else { 1382 } else {
1382 __ LoadImmediate(R4, 0, kNoPP); 1383 __ LoadImmediate(R4, 0, kNoPP);
1383 __ LoadImmediate(R5, 0, kNoPP); 1384 __ LoadImmediate(R5, 0, kNoPP);
1384 __ BranchLinkPatchable( 1385 __ BranchLinkPatchable(
1385 &StubCode::UnoptimizedIdenticalWithNumberCheckLabel()); 1386 &StubCode::UnoptimizedIdenticalWithNumberCheckLabel());
1386 } 1387 }
1387 if (token_pos != Scanner::kNoSourcePos) { 1388 if (token_pos != Scanner::kNoSourcePos) {
1388 AddCurrentDescriptor(PcDescriptors::kRuntimeCall, 1389 AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall,
1389 Isolate::kNoDeoptId, 1390 Isolate::kNoDeoptId,
1390 token_pos); 1391 token_pos);
1391 } 1392 }
1392 #if defined(DEBUG) 1393 #if defined(DEBUG)
1393 if (!is_optimizing()) { 1394 if (!is_optimizing()) {
1394 // Do this *after* adding the pc descriptor! 1395 // Do this *after* adding the pc descriptor!
1395 __ LoadImmediate(R4, kInvalidObjectPointer, kNoPP); 1396 __ LoadImmediate(R4, kInvalidObjectPointer, kNoPP);
1396 __ LoadImmediate(R5, kInvalidObjectPointer, kNoPP); 1397 __ LoadImmediate(R5, kInvalidObjectPointer, kNoPP);
1397 } 1398 }
1398 #endif 1399 #endif
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 if (is_last_check) { 1484 if (is_last_check) {
1484 __ b(deopt, NE); 1485 __ b(deopt, NE);
1485 } else { 1486 } else {
1486 __ b(&next_test, NE); 1487 __ b(&next_test, NE);
1487 } 1488 }
1488 // Do not use the code from the function, but let the code be patched so 1489 // Do not use the code from the function, but let the code be patched so
1489 // that we can record the outgoing edges to other code. 1490 // that we can record the outgoing edges to other code.
1490 GenerateDartCall(deopt_id, 1491 GenerateDartCall(deopt_id,
1491 token_index, 1492 token_index,
1492 &StubCode::CallStaticFunctionLabel(), 1493 &StubCode::CallStaticFunctionLabel(),
1493 PcDescriptors::kOptStaticCall, 1494 RawPcDescriptors::kOptStaticCall,
1494 locs); 1495 locs);
1495 const Function& function = *sorted[i].target; 1496 const Function& function = *sorted[i].target;
1496 AddStaticCallTarget(function); 1497 AddStaticCallTarget(function);
1497 __ Drop(argument_count); 1498 __ Drop(argument_count);
1498 if (!is_last_check) { 1499 if (!is_last_check) {
1499 __ b(&match_found); 1500 __ b(&match_found);
1500 } 1501 }
1501 __ Bind(&next_test); 1502 __ Bind(&next_test);
1502 } 1503 }
1503 __ Bind(&match_found); 1504 __ Bind(&match_found);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { 1727 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) {
1727 UNIMPLEMENTED(); 1728 UNIMPLEMENTED();
1728 } 1729 }
1729 1730
1730 1731
1731 #undef __ 1732 #undef __
1732 1733
1733 } // namespace dart 1734 } // namespace dart
1734 1735
1735 #endif // defined TARGET_ARCH_ARM64 1736 #endif // defined TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698