| 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 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 | 957 |
| 958 __ Bind(&is_instance); | 958 __ Bind(&is_instance); |
| 959 __ LoadObject(RAX, negate_result ? bool_false : bool_true); | 959 __ LoadObject(RAX, negate_result ? bool_false : bool_true); |
| 960 __ Bind(&done); | 960 __ Bind(&done); |
| 961 __ popq(RDX); // Remove pushed instantiator type arguments.. | 961 __ popq(RDX); // Remove pushed instantiator type arguments.. |
| 962 __ popq(RCX); // Remove pushed instantiator. | 962 __ popq(RCX); // Remove pushed instantiator. |
| 963 } | 963 } |
| 964 | 964 |
| 965 | 965 |
| 966 void FlowGraphCompiler::VisitInstanceOf(InstanceOfComp* comp) { | 966 void FlowGraphCompiler::VisitInstanceOf(InstanceOfComp* comp) { |
| 967 const Immediate raw_null = | 967 // Moved to intermediate_language_x64.cc. |
| 968 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 968 UNREACHABLE(); |
| 969 if (comp->type_arguments() == NULL) { | |
| 970 __ movq(RDX, raw_null); | |
| 971 } else { | |
| 972 LoadValue(RDX, comp->type_arguments()); | |
| 973 } | |
| 974 if (comp->instantiator() == NULL) { | |
| 975 __ movq(RCX, raw_null); | |
| 976 } else { | |
| 977 LoadValue(RCX, comp->instantiator()); | |
| 978 } | |
| 979 LoadValue(RAX, comp->value()); | |
| 980 GenerateInstanceOf(comp->cid(), | |
| 981 comp->token_index(), | |
| 982 comp->try_index(), | |
| 983 comp->type(), | |
| 984 comp->negate_result()); | |
| 985 } | 969 } |
| 986 | 970 |
| 987 | 971 |
| 988 void FlowGraphCompiler::VisitAllocateObject(AllocateObjectComp* comp) { | 972 void FlowGraphCompiler::VisitAllocateObject(AllocateObjectComp* comp) { |
| 989 // Moved to intermediate_language_x64.cc. | 973 // Moved to intermediate_language_x64.cc. |
| 990 UNREACHABLE(); | 974 UNREACHABLE(); |
| 991 } | 975 } |
| 992 | 976 |
| 993 | 977 |
| 994 void FlowGraphCompiler::VisitAllocateObjectWithBoundsCheck( | 978 void FlowGraphCompiler::VisitAllocateObjectWithBoundsCheck( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 | 1029 |
| 1046 | 1030 |
| 1047 void FlowGraphCompiler::VisitStoreVMField(StoreVMFieldComp* comp) { | 1031 void FlowGraphCompiler::VisitStoreVMField(StoreVMFieldComp* comp) { |
| 1048 // Moved to intermediate_language_x64.cc. | 1032 // Moved to intermediate_language_x64.cc. |
| 1049 UNREACHABLE(); | 1033 UNREACHABLE(); |
| 1050 } | 1034 } |
| 1051 | 1035 |
| 1052 | 1036 |
| 1053 void FlowGraphCompiler::VisitInstantiateTypeArguments( | 1037 void FlowGraphCompiler::VisitInstantiateTypeArguments( |
| 1054 InstantiateTypeArgumentsComp* comp) { | 1038 InstantiateTypeArgumentsComp* comp) { |
| 1055 __ popq(RAX); // Instantiator. | 1039 // Moved to intermediate_language_x64.cc. |
| 1056 | 1040 UNREACHABLE(); |
| 1057 // RAX is the instantiator AbstractTypeArguments object (or null). | |
| 1058 // If the instantiator is null and if the type argument vector | |
| 1059 // instantiated from null becomes a vector of Dynamic, then use null as | |
| 1060 // the type arguments. | |
| 1061 Label type_arguments_instantiated; | |
| 1062 const intptr_t len = comp->type_arguments().Length(); | |
| 1063 if (comp->type_arguments().IsRawInstantiatedRaw(len)) { | |
| 1064 const Immediate raw_null = | |
| 1065 Immediate(reinterpret_cast<intptr_t>(Object::null())); | |
| 1066 __ cmpq(RAX, raw_null); | |
| 1067 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); | |
| 1068 } | |
| 1069 // Instantiate non-null type arguments. | |
| 1070 if (comp->type_arguments().IsUninstantiatedIdentity()) { | |
| 1071 Label type_arguments_uninstantiated; | |
| 1072 // Check if the instantiator type argument vector is a TypeArguments of a | |
| 1073 // matching length and, if so, use it as the instantiated type_arguments. | |
| 1074 // No need to check the instantiator (RAX) for null here, because a null | |
| 1075 // instantiator will have the wrong class (Null instead of TypeArguments). | |
| 1076 __ LoadObject(RCX, Class::ZoneHandle(Object::type_arguments_class())); | |
| 1077 __ cmpq(RCX, FieldAddress(RAX, Object::class_offset())); | |
| 1078 __ j(NOT_EQUAL, &type_arguments_uninstantiated, Assembler::kNearJump); | |
| 1079 Immediate arguments_length = | |
| 1080 Immediate(Smi::RawValue(comp->type_arguments().Length())); | |
| 1081 __ cmpq(FieldAddress(RAX, TypeArguments::length_offset()), | |
| 1082 arguments_length); | |
| 1083 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); | |
| 1084 __ Bind(&type_arguments_uninstantiated); | |
| 1085 } | |
| 1086 // A runtime call to instantiate the type arguments is required. | |
| 1087 __ PushObject(Object::ZoneHandle()); // Make room for the result. | |
| 1088 __ PushObject(comp->type_arguments()); | |
| 1089 __ pushq(RAX); // Push instantiator type arguments. | |
| 1090 GenerateCallRuntime(comp->cid(), | |
| 1091 comp->token_index(), | |
| 1092 comp->try_index(), | |
| 1093 kInstantiateTypeArgumentsRuntimeEntry); | |
| 1094 __ popq(RAX); // Pop instantiator type arguments. | |
| 1095 __ popq(RAX); // Pop uninstantiated type arguments. | |
| 1096 __ popq(RAX); // Pop instantiated type arguments. | |
| 1097 __ Bind(&type_arguments_instantiated); | |
| 1098 // RAX: Instantiated type arguments. | |
| 1099 } | 1041 } |
| 1100 | 1042 |
| 1101 | 1043 |
| 1102 void FlowGraphCompiler::VisitExtractConstructorTypeArguments( | 1044 void FlowGraphCompiler::VisitExtractConstructorTypeArguments( |
| 1103 ExtractConstructorTypeArgumentsComp* comp) { | 1045 ExtractConstructorTypeArgumentsComp* comp) { |
| 1104 __ popq(RAX); // Instantiator. | 1046 __ popq(RAX); // Instantiator. |
| 1105 | 1047 |
| 1106 // RAX is the instantiator AbstractTypeArguments object (or null). | 1048 // RAX is the instantiator AbstractTypeArguments object (or null). |
| 1107 // If the instantiator is null and if the type argument vector | 1049 // If the instantiator is null and if the type argument vector |
| 1108 // instantiated from null becomes a vector of Dynamic, then use null as | 1050 // instantiated from null becomes a vector of Dynamic, then use null as |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1828 | 1770 |
| 1829 void FlowGraphCompiler::FinalizeComments(const Code& code) { | 1771 void FlowGraphCompiler::FinalizeComments(const Code& code) { |
| 1830 code.set_comments(assembler_->GetCodeComments()); | 1772 code.set_comments(assembler_->GetCodeComments()); |
| 1831 } | 1773 } |
| 1832 | 1774 |
| 1833 #undef __ | 1775 #undef __ |
| 1834 | 1776 |
| 1835 } // namespace dart | 1777 } // namespace dart |
| 1836 | 1778 |
| 1837 #endif // defined TARGET_ARCH_X64 | 1779 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |