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

Side by Side Diff: runtime/vm/flow_graph_compiler_x64.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) 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" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
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 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 1145
1146 if (is_optimizing()) { 1146 if (is_optimizing()) {
1147 lazy_deopt_pc_offset_ = assembler()->CodeSize(); 1147 lazy_deopt_pc_offset_ = assembler()->CodeSize();
1148 __ Jmp(&StubCode::DeoptimizeLazyLabel(), PP); 1148 __ Jmp(&StubCode::DeoptimizeLazyLabel(), PP);
1149 } 1149 }
1150 } 1150 }
1151 1151
1152 1152
1153 void FlowGraphCompiler::GenerateCall(intptr_t token_pos, 1153 void FlowGraphCompiler::GenerateCall(intptr_t token_pos,
1154 const ExternalLabel* label, 1154 const ExternalLabel* label,
1155 PcDescriptors::Kind kind, 1155 RawPcDescriptors::Kind kind,
1156 LocationSummary* locs) { 1156 LocationSummary* locs) {
1157 __ Call(label, PP); 1157 __ Call(label, PP);
1158 AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos); 1158 AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos);
1159 RecordSafepoint(locs); 1159 RecordSafepoint(locs);
1160 } 1160 }
1161 1161
1162 1162
1163 void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, 1163 void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id,
1164 intptr_t token_pos, 1164 intptr_t token_pos,
1165 const ExternalLabel* label, 1165 const ExternalLabel* label,
1166 PcDescriptors::Kind kind, 1166 RawPcDescriptors::Kind kind,
1167 LocationSummary* locs) { 1167 LocationSummary* locs) {
1168 __ CallPatchable(label); 1168 __ CallPatchable(label);
1169 AddCurrentDescriptor(kind, deopt_id, token_pos); 1169 AddCurrentDescriptor(kind, deopt_id, token_pos);
1170 RecordSafepoint(locs); 1170 RecordSafepoint(locs);
1171 // Marks either the continuation point in unoptimized code or the 1171 // Marks either the continuation point in unoptimized code or the
1172 // deoptimization point in optimized code, after call. 1172 // deoptimization point in optimized code, after call.
1173 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); 1173 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
1174 if (is_optimizing()) { 1174 if (is_optimizing()) {
1175 AddDeoptIndexAtCall(deopt_id_after, token_pos); 1175 AddDeoptIndexAtCall(deopt_id_after, token_pos);
1176 } else { 1176 } else {
1177 // Add deoptimization continuation point after the call and before the 1177 // Add deoptimization continuation point after the call and before the
1178 // arguments are removed. 1178 // arguments are removed.
1179 AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); 1179 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos);
1180 } 1180 }
1181 } 1181 }
1182 1182
1183 1183
1184 void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, 1184 void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos,
1185 intptr_t deopt_id, 1185 intptr_t deopt_id,
1186 const RuntimeEntry& entry, 1186 const RuntimeEntry& entry,
1187 intptr_t argument_count, 1187 intptr_t argument_count,
1188 LocationSummary* locs) { 1188 LocationSummary* locs) {
1189 __ CallRuntime(entry, argument_count); 1189 __ CallRuntime(entry, argument_count);
1190 AddCurrentDescriptor(PcDescriptors::kOther, deopt_id, token_pos); 1190 AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id, token_pos);
1191 RecordSafepoint(locs); 1191 RecordSafepoint(locs);
1192 if (deopt_id != Isolate::kNoDeoptId) { 1192 if (deopt_id != Isolate::kNoDeoptId) {
1193 // Marks either the continuation point in unoptimized code or the 1193 // Marks either the continuation point in unoptimized code or the
1194 // deoptimization point in optimized code, after call. 1194 // deoptimization point in optimized code, after call.
1195 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); 1195 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
1196 if (is_optimizing()) { 1196 if (is_optimizing()) {
1197 AddDeoptIndexAtCall(deopt_id_after, token_pos); 1197 AddDeoptIndexAtCall(deopt_id_after, token_pos);
1198 } else { 1198 } else {
1199 // Add deoptimization continuation point after the call and before the 1199 // Add deoptimization continuation point after the call and before the
1200 // arguments are removed. 1200 // arguments are removed.
1201 AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); 1201 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos);
1202 } 1202 }
1203 } 1203 }
1204 } 1204 }
1205 1205
1206 1206
1207 void FlowGraphCompiler::EmitUnoptimizedStaticCall( 1207 void FlowGraphCompiler::EmitUnoptimizedStaticCall(
1208 intptr_t argument_count, 1208 intptr_t argument_count,
1209 intptr_t deopt_id, 1209 intptr_t deopt_id,
1210 intptr_t token_pos, 1210 intptr_t token_pos,
1211 LocationSummary* locs, 1211 LocationSummary* locs,
1212 const ICData& ic_data) { 1212 const ICData& ic_data) {
1213 uword label_address = 0; 1213 uword label_address = 0;
1214 if (ic_data.NumArgsTested() == 0) { 1214 if (ic_data.NumArgsTested() == 0) {
1215 label_address = StubCode::ZeroArgsUnoptimizedStaticCallEntryPoint(); 1215 label_address = StubCode::ZeroArgsUnoptimizedStaticCallEntryPoint();
1216 } else if (ic_data.NumArgsTested() == 2) { 1216 } else if (ic_data.NumArgsTested() == 2) {
1217 label_address = StubCode::TwoArgsUnoptimizedStaticCallEntryPoint(); 1217 label_address = StubCode::TwoArgsUnoptimizedStaticCallEntryPoint();
1218 } else { 1218 } else {
1219 UNIMPLEMENTED(); 1219 UNIMPLEMENTED();
1220 } 1220 }
1221 ExternalLabel target_label(label_address); 1221 ExternalLabel target_label(label_address);
1222 __ movq(R10, Immediate(0)); 1222 __ movq(R10, Immediate(0));
1223 __ LoadObject(RBX, ic_data, PP); 1223 __ LoadObject(RBX, ic_data, PP);
1224 GenerateDartCall(deopt_id, 1224 GenerateDartCall(deopt_id,
1225 token_pos, 1225 token_pos,
1226 &target_label, 1226 &target_label,
1227 PcDescriptors::kUnoptStaticCall, 1227 RawPcDescriptors::kUnoptStaticCall,
1228 locs); 1228 locs);
1229 __ Drop(argument_count); 1229 __ Drop(argument_count);
1230 #if defined(DEBUG) 1230 #if defined(DEBUG)
1231 __ movq(R10, Immediate(kInvalidObjectPointer)); 1231 __ movq(R10, Immediate(kInvalidObjectPointer));
1232 #endif 1232 #endif
1233 } 1233 }
1234 1234
1235 1235
1236 void FlowGraphCompiler::EmitEdgeCounter() { 1236 void FlowGraphCompiler::EmitEdgeCounter() {
1237 // We do not check for overflow when incrementing the edge counter. The 1237 // We do not check for overflow when incrementing the edge counter. The
(...skipping 22 matching lines...) Expand all
1260 // function that corresponds to the Dart function of that IC call. Due 1260 // function that corresponds to the Dart function of that IC call. Due
1261 // to inlining in optimized code, that function may not correspond to the 1261 // to inlining in optimized code, that function may not correspond to the
1262 // top-level function (parsed_function().function()) which could be 1262 // top-level function (parsed_function().function()) which could be
1263 // reoptimized and which counter needs to be incremented. 1263 // reoptimized and which counter needs to be incremented.
1264 // Pass the function explicitly, it is used in IC stub. 1264 // Pass the function explicitly, it is used in IC stub.
1265 __ LoadObject(RDI, parsed_function().function(), PP); 1265 __ LoadObject(RDI, parsed_function().function(), PP);
1266 __ LoadObject(RBX, ic_data, PP); 1266 __ LoadObject(RBX, ic_data, PP);
1267 GenerateDartCall(deopt_id, 1267 GenerateDartCall(deopt_id,
1268 token_pos, 1268 token_pos,
1269 target_label, 1269 target_label,
1270 PcDescriptors::kIcCall, 1270 RawPcDescriptors::kIcCall,
1271 locs); 1271 locs);
1272 __ Drop(argument_count); 1272 __ Drop(argument_count);
1273 } 1273 }
1274 1274
1275 1275
1276 void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label, 1276 void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label,
1277 const ICData& ic_data, 1277 const ICData& ic_data,
1278 intptr_t argument_count, 1278 intptr_t argument_count,
1279 intptr_t deopt_id, 1279 intptr_t deopt_id,
1280 intptr_t token_pos, 1280 intptr_t token_pos,
1281 LocationSummary* locs) { 1281 LocationSummary* locs) {
1282 ASSERT(Array::Handle(ic_data.arguments_descriptor()).Length() > 0); 1282 ASSERT(Array::Handle(ic_data.arguments_descriptor()).Length() > 0);
1283 __ movq(R10, Immediate(0)); 1283 __ movq(R10, Immediate(0));
1284 __ LoadObject(RBX, ic_data, PP); 1284 __ LoadObject(RBX, ic_data, PP);
1285 GenerateDartCall(deopt_id, 1285 GenerateDartCall(deopt_id,
1286 token_pos, 1286 token_pos,
1287 target_label, 1287 target_label,
1288 PcDescriptors::kIcCall, 1288 RawPcDescriptors::kIcCall,
1289 locs); 1289 locs);
1290 __ Drop(argument_count); 1290 __ Drop(argument_count);
1291 #if defined(DEBUG) 1291 #if defined(DEBUG)
1292 __ movq(R10, Immediate(kInvalidObjectPointer)); 1292 __ movq(R10, Immediate(kInvalidObjectPointer));
1293 #endif 1293 #endif
1294 } 1294 }
1295 1295
1296 1296
1297 void FlowGraphCompiler::EmitMegamorphicInstanceCall( 1297 void FlowGraphCompiler::EmitMegamorphicInstanceCall(
1298 const ICData& ic_data, 1298 const ICData& ic_data,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 // proper target for the given name and arguments descriptor. If the 1340 // proper target for the given name and arguments descriptor. If the
1341 // illegal class id was found, the target is a cache miss handler that can 1341 // illegal class id was found, the target is a cache miss handler that can
1342 // be invoked as a normal Dart function. 1342 // be invoked as a normal Dart function.
1343 __ movq(RAX, FieldAddress(RDI, RCX, TIMES_8, base + kWordSize)); 1343 __ movq(RAX, FieldAddress(RDI, RCX, TIMES_8, base + kWordSize));
1344 __ movq(RCX, FieldAddress(RAX, Function::instructions_offset())); 1344 __ movq(RCX, FieldAddress(RAX, Function::instructions_offset()));
1345 __ LoadObject(RBX, ic_data, PP); 1345 __ LoadObject(RBX, ic_data, PP);
1346 __ LoadObject(R10, arguments_descriptor, PP); 1346 __ LoadObject(R10, arguments_descriptor, PP);
1347 __ AddImmediate( 1347 __ AddImmediate(
1348 RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag), PP); 1348 RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag), PP);
1349 __ call(RCX); 1349 __ call(RCX);
1350 AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); 1350 AddCurrentDescriptor(RawPcDescriptors::kOther,
1351 Isolate::kNoDeoptId, token_pos);
1351 RecordSafepoint(locs); 1352 RecordSafepoint(locs);
1352 AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); 1353 AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos);
1353 __ Drop(argument_count); 1354 __ Drop(argument_count);
1354 } 1355 }
1355 1356
1356 1357
1357 void FlowGraphCompiler::EmitOptimizedStaticCall( 1358 void FlowGraphCompiler::EmitOptimizedStaticCall(
1358 const Function& function, 1359 const Function& function,
1359 const Array& arguments_descriptor, 1360 const Array& arguments_descriptor,
1360 intptr_t argument_count, 1361 intptr_t argument_count,
1361 intptr_t deopt_id, 1362 intptr_t deopt_id,
1362 intptr_t token_pos, 1363 intptr_t token_pos,
1363 LocationSummary* locs) { 1364 LocationSummary* locs) {
1364 __ LoadObject(R10, arguments_descriptor, PP); 1365 __ LoadObject(R10, arguments_descriptor, PP);
1365 // Do not use the code from the function, but let the code be patched so that 1366 // Do not use the code from the function, but let the code be patched so that
1366 // we can record the outgoing edges to other code. 1367 // we can record the outgoing edges to other code.
1367 GenerateDartCall(deopt_id, 1368 GenerateDartCall(deopt_id,
1368 token_pos, 1369 token_pos,
1369 &StubCode::CallStaticFunctionLabel(), 1370 &StubCode::CallStaticFunctionLabel(),
1370 PcDescriptors::kOptStaticCall, 1371 RawPcDescriptors::kOptStaticCall,
1371 locs); 1372 locs);
1372 AddStaticCallTarget(function); 1373 AddStaticCallTarget(function);
1373 __ Drop(argument_count); 1374 __ Drop(argument_count);
1374 } 1375 }
1375 1376
1376 1377
1377 void FlowGraphCompiler::EmitEqualityRegConstCompare(Register reg, 1378 void FlowGraphCompiler::EmitEqualityRegConstCompare(Register reg,
1378 const Object& obj, 1379 const Object& obj,
1379 bool needs_number_check, 1380 bool needs_number_check,
1380 intptr_t token_pos) { 1381 intptr_t token_pos) {
1381 ASSERT(!needs_number_check || 1382 ASSERT(!needs_number_check ||
1382 (!obj.IsMint() && !obj.IsDouble() && !obj.IsBigint())); 1383 (!obj.IsMint() && !obj.IsDouble() && !obj.IsBigint()));
1383 1384
1384 if (obj.IsSmi() && (Smi::Cast(obj).Value() == 0)) { 1385 if (obj.IsSmi() && (Smi::Cast(obj).Value() == 0)) {
1385 ASSERT(!needs_number_check); 1386 ASSERT(!needs_number_check);
1386 __ testq(reg, reg); 1387 __ testq(reg, reg);
1387 return; 1388 return;
1388 } 1389 }
1389 1390
1390 if (needs_number_check) { 1391 if (needs_number_check) {
1391 __ pushq(reg); 1392 __ pushq(reg);
1392 __ PushObject(obj, PP); 1393 __ PushObject(obj, PP);
1393 if (is_optimizing()) { 1394 if (is_optimizing()) {
1394 __ CallPatchable(&StubCode::OptimizedIdenticalWithNumberCheckLabel()); 1395 __ CallPatchable(&StubCode::OptimizedIdenticalWithNumberCheckLabel());
1395 } else { 1396 } else {
1396 __ CallPatchable(&StubCode::UnoptimizedIdenticalWithNumberCheckLabel()); 1397 __ CallPatchable(&StubCode::UnoptimizedIdenticalWithNumberCheckLabel());
1397 } 1398 }
1398 if (token_pos != Scanner::kNoSourcePos) { 1399 if (token_pos != Scanner::kNoSourcePos) {
1399 AddCurrentDescriptor(PcDescriptors::kRuntimeCall, 1400 AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall,
1400 Isolate::kNoDeoptId, 1401 Isolate::kNoDeoptId,
1401 token_pos); 1402 token_pos);
1402 } 1403 }
1403 __ popq(reg); // Discard constant. 1404 __ popq(reg); // Discard constant.
1404 __ popq(reg); // Restore 'reg'. 1405 __ popq(reg); // Restore 'reg'.
1405 return; 1406 return;
1406 } 1407 }
1407 1408
1408 __ CompareObject(reg, obj, PP); 1409 __ CompareObject(reg, obj, PP);
1409 } 1410 }
1410 1411
1411 1412
1412 void FlowGraphCompiler::EmitEqualityRegRegCompare(Register left, 1413 void FlowGraphCompiler::EmitEqualityRegRegCompare(Register left,
1413 Register right, 1414 Register right,
1414 bool needs_number_check, 1415 bool needs_number_check,
1415 intptr_t token_pos) { 1416 intptr_t token_pos) {
1416 if (needs_number_check) { 1417 if (needs_number_check) {
1417 __ pushq(left); 1418 __ pushq(left);
1418 __ pushq(right); 1419 __ pushq(right);
1419 if (is_optimizing()) { 1420 if (is_optimizing()) {
1420 __ CallPatchable(&StubCode::OptimizedIdenticalWithNumberCheckLabel()); 1421 __ CallPatchable(&StubCode::OptimizedIdenticalWithNumberCheckLabel());
1421 } else { 1422 } else {
1422 __ movq(R10, Immediate(0)); 1423 __ movq(R10, Immediate(0));
1423 __ movq(RBX, Immediate(0)); 1424 __ movq(RBX, Immediate(0));
1424 __ CallPatchable(&StubCode::UnoptimizedIdenticalWithNumberCheckLabel()); 1425 __ CallPatchable(&StubCode::UnoptimizedIdenticalWithNumberCheckLabel());
1425 } 1426 }
1426 if (token_pos != Scanner::kNoSourcePos) { 1427 if (token_pos != Scanner::kNoSourcePos) {
1427 AddCurrentDescriptor(PcDescriptors::kRuntimeCall, 1428 AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall,
1428 Isolate::kNoDeoptId, 1429 Isolate::kNoDeoptId,
1429 token_pos); 1430 token_pos);
1430 } 1431 }
1431 #if defined(DEBUG) 1432 #if defined(DEBUG)
1432 // Do this *after* adding the pc descriptor! 1433 // Do this *after* adding the pc descriptor!
1433 if (!is_optimizing()) { 1434 if (!is_optimizing()) {
1434 __ movq(R10, Immediate(kInvalidObjectPointer)); 1435 __ movq(R10, Immediate(kInvalidObjectPointer));
1435 __ movq(RBX, Immediate(kInvalidObjectPointer)); 1436 __ movq(RBX, Immediate(kInvalidObjectPointer));
1436 } 1437 }
1437 #endif 1438 #endif
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 if (is_last_check) { 1487 if (is_last_check) {
1487 __ j(NOT_EQUAL, deopt); 1488 __ j(NOT_EQUAL, deopt);
1488 } else { 1489 } else {
1489 __ j(NOT_EQUAL, &next_test); 1490 __ j(NOT_EQUAL, &next_test);
1490 } 1491 }
1491 // Do not use the code from the function, but let the code be patched so 1492 // Do not use the code from the function, but let the code be patched so
1492 // that we can record the outgoing edges to other code. 1493 // that we can record the outgoing edges to other code.
1493 GenerateDartCall(deopt_id, 1494 GenerateDartCall(deopt_id,
1494 token_index, 1495 token_index,
1495 &StubCode::CallStaticFunctionLabel(), 1496 &StubCode::CallStaticFunctionLabel(),
1496 PcDescriptors::kOptStaticCall, 1497 RawPcDescriptors::kOptStaticCall,
1497 locs); 1498 locs);
1498 const Function& function = *sorted[i].target; 1499 const Function& function = *sorted[i].target;
1499 AddStaticCallTarget(function); 1500 AddStaticCallTarget(function);
1500 __ Drop(argument_count); 1501 __ Drop(argument_count);
1501 if (!is_last_check) { 1502 if (!is_last_check) {
1502 __ jmp(&match_found); 1503 __ jmp(&match_found);
1503 } 1504 }
1504 __ Bind(&next_test); 1505 __ Bind(&next_test);
1505 } 1506 }
1506 __ Bind(&match_found); 1507 __ Bind(&match_found);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1717 __ movups(reg, Address(RSP, 0)); 1718 __ movups(reg, Address(RSP, 0));
1718 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); 1719 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP);
1719 } 1720 }
1720 1721
1721 1722
1722 #undef __ 1723 #undef __
1723 1724
1724 } // namespace dart 1725 } // namespace dart
1725 1726
1726 #endif // defined TARGET_ARCH_X64 1727 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698