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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
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 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 // type check runtime call is the checked value. | 717 // type check runtime call is the checked value. |
718 __ Drop(6); | 718 __ Drop(6); |
719 __ popq(RAX); | 719 __ popq(RAX); |
720 | 720 |
721 __ Bind(&is_assignable); | 721 __ Bind(&is_assignable); |
722 __ popq(RDX); // Remove pushed instantiator type arguments. | 722 __ popq(RDX); // Remove pushed instantiator type arguments. |
723 __ popq(RCX); // Remove pushed instantiator. | 723 __ popq(RCX); // Remove pushed instantiator. |
724 } | 724 } |
725 | 725 |
726 | 726 |
727 void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) { | |
728 if (!is_optimizing()) { | |
729 if (FLAG_enable_type_checks && instr->IsAssertAssignable()) { | |
730 AssertAssignableInstr* assert = instr->AsAssertAssignable(); | |
731 AddCurrentDescriptor(PcDescriptors::kDeopt, | |
732 assert->deopt_id(), | |
733 assert->token_pos()); | |
734 } else if (instr->IsGuardField() || | |
735 instr->CanBecomeDeoptimizationTarget()) { | |
736 AddCurrentDescriptor(PcDescriptors::kDeopt, | |
737 instr->deopt_id(), | |
738 Scanner::kDummyTokenIndex); | |
739 } | |
740 AllocateRegistersLocally(instr); | |
741 } else if (instr->MayThrow() && | |
742 (CurrentTryIndex() != CatchClauseNode::kInvalidTryIndex)) { | |
743 // Optimized try-block: Sync locals to fixed stack locations. | |
744 EmitTrySync(instr, CurrentTryIndex()); | |
745 } | |
746 } | |
747 | |
748 | |
749 void FlowGraphCompiler::EmitTrySyncMove(intptr_t dest_offset, | 727 void FlowGraphCompiler::EmitTrySyncMove(intptr_t dest_offset, |
750 Location loc, | 728 Location loc, |
751 bool* push_emitted) { | 729 bool* push_emitted) { |
752 const Address dest(RBP, dest_offset); | 730 const Address dest(RBP, dest_offset); |
753 if (loc.IsConstant()) { | 731 if (loc.IsConstant()) { |
754 if (!*push_emitted) { | 732 if (!*push_emitted) { |
755 __ pushq(RAX); | 733 __ pushq(RAX); |
756 *push_emitted = true; | 734 *push_emitted = true; |
757 } | 735 } |
758 __ LoadObject(RAX, loc.constant(), PP); | 736 __ LoadObject(RAX, loc.constant(), PP); |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 __ LoadObject(RBX, ic_data, PP); | 1324 __ LoadObject(RBX, ic_data, PP); |
1347 GenerateDartCall(deopt_id, | 1325 GenerateDartCall(deopt_id, |
1348 token_pos, | 1326 token_pos, |
1349 &target_label, | 1327 &target_label, |
1350 PcDescriptors::kUnoptStaticCall, | 1328 PcDescriptors::kUnoptStaticCall, |
1351 locs); | 1329 locs); |
1352 __ Drop(argument_count); | 1330 __ Drop(argument_count); |
1353 } | 1331 } |
1354 | 1332 |
1355 | 1333 |
| 1334 void FlowGraphCompiler::EmitEdgeCounter() { |
| 1335 // We do not check for overflow when incrementing the edge counter. The |
| 1336 // function should normally be optimized long before the counter can |
| 1337 // overflow; and though we do not reset the counters when we optimize or |
| 1338 // deoptimize, there is a bound on the number of |
| 1339 // optimization/deoptimization cycles we will attempt. |
| 1340 const Array& counter = Array::ZoneHandle(Array::New(1, Heap::kOld)); |
| 1341 counter.SetAt(0, Smi::Handle(Smi::New(0))); |
| 1342 __ Comment("Edge counter"); |
| 1343 __ LoadObject(RAX, counter, PP); |
| 1344 __ addq(FieldAddress(RAX, Array::element_offset(0)), |
| 1345 Immediate(Smi::RawValue(1))); |
| 1346 } |
| 1347 |
| 1348 |
1356 void FlowGraphCompiler::EmitOptimizedInstanceCall( | 1349 void FlowGraphCompiler::EmitOptimizedInstanceCall( |
1357 ExternalLabel* target_label, | 1350 ExternalLabel* target_label, |
1358 const ICData& ic_data, | 1351 const ICData& ic_data, |
1359 intptr_t argument_count, | 1352 intptr_t argument_count, |
1360 intptr_t deopt_id, | 1353 intptr_t deopt_id, |
1361 intptr_t token_pos, | 1354 intptr_t token_pos, |
1362 LocationSummary* locs) { | 1355 LocationSummary* locs) { |
1363 // Each ICData propagated from unoptimized to optimized code contains the | 1356 // Each ICData propagated from unoptimized to optimized code contains the |
1364 // function that corresponds to the Dart function of that IC call. Due | 1357 // function that corresponds to the Dart function of that IC call. Due |
1365 // to inlining in optimized code, that function may not correspond to the | 1358 // to inlining in optimized code, that function may not correspond to the |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1935 __ movups(reg, Address(RSP, 0)); | 1928 __ movups(reg, Address(RSP, 0)); |
1936 __ addq(RSP, Immediate(kFpuRegisterSize)); | 1929 __ addq(RSP, Immediate(kFpuRegisterSize)); |
1937 } | 1930 } |
1938 | 1931 |
1939 | 1932 |
1940 #undef __ | 1933 #undef __ |
1941 | 1934 |
1942 } // namespace dart | 1935 } // namespace dart |
1943 | 1936 |
1944 #endif // defined TARGET_ARCH_X64 | 1937 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |