| 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 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 comp->token_index(), | 428 comp->token_index(), |
| 429 comp->try_index(), | 429 comp->try_index(), |
| 430 kConditionTypeErrorRuntimeEntry); | 430 kConditionTypeErrorRuntimeEntry); |
| 431 // We should never return here. | 431 // We should never return here. |
| 432 __ int3(); | 432 __ int3(); |
| 433 | 433 |
| 434 __ Bind(&done); | 434 __ Bind(&done); |
| 435 } | 435 } |
| 436 | 436 |
| 437 | 437 |
| 438 // True iff. the arguments to a call will be properly pushed and can |
| 439 // be popped after the call. |
| 440 template <typename T> static bool VerifyCallComputation(T* comp) { |
| 441 // Argument values should be consecutive temps. |
| 442 // |
| 443 // TODO(kmillikin): implement stack height tracking so we can also assert |
| 444 // they are on top of the stack. |
| 445 intptr_t previous = -1; |
| 446 for (int i = 0; i < comp->ArgumentCount(); ++i) { |
| 447 Value* val = comp->ArgumentAt(i); |
| 448 if (!val->IsUse()) return false; |
| 449 intptr_t current = val->AsUse()->definition()->temp_index(); |
| 450 if (i != 0) { |
| 451 if (current != (previous + 1)) return false; |
| 452 } |
| 453 previous = current; |
| 454 } |
| 455 return true; |
| 456 } |
| 457 |
| 458 |
| 438 // Truee iff. the v2 is above v1 on stack, or one of them is constant. | 459 // Truee iff. the v2 is above v1 on stack, or one of them is constant. |
| 439 static bool VerifyValues(Value* v1, Value* v2) { | 460 static bool VerifyValues(Value* v1, Value* v2) { |
| 440 if (v1->IsUse() && v2->IsUse()) { | 461 if (v1->IsUse() && v2->IsUse()) { |
| 441 return (v1->AsUse()->definition()->temp_index() + 1) == | 462 return (v1->AsUse()->definition()->temp_index() + 1) == |
| 442 v2->AsUse()->definition()->temp_index(); | 463 v2->AsUse()->definition()->temp_index(); |
| 443 } | 464 } |
| 444 return true; | 465 return true; |
| 445 } | 466 } |
| 446 | 467 |
| 447 | 468 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 __ movq(RAX, CTX); | 523 __ movq(RAX, CTX); |
| 503 } | 524 } |
| 504 | 525 |
| 505 | 526 |
| 506 void FlowGraphCompiler::VisitStoreContext(StoreContextComp* comp) { | 527 void FlowGraphCompiler::VisitStoreContext(StoreContextComp* comp) { |
| 507 LoadValue(CTX, comp->value()); | 528 LoadValue(CTX, comp->value()); |
| 508 } | 529 } |
| 509 | 530 |
| 510 | 531 |
| 511 void FlowGraphCompiler::VisitClosureCall(ClosureCallComp* comp) { | 532 void FlowGraphCompiler::VisitClosureCall(ClosureCallComp* comp) { |
| 512 // Moved to intermediate_language_x64.cc. | 533 ASSERT(VerifyCallComputation(comp)); |
| 513 UNREACHABLE(); | 534 // The arguments to the stub include the closure. The arguments |
| 535 // descriptor describes the closure's arguments (and so does not include |
| 536 // the closure). |
| 537 int argument_count = comp->ArgumentCount(); |
| 538 const Array& arguments_descriptor = |
| 539 CodeGenerator::ArgumentsDescriptor(argument_count - 1, |
| 540 comp->argument_names()); |
| 541 __ LoadObject(R10, arguments_descriptor); |
| 542 |
| 543 GenerateCall(comp->token_index(), |
| 544 comp->try_index(), |
| 545 &StubCode::CallClosureFunctionLabel(), |
| 546 PcDescriptors::kOther); |
| 547 __ Drop(argument_count); |
| 514 } | 548 } |
| 515 | 549 |
| 516 | 550 |
| 517 void FlowGraphCompiler::VisitInstanceCall(InstanceCallComp* comp) { | 551 void FlowGraphCompiler::VisitInstanceCall(InstanceCallComp* comp) { |
| 518 // Moved to intermediate_language_x64.cc. | 552 ASSERT(VerifyCallComputation(comp)); |
| 519 UNREACHABLE(); | 553 EmitInstanceCall(comp->cid(), |
| 554 comp->token_index(), |
| 555 comp->try_index(), |
| 556 comp->function_name(), |
| 557 comp->ArgumentCount(), |
| 558 comp->argument_names(), |
| 559 comp->checked_argument_count()); |
| 520 } | 560 } |
| 521 | 561 |
| 522 | 562 |
| 523 void FlowGraphCompiler::VisitStrictCompare(StrictCompareComp* comp) { | 563 void FlowGraphCompiler::VisitStrictCompare(StrictCompareComp* comp) { |
| 524 // Visitor should not be used to compile this instruction. | 564 // Visitor should not be used to compile this instruction. |
| 525 // Native code template for StrictCompareComp was moved to | 565 // Native code template for StrictCompareComp was moved to |
| 526 // StrictCompareComp::EmitNativeCode. | 566 // StrictCompareComp::EmitNativeCode. |
| 527 UNREACHABLE(); | 567 UNREACHABLE(); |
| 528 } | 568 } |
| 529 | 569 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 560 comp->try_index(), | 600 comp->try_index(), |
| 561 operator_name, | 601 operator_name, |
| 562 kNumberOfArguments, | 602 kNumberOfArguments, |
| 563 kNoArgumentNames, | 603 kNoArgumentNames, |
| 564 kNumArgumentsChecked); | 604 kNumArgumentsChecked); |
| 565 __ Bind(&done); | 605 __ Bind(&done); |
| 566 } | 606 } |
| 567 | 607 |
| 568 | 608 |
| 569 void FlowGraphCompiler::VisitStaticCall(StaticCallComp* comp) { | 609 void FlowGraphCompiler::VisitStaticCall(StaticCallComp* comp) { |
| 570 // Moved to intermediate_language_x64.cc. | 610 ASSERT(VerifyCallComputation(comp)); |
| 571 UNREACHABLE(); | 611 EmitStaticCall(comp->token_index(), |
| 612 comp->try_index(), |
| 613 comp->function(), |
| 614 comp->ArgumentCount(), |
| 615 comp->argument_names()); |
| 572 } | 616 } |
| 573 | 617 |
| 574 | 618 |
| 575 void FlowGraphCompiler::VisitLoadLocal(LoadLocalComp* comp) { | 619 void FlowGraphCompiler::VisitLoadLocal(LoadLocalComp* comp) { |
| 576 __ movq(RAX, Address(RBP, comp->local().index() * kWordSize)); | 620 __ movq(RAX, Address(RBP, comp->local().index() * kWordSize)); |
| 577 } | 621 } |
| 578 | 622 |
| 579 | 623 |
| 580 void FlowGraphCompiler::VisitStoreLocal(StoreLocalComp* comp) { | 624 void FlowGraphCompiler::VisitStoreLocal(StoreLocalComp* comp) { |
| 581 LoadValue(RAX, comp->value()); | 625 LoadValue(RAX, comp->value()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 603 } | 647 } |
| 604 | 648 |
| 605 | 649 |
| 606 void FlowGraphCompiler::VisitLoadInstanceField(LoadInstanceFieldComp* comp) { | 650 void FlowGraphCompiler::VisitLoadInstanceField(LoadInstanceFieldComp* comp) { |
| 607 LoadValue(RAX, comp->instance()); | 651 LoadValue(RAX, comp->instance()); |
| 608 __ movq(RAX, FieldAddress(RAX, comp->field().Offset())); | 652 __ movq(RAX, FieldAddress(RAX, comp->field().Offset())); |
| 609 } | 653 } |
| 610 | 654 |
| 611 | 655 |
| 612 void FlowGraphCompiler::VisitStoreInstanceField(StoreInstanceFieldComp* comp) { | 656 void FlowGraphCompiler::VisitStoreInstanceField(StoreInstanceFieldComp* comp) { |
| 613 ASSERT(VerifyValues(comp->instance(), comp->value())); | 657 VerifyValues(comp->instance(), comp->value()); |
| 614 LoadValue(RDX, comp->value()); | 658 LoadValue(RDX, comp->value()); |
| 615 LoadValue(RAX, comp->instance()); | 659 LoadValue(RAX, comp->instance()); |
| 616 __ StoreIntoObject(RAX, FieldAddress(RAX, comp->field().Offset()), RDX); | 660 __ StoreIntoObject(RAX, FieldAddress(RAX, comp->field().Offset()), RDX); |
| 617 } | 661 } |
| 618 | 662 |
| 619 | 663 |
| 620 | 664 |
| 621 void FlowGraphCompiler::VisitLoadStaticField(LoadStaticFieldComp* comp) { | 665 void FlowGraphCompiler::VisitLoadStaticField(LoadStaticFieldComp* comp) { |
| 622 __ LoadObject(RDX, comp->field()); | 666 __ LoadObject(RDX, comp->field()); |
| 623 __ movq(RAX, FieldAddress(RDX, Field::value_offset())); | 667 __ movq(RAX, FieldAddress(RDX, Field::value_offset())); |
| (...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 | 1752 |
| 1709 | 1753 |
| 1710 void FlowGraphCompiler::FinalizeComments(const Code& code) { | 1754 void FlowGraphCompiler::FinalizeComments(const Code& code) { |
| 1711 code.set_comments(assembler_->GetCodeComments()); | 1755 code.set_comments(assembler_->GetCodeComments()); |
| 1712 } | 1756 } |
| 1713 | 1757 |
| 1714 | 1758 |
| 1715 } // namespace dart | 1759 } // namespace dart |
| 1716 | 1760 |
| 1717 #endif // defined TARGET_ARCH_X64 | 1761 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |