OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 Register left = locs()->in(0).reg(); | |
584 Register right = locs()->in(1).reg(); | |
585 __ pushq(left); | |
586 __ pushq(right); | |
Florian Schneider
2012/05/24 02:13:30
It would be nice to avoid having to push the argum
srdjan
2012/05/24 16:41:19
This code is only transition code (adding comment)
| |
587 InstanceCallComp* instance_call_comp = instance_call(); | |
588 instance_call_comp->EmitNativeCode(compiler); | |
589 if (locs()->out().reg() != RAX) { | |
590 __ movq(locs()->out().reg(), RAX); | |
591 } | |
592 } | |
593 | |
520 } // namespace dart | 594 } // namespace dart |
521 | 595 |
522 #undef __ | 596 #undef __ |
523 | 597 |
524 #endif // defined TARGET_ARCH_X64 | 598 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |