| 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 // Generate runtime call. | 498 // Generate runtime call. |
| 499 __ movl(EDX, Address(ESP, 0)); // Get instantiator type arguments. | 499 __ movl(EDX, Address(ESP, 0)); // Get instantiator type arguments. |
| 500 __ movl(ECX, Address(ESP, kWordSize)); // Get instantiator. | 500 __ movl(ECX, Address(ESP, kWordSize)); // Get instantiator. |
| 501 __ PushObject(Object::ZoneHandle()); // Make room for the result. | 501 __ PushObject(Object::ZoneHandle()); // Make room for the result. |
| 502 __ pushl(EAX); // Push the instance. | 502 __ pushl(EAX); // Push the instance. |
| 503 __ PushObject(type); // Push the type. | 503 __ PushObject(type); // Push the type. |
| 504 __ pushl(ECX); // Instantiator. | 504 __ pushl(ECX); // Instantiator. |
| 505 __ pushl(EDX); // Instantiator type arguments. | 505 __ pushl(EDX); // Instantiator type arguments. |
| 506 __ LoadObject(EAX, test_cache); | 506 __ LoadObject(EAX, test_cache); |
| 507 __ pushl(EAX); | 507 __ pushl(EAX); |
| 508 GenerateCallRuntime(token_pos, deopt_id, kInstanceofRuntimeEntry, locs); | 508 GenerateCallRuntime(token_pos, |
| 509 deopt_id, |
| 510 kInstanceofRuntimeEntry, |
| 511 locs); |
| 509 // Pop the parameters supplied to the runtime entry. The result of the | 512 // Pop the parameters supplied to the runtime entry. The result of the |
| 510 // instanceof runtime call will be left as the result of the operation. | 513 // instanceof runtime call will be left as the result of the operation. |
| 511 __ Drop(5); | 514 __ Drop(5); |
| 512 if (negate_result) { | 515 if (negate_result) { |
| 513 __ popl(EDX); | 516 __ popl(EDX); |
| 514 __ LoadObject(EAX, Bool::True()); | 517 __ LoadObject(EAX, Bool::True()); |
| 515 __ cmpl(EDX, EAX); | 518 __ cmpl(EDX, EAX); |
| 516 __ j(NOT_EQUAL, &done, Assembler::kNearJump); | 519 __ j(NOT_EQUAL, &done, Assembler::kNearJump); |
| 517 __ LoadObject(EAX, Bool::False()); | 520 __ LoadObject(EAX, Bool::False()); |
| 518 } else { | 521 } else { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 __ Bind(&is_assignable); | 624 __ Bind(&is_assignable); |
| 622 __ popl(EDX); // Remove pushed instantiator type arguments. | 625 __ popl(EDX); // Remove pushed instantiator type arguments. |
| 623 __ popl(ECX); // Remove pushed instantiator. | 626 __ popl(ECX); // Remove pushed instantiator. |
| 624 } | 627 } |
| 625 | 628 |
| 626 | 629 |
| 627 void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) { | 630 void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) { |
| 628 if (!is_optimizing()) { | 631 if (!is_optimizing()) { |
| 629 if (FLAG_enable_type_checks && instr->IsAssertAssignable()) { | 632 if (FLAG_enable_type_checks && instr->IsAssertAssignable()) { |
| 630 AssertAssignableInstr* assert = instr->AsAssertAssignable(); | 633 AssertAssignableInstr* assert = instr->AsAssertAssignable(); |
| 631 AddCurrentDescriptor(PcDescriptors::kDeoptBefore, | 634 AddCurrentDescriptor(PcDescriptors::kDeopt, |
| 632 assert->deopt_id(), | 635 assert->deopt_id(), |
| 633 assert->token_pos()); | 636 assert->token_pos()); |
| 634 } else if (instr->IsGuardField()) { | 637 } else if (instr->IsGuardField()) { |
| 635 GuardFieldInstr* guard = instr->AsGuardField(); | 638 GuardFieldInstr* guard = instr->AsGuardField(); |
| 636 AddCurrentDescriptor(PcDescriptors::kDeoptBefore, | 639 AddCurrentDescriptor(PcDescriptors::kDeopt, |
| 637 guard->deopt_id(), | 640 guard->deopt_id(), |
| 638 Scanner::kDummyTokenIndex); | 641 Scanner::kDummyTokenIndex); |
| 642 } else if (instr->CanBeDeoptimizationTarget()) { |
| 643 AddCurrentDescriptor(PcDescriptors::kDeopt, |
| 644 instr->deopt_id(), |
| 645 Scanner::kDummyTokenIndex); |
| 639 } | 646 } |
| 640 AllocateRegistersLocally(instr); | 647 AllocateRegistersLocally(instr); |
| 641 } | 648 } |
| 642 } | 649 } |
| 643 | 650 |
| 644 | 651 |
| 645 void FlowGraphCompiler::EmitInstructionEpilogue(Instruction* instr) { | 652 void FlowGraphCompiler::EmitInstructionEpilogue(Instruction* instr) { |
| 646 if (is_optimizing()) return; | 653 if (is_optimizing()) return; |
| 647 Definition* defn = instr->AsDefinition(); | 654 Definition* defn = instr->AsDefinition(); |
| 648 if ((defn != NULL) && defn->is_used()) { | 655 if ((defn != NULL) && defn->is_used()) { |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, | 1094 void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, |
| 1088 intptr_t token_pos, | 1095 intptr_t token_pos, |
| 1089 const ExternalLabel* label, | 1096 const ExternalLabel* label, |
| 1090 PcDescriptors::Kind kind, | 1097 PcDescriptors::Kind kind, |
| 1091 LocationSummary* locs) { | 1098 LocationSummary* locs) { |
| 1092 __ call(label); | 1099 __ call(label); |
| 1093 AddCurrentDescriptor(kind, deopt_id, token_pos); | 1100 AddCurrentDescriptor(kind, deopt_id, token_pos); |
| 1094 RecordSafepoint(locs); | 1101 RecordSafepoint(locs); |
| 1095 // Marks either the continuation point in unoptimized code or the | 1102 // Marks either the continuation point in unoptimized code or the |
| 1096 // deoptimization point in optimized code, after call. | 1103 // deoptimization point in optimized code, after call. |
| 1104 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); |
| 1097 if (is_optimizing()) { | 1105 if (is_optimizing()) { |
| 1098 AddDeoptIndexAtCall(deopt_id, token_pos); | 1106 AddDeoptIndexAtCall(deopt_id_after, token_pos); |
| 1099 } else { | 1107 } else { |
| 1100 // Add deoptimization continuation point after the call and before the | 1108 // Add deoptimization continuation point after the call and before the |
| 1101 // arguments are removed. | 1109 // arguments are removed. |
| 1102 AddCurrentDescriptor(PcDescriptors::kDeoptAfter, | 1110 AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); |
| 1103 deopt_id, | |
| 1104 token_pos); | |
| 1105 } | 1111 } |
| 1106 } | 1112 } |
| 1107 | 1113 |
| 1108 | 1114 |
| 1109 void FlowGraphCompiler::GenerateCallRuntime(intptr_t token_pos, | 1115 void FlowGraphCompiler::GenerateCallRuntime(intptr_t token_pos, |
| 1110 intptr_t deopt_id, | 1116 intptr_t deopt_id, |
| 1111 const RuntimeEntry& entry, | 1117 const RuntimeEntry& entry, |
| 1112 LocationSummary* locs) { | 1118 LocationSummary* locs) { |
| 1113 __ CallRuntime(entry); | 1119 __ CallRuntime(entry); |
| 1114 AddCurrentDescriptor(PcDescriptors::kOther, deopt_id, token_pos); | 1120 AddCurrentDescriptor(PcDescriptors::kOther, deopt_id, token_pos); |
| 1115 RecordSafepoint(locs); | 1121 RecordSafepoint(locs); |
| 1116 if (deopt_id != Isolate::kNoDeoptId) { | 1122 if (deopt_id != Isolate::kNoDeoptId) { |
| 1117 // Marks either the continuation point in unoptimized code or the | 1123 // Marks either the continuation point in unoptimized code or the |
| 1118 // deoptimization point in optimized code, after call. | 1124 // deoptimization point in optimized code, after call. |
| 1125 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); |
| 1119 if (is_optimizing()) { | 1126 if (is_optimizing()) { |
| 1120 AddDeoptIndexAtCall(deopt_id, token_pos); | 1127 AddDeoptIndexAtCall(deopt_id_after, token_pos); |
| 1121 } else { | 1128 } else { |
| 1122 // Add deoptimization continuation point after the call and before the | 1129 // Add deoptimization continuation point after the call and before the |
| 1123 // arguments are removed. | 1130 // arguments are removed. |
| 1124 AddCurrentDescriptor(PcDescriptors::kDeoptAfter, | 1131 AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); |
| 1125 deopt_id, | |
| 1126 token_pos); | |
| 1127 } | 1132 } |
| 1128 } | 1133 } |
| 1129 } | 1134 } |
| 1130 | 1135 |
| 1131 | 1136 |
| 1132 void FlowGraphCompiler::EmitOptimizedInstanceCall( | 1137 void FlowGraphCompiler::EmitOptimizedInstanceCall( |
| 1133 ExternalLabel* target_label, | 1138 ExternalLabel* target_label, |
| 1134 const ICData& ic_data, | 1139 const ICData& ic_data, |
| 1135 const Array& arguments_descriptor, | 1140 const Array& arguments_descriptor, |
| 1136 intptr_t argument_count, | 1141 intptr_t argument_count, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 // be invoked as a normal Dart function. | 1233 // be invoked as a normal Dart function. |
| 1229 __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize)); | 1234 __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize)); |
| 1230 __ movl(EAX, FieldAddress(EAX, Function::code_offset())); | 1235 __ movl(EAX, FieldAddress(EAX, Function::code_offset())); |
| 1231 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); | 1236 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); |
| 1232 __ LoadObject(ECX, ic_data); | 1237 __ LoadObject(ECX, ic_data); |
| 1233 __ LoadObject(EDX, arguments_descriptor); | 1238 __ LoadObject(EDX, arguments_descriptor); |
| 1234 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 1239 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 1235 __ call(EAX); | 1240 __ call(EAX); |
| 1236 AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); | 1241 AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); |
| 1237 RecordSafepoint(locs); | 1242 RecordSafepoint(locs); |
| 1238 AddDeoptIndexAtCall(deopt_id, token_pos); | 1243 AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); |
| 1239 __ Drop(argument_count); | 1244 __ Drop(argument_count); |
| 1240 } | 1245 } |
| 1241 | 1246 |
| 1242 | 1247 |
| 1243 void FlowGraphCompiler::EmitStaticCall(const Function& function, | 1248 void FlowGraphCompiler::EmitStaticCall(const Function& function, |
| 1244 const Array& arguments_descriptor, | 1249 const Array& arguments_descriptor, |
| 1245 intptr_t argument_count, | 1250 intptr_t argument_count, |
| 1246 intptr_t deopt_id, | 1251 intptr_t deopt_id, |
| 1247 intptr_t token_pos, | 1252 intptr_t token_pos, |
| 1248 LocationSummary* locs) { | 1253 LocationSummary* locs) { |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1718 __ popl(ECX); | 1723 __ popl(ECX); |
| 1719 __ popl(EAX); | 1724 __ popl(EAX); |
| 1720 } | 1725 } |
| 1721 | 1726 |
| 1722 | 1727 |
| 1723 #undef __ | 1728 #undef __ |
| 1724 | 1729 |
| 1725 } // namespace dart | 1730 } // namespace dart |
| 1726 | 1731 |
| 1727 #endif // defined TARGET_ARCH_IA32 | 1732 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |