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 "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 // type check runtime call is the checked value. | 735 // type check runtime call is the checked value. |
736 __ Drop(6); | 736 __ Drop(6); |
737 __ popl(EAX); | 737 __ popl(EAX); |
738 | 738 |
739 __ Bind(&is_assignable); | 739 __ Bind(&is_assignable); |
740 __ popl(EDX); // Remove pushed instantiator type arguments. | 740 __ popl(EDX); // Remove pushed instantiator type arguments. |
741 __ popl(ECX); // Remove pushed instantiator. | 741 __ popl(ECX); // Remove pushed instantiator. |
742 } | 742 } |
743 | 743 |
744 | 744 |
745 void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) { | |
746 if (!is_optimizing()) { | |
747 if (FLAG_enable_type_checks && instr->IsAssertAssignable()) { | |
748 AssertAssignableInstr* assert = instr->AsAssertAssignable(); | |
749 AddCurrentDescriptor(PcDescriptors::kDeopt, | |
750 assert->deopt_id(), | |
751 assert->token_pos()); | |
752 } else if (instr->IsGuardField() || | |
753 instr->CanBecomeDeoptimizationTarget()) { | |
754 AddCurrentDescriptor(PcDescriptors::kDeopt, | |
755 instr->deopt_id(), | |
756 Scanner::kDummyTokenIndex); | |
757 } | |
758 AllocateRegistersLocally(instr); | |
759 } else if (instr->MayThrow() && | |
760 (CurrentTryIndex() != CatchClauseNode::kInvalidTryIndex)) { | |
761 // Optimized try-block: Sync locals to fixed stack locations. | |
762 EmitTrySync(instr, CurrentTryIndex()); | |
763 } | |
764 } | |
765 | |
766 | |
767 void FlowGraphCompiler::EmitTrySyncMove(intptr_t dest_offset, | 745 void FlowGraphCompiler::EmitTrySyncMove(intptr_t dest_offset, |
768 Location loc, | 746 Location loc, |
769 bool* push_emitted) { | 747 bool* push_emitted) { |
770 const Address dest(EBP, dest_offset); | 748 const Address dest(EBP, dest_offset); |
771 if (loc.IsConstant()) { | 749 if (loc.IsConstant()) { |
772 if (!*push_emitted) { | 750 if (!*push_emitted) { |
773 __ pushl(EAX); | 751 __ pushl(EAX); |
774 *push_emitted = true; | 752 *push_emitted = true; |
775 } | 753 } |
776 __ LoadObject(EAX, loc.constant()); | 754 __ LoadObject(EAX, loc.constant()); |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 __ LoadObject(ECX, ic_data); | 1294 __ LoadObject(ECX, ic_data); |
1317 GenerateDartCall(deopt_id, | 1295 GenerateDartCall(deopt_id, |
1318 token_pos, | 1296 token_pos, |
1319 &target_label, | 1297 &target_label, |
1320 PcDescriptors::kUnoptStaticCall, | 1298 PcDescriptors::kUnoptStaticCall, |
1321 locs); | 1299 locs); |
1322 __ Drop(argument_count); | 1300 __ Drop(argument_count); |
1323 } | 1301 } |
1324 | 1302 |
1325 | 1303 |
| 1304 void FlowGraphCompiler::EmitEdgeCounter() { |
| 1305 // We do not check for overflow when incrementing the edge counter. The |
| 1306 // function should normally be optimized long before the counter can |
| 1307 // overflow; and though we do not reset the counters when we optimize or |
| 1308 // deoptimize, there is a bound on the number of |
| 1309 // optimization/deoptimization cycles we will attempt. |
| 1310 const Array& counter = Array::ZoneHandle(Array::New(1, Heap::kOld)); |
| 1311 counter.SetAt(0, Smi::Handle(Smi::New(0))); |
| 1312 __ Comment("Edge counter"); |
| 1313 __ LoadObject(EAX, counter); |
| 1314 __ addl(FieldAddress(EAX, Array::element_offset(0)), |
| 1315 Immediate(Smi::RawValue(1))); |
| 1316 } |
| 1317 |
| 1318 |
1326 void FlowGraphCompiler::EmitOptimizedInstanceCall( | 1319 void FlowGraphCompiler::EmitOptimizedInstanceCall( |
1327 ExternalLabel* target_label, | 1320 ExternalLabel* target_label, |
1328 const ICData& ic_data, | 1321 const ICData& ic_data, |
1329 intptr_t argument_count, | 1322 intptr_t argument_count, |
1330 intptr_t deopt_id, | 1323 intptr_t deopt_id, |
1331 intptr_t token_pos, | 1324 intptr_t token_pos, |
1332 LocationSummary* locs) { | 1325 LocationSummary* locs) { |
1333 // Each ICData propagated from unoptimized to optimized code contains the | 1326 // Each ICData propagated from unoptimized to optimized code contains the |
1334 // function that corresponds to the Dart function of that IC call. Due | 1327 // function that corresponds to the Dart function of that IC call. Due |
1335 // to inlining in optimized code, that function may not correspond to the | 1328 // to inlining in optimized code, that function may not correspond to the |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1922 __ movups(reg, Address(ESP, 0)); | 1915 __ movups(reg, Address(ESP, 0)); |
1923 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1916 __ addl(ESP, Immediate(kFpuRegisterSize)); |
1924 } | 1917 } |
1925 | 1918 |
1926 | 1919 |
1927 #undef __ | 1920 #undef __ |
1928 | 1921 |
1929 } // namespace dart | 1922 } // namespace dart |
1930 | 1923 |
1931 #endif // defined TARGET_ARCH_IA32 | 1924 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |