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 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 __ LoadObject(RBX, ic_data, PP); | 1329 __ LoadObject(RBX, ic_data, PP); |
1352 GenerateDartCall(deopt_id, | 1330 GenerateDartCall(deopt_id, |
1353 token_pos, | 1331 token_pos, |
1354 &target_label, | 1332 &target_label, |
1355 PcDescriptors::kUnoptStaticCall, | 1333 PcDescriptors::kUnoptStaticCall, |
1356 locs); | 1334 locs); |
1357 __ Drop(argument_count); | 1335 __ Drop(argument_count); |
1358 } | 1336 } |
1359 | 1337 |
1360 | 1338 |
| 1339 void FlowGraphCompiler::EmitEdgeCounter() { |
| 1340 // We do not check for overflow when incrementing the edge counter. The |
| 1341 // function should normally be optimized long before the counter can |
| 1342 // overflow; and though we do not reset the counters when we optimize or |
| 1343 // deoptimize, there is a bound on the number of |
| 1344 // optimization/deoptimization cycles we will attempt. |
| 1345 const Array& counter = Array::ZoneHandle(Array::New(1, Heap::kOld)); |
| 1346 counter.SetAt(0, Smi::Handle(Smi::New(0))); |
| 1347 __ Comment("Edge counter"); |
| 1348 __ LoadObject(RAX, counter, PP); |
| 1349 __ AddImmediate(FieldAddress(RAX, Array::element_offset(0)), |
| 1350 Immediate(Smi::RawValue(1)), PP); |
| 1351 } |
| 1352 |
| 1353 |
1361 void FlowGraphCompiler::EmitOptimizedInstanceCall( | 1354 void FlowGraphCompiler::EmitOptimizedInstanceCall( |
1362 ExternalLabel* target_label, | 1355 ExternalLabel* target_label, |
1363 const ICData& ic_data, | 1356 const ICData& ic_data, |
1364 intptr_t argument_count, | 1357 intptr_t argument_count, |
1365 intptr_t deopt_id, | 1358 intptr_t deopt_id, |
1366 intptr_t token_pos, | 1359 intptr_t token_pos, |
1367 LocationSummary* locs) { | 1360 LocationSummary* locs) { |
1368 // Each ICData propagated from unoptimized to optimized code contains the | 1361 // Each ICData propagated from unoptimized to optimized code contains the |
1369 // function that corresponds to the Dart function of that IC call. Due | 1362 // function that corresponds to the Dart function of that IC call. Due |
1370 // to inlining in optimized code, that function may not correspond to the | 1363 // to inlining in optimized code, that function may not correspond to the |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1941 __ movups(reg, Address(RSP, 0)); | 1934 __ movups(reg, Address(RSP, 0)); |
1942 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); | 1935 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); |
1943 } | 1936 } |
1944 | 1937 |
1945 | 1938 |
1946 #undef __ | 1939 #undef __ |
1947 | 1940 |
1948 } // namespace dart | 1941 } // namespace dart |
1949 | 1942 |
1950 #endif // defined TARGET_ARCH_X64 | 1943 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |