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/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 4481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4492 void GraphEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4492 void GraphEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
4493 if (!compiler->CanFallThroughTo(normal_entry())) { | 4493 if (!compiler->CanFallThroughTo(normal_entry())) { |
4494 __ jmp(compiler->GetJumpLabel(normal_entry())); | 4494 __ jmp(compiler->GetJumpLabel(normal_entry())); |
4495 } | 4495 } |
4496 } | 4496 } |
4497 | 4497 |
4498 | 4498 |
4499 void TargetEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4499 void TargetEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
4500 __ Bind(compiler->GetJumpLabel(this)); | 4500 __ Bind(compiler->GetJumpLabel(this)); |
4501 if (!compiler->is_optimizing()) { | 4501 if (!compiler->is_optimizing()) { |
| 4502 compiler->EmitEdgeCounter(); |
| 4503 // The deoptimization descriptor points after the edge counter code for |
| 4504 // uniformity with ARM and MIPS, where we can reuse pattern matching |
| 4505 // code that matches backwards from the end of the pattern. |
4502 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, | 4506 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, |
4503 deopt_id_, | 4507 deopt_id_, |
4504 Scanner::kDummyTokenIndex); | 4508 Scanner::kDummyTokenIndex); |
4505 // Add an edge counter. | |
4506 const Array& counter = Array::ZoneHandle(Array::New(1, Heap::kOld)); | |
4507 counter.SetAt(0, Smi::Handle(Smi::New(0))); | |
4508 Label done; | |
4509 __ Comment("Edge counter"); | |
4510 __ LoadObject(RAX, counter, PP); | |
4511 __ AddImmediate(FieldAddress(RAX, Array::element_offset(0)), | |
4512 Immediate(Smi::RawValue(1)), PP); | |
4513 __ j(NO_OVERFLOW, &done); | |
4514 __ LoadImmediate(FieldAddress(RAX, Array::element_offset(0)), | |
4515 Immediate(Smi::RawValue(Smi::kMaxValue)), PP); | |
4516 __ Bind(&done); | |
4517 } | 4509 } |
4518 if (HasParallelMove()) { | 4510 if (HasParallelMove()) { |
4519 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); | 4511 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); |
4520 } | 4512 } |
4521 } | 4513 } |
4522 | 4514 |
4523 | 4515 |
4524 LocationSummary* GotoInstr::MakeLocationSummary() const { | 4516 LocationSummary* GotoInstr::MakeLocationSummary() const { |
4525 return new LocationSummary(0, 0, LocationSummary::kNoCall); | 4517 return new LocationSummary(0, 0, LocationSummary::kNoCall); |
4526 } | 4518 } |
4527 | 4519 |
4528 | 4520 |
4529 void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4521 void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
4530 if (!compiler->is_optimizing()) { | 4522 if (!compiler->is_optimizing()) { |
4531 // Add deoptimization descriptor for deoptimizing instructions that may | 4523 compiler->EmitEdgeCounter(); |
4532 // be inserted before this instruction. | 4524 // Add a deoptimization descriptor for deoptimizing instructions that |
| 4525 // may be inserted before this instruction. This descriptor points |
| 4526 // after the edge counter for uniformity with ARM and MIPS, where we can |
| 4527 // reuse pattern matching that matches backwards from the end of the |
| 4528 // pattern. |
4533 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, | 4529 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, |
4534 GetDeoptId(), | 4530 GetDeoptId(), |
4535 0); // No token position. | 4531 Scanner::kDummyTokenIndex); |
4536 // Add an edge counter. | |
4537 const Array& counter = Array::ZoneHandle(Array::New(1, Heap::kOld)); | |
4538 counter.SetAt(0, Smi::Handle(Smi::New(0))); | |
4539 Label done; | |
4540 __ Comment("Edge counter"); | |
4541 __ LoadObject(RAX, counter, PP); | |
4542 __ AddImmediate(FieldAddress(RAX, Array::element_offset(0)), | |
4543 Immediate(Smi::RawValue(1)), PP); | |
4544 __ j(NO_OVERFLOW, &done); | |
4545 __ LoadImmediate(FieldAddress(RAX, Array::element_offset(0)), | |
4546 Immediate(Smi::RawValue(Smi::kMaxValue)), PP); | |
4547 __ Bind(&done); | |
4548 } | 4532 } |
4549 if (HasParallelMove()) { | 4533 if (HasParallelMove()) { |
4550 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); | 4534 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); |
4551 } | 4535 } |
4552 | 4536 |
4553 // We can fall through if the successor is the next block in the list. | 4537 // We can fall through if the successor is the next block in the list. |
4554 // Otherwise, we need a jump. | 4538 // Otherwise, we need a jump. |
4555 if (!compiler->CanFallThroughTo(successor())) { | 4539 if (!compiler->CanFallThroughTo(successor())) { |
4556 __ jmp(compiler->GetJumpLabel(successor())); | 4540 __ jmp(compiler->GetJumpLabel(successor())); |
4557 } | 4541 } |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4795 PcDescriptors::kOther, | 4779 PcDescriptors::kOther, |
4796 locs()); | 4780 locs()); |
4797 __ Drop(2); // Discard type arguments and receiver. | 4781 __ Drop(2); // Discard type arguments and receiver. |
4798 } | 4782 } |
4799 | 4783 |
4800 } // namespace dart | 4784 } // namespace dart |
4801 | 4785 |
4802 #undef __ | 4786 #undef __ |
4803 | 4787 |
4804 #endif // defined TARGET_ARCH_X64 | 4788 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |