| 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 | |
| 459 // Truee iff. the v2 is above v1 on stack, or one of them is constant. | 438 // Truee iff. the v2 is above v1 on stack, or one of them is constant. |
| 460 static bool VerifyValues(Value* v1, Value* v2) { | 439 static bool VerifyValues(Value* v1, Value* v2) { |
| 461 if (v1->IsUse() && v2->IsUse()) { | 440 if (v1->IsUse() && v2->IsUse()) { |
| 462 return (v1->AsUse()->definition()->temp_index() + 1) == | 441 return (v1->AsUse()->definition()->temp_index() + 1) == |
| 463 v2->AsUse()->definition()->temp_index(); | 442 v2->AsUse()->definition()->temp_index(); |
| 464 } | 443 } |
| 465 return true; | 444 return true; |
| 466 } | 445 } |
| 467 | 446 |
| 468 | 447 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 __ movq(RAX, CTX); | 502 __ movq(RAX, CTX); |
| 524 } | 503 } |
| 525 | 504 |
| 526 | 505 |
| 527 void FlowGraphCompiler::VisitStoreContext(StoreContextComp* comp) { | 506 void FlowGraphCompiler::VisitStoreContext(StoreContextComp* comp) { |
| 528 LoadValue(CTX, comp->value()); | 507 LoadValue(CTX, comp->value()); |
| 529 } | 508 } |
| 530 | 509 |
| 531 | 510 |
| 532 void FlowGraphCompiler::VisitClosureCall(ClosureCallComp* comp) { | 511 void FlowGraphCompiler::VisitClosureCall(ClosureCallComp* comp) { |
| 533 ASSERT(VerifyCallComputation(comp)); | 512 // Moved to intermediate_language_x64.cc. |
| 534 // The arguments to the stub include the closure. The arguments | 513 UNREACHABLE(); |
| 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); | |
| 548 } | 514 } |
| 549 | 515 |
| 550 | 516 |
| 551 void FlowGraphCompiler::VisitInstanceCall(InstanceCallComp* comp) { | 517 void FlowGraphCompiler::VisitInstanceCall(InstanceCallComp* comp) { |
| 552 ASSERT(VerifyCallComputation(comp)); | 518 // Moved to intermediate_language_x64.cc. |
| 553 EmitInstanceCall(comp->cid(), | 519 UNREACHABLE(); |
| 554 comp->token_index(), | |
| 555 comp->try_index(), | |
| 556 comp->function_name(), | |
| 557 comp->ArgumentCount(), | |
| 558 comp->argument_names(), | |
| 559 comp->checked_argument_count()); | |
| 560 } | 520 } |
| 561 | 521 |
| 562 | 522 |
| 563 void FlowGraphCompiler::VisitStrictCompare(StrictCompareComp* comp) { | 523 void FlowGraphCompiler::VisitStrictCompare(StrictCompareComp* comp) { |
| 564 // Visitor should not be used to compile this instruction. | 524 // Visitor should not be used to compile this instruction. |
| 565 // Native code template for StrictCompareComp was moved to | 525 // Native code template for StrictCompareComp was moved to |
| 566 // StrictCompareComp::EmitNativeCode. | 526 // StrictCompareComp::EmitNativeCode. |
| 567 UNREACHABLE(); | 527 UNREACHABLE(); |
| 568 } | 528 } |
| 569 | 529 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 600 comp->try_index(), | 560 comp->try_index(), |
| 601 operator_name, | 561 operator_name, |
| 602 kNumberOfArguments, | 562 kNumberOfArguments, |
| 603 kNoArgumentNames, | 563 kNoArgumentNames, |
| 604 kNumArgumentsChecked); | 564 kNumArgumentsChecked); |
| 605 __ Bind(&done); | 565 __ Bind(&done); |
| 606 } | 566 } |
| 607 | 567 |
| 608 | 568 |
| 609 void FlowGraphCompiler::VisitStaticCall(StaticCallComp* comp) { | 569 void FlowGraphCompiler::VisitStaticCall(StaticCallComp* comp) { |
| 610 ASSERT(VerifyCallComputation(comp)); | 570 // Moved to intermediate_language_x64.cc. |
| 611 EmitStaticCall(comp->token_index(), | 571 UNREACHABLE(); |
| 612 comp->try_index(), | |
| 613 comp->function(), | |
| 614 comp->ArgumentCount(), | |
| 615 comp->argument_names()); | |
| 616 } | 572 } |
| 617 | 573 |
| 618 | 574 |
| 619 void FlowGraphCompiler::VisitLoadLocal(LoadLocalComp* comp) { | 575 void FlowGraphCompiler::VisitLoadLocal(LoadLocalComp* comp) { |
| 620 __ movq(RAX, Address(RBP, comp->local().index() * kWordSize)); | 576 __ movq(RAX, Address(RBP, comp->local().index() * kWordSize)); |
| 621 } | 577 } |
| 622 | 578 |
| 623 | 579 |
| 624 void FlowGraphCompiler::VisitStoreLocal(StoreLocalComp* comp) { | 580 void FlowGraphCompiler::VisitStoreLocal(StoreLocalComp* comp) { |
| 625 LoadValue(RAX, comp->value()); | 581 LoadValue(RAX, comp->value()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 647 } | 603 } |
| 648 | 604 |
| 649 | 605 |
| 650 void FlowGraphCompiler::VisitLoadInstanceField(LoadInstanceFieldComp* comp) { | 606 void FlowGraphCompiler::VisitLoadInstanceField(LoadInstanceFieldComp* comp) { |
| 651 LoadValue(RAX, comp->instance()); | 607 LoadValue(RAX, comp->instance()); |
| 652 __ movq(RAX, FieldAddress(RAX, comp->field().Offset())); | 608 __ movq(RAX, FieldAddress(RAX, comp->field().Offset())); |
| 653 } | 609 } |
| 654 | 610 |
| 655 | 611 |
| 656 void FlowGraphCompiler::VisitStoreInstanceField(StoreInstanceFieldComp* comp) { | 612 void FlowGraphCompiler::VisitStoreInstanceField(StoreInstanceFieldComp* comp) { |
| 657 VerifyValues(comp->instance(), comp->value()); | 613 ASSERT(VerifyValues(comp->instance(), comp->value())); |
| 658 LoadValue(RDX, comp->value()); | 614 LoadValue(RDX, comp->value()); |
| 659 LoadValue(RAX, comp->instance()); | 615 LoadValue(RAX, comp->instance()); |
| 660 __ StoreIntoObject(RAX, FieldAddress(RAX, comp->field().Offset()), RDX); | 616 __ StoreIntoObject(RAX, FieldAddress(RAX, comp->field().Offset()), RDX); |
| 661 } | 617 } |
| 662 | 618 |
| 663 | 619 |
| 664 | 620 |
| 665 void FlowGraphCompiler::VisitLoadStaticField(LoadStaticFieldComp* comp) { | 621 void FlowGraphCompiler::VisitLoadStaticField(LoadStaticFieldComp* comp) { |
| 666 __ LoadObject(RDX, comp->field()); | 622 __ LoadObject(RDX, comp->field()); |
| 667 __ movq(RAX, FieldAddress(RDX, Field::value_offset())); | 623 __ movq(RAX, FieldAddress(RDX, Field::value_offset())); |
| (...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1755 | 1711 |
| 1756 | 1712 |
| 1757 void FlowGraphCompiler::FinalizeComments(const Code& code) { | 1713 void FlowGraphCompiler::FinalizeComments(const Code& code) { |
| 1758 code.set_comments(assembler_->GetCodeComments()); | 1714 code.set_comments(assembler_->GetCodeComments()); |
| 1759 } | 1715 } |
| 1760 | 1716 |
| 1761 | 1717 |
| 1762 } // namespace dart | 1718 } // namespace dart |
| 1763 | 1719 |
| 1764 #endif // defined TARGET_ARCH_X64 | 1720 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |