| 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 "lib/error.h" | 8 #include "lib/error.h" |
| 9 #include "vm/flow_graph_compiler.h" | 9 #include "vm/flow_graph_compiler.h" |
| 10 #include "vm/locations.h" | 10 #include "vm/locations.h" |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 Label done; | 487 Label done; |
| 488 __ LoadObject(result, bool_true); | 488 __ LoadObject(result, bool_true); |
| 489 __ cmpq(result, value); | 489 __ cmpq(result, value); |
| 490 __ j(NOT_EQUAL, &done, Assembler::kNearJump); | 490 __ j(NOT_EQUAL, &done, Assembler::kNearJump); |
| 491 __ LoadObject(result, bool_false); | 491 __ LoadObject(result, bool_false); |
| 492 __ Bind(&done); | 492 __ Bind(&done); |
| 493 } | 493 } |
| 494 | 494 |
| 495 | 495 |
| 496 LocationSummary* InstanceOfComp::MakeLocationSummary() const { | 496 LocationSummary* InstanceOfComp::MakeLocationSummary() const { |
| 497 return NULL; | 497 LocationSummary* summary = new LocationSummary(3, 0); |
| 498 summary->set_in(0, Location::RegisterLocation(RAX)); |
| 499 summary->set_in(1, Location::RegisterLocation(RCX)); |
| 500 summary->set_in(2, Location::RegisterLocation(RDX)); |
| 501 summary->set_out(Location::RegisterLocation(RAX)); |
| 502 return summary; |
| 498 } | 503 } |
| 499 | 504 |
| 500 | 505 |
| 501 void InstanceOfComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 506 void InstanceOfComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 502 UNIMPLEMENTED(); | 507 ASSERT(locs()->in(0).reg() == RAX); // Value. |
| 508 ASSERT(locs()->in(1).reg() == RCX); // Instantiator. |
| 509 ASSERT(locs()->in(2).reg() == RDX); // Instantiator type arguments. |
| 510 |
| 511 compiler->GenerateInstanceOf(cid(), |
| 512 token_index(), |
| 513 try_index(), |
| 514 type(), |
| 515 negate_result()); |
| 516 ASSERT(locs()->out().reg() == RAX); |
| 503 } | 517 } |
| 504 | 518 |
| 505 | 519 |
| 506 LocationSummary* CreateArrayComp::MakeLocationSummary() const { | 520 LocationSummary* CreateArrayComp::MakeLocationSummary() const { |
| 507 return NULL; | 521 return NULL; |
| 508 } | 522 } |
| 509 | 523 |
| 510 | 524 |
| 511 void CreateArrayComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 525 void CreateArrayComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 512 UNIMPLEMENTED(); | 526 UNIMPLEMENTED(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 Register value_reg = locs()->in(0).reg(); | 606 Register value_reg = locs()->in(0).reg(); |
| 593 Register dest_reg = locs()->in(1).reg(); | 607 Register dest_reg = locs()->in(1).reg(); |
| 594 ASSERT(value_reg == locs()->out().reg()); | 608 ASSERT(value_reg == locs()->out().reg()); |
| 595 | 609 |
| 596 __ StoreIntoObject(dest_reg, FieldAddress(dest_reg, offset_in_bytes()), | 610 __ StoreIntoObject(dest_reg, FieldAddress(dest_reg, offset_in_bytes()), |
| 597 value_reg); | 611 value_reg); |
| 598 } | 612 } |
| 599 | 613 |
| 600 | 614 |
| 601 LocationSummary* InstantiateTypeArgumentsComp::MakeLocationSummary() const { | 615 LocationSummary* InstantiateTypeArgumentsComp::MakeLocationSummary() const { |
| 602 return NULL; | 616 const intptr_t kNumInputs = 1; |
| 617 const intptr_t kNumTemps = 1; |
| 618 LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps); |
| 619 locs->set_in(0, Location::RequiresRegister()); |
| 620 locs->set_temp(0, Location::RequiresRegister()); |
| 621 locs->set_out(Location::SameAsFirstInput()); |
| 622 return locs; |
| 603 } | 623 } |
| 604 | 624 |
| 605 | 625 |
| 606 void InstantiateTypeArgumentsComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 626 void InstantiateTypeArgumentsComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 607 UNIMPLEMENTED(); | 627 Register instantiator_reg = locs()->in(0).reg(); |
| 628 Register temp_reg = locs()->temp(0).reg(); |
| 629 Register result_reg = locs()->out().reg(); |
| 630 |
| 631 // 'instantiator_reg' is the instantiator AbstractTypeArguments object |
| 632 // (or null). |
| 633 // If the instantiator is null and if the type argument vector |
| 634 // instantiated from null becomes a vector of Dynamic, then use null as |
| 635 // the type arguments. |
| 636 Label type_arguments_instantiated; |
| 637 const intptr_t len = type_arguments().Length(); |
| 638 if (type_arguments().IsRawInstantiatedRaw(len)) { |
| 639 const Immediate raw_null = |
| 640 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 641 __ cmpq(instantiator_reg, raw_null); |
| 642 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); |
| 643 } |
| 644 // Instantiate non-null type arguments. |
| 645 if (type_arguments().IsUninstantiatedIdentity()) { |
| 646 Label type_arguments_uninstantiated; |
| 647 // Check if the instantiator type argument vector is a TypeArguments of a |
| 648 // matching length and, if so, use it as the instantiated type_arguments. |
| 649 // No need to check the instantiator ('instantiator_reg') for null here, |
| 650 // because a null instantiator will have the wrong class (Null instead of |
| 651 // TypeArguments). |
| 652 __ LoadObject(temp_reg, Class::ZoneHandle(Object::type_arguments_class())); |
| 653 __ cmpq(temp_reg, FieldAddress(instantiator_reg, Object::class_offset())); |
| 654 __ j(NOT_EQUAL, &type_arguments_uninstantiated, Assembler::kNearJump); |
| 655 Immediate arguments_length = |
| 656 Immediate(Smi::RawValue(type_arguments().Length())); |
| 657 __ cmpq(FieldAddress(instantiator_reg, TypeArguments::length_offset()), |
| 658 arguments_length); |
| 659 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); |
| 660 __ Bind(&type_arguments_uninstantiated); |
| 661 } |
| 662 // A runtime call to instantiate the type arguments is required. |
| 663 __ PushObject(Object::ZoneHandle()); // Make room for the result. |
| 664 __ PushObject(type_arguments()); |
| 665 __ pushq(instantiator_reg); // Push instantiator type arguments. |
| 666 compiler->GenerateCallRuntime(cid(), |
| 667 token_index(), |
| 668 try_index(), |
| 669 kInstantiateTypeArgumentsRuntimeEntry); |
| 670 __ popq(temp_reg); // Pop instantiator type arguments. |
| 671 __ popq(temp_reg); // Pop uninstantiated type arguments. |
| 672 __ popq(result_reg); // Pop instantiated type arguments. |
| 673 __ Bind(&type_arguments_instantiated); |
| 674 ASSERT(instantiator_reg == result_reg); |
| 675 // 'result_reg': Instantiated type arguments. |
| 608 } | 676 } |
| 609 | 677 |
| 610 | 678 |
| 611 LocationSummary* ExtractConstructorTypeArgumentsComp:: | 679 LocationSummary* ExtractConstructorTypeArgumentsComp:: |
| 612 MakeLocationSummary() const { | 680 MakeLocationSummary() const { |
| 613 return NULL; | 681 return NULL; |
| 614 } | 682 } |
| 615 | 683 |
| 616 | 684 |
| 617 void ExtractConstructorTypeArgumentsComp::EmitNativeCode( | 685 void ExtractConstructorTypeArgumentsComp::EmitNativeCode( |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 if (locs()->out().reg() != RAX) { | 902 if (locs()->out().reg() != RAX) { |
| 835 __ movq(locs()->out().reg(), RAX); | 903 __ movq(locs()->out().reg(), RAX); |
| 836 } | 904 } |
| 837 } | 905 } |
| 838 | 906 |
| 839 } // namespace dart | 907 } // namespace dart |
| 840 | 908 |
| 841 #undef __ | 909 #undef __ |
| 842 | 910 |
| 843 #endif // defined TARGET_ARCH_X64 | 911 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |