OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
9 #include "vm/flow_graph_allocator.h" | 9 #include "vm/flow_graph_allocator.h" |
10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 void JoinEntryInstr::PrepareEntry(FlowGraphCompiler* compiler) { | 1184 void JoinEntryInstr::PrepareEntry(FlowGraphCompiler* compiler) { |
1185 __ Bind(compiler->GetBlockLabel(this)); | 1185 __ Bind(compiler->GetBlockLabel(this)); |
1186 if (HasParallelMove()) { | 1186 if (HasParallelMove()) { |
1187 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); | 1187 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); |
1188 } | 1188 } |
1189 } | 1189 } |
1190 | 1190 |
1191 | 1191 |
1192 void TargetEntryInstr::PrepareEntry(FlowGraphCompiler* compiler) { | 1192 void TargetEntryInstr::PrepareEntry(FlowGraphCompiler* compiler) { |
1193 __ Bind(compiler->GetBlockLabel(this)); | 1193 __ Bind(compiler->GetBlockLabel(this)); |
1194 if (HasTryIndex()) { | 1194 if (IsCatchEntry()) { |
1195 compiler->AddExceptionHandler(try_index(), | 1195 compiler->AddExceptionHandler(catch_try_index(), |
1196 compiler->assembler()->CodeSize()); | 1196 compiler->assembler()->CodeSize()); |
1197 } | 1197 } |
1198 if (HasParallelMove()) { | 1198 if (HasParallelMove()) { |
1199 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); | 1199 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); |
1200 } | 1200 } |
1201 } | 1201 } |
1202 | 1202 |
1203 | 1203 |
1204 LocationSummary* ThrowInstr::MakeLocationSummary() const { | 1204 LocationSummary* ThrowInstr::MakeLocationSummary() const { |
1205 return new LocationSummary(0, 0, LocationSummary::kCall); | 1205 return new LocationSummary(0, 0, LocationSummary::kCall); |
1206 } | 1206 } |
1207 | 1207 |
1208 | 1208 |
1209 | 1209 |
1210 void ThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1210 void ThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
1211 compiler->GenerateCallRuntime(deopt_id(), | 1211 compiler->GenerateCallRuntime(deopt_id(), |
1212 token_pos(), | 1212 token_pos(), |
1213 try_index(), | |
1214 kThrowRuntimeEntry, | 1213 kThrowRuntimeEntry, |
1215 locs()); | 1214 locs()); |
1216 __ int3(); | 1215 __ int3(); |
1217 } | 1216 } |
1218 | 1217 |
1219 | 1218 |
1220 LocationSummary* ReThrowInstr::MakeLocationSummary() const { | 1219 LocationSummary* ReThrowInstr::MakeLocationSummary() const { |
1221 return new LocationSummary(0, 0, LocationSummary::kCall); | 1220 return new LocationSummary(0, 0, LocationSummary::kCall); |
1222 } | 1221 } |
1223 | 1222 |
1224 | 1223 |
1225 void ReThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1224 void ReThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
1226 compiler->GenerateCallRuntime(deopt_id(), | 1225 compiler->GenerateCallRuntime(deopt_id(), |
1227 token_pos(), | 1226 token_pos(), |
1228 try_index(), | |
1229 kReThrowRuntimeEntry, | 1227 kReThrowRuntimeEntry, |
1230 locs()); | 1228 locs()); |
1231 __ int3(); | 1229 __ int3(); |
1232 } | 1230 } |
1233 | 1231 |
1234 | 1232 |
1235 LocationSummary* GotoInstr::MakeLocationSummary() const { | 1233 LocationSummary* GotoInstr::MakeLocationSummary() const { |
1236 return new LocationSummary(0, 0, LocationSummary::kNoCall); | 1234 return new LocationSummary(0, 0, LocationSummary::kNoCall); |
1237 } | 1235 } |
1238 | 1236 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 // descriptor describes the closure's arguments (and so does not include | 1353 // descriptor describes the closure's arguments (and so does not include |
1356 // the closure). | 1354 // the closure). |
1357 Register temp_reg = locs()->temp(0).reg(); | 1355 Register temp_reg = locs()->temp(0).reg(); |
1358 int argument_count = ArgumentCount(); | 1356 int argument_count = ArgumentCount(); |
1359 const Array& arguments_descriptor = | 1357 const Array& arguments_descriptor = |
1360 DartEntry::ArgumentsDescriptor(argument_count - 1, | 1358 DartEntry::ArgumentsDescriptor(argument_count - 1, |
1361 argument_names()); | 1359 argument_names()); |
1362 __ LoadObject(temp_reg, arguments_descriptor); | 1360 __ LoadObject(temp_reg, arguments_descriptor); |
1363 | 1361 |
1364 compiler->GenerateCall(token_pos(), | 1362 compiler->GenerateCall(token_pos(), |
1365 try_index(), | |
1366 &StubCode::CallClosureFunctionLabel(), | 1363 &StubCode::CallClosureFunctionLabel(), |
1367 PcDescriptors::kOther, | 1364 PcDescriptors::kOther, |
1368 locs()); | 1365 locs()); |
1369 __ Drop(argument_count); | 1366 __ Drop(argument_count); |
1370 } | 1367 } |
1371 | 1368 |
1372 | 1369 |
1373 LocationSummary* InstanceCallComp::MakeLocationSummary() const { | 1370 LocationSummary* InstanceCallComp::MakeLocationSummary() const { |
1374 return MakeCallSummary(); | 1371 return MakeCallSummary(); |
1375 } | 1372 } |
1376 | 1373 |
1377 | 1374 |
1378 void InstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 1375 void InstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
1379 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, | 1376 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, |
1380 deopt_id(), | 1377 deopt_id(), |
1381 token_pos(), | 1378 token_pos()); |
1382 try_index()); | |
1383 compiler->GenerateInstanceCall(deopt_id(), | 1379 compiler->GenerateInstanceCall(deopt_id(), |
1384 token_pos(), | 1380 token_pos(), |
1385 try_index(), | |
1386 function_name(), | 1381 function_name(), |
1387 ArgumentCount(), | 1382 ArgumentCount(), |
1388 argument_names(), | 1383 argument_names(), |
1389 checked_argument_count(), | 1384 checked_argument_count(), |
1390 locs()); | 1385 locs()); |
1391 } | 1386 } |
1392 | 1387 |
1393 | 1388 |
1394 LocationSummary* StaticCallComp::MakeLocationSummary() const { | 1389 LocationSummary* StaticCallComp::MakeLocationSummary() const { |
1395 return MakeCallSummary(); | 1390 return MakeCallSummary(); |
1396 } | 1391 } |
1397 | 1392 |
1398 | 1393 |
1399 void StaticCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 1394 void StaticCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
1400 Label done; | 1395 Label done; |
1401 if (recognized() == MethodRecognizer::kMathSqrt) { | 1396 if (recognized() == MethodRecognizer::kMathSqrt) { |
1402 compiler->GenerateInlinedMathSqrt(&done); | 1397 compiler->GenerateInlinedMathSqrt(&done); |
1403 // Falls through to static call when operand type is not double or smi. | 1398 // Falls through to static call when operand type is not double or smi. |
1404 } | 1399 } |
1405 compiler->GenerateStaticCall(deopt_id(), | 1400 compiler->GenerateStaticCall(deopt_id(), |
1406 token_pos(), | 1401 token_pos(), |
1407 try_index(), | |
1408 function(), | 1402 function(), |
1409 ArgumentCount(), | 1403 ArgumentCount(), |
1410 argument_names(), | 1404 argument_names(), |
1411 locs()); | 1405 locs()); |
1412 __ Bind(&done); | 1406 __ Bind(&done); |
1413 } | 1407 } |
1414 | 1408 |
1415 | 1409 |
1416 void AssertAssignableComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 1410 void AssertAssignableComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
1417 if (!is_eliminated()) { | 1411 if (!is_eliminated()) { |
1418 compiler->GenerateAssertAssignable(deopt_id(), | 1412 compiler->GenerateAssertAssignable(deopt_id(), |
1419 token_pos(), | 1413 token_pos(), |
1420 try_index(), | |
1421 dst_type(), | 1414 dst_type(), |
1422 dst_name(), | 1415 dst_name(), |
1423 locs()); | 1416 locs()); |
1424 } | 1417 } |
1425 ASSERT(locs()->in(0).reg() == locs()->out().reg()); | 1418 ASSERT(locs()->in(0).reg() == locs()->out().reg()); |
1426 } | 1419 } |
1427 | 1420 |
1428 | 1421 |
1429 LocationSummary* BooleanNegateComp::MakeLocationSummary() const { | 1422 LocationSummary* BooleanNegateComp::MakeLocationSummary() const { |
1430 return LocationSummary::Make(1, | 1423 return LocationSummary::Make(1, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 LocationSummary* AllocateObjectComp::MakeLocationSummary() const { | 1483 LocationSummary* AllocateObjectComp::MakeLocationSummary() const { |
1491 return MakeCallSummary(); | 1484 return MakeCallSummary(); |
1492 } | 1485 } |
1493 | 1486 |
1494 | 1487 |
1495 void AllocateObjectComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 1488 void AllocateObjectComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
1496 const Class& cls = Class::ZoneHandle(constructor().Owner()); | 1489 const Class& cls = Class::ZoneHandle(constructor().Owner()); |
1497 const Code& stub = Code::Handle(StubCode::GetAllocationStubForClass(cls)); | 1490 const Code& stub = Code::Handle(StubCode::GetAllocationStubForClass(cls)); |
1498 const ExternalLabel label(cls.ToCString(), stub.EntryPoint()); | 1491 const ExternalLabel label(cls.ToCString(), stub.EntryPoint()); |
1499 compiler->GenerateCall(token_pos(), | 1492 compiler->GenerateCall(token_pos(), |
1500 try_index(), | |
1501 &label, | 1493 &label, |
1502 PcDescriptors::kOther, | 1494 PcDescriptors::kOther, |
1503 locs()); | 1495 locs()); |
1504 __ Drop(ArgumentCount()); // Discard arguments. | 1496 __ Drop(ArgumentCount()); // Discard arguments. |
1505 } | 1497 } |
1506 | 1498 |
1507 | 1499 |
1508 LocationSummary* CreateClosureComp::MakeLocationSummary() const { | 1500 LocationSummary* CreateClosureComp::MakeLocationSummary() const { |
1509 return MakeCallSummary(); | 1501 return MakeCallSummary(); |
1510 } | 1502 } |
1511 | 1503 |
1512 | 1504 |
1513 void CreateClosureComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 1505 void CreateClosureComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
1514 const Function& closure_function = function(); | 1506 const Function& closure_function = function(); |
1515 const Code& stub = Code::Handle( | 1507 const Code& stub = Code::Handle( |
1516 StubCode::GetAllocationStubForClosure(closure_function)); | 1508 StubCode::GetAllocationStubForClosure(closure_function)); |
1517 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); | 1509 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); |
1518 compiler->GenerateCall(token_pos(), try_index(), &label, | 1510 compiler->GenerateCall(token_pos(), |
| 1511 &label, |
1519 PcDescriptors::kOther, | 1512 PcDescriptors::kOther, |
1520 locs()); | 1513 locs()); |
1521 __ Drop(2); // Discard type arguments and receiver. | 1514 __ Drop(2); // Discard type arguments and receiver. |
1522 } | 1515 } |
1523 | 1516 |
1524 | 1517 |
1525 LocationSummary* PushArgumentInstr::MakeLocationSummary() const { | 1518 LocationSummary* PushArgumentInstr::MakeLocationSummary() const { |
1526 const intptr_t kNumInputs = 1; | 1519 const intptr_t kNumInputs = 1; |
1527 const intptr_t kNumTemps= 0; | 1520 const intptr_t kNumTemps= 0; |
1528 LocationSummary* locs = | 1521 LocationSummary* locs = |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1580 use->AddToEnvUseList(); | 1573 use->AddToEnvUseList(); |
1581 } | 1574 } |
1582 } | 1575 } |
1583 instr->set_env(copy); | 1576 instr->set_env(copy); |
1584 } | 1577 } |
1585 | 1578 |
1586 | 1579 |
1587 #undef __ | 1580 #undef __ |
1588 | 1581 |
1589 } // namespace dart | 1582 } // namespace dart |
OLD | NEW |