Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: runtime/vm/intermediate_language_ia32.cc

Issue 24744002: Pattern match on generated code to find edge counters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporated review comments. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language_arm.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 4695 matching lines...) Expand 10 before | Expand all | Expand 10 after
4706 void GraphEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4706 void GraphEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4707 if (!compiler->CanFallThroughTo(normal_entry())) { 4707 if (!compiler->CanFallThroughTo(normal_entry())) {
4708 __ jmp(compiler->GetJumpLabel(normal_entry())); 4708 __ jmp(compiler->GetJumpLabel(normal_entry()));
4709 } 4709 }
4710 } 4710 }
4711 4711
4712 4712
4713 void TargetEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4713 void TargetEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4714 __ Bind(compiler->GetJumpLabel(this)); 4714 __ Bind(compiler->GetJumpLabel(this));
4715 if (!compiler->is_optimizing()) { 4715 if (!compiler->is_optimizing()) {
4716 compiler->EmitEdgeCounter();
4717 // The deoptimization descriptor points after the edge counter code for
4718 // uniformity with ARM and MIPS, where we can reuse pattern matching
4719 // code that matches backwards from the end of the pattern.
4716 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, 4720 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
4717 deopt_id_, 4721 deopt_id_,
4718 Scanner::kDummyTokenIndex); 4722 Scanner::kDummyTokenIndex);
4719 // Add an edge counter.
4720 const Array& counter = Array::ZoneHandle(Array::New(1, Heap::kOld));
4721 counter.SetAt(0, Smi::Handle(Smi::New(0)));
4722 Label done;
4723 __ Comment("Edge counter");
4724 __ LoadObject(EAX, counter);
4725 __ addl(FieldAddress(EAX, Array::element_offset(0)),
4726 Immediate(Smi::RawValue(1)));
4727 __ j(NO_OVERFLOW, &done);
4728 __ movl(FieldAddress(EAX, Array::element_offset(0)),
4729 Immediate(Smi::RawValue(Smi::kMaxValue)));
4730 __ Bind(&done);
4731 } 4723 }
4732 if (HasParallelMove()) { 4724 if (HasParallelMove()) {
4733 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); 4725 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
4734 } 4726 }
4735 } 4727 }
4736 4728
4737 4729
4738 LocationSummary* GotoInstr::MakeLocationSummary() const { 4730 LocationSummary* GotoInstr::MakeLocationSummary() const {
4739 return new LocationSummary(0, 0, LocationSummary::kNoCall); 4731 return new LocationSummary(0, 0, LocationSummary::kNoCall);
4740 } 4732 }
4741 4733
4742 4734
4743 void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4735 void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4744 if (!compiler->is_optimizing()) { 4736 if (!compiler->is_optimizing()) {
4745 // Add deoptimization descriptor for deoptimizing instructions that may 4737 compiler->EmitEdgeCounter();
4746 // be inserted before this instruction. 4738 // Add a deoptimization descriptor for deoptimizing instructions that
4739 // may be inserted before this instruction. This descriptor points
4740 // after the edge counter for uniformity with ARM and MIPS, where we can
4741 // reuse pattern matching that matches backwards from the end of the
4742 // pattern.
4747 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, 4743 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
4748 GetDeoptId(), 4744 GetDeoptId(),
4749 0); // No token position. 4745 Scanner::kDummyTokenIndex);
4750 // Add an edge counter.
4751 const Array& counter = Array::ZoneHandle(Array::New(1, Heap::kOld));
4752 counter.SetAt(0, Smi::Handle(Smi::New(0)));
4753 Label done;
4754 __ Comment("Edge counter");
4755 __ LoadObject(EAX, counter);
4756 __ addl(FieldAddress(EAX, Array::element_offset(0)),
4757 Immediate(Smi::RawValue(1)));
4758 __ j(NO_OVERFLOW, &done);
4759 __ movl(FieldAddress(EAX, Array::element_offset(0)),
4760 Immediate(Smi::RawValue(Smi::kMaxValue)));
4761 __ Bind(&done);
4762 } 4746 }
4763 if (HasParallelMove()) { 4747 if (HasParallelMove()) {
4764 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); 4748 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
4765 } 4749 }
4766 4750
4767 // We can fall through if the successor is the next block in the list. 4751 // We can fall through if the successor is the next block in the list.
4768 // Otherwise, we need a jump. 4752 // Otherwise, we need a jump.
4769 if (!compiler->CanFallThroughTo(successor())) { 4753 if (!compiler->CanFallThroughTo(successor())) {
4770 __ jmp(compiler->GetJumpLabel(successor())); 4754 __ jmp(compiler->GetJumpLabel(successor()));
4771 } 4755 }
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
5166 PcDescriptors::kOther, 5150 PcDescriptors::kOther,
5167 locs()); 5151 locs());
5168 __ Drop(2); // Discard type arguments and receiver. 5152 __ Drop(2); // Discard type arguments and receiver.
5169 } 5153 }
5170 5154
5171 } // namespace dart 5155 } // namespace dart
5172 5156
5173 #undef __ 5157 #undef __
5174 5158
5175 #endif // defined TARGET_ARCH_IA32 5159 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_arm.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698