| 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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 __ popq(temp_reg); // Pop uninstantiated type arguments. | 776 __ popq(temp_reg); // Pop uninstantiated type arguments. |
| 777 __ popq(result_reg); // Pop instantiated type arguments. | 777 __ popq(result_reg); // Pop instantiated type arguments. |
| 778 __ Bind(&type_arguments_instantiated); | 778 __ Bind(&type_arguments_instantiated); |
| 779 ASSERT(instantiator_reg == result_reg); | 779 ASSERT(instantiator_reg == result_reg); |
| 780 // 'result_reg': Instantiated type arguments. | 780 // 'result_reg': Instantiated type arguments. |
| 781 } | 781 } |
| 782 | 782 |
| 783 | 783 |
| 784 LocationSummary* ExtractConstructorTypeArgumentsComp:: | 784 LocationSummary* ExtractConstructorTypeArgumentsComp:: |
| 785 MakeLocationSummary() const { | 785 MakeLocationSummary() const { |
| 786 return NULL; | 786 const intptr_t kNumInputs = 1; |
| 787 const intptr_t kNumTemps = 1; |
| 788 LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps); |
| 789 locs->set_in(0, Location::RequiresRegister()); |
| 790 locs->set_temp(0, Location::RequiresRegister()); |
| 791 locs->set_out(Location::SameAsFirstInput()); |
| 792 return locs; |
| 787 } | 793 } |
| 788 | 794 |
| 789 | 795 |
| 790 void ExtractConstructorTypeArgumentsComp::EmitNativeCode( | 796 void ExtractConstructorTypeArgumentsComp::EmitNativeCode( |
| 791 FlowGraphCompiler* compiler) { | 797 FlowGraphCompiler* compiler) { |
| 792 UNIMPLEMENTED(); | 798 Register instantiator_reg = locs()->in(0).reg(); |
| 799 Register temp_reg = locs()->temp(0).reg(); |
| 800 Register result_reg = locs()->out().reg(); |
| 801 ASSERT(instantiator_reg == result_reg); |
| 802 |
| 803 // instantiator_reg is the instantiator type argument vector, i.e. an |
| 804 // AbstractTypeArguments object (or null). |
| 805 // If the instantiator is null and if the type argument vector |
| 806 // instantiated from null becomes a vector of Dynamic, then use null as |
| 807 // the type arguments. |
| 808 Label type_arguments_instantiated; |
| 809 const intptr_t len = type_arguments().Length(); |
| 810 if (type_arguments().IsRawInstantiatedRaw(len)) { |
| 811 const Immediate raw_null = |
| 812 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 813 __ cmpq(instantiator_reg, raw_null); |
| 814 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); |
| 815 } |
| 816 // Instantiate non-null type arguments. |
| 817 if (type_arguments().IsUninstantiatedIdentity()) { |
| 818 // Check if the instantiator type argument vector is a TypeArguments of a |
| 819 // matching length and, if so, use it as the instantiated type_arguments. |
| 820 // No need to check instantiator_reg for null here, because a null |
| 821 // instantiator will have the wrong class (Null instead of TypeArguments). |
| 822 Label type_arguments_uninstantiated; |
| 823 __ LoadObject(temp_reg, Class::ZoneHandle(Object::type_arguments_class())); |
| 824 __ cmpq(temp_reg, FieldAddress(instantiator_reg, Object::class_offset())); |
| 825 __ j(NOT_EQUAL, &type_arguments_uninstantiated, Assembler::kNearJump); |
| 826 Immediate arguments_length = |
| 827 Immediate(Smi::RawValue(type_arguments().Length())); |
| 828 __ cmpq(FieldAddress(instantiator_reg, TypeArguments::length_offset()), |
| 829 arguments_length); |
| 830 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); |
| 831 __ Bind(&type_arguments_uninstantiated); |
| 832 } |
| 833 // In the non-factory case, we rely on the allocation stub to |
| 834 // instantiate the type arguments. |
| 835 __ LoadObject(result_reg, type_arguments()); |
| 836 // result_reg: uninstantiated type arguments. |
| 837 __ Bind(&type_arguments_instantiated); |
| 838 // result_reg: uninstantiated or instantiated type arguments. |
| 793 } | 839 } |
| 794 | 840 |
| 795 | 841 |
| 796 LocationSummary* ExtractConstructorInstantiatorComp:: | 842 LocationSummary* ExtractConstructorInstantiatorComp:: |
| 797 MakeLocationSummary() const { | 843 MakeLocationSummary() const { |
| 798 const intptr_t kNumInputs = 1; | 844 const intptr_t kNumInputs = 1; |
| 799 const intptr_t kNumTemps = 1; | 845 const intptr_t kNumTemps = 1; |
| 800 LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps); | 846 LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps); |
| 801 locs->set_in(0, Location::RequiresRegister()); | 847 locs->set_in(0, Location::RequiresRegister()); |
| 802 locs->set_temp(0, Location::RequiresRegister()); | 848 locs->set_temp(0, Location::RequiresRegister()); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 compiler->GenerateCallRuntime(cid(), | 961 compiler->GenerateCallRuntime(cid(), |
| 916 token_index(), | 962 token_index(), |
| 917 try_index(), | 963 try_index(), |
| 918 kCloneContextRuntimeEntry); | 964 kCloneContextRuntimeEntry); |
| 919 __ popq(result); // Remove argument. | 965 __ popq(result); // Remove argument. |
| 920 __ popq(result); // Get result (cloned context). | 966 __ popq(result); // Get result (cloned context). |
| 921 } | 967 } |
| 922 | 968 |
| 923 | 969 |
| 924 LocationSummary* CatchEntryComp::MakeLocationSummary() const { | 970 LocationSummary* CatchEntryComp::MakeLocationSummary() const { |
| 925 return NULL; | 971 return MakeSimpleLocationSummary(0, Location::NoLocation()); |
| 926 } | 972 } |
| 927 | 973 |
| 928 | 974 |
| 975 // Restore stack and initialize the two exception variables: |
| 976 // exception and stack trace variables. |
| 929 void CatchEntryComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 977 void CatchEntryComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 930 UNIMPLEMENTED(); | 978 // Restore RSP from RBP as we are coming from a throw and the code for |
| 979 // popping arguments has not been run. |
| 980 const intptr_t locals_space_size = compiler->StackSize() * kWordSize; |
| 981 ASSERT(locals_space_size >= 0); |
| 982 const intptr_t offset_size = |
| 983 -locals_space_size + FlowGraphCompiler::kLocalsOffsetFromFP; |
| 984 __ leaq(RSP, Address(RBP, offset_size)); |
| 985 |
| 986 ASSERT(!exception_var().is_captured()); |
| 987 ASSERT(!stacktrace_var().is_captured()); |
| 988 __ movq(Address(RBP, exception_var().index() * kWordSize), |
| 989 kExceptionObjectReg); |
| 990 __ movq(Address(RBP, stacktrace_var().index() * kWordSize), |
| 991 kStackTraceObjectReg); |
| 931 } | 992 } |
| 932 | 993 |
| 933 | 994 |
| 934 LocationSummary* BinaryOpComp::MakeLocationSummary() const { | 995 LocationSummary* BinaryOpComp::MakeLocationSummary() const { |
| 935 const intptr_t kNumTemps = 1; | 996 const intptr_t kNumTemps = 1; |
| 936 const intptr_t kNumInputs = 2; | 997 const intptr_t kNumInputs = 2; |
| 937 LocationSummary* summary = new LocationSummary(kNumInputs, kNumTemps); | 998 LocationSummary* summary = new LocationSummary(kNumInputs, kNumTemps); |
| 938 summary->set_in(0, Location::RequiresRegister()); | 999 summary->set_in(0, Location::RequiresRegister()); |
| 939 summary->set_in(1, Location::RequiresRegister()); | 1000 summary->set_in(1, Location::RequiresRegister()); |
| 940 summary->set_out(Location::SameAsFirstInput()); | 1001 summary->set_out(Location::SameAsFirstInput()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 if (locs()->out().reg() != RAX) { | 1068 if (locs()->out().reg() != RAX) { |
| 1008 __ movq(locs()->out().reg(), RAX); | 1069 __ movq(locs()->out().reg(), RAX); |
| 1009 } | 1070 } |
| 1010 } | 1071 } |
| 1011 | 1072 |
| 1012 } // namespace dart | 1073 } // namespace dart |
| 1013 | 1074 |
| 1014 #undef __ | 1075 #undef __ |
| 1015 | 1076 |
| 1016 #endif // defined TARGET_ARCH_X64 | 1077 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |