| 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 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 | 960 |
| 961 void FlowGraphCompiler::VisitInstantiateTypeArguments( | 961 void FlowGraphCompiler::VisitInstantiateTypeArguments( |
| 962 InstantiateTypeArgumentsComp* comp) { | 962 InstantiateTypeArgumentsComp* comp) { |
| 963 // Moved to intermediate_language_x64.cc. | 963 // Moved to intermediate_language_x64.cc. |
| 964 UNREACHABLE(); | 964 UNREACHABLE(); |
| 965 } | 965 } |
| 966 | 966 |
| 967 | 967 |
| 968 void FlowGraphCompiler::VisitExtractConstructorTypeArguments( | 968 void FlowGraphCompiler::VisitExtractConstructorTypeArguments( |
| 969 ExtractConstructorTypeArgumentsComp* comp) { | 969 ExtractConstructorTypeArgumentsComp* comp) { |
| 970 __ popq(RAX); // Instantiator. | 970 // Moved to intermediate_language_x64.cc. |
| 971 | 971 UNREACHABLE(); |
| 972 // RAX is the instantiator AbstractTypeArguments object (or null). | |
| 973 // If the instantiator is null and if the type argument vector | |
| 974 // instantiated from null becomes a vector of Dynamic, then use null as | |
| 975 // the type arguments. | |
| 976 Label type_arguments_instantiated; | |
| 977 const intptr_t len = comp->type_arguments().Length(); | |
| 978 if (comp->type_arguments().IsRawInstantiatedRaw(len)) { | |
| 979 const Immediate raw_null = | |
| 980 Immediate(reinterpret_cast<intptr_t>(Object::null())); | |
| 981 __ cmpq(RAX, raw_null); | |
| 982 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); | |
| 983 } | |
| 984 // Instantiate non-null type arguments. | |
| 985 if (comp->type_arguments().IsUninstantiatedIdentity()) { | |
| 986 // Check if the instantiator type argument vector is a TypeArguments of a | |
| 987 // matching length and, if so, use it as the instantiated type_arguments. | |
| 988 // No need to check the instantiator (RAX) for null here, because a null | |
| 989 // instantiator will have the wrong class (Null instead of TypeArguments). | |
| 990 Label type_arguments_uninstantiated; | |
| 991 __ LoadObject(RCX, Class::ZoneHandle(Object::type_arguments_class())); | |
| 992 __ cmpq(RCX, FieldAddress(RAX, Object::class_offset())); | |
| 993 __ j(NOT_EQUAL, &type_arguments_uninstantiated, Assembler::kNearJump); | |
| 994 Immediate arguments_length = | |
| 995 Immediate(Smi::RawValue(comp->type_arguments().Length())); | |
| 996 __ cmpq(FieldAddress(RAX, TypeArguments::length_offset()), | |
| 997 arguments_length); | |
| 998 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); | |
| 999 __ Bind(&type_arguments_uninstantiated); | |
| 1000 } | |
| 1001 // In the non-factory case, we rely on the allocation stub to | |
| 1002 // instantiate the type arguments. | |
| 1003 __ LoadObject(RAX, comp->type_arguments()); | |
| 1004 // RAX: uninstantiated type arguments. | |
| 1005 __ Bind(&type_arguments_instantiated); | |
| 1006 // RAX: uninstantiated or instantiated type arguments. | |
| 1007 } | 972 } |
| 1008 | 973 |
| 1009 | 974 |
| 1010 void FlowGraphCompiler::VisitExtractConstructorInstantiator( | 975 void FlowGraphCompiler::VisitExtractConstructorInstantiator( |
| 1011 ExtractConstructorInstantiatorComp* comp) { | 976 ExtractConstructorInstantiatorComp* comp) { |
| 1012 // Moved to intermediate_language_x64.cc. | 977 // Moved to intermediate_language_x64.cc. |
| 1013 UNREACHABLE(); | 978 UNREACHABLE(); |
| 1014 } | 979 } |
| 1015 | 980 |
| 1016 | 981 |
| 1017 void FlowGraphCompiler::VisitAllocateContext(AllocateContextComp* comp) { | 982 void FlowGraphCompiler::VisitAllocateContext(AllocateContextComp* comp) { |
| 1018 // Moved to intermediate_language_x64.cc. | 983 // Moved to intermediate_language_x64.cc. |
| 1019 UNREACHABLE(); | 984 UNREACHABLE(); |
| 1020 } | 985 } |
| 1021 | 986 |
| 1022 | 987 |
| 1023 void FlowGraphCompiler::VisitChainContext(ChainContextComp* comp) { | 988 void FlowGraphCompiler::VisitChainContext(ChainContextComp* comp) { |
| 1024 // Moved to intermediate_language_x64.cc. | 989 // Moved to intermediate_language_x64.cc. |
| 1025 UNREACHABLE(); | 990 UNREACHABLE(); |
| 1026 } | 991 } |
| 1027 | 992 |
| 1028 | 993 |
| 1029 void FlowGraphCompiler::VisitCloneContext(CloneContextComp* comp) { | 994 void FlowGraphCompiler::VisitCloneContext(CloneContextComp* comp) { |
| 1030 // Moved to intermediate_language_x64.cc. | 995 // Moved to intermediate_language_x64.cc. |
| 1031 UNREACHABLE(); | 996 UNREACHABLE(); |
| 1032 } | 997 } |
| 1033 | 998 |
| 1034 | 999 |
| 1035 // Restore stack and initialize the two exception variables: | |
| 1036 // exception and stack trace variables. | |
| 1037 void FlowGraphCompiler::VisitCatchEntry(CatchEntryComp* comp) { | 1000 void FlowGraphCompiler::VisitCatchEntry(CatchEntryComp* comp) { |
| 1038 // Restore RSP from RBP as we are coming from a throw and the code for | 1001 // Moved to intermediate_language_x64.cc. |
| 1039 // popping arguments has not been run. | 1002 UNREACHABLE(); |
| 1040 const intptr_t locals_space_size = StackSize() * kWordSize; | |
| 1041 ASSERT(locals_space_size >= 0); | |
| 1042 intptr_t offset_size = -locals_space_size + kLocalsOffsetFromFP; | |
| 1043 __ leaq(RSP, Address(RBP, offset_size)); | |
| 1044 | |
| 1045 ASSERT(!comp->exception_var().is_captured()); | |
| 1046 ASSERT(!comp->stacktrace_var().is_captured()); | |
| 1047 __ movq(Address(RBP, comp->exception_var().index() * kWordSize), | |
| 1048 kExceptionObjectReg); | |
| 1049 __ movq(Address(RBP, comp->stacktrace_var().index() * kWordSize), | |
| 1050 kStackTraceObjectReg); | |
| 1051 } | 1003 } |
| 1052 | 1004 |
| 1053 | 1005 |
| 1054 void FlowGraphCompiler::VisitBinaryOp(BinaryOpComp* comp) { | 1006 void FlowGraphCompiler::VisitBinaryOp(BinaryOpComp* comp) { |
| 1055 UNIMPLEMENTED(); | 1007 UNIMPLEMENTED(); |
| 1056 } | 1008 } |
| 1057 | 1009 |
| 1058 | 1010 |
| 1059 void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) { | 1011 void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) { |
| 1060 LocationSummary* locs = instr->locs(); | 1012 LocationSummary* locs = instr->locs(); |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1692 | 1644 |
| 1693 void FlowGraphCompiler::FinalizeComments(const Code& code) { | 1645 void FlowGraphCompiler::FinalizeComments(const Code& code) { |
| 1694 code.set_comments(assembler_->GetCodeComments()); | 1646 code.set_comments(assembler_->GetCodeComments()); |
| 1695 } | 1647 } |
| 1696 | 1648 |
| 1697 #undef __ | 1649 #undef __ |
| 1698 | 1650 |
| 1699 } // namespace dart | 1651 } // namespace dart |
| 1700 | 1652 |
| 1701 #endif // defined TARGET_ARCH_X64 | 1653 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |