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

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

Issue 10431006: First step toward an optimizing compiler: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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_test.cc ('k') | runtime/vm/stub_code_x64.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #include "vm/locations.h" 9 #include "vm/locations.h"
10 #include "vm/object_store.h"
10 #include "vm/stub_code.h" 11 #include "vm/stub_code.h"
11 12
12 #define __ compiler->assembler()-> 13 #define __ compiler->assembler()->
13 14
14 namespace dart { 15 namespace dart {
15 16
16 17
17 // True iff. the arguments to a call will be properly pushed and can 18 // True iff. the arguments to a call will be properly pushed and can
18 // be popped after the call. 19 // be popped after the call.
19 template <typename T> static bool VerifyCallComputation(T* comp) { 20 template <typename T> static bool VerifyCallComputation(T* comp) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 137 }
137 138
138 139
139 LocationSummary* InstanceCallComp::MakeLocationSummary() const { 140 LocationSummary* InstanceCallComp::MakeLocationSummary() const {
140 return MakeCallSummary(); 141 return MakeCallSummary();
141 } 142 }
142 143
143 144
144 void InstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { 145 void InstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) {
145 ASSERT(VerifyCallComputation(this)); 146 ASSERT(VerifyCallComputation(this));
147 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
148 cid(),
149 token_index(),
150 try_index());
146 compiler->EmitInstanceCall(cid(), 151 compiler->EmitInstanceCall(cid(),
147 token_index(), 152 token_index(),
148 try_index(), 153 try_index(),
149 function_name(), 154 function_name(),
150 ArgumentCount(), 155 ArgumentCount(),
151 argument_names(), 156 argument_names(),
152 checked_argument_count()); 157 checked_argument_count());
153 } 158 }
154 159
155 160
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 LocationSummary* CatchEntryComp::MakeLocationSummary() const { 515 LocationSummary* CatchEntryComp::MakeLocationSummary() const {
511 return NULL; 516 return NULL;
512 } 517 }
513 518
514 519
515 void CatchEntryComp::EmitNativeCode(FlowGraphCompiler* compiler) { 520 void CatchEntryComp::EmitNativeCode(FlowGraphCompiler* compiler) {
516 UNIMPLEMENTED(); 521 UNIMPLEMENTED();
517 } 522 }
518 523
519 524
525 LocationSummary* BinaryOpComp::MakeLocationSummary() const {
526 return MakeSimpleLocationSummary(2, Location::SameAsFirstInput());
527 }
528
529
530 // TODO(srdjan): Implement variations.
531 static bool TryEmitSmiBinaryOp(FlowGraphCompiler* compiler,
532 BinaryOpComp* comp) {
533 ASSERT((comp->ic_data() != NULL));
534 const ICData& ic_data = *comp->ic_data();
535 if (ic_data.IsNull()) return false;
536 if (ic_data.num_args_tested() != 2) return false;
537 if (ic_data.NumberOfChecks() != 1) return false;
538 Function& target = Function::Handle();
539 GrowableArray<const Class*> classes;
540 ic_data.GetCheckAt(0, &classes, &target);
541 const Class& smi_class =
542 Class::Handle(Isolate::Current()->object_store()->smi_class());
543 if ((classes[0]->raw() != smi_class.raw()) ||
544 (classes[1]->raw() != smi_class.raw())) {
545 return false;
546 }
547 // TODO(srdjan): need to allocate a temporary register (now using r10)
548 Register left = comp->locs()->in(0).reg();
549 Register right = comp->locs()->in(1).reg();
550 Register result = comp->locs()->out().reg();
551 Register temp = R10;
552 Label* deopt = compiler->AddDeoptStub(comp->instance_call()->cid(),
553 comp->instance_call()->token_index(),
554 comp->instance_call()->try_index(),
555 kDeoptSmiBinaryOp,
556 temp,
557 right);
558 __ movq(temp, left);
559 __ orq(left, right);
560 __ testq(left, Immediate(kSmiTagMask));
561 __ j(NOT_ZERO, deopt);
562 __ movq(left, temp);
563 switch (comp->op_kind()) {
564 case Token::kADD: {
565 __ addq(left, right);
566 __ j(OVERFLOW, deopt);
567 if (result != left) {
568 __ movq(result, left);
569 }
570 break;
571 }
572 default:
573 UNREACHABLE();
574 }
575 return true;
576 }
577
578 void BinaryOpComp::EmitNativeCode(FlowGraphCompiler* compiler) {
579 if (TryEmitSmiBinaryOp(compiler, this)) {
580 // Operation inlined.
581 return;
582 }
583 // TODO(srdjan): Remove this code once BinaryOpComp has been implemeneted
584 // for all intended operations.
585 Register left = locs()->in(0).reg();
586 Register right = locs()->in(1).reg();
587 __ pushq(left);
588 __ pushq(right);
589 InstanceCallComp* instance_call_comp = instance_call();
590 instance_call_comp->EmitNativeCode(compiler);
591 if (locs()->out().reg() != RAX) {
592 __ movq(locs()->out().reg(), RAX);
593 }
594 }
595
520 } // namespace dart 596 } // namespace dart
521 597
522 #undef __ 598 #undef __
523 599
524 #endif // defined TARGET_ARCH_X64 600 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_test.cc ('k') | runtime/vm/stub_code_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698