| 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_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // Allocate a new object. | 142 // Allocate a new object. |
| 143 // Arg0: class of the object that needs to be allocated. | 143 // Arg0: class of the object that needs to be allocated. |
| 144 // Arg1: type arguments of the object that needs to be allocated. | 144 // Arg1: type arguments of the object that needs to be allocated. |
| 145 // Arg2: type arguments of the instantiator. | 145 // Arg2: type arguments of the instantiator. |
| 146 // Return value: newly allocated object. | 146 // Return value: newly allocated object. |
| 147 DEFINE_RUNTIME_ENTRY(AllocateObject, 3) { | 147 DEFINE_RUNTIME_ENTRY(AllocateObject, 3) { |
| 148 ASSERT(arguments.Count() == kAllocateObjectRuntimeEntry.argument_count()); | 148 ASSERT(arguments.Count() == kAllocateObjectRuntimeEntry.argument_count()); |
| 149 const Class& cls = Class::CheckedHandle(arguments.At(0)); | 149 const Class& cls = Class::CheckedHandle(arguments.At(0)); |
| 150 const Instance& instance = Instance::Handle(Instance::New(cls)); | 150 const Instance& instance = Instance::Handle(Instance::New(cls)); |
| 151 arguments.SetReturn(instance); | 151 arguments.SetReturn(instance); |
| 152 const intptr_t num_type_arguments = cls.NumTypeArguments(); | 152 if (!cls.HasTypeArguments()) { |
| 153 if (num_type_arguments > 0) { | |
| 154 // No type arguments required for a non-parameterized type. | 153 // No type arguments required for a non-parameterized type. |
| 155 ASSERT(Instance::CheckedHandle(arguments.At(1)).IsNull()); | 154 ASSERT(Instance::CheckedHandle(arguments.At(1)).IsNull()); |
| 156 return; | 155 return; |
| 157 } | 156 } |
| 158 TypeArguments& type_arguments = TypeArguments::CheckedHandle(arguments.At(1)); | 157 TypeArguments& type_arguments = TypeArguments::CheckedHandle(arguments.At(1)); |
| 159 if (type_arguments.IsNull()) { | 158 if (type_arguments.IsNull()) { |
| 160 // No instantiator is required for a raw type. | 159 // No instantiator is required for a raw type. |
| 161 ASSERT(Instance::CheckedHandle(arguments.At(2)).IsNull()); | 160 ASSERT(Instance::CheckedHandle(arguments.At(2)).IsNull()); |
| 162 return; | 161 return; |
| 163 } | 162 } |
| 164 ASSERT(type_arguments.Length() == num_type_arguments); | 163 ASSERT(type_arguments.Length() == cls.NumTypeArguments()); |
| 165 const TypeArguments& instantiator = | 164 const TypeArguments& instantiator = |
| 166 TypeArguments::CheckedHandle(arguments.At(2)); | 165 TypeArguments::CheckedHandle(arguments.At(2)); |
| 167 if (instantiator.IsNull()) { | 166 if (instantiator.IsNull()) { |
| 168 // Either the type argument vector is instantiated (use it), or the | 167 // Either the type argument vector is instantiated (use it), or the |
| 169 // instantiator is of a raw type and we cannot instantiate the type argument | 168 // instantiator is of a raw type and we cannot instantiate the type argument |
| 170 // vector (leave it as null). | 169 // vector (leave it as null). |
| 171 if (type_arguments.IsInstantiated()) { | 170 if (type_arguments.IsInstantiated()) { |
| 172 instance.SetTypeArguments(type_arguments); | 171 instance.SetTypeArguments(type_arguments); |
| 173 } | 172 } |
| 174 return; | 173 return; |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 } | 1008 } |
| 1010 } | 1009 } |
| 1011 } | 1010 } |
| 1012 // The cache is null terminated, therefore the loop above should never | 1011 // The cache is null terminated, therefore the loop above should never |
| 1013 // terminate by itself. | 1012 // terminate by itself. |
| 1014 UNREACHABLE(); | 1013 UNREACHABLE(); |
| 1015 return Code::null(); | 1014 return Code::null(); |
| 1016 } | 1015 } |
| 1017 | 1016 |
| 1018 } // namespace dart | 1017 } // namespace dart |
| OLD | NEW |