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

Side by Side Diff: runtime/vm/flow_graph_compiler_ia32.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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
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 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 1108
1109 if (is_optimizing()) { 1109 if (is_optimizing()) {
1110 lazy_deopt_pc_offset_ = assembler()->CodeSize(); 1110 lazy_deopt_pc_offset_ = assembler()->CodeSize();
1111 __ jmp(&StubCode::DeoptimizeLazyLabel()); 1111 __ jmp(&StubCode::DeoptimizeLazyLabel());
1112 } 1112 }
1113 } 1113 }
1114 1114
1115 1115
1116 void FlowGraphCompiler::GenerateCall(intptr_t token_pos, 1116 void FlowGraphCompiler::GenerateCall(intptr_t token_pos,
1117 const ExternalLabel* label, 1117 const ExternalLabel* label,
1118 PcDescriptors::Kind kind, 1118 RawPcDescriptors::Kind kind,
1119 LocationSummary* locs) { 1119 LocationSummary* locs) {
1120 __ call(label); 1120 __ call(label);
1121 AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos); 1121 AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos);
1122 RecordSafepoint(locs); 1122 RecordSafepoint(locs);
1123 } 1123 }
1124 1124
1125 1125
1126 void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, 1126 void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id,
1127 intptr_t token_pos, 1127 intptr_t token_pos,
1128 const ExternalLabel* label, 1128 const ExternalLabel* label,
1129 PcDescriptors::Kind kind, 1129 RawPcDescriptors::Kind kind,
1130 LocationSummary* locs) { 1130 LocationSummary* locs) {
1131 __ call(label); 1131 __ call(label);
1132 AddCurrentDescriptor(kind, deopt_id, token_pos); 1132 AddCurrentDescriptor(kind, deopt_id, token_pos);
1133 RecordSafepoint(locs); 1133 RecordSafepoint(locs);
1134 // Marks either the continuation point in unoptimized code or the 1134 // Marks either the continuation point in unoptimized code or the
1135 // deoptimization point in optimized code, after call. 1135 // deoptimization point in optimized code, after call.
1136 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); 1136 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
1137 if (is_optimizing()) { 1137 if (is_optimizing()) {
1138 AddDeoptIndexAtCall(deopt_id_after, token_pos); 1138 AddDeoptIndexAtCall(deopt_id_after, token_pos);
1139 } else { 1139 } else {
1140 // Add deoptimization continuation point after the call and before the 1140 // Add deoptimization continuation point after the call and before the
1141 // arguments are removed. 1141 // arguments are removed.
1142 AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); 1142 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos);
1143 } 1143 }
1144 } 1144 }
1145 1145
1146 1146
1147 void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, 1147 void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos,
1148 intptr_t deopt_id, 1148 intptr_t deopt_id,
1149 const RuntimeEntry& entry, 1149 const RuntimeEntry& entry,
1150 intptr_t argument_count, 1150 intptr_t argument_count,
1151 LocationSummary* locs) { 1151 LocationSummary* locs) {
1152 __ CallRuntime(entry, argument_count); 1152 __ CallRuntime(entry, argument_count);
1153 AddCurrentDescriptor(PcDescriptors::kOther, deopt_id, token_pos); 1153 AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id, token_pos);
1154 RecordSafepoint(locs); 1154 RecordSafepoint(locs);
1155 if (deopt_id != Isolate::kNoDeoptId) { 1155 if (deopt_id != Isolate::kNoDeoptId) {
1156 // Marks either the continuation point in unoptimized code or the 1156 // Marks either the continuation point in unoptimized code or the
1157 // deoptimization point in optimized code, after call. 1157 // deoptimization point in optimized code, after call.
1158 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); 1158 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
1159 if (is_optimizing()) { 1159 if (is_optimizing()) {
1160 AddDeoptIndexAtCall(deopt_id_after, token_pos); 1160 AddDeoptIndexAtCall(deopt_id_after, token_pos);
1161 } else { 1161 } else {
1162 // Add deoptimization continuation point after the call and before the 1162 // Add deoptimization continuation point after the call and before the
1163 // arguments are removed. 1163 // arguments are removed.
1164 AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); 1164 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos);
1165 } 1165 }
1166 } 1166 }
1167 } 1167 }
1168 1168
1169 1169
1170 void FlowGraphCompiler::EmitUnoptimizedStaticCall( 1170 void FlowGraphCompiler::EmitUnoptimizedStaticCall(
1171 intptr_t argument_count, 1171 intptr_t argument_count,
1172 intptr_t deopt_id, 1172 intptr_t deopt_id,
1173 intptr_t token_pos, 1173 intptr_t token_pos,
1174 LocationSummary* locs, 1174 LocationSummary* locs,
1175 const ICData& ic_data) { 1175 const ICData& ic_data) {
1176 uword label_address = 0; 1176 uword label_address = 0;
1177 if (ic_data.NumArgsTested() == 0) { 1177 if (ic_data.NumArgsTested() == 0) {
1178 label_address = StubCode::ZeroArgsUnoptimizedStaticCallEntryPoint(); 1178 label_address = StubCode::ZeroArgsUnoptimizedStaticCallEntryPoint();
1179 } else if (ic_data.NumArgsTested() == 2) { 1179 } else if (ic_data.NumArgsTested() == 2) {
1180 label_address = StubCode::TwoArgsUnoptimizedStaticCallEntryPoint(); 1180 label_address = StubCode::TwoArgsUnoptimizedStaticCallEntryPoint();
1181 } else { 1181 } else {
1182 UNIMPLEMENTED(); 1182 UNIMPLEMENTED();
1183 } 1183 }
1184 ExternalLabel target_label(label_address); 1184 ExternalLabel target_label(label_address);
1185 __ movl(EDX, Immediate(0)); 1185 __ movl(EDX, Immediate(0));
1186 __ LoadObject(ECX, ic_data); 1186 __ LoadObject(ECX, ic_data);
1187 GenerateDartCall(deopt_id, 1187 GenerateDartCall(deopt_id,
1188 token_pos, 1188 token_pos,
1189 &target_label, 1189 &target_label,
1190 PcDescriptors::kUnoptStaticCall, 1190 RawPcDescriptors::kUnoptStaticCall,
1191 locs); 1191 locs);
1192 __ Drop(argument_count); 1192 __ Drop(argument_count);
1193 #if defined(DEBUG) 1193 #if defined(DEBUG)
1194 __ movl(EDX, Immediate(kInvalidObjectPointer)); 1194 __ movl(EDX, Immediate(kInvalidObjectPointer));
1195 #endif 1195 #endif
1196 } 1196 }
1197 1197
1198 1198
1199 void FlowGraphCompiler::EmitEdgeCounter() { 1199 void FlowGraphCompiler::EmitEdgeCounter() {
1200 // We do not check for overflow when incrementing the edge counter. The 1200 // We do not check for overflow when incrementing the edge counter. The
(...skipping 22 matching lines...) Expand all
1223 // function that corresponds to the Dart function of that IC call. Due 1223 // function that corresponds to the Dart function of that IC call. Due
1224 // to inlining in optimized code, that function may not correspond to the 1224 // to inlining in optimized code, that function may not correspond to the
1225 // top-level function (parsed_function().function()) which could be 1225 // top-level function (parsed_function().function()) which could be
1226 // reoptimized and which counter needs to be incremented. 1226 // reoptimized and which counter needs to be incremented.
1227 // Pass the function explicitly, it is used in IC stub. 1227 // Pass the function explicitly, it is used in IC stub.
1228 __ LoadObject(EDI, parsed_function().function()); 1228 __ LoadObject(EDI, parsed_function().function());
1229 __ LoadObject(ECX, ic_data); 1229 __ LoadObject(ECX, ic_data);
1230 GenerateDartCall(deopt_id, 1230 GenerateDartCall(deopt_id,
1231 token_pos, 1231 token_pos,
1232 target_label, 1232 target_label,
1233 PcDescriptors::kIcCall, 1233 RawPcDescriptors::kIcCall,
1234 locs); 1234 locs);
1235 __ Drop(argument_count); 1235 __ Drop(argument_count);
1236 } 1236 }
1237 1237
1238 1238
1239 void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label, 1239 void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label,
1240 const ICData& ic_data, 1240 const ICData& ic_data,
1241 intptr_t argument_count, 1241 intptr_t argument_count,
1242 intptr_t deopt_id, 1242 intptr_t deopt_id,
1243 intptr_t token_pos, 1243 intptr_t token_pos,
1244 LocationSummary* locs) { 1244 LocationSummary* locs) {
1245 ASSERT(Array::Handle(ic_data.arguments_descriptor()).Length() > 0); 1245 ASSERT(Array::Handle(ic_data.arguments_descriptor()).Length() > 0);
1246 __ movl(EDX, Immediate(0)); 1246 __ movl(EDX, Immediate(0));
1247 __ LoadObject(ECX, ic_data); 1247 __ LoadObject(ECX, ic_data);
1248 GenerateDartCall(deopt_id, 1248 GenerateDartCall(deopt_id,
1249 token_pos, 1249 token_pos,
1250 target_label, 1250 target_label,
1251 PcDescriptors::kIcCall, 1251 RawPcDescriptors::kIcCall,
1252 locs); 1252 locs);
1253 __ Drop(argument_count); 1253 __ Drop(argument_count);
1254 #if defined(DEBUG) 1254 #if defined(DEBUG)
1255 __ movl(EDX, Immediate(kInvalidObjectPointer)); 1255 __ movl(EDX, Immediate(kInvalidObjectPointer));
1256 #endif 1256 #endif
1257 } 1257 }
1258 1258
1259 1259
1260 void FlowGraphCompiler::EmitMegamorphicInstanceCall( 1260 void FlowGraphCompiler::EmitMegamorphicInstanceCall(
1261 const ICData& ic_data, 1261 const ICData& ic_data,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 // Call the target found in the cache. For a class id match, this is a 1304 // Call the target found in the cache. For a class id match, this is a
1305 // proper target for the given name and arguments descriptor. If the 1305 // proper target for the given name and arguments descriptor. If the
1306 // illegal class id was found, the target is a cache miss handler that can 1306 // illegal class id was found, the target is a cache miss handler that can
1307 // be invoked as a normal Dart function. 1307 // be invoked as a normal Dart function.
1308 __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize)); 1308 __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize));
1309 __ movl(EBX, FieldAddress(EAX, Function::instructions_offset())); 1309 __ movl(EBX, FieldAddress(EAX, Function::instructions_offset()));
1310 __ LoadObject(ECX, ic_data); 1310 __ LoadObject(ECX, ic_data);
1311 __ LoadObject(EDX, arguments_descriptor); 1311 __ LoadObject(EDX, arguments_descriptor);
1312 __ addl(EBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); 1312 __ addl(EBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
1313 __ call(EBX); 1313 __ call(EBX);
1314 AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); 1314 AddCurrentDescriptor(RawPcDescriptors::kOther,
1315 Isolate::kNoDeoptId, token_pos);
1315 RecordSafepoint(locs); 1316 RecordSafepoint(locs);
1316 AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); 1317 AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos);
1317 __ Drop(argument_count); 1318 __ Drop(argument_count);
1318 } 1319 }
1319 1320
1320 1321
1321 void FlowGraphCompiler::EmitOptimizedStaticCall( 1322 void FlowGraphCompiler::EmitOptimizedStaticCall(
1322 const Function& function, 1323 const Function& function,
1323 const Array& arguments_descriptor, 1324 const Array& arguments_descriptor,
1324 intptr_t argument_count, 1325 intptr_t argument_count,
1325 intptr_t deopt_id, 1326 intptr_t deopt_id,
1326 intptr_t token_pos, 1327 intptr_t token_pos,
1327 LocationSummary* locs) { 1328 LocationSummary* locs) {
1328 __ LoadObject(EDX, arguments_descriptor); 1329 __ LoadObject(EDX, arguments_descriptor);
1329 // Do not use the code from the function, but let the code be patched so that 1330 // Do not use the code from the function, but let the code be patched so that
1330 // we can record the outgoing edges to other code. 1331 // we can record the outgoing edges to other code.
1331 GenerateDartCall(deopt_id, 1332 GenerateDartCall(deopt_id,
1332 token_pos, 1333 token_pos,
1333 &StubCode::CallStaticFunctionLabel(), 1334 &StubCode::CallStaticFunctionLabel(),
1334 PcDescriptors::kOptStaticCall, 1335 RawPcDescriptors::kOptStaticCall,
1335 locs); 1336 locs);
1336 AddStaticCallTarget(function); 1337 AddStaticCallTarget(function);
1337 __ Drop(argument_count); 1338 __ Drop(argument_count);
1338 } 1339 }
1339 1340
1340 1341
1341 void FlowGraphCompiler::EmitEqualityRegConstCompare(Register reg, 1342 void FlowGraphCompiler::EmitEqualityRegConstCompare(Register reg,
1342 const Object& obj, 1343 const Object& obj,
1343 bool needs_number_check, 1344 bool needs_number_check,
1344 intptr_t token_pos) { 1345 intptr_t token_pos) {
1345 ASSERT(!needs_number_check || 1346 ASSERT(!needs_number_check ||
1346 (!obj.IsMint() && !obj.IsDouble() && !obj.IsBigint())); 1347 (!obj.IsMint() && !obj.IsDouble() && !obj.IsBigint()));
1347 1348
1348 if (obj.IsSmi() && (Smi::Cast(obj).Value() == 0)) { 1349 if (obj.IsSmi() && (Smi::Cast(obj).Value() == 0)) {
1349 ASSERT(!needs_number_check); 1350 ASSERT(!needs_number_check);
1350 __ testl(reg, reg); 1351 __ testl(reg, reg);
1351 return; 1352 return;
1352 } 1353 }
1353 1354
1354 if (needs_number_check) { 1355 if (needs_number_check) {
1355 __ pushl(reg); 1356 __ pushl(reg);
1356 __ PushObject(obj); 1357 __ PushObject(obj);
1357 if (is_optimizing()) { 1358 if (is_optimizing()) {
1358 __ call(&StubCode::OptimizedIdenticalWithNumberCheckLabel()); 1359 __ call(&StubCode::OptimizedIdenticalWithNumberCheckLabel());
1359 } else { 1360 } else {
1360 __ call(&StubCode::UnoptimizedIdenticalWithNumberCheckLabel()); 1361 __ call(&StubCode::UnoptimizedIdenticalWithNumberCheckLabel());
1361 } 1362 }
1362 if (token_pos != Scanner::kNoSourcePos) { 1363 if (token_pos != Scanner::kNoSourcePos) {
1363 AddCurrentDescriptor(PcDescriptors::kRuntimeCall, 1364 AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall,
1364 Isolate::kNoDeoptId, 1365 Isolate::kNoDeoptId,
1365 token_pos); 1366 token_pos);
1366 } 1367 }
1367 __ popl(reg); // Discard constant. 1368 __ popl(reg); // Discard constant.
1368 __ popl(reg); // Restore 'reg'. 1369 __ popl(reg); // Restore 'reg'.
1369 return; 1370 return;
1370 } 1371 }
1371 1372
1372 __ CompareObject(reg, obj); 1373 __ CompareObject(reg, obj);
1373 } 1374 }
1374 1375
1375 1376
1376 void FlowGraphCompiler::EmitEqualityRegRegCompare(Register left, 1377 void FlowGraphCompiler::EmitEqualityRegRegCompare(Register left,
1377 Register right, 1378 Register right,
1378 bool needs_number_check, 1379 bool needs_number_check,
1379 intptr_t token_pos) { 1380 intptr_t token_pos) {
1380 if (needs_number_check) { 1381 if (needs_number_check) {
1381 __ pushl(left); 1382 __ pushl(left);
1382 __ pushl(right); 1383 __ pushl(right);
1383 if (is_optimizing()) { 1384 if (is_optimizing()) {
1384 __ call(&StubCode::OptimizedIdenticalWithNumberCheckLabel()); 1385 __ call(&StubCode::OptimizedIdenticalWithNumberCheckLabel());
1385 } else { 1386 } else {
1386 __ movl(EDX, Immediate(0)); 1387 __ movl(EDX, Immediate(0));
1387 __ movl(ECX, Immediate(0)); 1388 __ movl(ECX, Immediate(0));
1388 __ call(&StubCode::UnoptimizedIdenticalWithNumberCheckLabel()); 1389 __ call(&StubCode::UnoptimizedIdenticalWithNumberCheckLabel());
1389 } 1390 }
1390 if (token_pos != Scanner::kNoSourcePos) { 1391 if (token_pos != Scanner::kNoSourcePos) {
1391 AddCurrentDescriptor(PcDescriptors::kRuntimeCall, 1392 AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall,
1392 Isolate::kNoDeoptId, 1393 Isolate::kNoDeoptId,
1393 token_pos); 1394 token_pos);
1394 } 1395 }
1395 #if defined(DEBUG) 1396 #if defined(DEBUG)
1396 if (!is_optimizing()) { 1397 if (!is_optimizing()) {
1397 // Do this *after* adding the pc descriptor! 1398 // Do this *after* adding the pc descriptor!
1398 __ movl(EDX, Immediate(kInvalidObjectPointer)); 1399 __ movl(EDX, Immediate(kInvalidObjectPointer));
1399 __ movl(ECX, Immediate(kInvalidObjectPointer)); 1400 __ movl(ECX, Immediate(kInvalidObjectPointer));
1400 } 1401 }
1401 #endif 1402 #endif
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 if (is_last_check) { 1494 if (is_last_check) {
1494 assembler()->j(NOT_EQUAL, deopt); 1495 assembler()->j(NOT_EQUAL, deopt);
1495 } else { 1496 } else {
1496 assembler()->j(NOT_EQUAL, &next_test); 1497 assembler()->j(NOT_EQUAL, &next_test);
1497 } 1498 }
1498 // Do not use the code from the function, but let the code be patched so 1499 // Do not use the code from the function, but let the code be patched so
1499 // that we can record the outgoing edges to other code. 1500 // that we can record the outgoing edges to other code.
1500 GenerateDartCall(deopt_id, 1501 GenerateDartCall(deopt_id,
1501 token_index, 1502 token_index,
1502 &StubCode::CallStaticFunctionLabel(), 1503 &StubCode::CallStaticFunctionLabel(),
1503 PcDescriptors::kOptStaticCall, 1504 RawPcDescriptors::kOptStaticCall,
1504 locs); 1505 locs);
1505 const Function& function = *sorted[i].target; 1506 const Function& function = *sorted[i].target;
1506 AddStaticCallTarget(function); 1507 AddStaticCallTarget(function);
1507 __ Drop(argument_count); 1508 __ Drop(argument_count);
1508 if (!is_last_check) { 1509 if (!is_last_check) {
1509 assembler()->jmp(&match_found); 1510 assembler()->jmp(&match_found);
1510 } 1511 }
1511 assembler()->Bind(&next_test); 1512 assembler()->Bind(&next_test);
1512 } 1513 }
1513 assembler()->Bind(&match_found); 1514 assembler()->Bind(&match_found);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 __ movups(reg, Address(ESP, 0)); 1757 __ movups(reg, Address(ESP, 0));
1757 __ addl(ESP, Immediate(kFpuRegisterSize)); 1758 __ addl(ESP, Immediate(kFpuRegisterSize));
1758 } 1759 }
1759 1760
1760 1761
1761 #undef __ 1762 #undef __
1762 1763
1763 } // namespace dart 1764 } // namespace dart
1764 1765
1765 #endif // defined TARGET_ARCH_IA32 1766 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698