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

Side by Side Diff: runtime/vm/intermediate_language_arm.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: 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
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_ARM. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM.
6 #if defined(TARGET_ARCH_ARM) 6 #if defined(TARGET_ARCH_ARM)
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 4426 matching lines...) Expand 10 before | Expand all | Expand 10 after
4437 void GraphEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4437 void GraphEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4438 if (!compiler->CanFallThroughTo(normal_entry())) { 4438 if (!compiler->CanFallThroughTo(normal_entry())) {
4439 __ b(compiler->GetJumpLabel(normal_entry())); 4439 __ b(compiler->GetJumpLabel(normal_entry()));
4440 } 4440 }
4441 } 4441 }
4442 4442
4443 4443
4444 void TargetEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4444 void TargetEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4445 __ Bind(compiler->GetJumpLabel(this)); 4445 __ Bind(compiler->GetJumpLabel(this));
4446 if (!compiler->is_optimizing()) { 4446 if (!compiler->is_optimizing()) {
4447 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
4448 deopt_id_,
4449 Scanner::kDummyTokenIndex);
4450 // Add an edge counter. 4447 // Add an edge counter.
4451 const Array& counter = Array::ZoneHandle(Array::New(1, Heap::kOld)); 4448 const Array& counter = Array::ZoneHandle(Array::New(1, Heap::kOld));
4452 counter.SetAt(0, Smi::Handle(Smi::New(0))); 4449 counter.SetAt(0, Smi::Handle(Smi::New(0)));
4453 __ Comment("Edge counter"); 4450 __ Comment("Edge counter");
4454 __ LoadObject(R0, counter); 4451 __ LoadObject(R0, counter);
4455 __ ldr(IP, FieldAddress(R0, Array::element_offset(0))); 4452 __ ldr(IP, FieldAddress(R0, Array::element_offset(0)));
4456 __ adds(IP, IP, ShifterOperand(Smi::RawValue(1))); 4453 __ adds(IP, IP, ShifterOperand(Smi::RawValue(1)));
4457 __ LoadImmediate(IP, Smi::RawValue(Smi::kMaxValue), VS); // If overflow. 4454 __ LoadImmediate(IP, Smi::RawValue(Smi::kMaxValue), VS); // If overflow.
4458 __ str(IP, FieldAddress(R0, Array::element_offset(0))); 4455 __ str(IP, FieldAddress(R0, Array::element_offset(0)));
4456 // On ARM the deoptimization descriptor points after the edge counter
4457 // code so that we can reuse the same pattern matching code as at call
4458 // sites, which matches backwards from the end of the pattern.
4459 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
4460 deopt_id_,
4461 Scanner::kDummyTokenIndex);
4459 } 4462 }
4460 if (HasParallelMove()) { 4463 if (HasParallelMove()) {
4461 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); 4464 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
4462 } 4465 }
4463 } 4466 }
4464 4467
4465 4468
4466 LocationSummary* GotoInstr::MakeLocationSummary() const { 4469 LocationSummary* GotoInstr::MakeLocationSummary() const {
4467 return new LocationSummary(0, 0, LocationSummary::kNoCall); 4470 return new LocationSummary(0, 0, LocationSummary::kNoCall);
4468 } 4471 }
4469 4472
4470 4473
4471 void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4474 void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4475 if (!compiler->is_optimizing()) {
4476 // Add an edge counter.
4477 const Array& counter = Array::ZoneHandle(Array::New(1, Heap::kOld));
4478 counter.SetAt(0, Smi::Handle(Smi::New(0)));
4479 __ Comment("Edge counter");
4480 __ LoadObject(R0, counter);
4481 __ ldr(IP, FieldAddress(R0, Array::element_offset(0)));
4482 __ adds(IP, IP, ShifterOperand(Smi::RawValue(1)));
4483 __ LoadImmediate(IP, Smi::RawValue(Smi::kMaxValue), VS); // If overflow.
4484 __ str(IP, FieldAddress(R0, Array::element_offset(0)));
4485 // Add a deoptimization descriptor for deoptimizing instructions that
4486 // may be inserted before this instruction. On ARM this descriptor
4487 // points after the edge counter code so that we can reuse the same
4488 // pattern matching code as at call sites, which matches backwards from
4489 // the end of the pattern.
4490 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
4491 GetDeoptId(),
4492 0); // No token position.
4493 }
4472 if (HasParallelMove()) { 4494 if (HasParallelMove()) {
4473 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); 4495 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
4474 } 4496 }
4475 4497
4476 // We can fall through if the successor is the next block in the list. 4498 // We can fall through if the successor is the next block in the list.
4477 // Otherwise, we need a jump. 4499 // Otherwise, we need a jump.
4478 if (!compiler->CanFallThroughTo(successor())) { 4500 if (!compiler->CanFallThroughTo(successor())) {
4479 __ b(compiler->GetJumpLabel(successor())); 4501 __ b(compiler->GetJumpLabel(successor()));
4480 } 4502 }
4481 } 4503 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
4678 compiler->GenerateCall(token_pos(), 4700 compiler->GenerateCall(token_pos(),
4679 &label, 4701 &label,
4680 PcDescriptors::kOther, 4702 PcDescriptors::kOther,
4681 locs()); 4703 locs());
4682 __ Drop(2); // Discard type arguments and receiver. 4704 __ Drop(2); // Discard type arguments and receiver.
4683 } 4705 }
4684 4706
4685 } // namespace dart 4707 } // namespace dart
4686 4708
4687 #endif // defined TARGET_ARCH_ARM 4709 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698