| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/code_generator.h" | 5 #include "vm/code_generator.h" |
| 6 | 6 |
| 7 #include "vm/code_index_table.h" | 7 #include "vm/code_index_table.h" |
| 8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 } | 130 } |
| 131 return; | 131 return; |
| 132 } | 132 } |
| 133 ASSERT(!element_type.IsInstantiated()); | 133 ASSERT(!element_type.IsInstantiated()); |
| 134 // If possible, use the instantiator as the type argument vector. | 134 // If possible, use the instantiator as the type argument vector. |
| 135 if (element_type.IsUninstantiatedIdentity() && (instantiator.Length() == 1)) { | 135 if (element_type.IsUninstantiatedIdentity() && (instantiator.Length() == 1)) { |
| 136 // No need to check that the instantiator is a TypeArguments, since the | 136 // No need to check that the instantiator is a TypeArguments, since the |
| 137 // virtual call to Length() handles other cases that are harder to inline. | 137 // virtual call to Length() handles other cases that are harder to inline. |
| 138 element_type = instantiator.raw(); | 138 element_type = instantiator.raw(); |
| 139 } else { | 139 } else { |
| 140 element_type = | 140 element_type = InstantiatedTypeArguments::New(element_type, instantiator); |
| 141 AbstractTypeArguments::NewInstantiatedTypeArguments(element_type, | |
| 142 instantiator); | |
| 143 } | 141 } |
| 144 array.SetTypeArguments(element_type); | 142 array.SetTypeArguments(element_type); |
| 145 } | 143 } |
| 146 | 144 |
| 147 | 145 |
| 148 // Allocate a new object. | 146 // Allocate a new object. |
| 149 // Arg0: class of the object that needs to be allocated. | 147 // Arg0: class of the object that needs to be allocated. |
| 150 // Arg1: type arguments of the object that needs to be allocated. | 148 // Arg1: type arguments of the object that needs to be allocated. |
| 151 // Arg2: type arguments of the instantiator. | 149 // Arg2: type arguments of the instantiator. |
| 152 // Return value: newly allocated object. | 150 // Return value: newly allocated object. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 180 return; | 178 return; |
| 181 } | 179 } |
| 182 ASSERT(!type_arguments.IsInstantiated()); | 180 ASSERT(!type_arguments.IsInstantiated()); |
| 183 // If possible, use the instantiator as the type argument vector. | 181 // If possible, use the instantiator as the type argument vector. |
| 184 if (instantiator.IsTypeArguments()) { | 182 if (instantiator.IsTypeArguments()) { |
| 185 // Code inlined in the caller should have optimized the case where the | 183 // Code inlined in the caller should have optimized the case where the |
| 186 // instantiator is a TypeArguments and can be used as type argument vector. | 184 // instantiator is a TypeArguments and can be used as type argument vector. |
| 187 ASSERT(!type_arguments.IsUninstantiatedIdentity() || | 185 ASSERT(!type_arguments.IsUninstantiatedIdentity() || |
| 188 (instantiator.Length() != type_arguments.Length())); | 186 (instantiator.Length() != type_arguments.Length())); |
| 189 type_arguments = | 187 type_arguments = |
| 190 AbstractTypeArguments::NewInstantiatedTypeArguments(type_arguments, | 188 InstantiatedTypeArguments::New(type_arguments, instantiator); |
| 191 instantiator); | |
| 192 } else { | 189 } else { |
| 193 if (type_arguments.IsUninstantiatedIdentity() && | 190 if (type_arguments.IsUninstantiatedIdentity() && |
| 194 (instantiator.Length() == type_arguments.Length())) { | 191 (instantiator.Length() == type_arguments.Length())) { |
| 195 type_arguments = instantiator.raw(); | 192 type_arguments = instantiator.raw(); |
| 196 } else { | 193 } else { |
| 197 type_arguments = | 194 type_arguments = |
| 198 AbstractTypeArguments::NewInstantiatedTypeArguments(type_arguments, | 195 InstantiatedTypeArguments::New(type_arguments, instantiator); |
| 199 instantiator); | |
| 200 } | 196 } |
| 201 } | 197 } |
| 202 instance.SetTypeArguments(type_arguments); | 198 instance.SetTypeArguments(type_arguments); |
| 203 } | 199 } |
| 204 | 200 |
| 205 | 201 |
| 206 // Instantiate type arguments. | 202 // Instantiate type arguments. |
| 207 // Arg0: uninstantiated type arguments. | 203 // Arg0: uninstantiated type arguments. |
| 208 // Arg1: instantiator type arguments. | 204 // Arg1: instantiator type arguments. |
| 209 // Return value: instantiated type arguments. | 205 // Return value: instantiated type arguments. |
| 210 DEFINE_RUNTIME_ENTRY(InstantiateTypeArguments, 2) { | 206 DEFINE_RUNTIME_ENTRY(InstantiateTypeArguments, 2) { |
| 211 ASSERT(arguments.Count() == | 207 ASSERT(arguments.Count() == |
| 212 kInstantiateTypeArgumentsRuntimeEntry.argument_count()); | 208 kInstantiateTypeArgumentsRuntimeEntry.argument_count()); |
| 213 AbstractTypeArguments& type_arguments = | 209 AbstractTypeArguments& type_arguments = |
| 214 AbstractTypeArguments::CheckedHandle(arguments.At(0)); | 210 AbstractTypeArguments::CheckedHandle(arguments.At(0)); |
| 215 const AbstractTypeArguments& instantiator = | 211 const AbstractTypeArguments& instantiator = |
| 216 AbstractTypeArguments::CheckedHandle(arguments.At(1)); | 212 AbstractTypeArguments::CheckedHandle(arguments.At(1)); |
| 217 ASSERT(!type_arguments.IsNull() && | 213 ASSERT(!type_arguments.IsNull() && |
| 218 !type_arguments.IsInstantiated() && | 214 !type_arguments.IsInstantiated() && |
| 219 !instantiator.IsNull()); | 215 !instantiator.IsNull()); |
| 220 // Code inlined in the caller should have optimized the case where the | 216 // Code inlined in the caller should have optimized the case where the |
| 221 // instantiator can be used as type argument vector. | 217 // instantiator can be used as type argument vector. |
| 222 ASSERT(!type_arguments.IsUninstantiatedIdentity() || | 218 ASSERT(!type_arguments.IsUninstantiatedIdentity() || |
| 223 !instantiator.IsTypeArguments() || | 219 !instantiator.IsTypeArguments() || |
| 224 (instantiator.Length() != type_arguments.Length())); | 220 (instantiator.Length() != type_arguments.Length())); |
| 225 type_arguments = | 221 type_arguments = InstantiatedTypeArguments::New(type_arguments, instantiator); |
| 226 AbstractTypeArguments::NewInstantiatedTypeArguments(type_arguments, | |
| 227 instantiator); | |
| 228 arguments.SetReturn(type_arguments); | 222 arguments.SetReturn(type_arguments); |
| 229 } | 223 } |
| 230 | 224 |
| 231 | 225 |
| 232 // Allocate a new closure. | 226 // Allocate a new closure. |
| 233 // Arg0: local function. | 227 // Arg0: local function. |
| 234 // Arg1: type arguments of the closure. | 228 // Arg1: type arguments of the closure. |
| 235 // Return value: newly allocated closure. | 229 // Return value: newly allocated closure. |
| 236 DEFINE_RUNTIME_ENTRY(AllocateClosure, 2) { | 230 DEFINE_RUNTIME_ENTRY(AllocateClosure, 2) { |
| 237 ASSERT(arguments.Count() == kAllocateClosureRuntimeEntry.argument_count()); | 231 ASSERT(arguments.Count() == kAllocateClosureRuntimeEntry.argument_count()); |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 } | 1041 } |
| 1048 } | 1042 } |
| 1049 } | 1043 } |
| 1050 // The cache is null terminated, therefore the loop above should never | 1044 // The cache is null terminated, therefore the loop above should never |
| 1051 // terminate by itself. | 1045 // terminate by itself. |
| 1052 UNREACHABLE(); | 1046 UNREACHABLE(); |
| 1053 return Code::null(); | 1047 return Code::null(); |
| 1054 } | 1048 } |
| 1055 | 1049 |
| 1056 } // namespace dart | 1050 } // namespace dart |
| OLD | NEW |