Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: runtime/lib/object.cc

Issue 2941643002: Check for a passed-in type argument vector in the prolog of generic functions. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/heap.h" 10 #include "vm/heap.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 163
164 const TypeArguments& left_type_arguments = 164 const TypeArguments& left_type_arguments =
165 TypeArguments::Handle(left.GetTypeArguments()); 165 TypeArguments::Handle(left.GetTypeArguments());
166 const TypeArguments& right_type_arguments = 166 const TypeArguments& right_type_arguments =
167 TypeArguments::Handle(right.GetTypeArguments()); 167 TypeArguments::Handle(right.GetTypeArguments());
168 return Bool::Get(left_type_arguments.Equals(right_type_arguments)).raw(); 168 return Bool::Get(left_type_arguments.Equals(right_type_arguments)).raw();
169 } 169 }
170 170
171 171
172 DEFINE_NATIVE_ENTRY(Object_prependTypeArguments, 3) {
173 const TypeArguments& function_type_arguments =
174 TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(0));
175 const TypeArguments& parent_type_arguments =
176 TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(1));
177 if (function_type_arguments.IsNull() && parent_type_arguments.IsNull()) {
178 return TypeArguments::null();
179 }
180 GET_NON_NULL_NATIVE_ARGUMENT(Smi, smi_len, arguments->NativeArgAt(2));
181 const intptr_t len = smi_len.Value();
182 const TypeArguments& result =
183 TypeArguments::Handle(zone, TypeArguments::New(len, Heap::kOld));
184 AbstractType& type = AbstractType::Handle(zone);
185 const intptr_t split = parent_type_arguments.IsNull()
186 ? len - function_type_arguments.Length()
187 : parent_type_arguments.Length();
188 for (intptr_t i = 0; i < split; i++) {
189 type = parent_type_arguments.IsNull() ? Type::DynamicType()
190 : parent_type_arguments.TypeAt(i);
191 result.SetTypeAt(i, type);
192 }
193 for (intptr_t i = split; i < len; i++) {
194 type = function_type_arguments.IsNull()
195 ? Type::DynamicType()
196 : function_type_arguments.TypeAt(i - split);
197 result.SetTypeAt(i, type);
198 }
199 return result.Canonicalize();
200 }
201
202
172 DEFINE_NATIVE_ENTRY(Object_instanceOf, 4) { 203 DEFINE_NATIVE_ENTRY(Object_instanceOf, 4) {
173 const Instance& instance = 204 const Instance& instance =
174 Instance::CheckedHandle(zone, arguments->NativeArgAt(0)); 205 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
175 const TypeArguments& instantiator_type_arguments = 206 const TypeArguments& instantiator_type_arguments =
176 TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(1)); 207 TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(1));
177 const TypeArguments& function_type_arguments = 208 const TypeArguments& function_type_arguments =
178 TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(2)); 209 TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(2));
179 const AbstractType& type = 210 const AbstractType& type =
180 AbstractType::CheckedHandle(zone, arguments->NativeArgAt(3)); 211 AbstractType::CheckedHandle(zone, arguments->NativeArgAt(3));
181 ASSERT(type.IsFinalized()); 212 ASSERT(type.IsFinalized());
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 385
355 DEFINE_NATIVE_ENTRY(Internal_inquireIs64Bit, 0) { 386 DEFINE_NATIVE_ENTRY(Internal_inquireIs64Bit, 0) {
356 #if defined(ARCH_IS_64_BIT) 387 #if defined(ARCH_IS_64_BIT)
357 return Bool::True().raw(); 388 return Bool::True().raw();
358 #else 389 #else
359 return Bool::False().raw(); 390 return Bool::False().raw();
360 #endif // defined(ARCH_IS_64_BIT) 391 #endif // defined(ARCH_IS_64_BIT)
361 } 392 }
362 393
363 } // namespace dart 394 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698