| OLD | NEW |
| 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 "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 __ LoadObject(EDX, arguments_descriptor); | 1426 __ LoadObject(EDX, arguments_descriptor); |
| 1427 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 1427 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 1428 __ call(EAX); | 1428 __ call(EAX); |
| 1429 AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); | 1429 AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); |
| 1430 RecordSafepoint(locs); | 1430 RecordSafepoint(locs); |
| 1431 AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); | 1431 AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); |
| 1432 __ Drop(argument_count); | 1432 __ Drop(argument_count); |
| 1433 } | 1433 } |
| 1434 | 1434 |
| 1435 | 1435 |
| 1436 void FlowGraphCompiler::EmitStaticCall(const Function& function, | 1436 void FlowGraphCompiler::EmitOptimizedStaticCall( |
| 1437 const Array& arguments_descriptor, | 1437 const Function& function, |
| 1438 intptr_t argument_count, | 1438 const Array& arguments_descriptor, |
| 1439 intptr_t deopt_id, | 1439 intptr_t argument_count, |
| 1440 intptr_t token_pos, | 1440 intptr_t deopt_id, |
| 1441 LocationSummary* locs) { | 1441 intptr_t token_pos, |
| 1442 LocationSummary* locs) { |
| 1442 __ LoadObject(EDX, arguments_descriptor); | 1443 __ LoadObject(EDX, arguments_descriptor); |
| 1443 // Do not use the code from the function, but let the code be patched so that | 1444 // Do not use the code from the function, but let the code be patched so that |
| 1444 // we can record the outgoing edges to other code. | 1445 // we can record the outgoing edges to other code. |
| 1445 GenerateDartCall(deopt_id, | 1446 GenerateDartCall(deopt_id, |
| 1446 token_pos, | 1447 token_pos, |
| 1447 &StubCode::CallStaticFunctionLabel(), | 1448 &StubCode::CallStaticFunctionLabel(), |
| 1448 PcDescriptors::kFuncCall, | 1449 PcDescriptors::kOptStaticCall, |
| 1449 locs); | 1450 locs); |
| 1450 AddStaticCallTarget(function); | 1451 AddStaticCallTarget(function); |
| 1451 __ Drop(argument_count); | 1452 __ Drop(argument_count); |
| 1452 } | 1453 } |
| 1453 | 1454 |
| 1454 | 1455 |
| 1455 void FlowGraphCompiler::EmitUnoptimizedStaticCall( | 1456 void FlowGraphCompiler::EmitUnoptimizedStaticCall( |
| 1456 const Function& target_function, | 1457 const Function& target_function, |
| 1457 const Array& arguments_descriptor, | 1458 const Array& arguments_descriptor, |
| 1458 intptr_t argument_count, | 1459 intptr_t argument_count, |
| 1459 intptr_t deopt_id, | 1460 intptr_t deopt_id, |
| 1460 intptr_t token_pos, | 1461 intptr_t token_pos, |
| 1461 LocationSummary* locs) { | 1462 LocationSummary* locs) { |
| 1462 const ICData& ic_data = ICData::ZoneHandle( | 1463 const ICData& ic_data = ICData::ZoneHandle( |
| 1463 ICData::New(parsed_function().function(), // Caller function. | 1464 ICData::New(parsed_function().function(), // Caller function. |
| 1464 String::Handle(target_function.name()), | 1465 String::Handle(target_function.name()), |
| 1465 arguments_descriptor, | 1466 arguments_descriptor, |
| 1466 deopt_id, | 1467 deopt_id, |
| 1467 0)); // No arguments checked. | 1468 0)); // No arguments checked. |
| 1468 ic_data.AddTarget(target_function); | 1469 ic_data.AddTarget(target_function); |
| 1469 __ LoadObject(ECX, ic_data); | 1470 __ LoadObject(ECX, ic_data); |
| 1470 GenerateDartCall(deopt_id, | 1471 GenerateDartCall(deopt_id, |
| 1471 token_pos, | 1472 token_pos, |
| 1472 &StubCode::UnoptimizedStaticCallLabel(), | 1473 &StubCode::UnoptimizedStaticCallLabel(), |
| 1473 PcDescriptors::kFuncCall, | 1474 PcDescriptors::kUnoptStaticCall, |
| 1474 locs); | 1475 locs); |
| 1475 __ Drop(argument_count); | 1476 __ Drop(argument_count); |
| 1476 } | 1477 } |
| 1477 | 1478 |
| 1478 | 1479 |
| 1479 void FlowGraphCompiler::EmitEqualityRegConstCompare(Register reg, | 1480 void FlowGraphCompiler::EmitEqualityRegConstCompare(Register reg, |
| 1480 const Object& obj, | 1481 const Object& obj, |
| 1481 bool needs_number_check, | 1482 bool needs_number_check, |
| 1482 intptr_t token_pos) { | 1483 intptr_t token_pos) { |
| 1483 if (needs_number_check) { | 1484 if (needs_number_check) { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 | 1615 |
| 1615 | 1616 |
| 1616 void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data, | 1617 void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data, |
| 1617 Register class_id_reg, | 1618 Register class_id_reg, |
| 1618 intptr_t argument_count, | 1619 intptr_t argument_count, |
| 1619 const Array& argument_names, | 1620 const Array& argument_names, |
| 1620 Label* deopt, | 1621 Label* deopt, |
| 1621 intptr_t deopt_id, | 1622 intptr_t deopt_id, |
| 1622 intptr_t token_index, | 1623 intptr_t token_index, |
| 1623 LocationSummary* locs) { | 1624 LocationSummary* locs) { |
| 1625 ASSERT(is_optimizing()); |
| 1624 ASSERT(!ic_data.IsNull() && (ic_data.NumberOfChecks() > 0)); | 1626 ASSERT(!ic_data.IsNull() && (ic_data.NumberOfChecks() > 0)); |
| 1625 Label match_found; | 1627 Label match_found; |
| 1626 const intptr_t len = ic_data.NumberOfChecks(); | 1628 const intptr_t len = ic_data.NumberOfChecks(); |
| 1627 GrowableArray<CidTarget> sorted(len); | 1629 GrowableArray<CidTarget> sorted(len); |
| 1628 SortICDataByCount(ic_data, &sorted); | 1630 SortICDataByCount(ic_data, &sorted); |
| 1629 ASSERT(class_id_reg != EDX); | 1631 ASSERT(class_id_reg != EDX); |
| 1630 ASSERT(len > 0); // Why bother otherwise. | 1632 ASSERT(len > 0); // Why bother otherwise. |
| 1631 const Array& arguments_descriptor = | 1633 const Array& arguments_descriptor = |
| 1632 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, | 1634 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, |
| 1633 argument_names)); | 1635 argument_names)); |
| 1634 __ LoadObject(EDX, arguments_descriptor); | 1636 __ LoadObject(EDX, arguments_descriptor); |
| 1635 for (intptr_t i = 0; i < len; i++) { | 1637 for (intptr_t i = 0; i < len; i++) { |
| 1636 const bool is_last_check = (i == (len - 1)); | 1638 const bool is_last_check = (i == (len - 1)); |
| 1637 Label next_test; | 1639 Label next_test; |
| 1638 assembler()->cmpl(class_id_reg, Immediate(sorted[i].cid)); | 1640 assembler()->cmpl(class_id_reg, Immediate(sorted[i].cid)); |
| 1639 if (is_last_check) { | 1641 if (is_last_check) { |
| 1640 assembler()->j(NOT_EQUAL, deopt); | 1642 assembler()->j(NOT_EQUAL, deopt); |
| 1641 } else { | 1643 } else { |
| 1642 assembler()->j(NOT_EQUAL, &next_test); | 1644 assembler()->j(NOT_EQUAL, &next_test); |
| 1643 } | 1645 } |
| 1644 // Do not use the code from the function, but let the code be patched so | 1646 // Do not use the code from the function, but let the code be patched so |
| 1645 // that we can record the outgoing edges to other code. | 1647 // that we can record the outgoing edges to other code. |
| 1646 GenerateDartCall(deopt_id, | 1648 GenerateDartCall(deopt_id, |
| 1647 token_index, | 1649 token_index, |
| 1648 &StubCode::CallStaticFunctionLabel(), | 1650 &StubCode::CallStaticFunctionLabel(), |
| 1649 PcDescriptors::kFuncCall, | 1651 PcDescriptors::kOptStaticCall, |
| 1650 locs); | 1652 locs); |
| 1651 const Function& function = *sorted[i].target; | 1653 const Function& function = *sorted[i].target; |
| 1652 AddStaticCallTarget(function); | 1654 AddStaticCallTarget(function); |
| 1653 __ Drop(argument_count); | 1655 __ Drop(argument_count); |
| 1654 if (!is_last_check) { | 1656 if (!is_last_check) { |
| 1655 assembler()->jmp(&match_found); | 1657 assembler()->jmp(&match_found); |
| 1656 } | 1658 } |
| 1657 assembler()->Bind(&next_test); | 1659 assembler()->Bind(&next_test); |
| 1658 } | 1660 } |
| 1659 assembler()->Bind(&match_found); | 1661 assembler()->Bind(&match_found); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1954 __ movups(reg, Address(ESP, 0)); | 1956 __ movups(reg, Address(ESP, 0)); |
| 1955 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1957 __ addl(ESP, Immediate(kFpuRegisterSize)); |
| 1956 } | 1958 } |
| 1957 | 1959 |
| 1958 | 1960 |
| 1959 #undef __ | 1961 #undef __ |
| 1960 | 1962 |
| 1961 } // namespace dart | 1963 } // namespace dart |
| 1962 | 1964 |
| 1963 #endif // defined TARGET_ARCH_IA32 | 1965 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |