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

Side by Side Diff: runtime/vm/code_generator.cc

Issue 33313003: Report use of malbounded interface in type test. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « runtime/lib/object.cc ('k') | runtime/vm/exceptions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 ASSERT(type_arguments.IsNull() || 177 ASSERT(type_arguments.IsNull() ||
178 (type_arguments.IsInstantiated() && 178 (type_arguments.IsInstantiated() &&
179 (type_arguments.Length() >= cls.NumTypeArguments()))); 179 (type_arguments.Length() >= cls.NumTypeArguments())));
180 } else { 180 } else {
181 // A still uninstantiated type argument vector must have the correct length. 181 // A still uninstantiated type argument vector must have the correct length.
182 ASSERT(!type_arguments.IsInstantiated() && 182 ASSERT(!type_arguments.IsInstantiated() &&
183 (type_arguments.Length() == cls.NumTypeArguments())); 183 (type_arguments.Length() == cls.NumTypeArguments()));
184 const AbstractTypeArguments& instantiator = 184 const AbstractTypeArguments& instantiator =
185 AbstractTypeArguments::CheckedHandle(arguments.ArgAt(2)); 185 AbstractTypeArguments::CheckedHandle(arguments.ArgAt(2));
186 ASSERT(instantiator.IsNull() || instantiator.IsInstantiated()); 186 ASSERT(instantiator.IsNull() || instantiator.IsInstantiated());
187 Error& malformed_error = Error::Handle(); 187 Error& bound_error = Error::Handle();
188 // Code inlined in the caller should have optimized the case where the 188 // Code inlined in the caller should have optimized the case where the
189 // instantiator can be reused as type argument vector. 189 // instantiator can be reused as type argument vector.
190 ASSERT(instantiator.IsNull() || !type_arguments.IsUninstantiatedIdentity()); 190 ASSERT(instantiator.IsNull() || !type_arguments.IsUninstantiatedIdentity());
191 type_arguments = type_arguments.InstantiateFrom(instantiator, 191 type_arguments = type_arguments.InstantiateFrom(instantiator, &bound_error);
192 &malformed_error); 192 if (!bound_error.IsNull()) {
193 if (!malformed_error.IsNull()) {
194 // Throw a dynamic type error. 193 // Throw a dynamic type error.
195 const intptr_t location = GetCallerLocation(); 194 const intptr_t location = GetCallerLocation();
196 String& malformed_error_message = String::Handle( 195 String& bound_error_message = String::Handle(
197 String::New(malformed_error.ToErrorCString())); 196 String::New(bound_error.ToErrorCString()));
198 Exceptions::CreateAndThrowTypeError( 197 Exceptions::CreateAndThrowTypeError(
199 location, Symbols::Empty(), Symbols::Empty(), 198 location, Symbols::Empty(), Symbols::Empty(),
200 Symbols::Empty(), malformed_error_message); 199 Symbols::Empty(), bound_error_message);
201 UNREACHABLE(); 200 UNREACHABLE();
202 } 201 }
203 } 202 }
204 ASSERT(type_arguments.IsNull() || type_arguments.IsInstantiated()); 203 ASSERT(type_arguments.IsNull() || type_arguments.IsInstantiated());
205 instance.SetTypeArguments(type_arguments); 204 instance.SetTypeArguments(type_arguments);
206 } 205 }
207 206
208 207
209 // Instantiate type. 208 // Instantiate type.
210 // Arg0: uninstantiated type. 209 // Arg0: uninstantiated type.
211 // Arg1: instantiator type arguments. 210 // Arg1: instantiator type arguments.
212 // Return value: instantiated type. 211 // Return value: instantiated type.
213 DEFINE_RUNTIME_ENTRY(InstantiateType, 2) { 212 DEFINE_RUNTIME_ENTRY(InstantiateType, 2) {
214 AbstractType& type = AbstractType::CheckedHandle(arguments.ArgAt(0)); 213 AbstractType& type = AbstractType::CheckedHandle(arguments.ArgAt(0));
215 const AbstractTypeArguments& instantiator = 214 const AbstractTypeArguments& instantiator =
216 AbstractTypeArguments::CheckedHandle(arguments.ArgAt(1)); 215 AbstractTypeArguments::CheckedHandle(arguments.ArgAt(1));
217 ASSERT(!type.IsNull() && !type.IsInstantiated()); 216 ASSERT(!type.IsNull() && !type.IsInstantiated());
218 ASSERT(instantiator.IsNull() || instantiator.IsInstantiated()); 217 ASSERT(instantiator.IsNull() || instantiator.IsInstantiated());
219 Error& malformed_error = Error::Handle(); 218 Error& bound_error = Error::Handle();
220 type = type.InstantiateFrom(instantiator, &malformed_error); 219 type = type.InstantiateFrom(instantiator, &bound_error);
221 if (!malformed_error.IsNull()) { 220 if (!bound_error.IsNull()) {
222 // Throw a dynamic type error. 221 // Throw a dynamic type error.
223 const intptr_t location = GetCallerLocation(); 222 const intptr_t location = GetCallerLocation();
224 String& malformed_error_message = String::Handle( 223 String& bound_error_message = String::Handle(
225 String::New(malformed_error.ToErrorCString())); 224 String::New(bound_error.ToErrorCString()));
226 Exceptions::CreateAndThrowTypeError( 225 Exceptions::CreateAndThrowTypeError(
227 location, Symbols::Empty(), Symbols::Empty(), 226 location, Symbols::Empty(), Symbols::Empty(),
228 Symbols::Empty(), malformed_error_message); 227 Symbols::Empty(), bound_error_message);
229 UNREACHABLE(); 228 UNREACHABLE();
230 } 229 }
231 ASSERT(!type.IsNull() && type.IsInstantiated()); 230 ASSERT(!type.IsNull() && type.IsInstantiated());
232 arguments.SetReturn(type); 231 arguments.SetReturn(type);
233 } 232 }
234 233
235 234
236 // Instantiate type arguments. 235 // Instantiate type arguments.
237 // Arg0: uninstantiated type arguments. 236 // Arg0: uninstantiated type arguments.
238 // Arg1: instantiator type arguments. 237 // Arg1: instantiator type arguments.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 OS::PrintErr("%s: '%s' %" Pd " %s '%s' %" Pd " (pc: %#" Px ").\n", 338 OS::PrintErr("%s: '%s' %" Pd " %s '%s' %" Pd " (pc: %#" Px ").\n",
340 message, 339 message,
341 String::Handle(instance_type.Name()).ToCString(), 340 String::Handle(instance_type.Name()).ToCString(),
342 Class::Handle(instance_type.type_class()).id(), 341 Class::Handle(instance_type.type_class()).id(),
343 (result.raw() == Bool::True().raw()) ? "is" : "is !", 342 (result.raw() == Bool::True().raw()) ? "is" : "is !",
344 String::Handle(type.Name()).ToCString(), 343 String::Handle(type.Name()).ToCString(),
345 Class::Handle(type.type_class()).id(), 344 Class::Handle(type.type_class()).id(),
346 caller_frame->pc()); 345 caller_frame->pc());
347 } else { 346 } else {
348 // Instantiate type before printing. 347 // Instantiate type before printing.
349 Error& malformed_error = Error::Handle(); 348 Error& bound_error = Error::Handle();
350 const AbstractType& instantiated_type = AbstractType::Handle( 349 const AbstractType& instantiated_type = AbstractType::Handle(
351 type.InstantiateFrom(instantiator_type_arguments, &malformed_error)); 350 type.InstantiateFrom(instantiator_type_arguments, &bound_error));
352 OS::PrintErr("%s: '%s' %s '%s' instantiated from '%s' (pc: %#" Px ").\n", 351 OS::PrintErr("%s: '%s' %s '%s' instantiated from '%s' (pc: %#" Px ").\n",
353 message, 352 message,
354 String::Handle(instance_type.Name()).ToCString(), 353 String::Handle(instance_type.Name()).ToCString(),
355 (result.raw() == Bool::True().raw()) ? "is" : "is !", 354 (result.raw() == Bool::True().raw()) ? "is" : "is !",
356 String::Handle(instantiated_type.Name()).ToCString(), 355 String::Handle(instantiated_type.Name()).ToCString(),
357 String::Handle(type.Name()).ToCString(), 356 String::Handle(type.Name()).ToCString(),
358 caller_frame->pc()); 357 caller_frame->pc());
359 if (!malformed_error.IsNull()) { 358 if (!bound_error.IsNull()) {
360 OS::Print(" malformed error: %s\n", malformed_error.ToErrorCString()); 359 OS::Print(" bound error: %s\n", bound_error.ToErrorCString());
361 } 360 }
362 } 361 }
363 const Function& function = Function::Handle( 362 const Function& function = Function::Handle(
364 caller_frame->LookupDartFunction()); 363 caller_frame->LookupDartFunction());
365 OS::PrintErr(" -> Function %s\n", function.ToFullyQualifiedCString()); 364 OS::PrintErr(" -> Function %s\n", function.ToFullyQualifiedCString());
366 } 365 }
367 366
368 367
369 // Converts InstantiatedTypeArguments to TypeArguments and stores it 368 // Converts InstantiatedTypeArguments to TypeArguments and stores it
370 // into the instance. The assembly code can handle only type arguments of 369 // into the instance. The assembly code can handle only type arguments of
(...skipping 12 matching lines...) Expand all
383 bool replaced = false; 382 bool replaced = false;
384 if (type_arguments.IsInstantiatedTypeArguments()) { 383 if (type_arguments.IsInstantiatedTypeArguments()) {
385 AbstractTypeArguments& uninstantiated = AbstractTypeArguments::Handle(); 384 AbstractTypeArguments& uninstantiated = AbstractTypeArguments::Handle();
386 AbstractTypeArguments& instantiator = AbstractTypeArguments::Handle(); 385 AbstractTypeArguments& instantiator = AbstractTypeArguments::Handle();
387 do { 386 do {
388 const InstantiatedTypeArguments& instantiated_type_arguments = 387 const InstantiatedTypeArguments& instantiated_type_arguments =
389 InstantiatedTypeArguments::Cast(type_arguments); 388 InstantiatedTypeArguments::Cast(type_arguments);
390 uninstantiated = 389 uninstantiated =
391 instantiated_type_arguments.uninstantiated_type_arguments(); 390 instantiated_type_arguments.uninstantiated_type_arguments();
392 instantiator = instantiated_type_arguments.instantiator_type_arguments(); 391 instantiator = instantiated_type_arguments.instantiator_type_arguments();
393 Error& malformed_error = Error::Handle(); 392 Error& bound_error = Error::Handle();
394 type_arguments = uninstantiated.InstantiateFrom(instantiator, 393 type_arguments = uninstantiated.InstantiateFrom(instantiator,
395 &malformed_error); 394 &bound_error);
396 ASSERT(malformed_error.IsNull()); // Malformed types are not optimized. 395 ASSERT(bound_error.IsNull()); // Malbounded types are not optimized.
397 } while (type_arguments.IsInstantiatedTypeArguments()); 396 } while (type_arguments.IsInstantiatedTypeArguments());
398 AbstractTypeArguments& new_type_arguments = AbstractTypeArguments::Handle(); 397 AbstractTypeArguments& new_type_arguments = AbstractTypeArguments::Handle();
399 new_type_arguments = type_arguments.Canonicalize(); 398 new_type_arguments = type_arguments.Canonicalize();
400 instance.SetTypeArguments(new_type_arguments); 399 instance.SetTypeArguments(new_type_arguments);
401 replaced = true; 400 replaced = true;
402 } else if (!type_arguments.IsCanonical()) { 401 } else if (!type_arguments.IsCanonical()) {
403 AbstractTypeArguments& new_type_arguments = AbstractTypeArguments::Handle(); 402 AbstractTypeArguments& new_type_arguments = AbstractTypeArguments::Handle();
404 new_type_arguments = type_arguments.Canonicalize(); 403 new_type_arguments = type_arguments.Canonicalize();
405 instance.SetTypeArguments(new_type_arguments); 404 instance.SetTypeArguments(new_type_arguments);
406 replaced = true; 405 replaced = true;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 } 488 }
490 if (!instantiator_type_arguments.IsInstantiatedTypeArguments()) { 489 if (!instantiator_type_arguments.IsInstantiatedTypeArguments()) {
491 new_cache.AddCheck(instance_class.id(), 490 new_cache.AddCheck(instance_class.id(),
492 instance_type_arguments, 491 instance_type_arguments,
493 instantiator_type_arguments, 492 instantiator_type_arguments,
494 result); 493 result);
495 } 494 }
496 if (FLAG_trace_type_checks) { 495 if (FLAG_trace_type_checks) {
497 AbstractType& test_type = AbstractType::Handle(type.raw()); 496 AbstractType& test_type = AbstractType::Handle(type.raw());
498 if (!test_type.IsInstantiated()) { 497 if (!test_type.IsInstantiated()) {
499 Error& malformed_error = Error::Handle(); 498 Error& bound_error = Error::Handle();
500 test_type = type.InstantiateFrom(instantiator_type_arguments, 499 test_type = type.InstantiateFrom(instantiator_type_arguments,
501 &malformed_error); 500 &bound_error);
502 ASSERT(malformed_error.IsNull()); // Malformed types are not optimized. 501 ASSERT(bound_error.IsNull()); // Malbounded types are not optimized.
503 } 502 }
504 OS::PrintErr(" Updated test cache %p ix: %" Pd " with " 503 OS::PrintErr(" Updated test cache %p ix: %" Pd " with "
505 "(cid: %" Pd ", type-args: %p, instantiator: %p, result: %s)\n" 504 "(cid: %" Pd ", type-args: %p, instantiator: %p, result: %s)\n"
506 " instance [class: (%p '%s' cid: %" Pd "), type-args: %p %s]\n" 505 " instance [class: (%p '%s' cid: %" Pd "), type-args: %p %s]\n"
507 " test-type [class: (%p '%s' cid: %" Pd "), in-type-args: %p %s]\n", 506 " test-type [class: (%p '%s' cid: %" Pd "), in-type-args: %p %s]\n",
508 new_cache.raw(), 507 new_cache.raw(),
509 len, 508 len,
510 509
511 instance_class.id(), 510 instance_class.id(),
512 instance_type_arguments.raw(), 511 instance_type_arguments.raw(),
(...skipping 26 matching lines...) Expand all
539 // Return value: true or false, or may throw a type error in checked mode. 538 // Return value: true or false, or may throw a type error in checked mode.
540 DEFINE_RUNTIME_ENTRY(Instanceof, 5) { 539 DEFINE_RUNTIME_ENTRY(Instanceof, 5) {
541 const Instance& instance = Instance::CheckedHandle(arguments.ArgAt(0)); 540 const Instance& instance = Instance::CheckedHandle(arguments.ArgAt(0));
542 const AbstractType& type = AbstractType::CheckedHandle(arguments.ArgAt(1)); 541 const AbstractType& type = AbstractType::CheckedHandle(arguments.ArgAt(1));
543 const Instance& instantiator = Instance::CheckedHandle(arguments.ArgAt(2)); 542 const Instance& instantiator = Instance::CheckedHandle(arguments.ArgAt(2));
544 const AbstractTypeArguments& instantiator_type_arguments = 543 const AbstractTypeArguments& instantiator_type_arguments =
545 AbstractTypeArguments::CheckedHandle(arguments.ArgAt(3)); 544 AbstractTypeArguments::CheckedHandle(arguments.ArgAt(3));
546 const SubtypeTestCache& cache = 545 const SubtypeTestCache& cache =
547 SubtypeTestCache::CheckedHandle(arguments.ArgAt(4)); 546 SubtypeTestCache::CheckedHandle(arguments.ArgAt(4));
548 ASSERT(type.IsFinalized()); 547 ASSERT(type.IsFinalized());
549 Error& malformed_error = Error::Handle(); 548 Error& bound_error = Error::Handle();
550 const Bool& result = 549 const Bool& result =
551 Bool::Get(instance.IsInstanceOf(type, 550 Bool::Get(instance.IsInstanceOf(type,
552 instantiator_type_arguments, 551 instantiator_type_arguments,
553 &malformed_error)); 552 &bound_error));
554 if (FLAG_trace_type_checks) { 553 if (FLAG_trace_type_checks) {
555 PrintTypeCheck("InstanceOf", 554 PrintTypeCheck("InstanceOf",
556 instance, type, instantiator_type_arguments, result); 555 instance, type, instantiator_type_arguments, result);
557 } 556 }
558 if (!result.value() && !malformed_error.IsNull()) { 557 if (!result.value() && !bound_error.IsNull()) {
559 // Throw a dynamic type error only if the instanceof test fails. 558 // Throw a dynamic type error only if the instanceof test fails.
560 const intptr_t location = GetCallerLocation(); 559 const intptr_t location = GetCallerLocation();
561 String& malformed_error_message = String::Handle( 560 String& bound_error_message = String::Handle(
562 String::New(malformed_error.ToErrorCString())); 561 String::New(bound_error.ToErrorCString()));
563 Exceptions::CreateAndThrowTypeError( 562 Exceptions::CreateAndThrowTypeError(
564 location, Symbols::Empty(), Symbols::Empty(), 563 location, Symbols::Empty(), Symbols::Empty(),
565 Symbols::Empty(), malformed_error_message); 564 Symbols::Empty(), bound_error_message);
566 UNREACHABLE(); 565 UNREACHABLE();
567 } 566 }
568 UpdateTypeTestCache(instance, type, instantiator, 567 UpdateTypeTestCache(instance, type, instantiator,
569 instantiator_type_arguments, result, cache); 568 instantiator_type_arguments, result, cache);
570 arguments.SetReturn(result); 569 arguments.SetReturn(result);
571 } 570 }
572 571
573 572
574 // Check that the type of the given instance is a subtype of the given type and 573 // Check that the type of the given instance is a subtype of the given type and
575 // can therefore be assigned. 574 // can therefore be assigned.
(...skipping 13 matching lines...) Expand all
589 const AbstractTypeArguments& instantiator_type_arguments = 588 const AbstractTypeArguments& instantiator_type_arguments =
590 AbstractTypeArguments::CheckedHandle(arguments.ArgAt(3)); 589 AbstractTypeArguments::CheckedHandle(arguments.ArgAt(3));
591 const String& dst_name = String::CheckedHandle(arguments.ArgAt(4)); 590 const String& dst_name = String::CheckedHandle(arguments.ArgAt(4));
592 const SubtypeTestCache& cache = 591 const SubtypeTestCache& cache =
593 SubtypeTestCache::CheckedHandle(arguments.ArgAt(5)); 592 SubtypeTestCache::CheckedHandle(arguments.ArgAt(5));
594 ASSERT(!dst_type.IsDynamicType()); // No need to check assignment. 593 ASSERT(!dst_type.IsDynamicType()); // No need to check assignment.
595 ASSERT(!dst_type.IsMalformed()); // Already checked in code generator. 594 ASSERT(!dst_type.IsMalformed()); // Already checked in code generator.
596 ASSERT(!dst_type.IsMalbounded()); // Already checked in code generator. 595 ASSERT(!dst_type.IsMalbounded()); // Already checked in code generator.
597 ASSERT(!src_instance.IsNull()); // Already checked in inlined code. 596 ASSERT(!src_instance.IsNull()); // Already checked in inlined code.
598 597
599 Error& malformed_error = Error::Handle(); 598 Error& bound_error = Error::Handle();
600 const bool is_instance_of = src_instance.IsInstanceOf( 599 const bool is_instance_of = src_instance.IsInstanceOf(
601 dst_type, instantiator_type_arguments, &malformed_error); 600 dst_type, instantiator_type_arguments, &bound_error);
602 601
603 if (FLAG_trace_type_checks) { 602 if (FLAG_trace_type_checks) {
604 PrintTypeCheck("TypeCheck", 603 PrintTypeCheck("TypeCheck",
605 src_instance, dst_type, instantiator_type_arguments, 604 src_instance, dst_type, instantiator_type_arguments,
606 Bool::Get(is_instance_of)); 605 Bool::Get(is_instance_of));
607 } 606 }
608 if (!is_instance_of) { 607 if (!is_instance_of) {
609 // Throw a dynamic type error. 608 // Throw a dynamic type error.
610 const intptr_t location = GetCallerLocation(); 609 const intptr_t location = GetCallerLocation();
611 const AbstractType& src_type = AbstractType::Handle(src_instance.GetType()); 610 const AbstractType& src_type = AbstractType::Handle(src_instance.GetType());
612 const String& src_type_name = String::Handle(src_type.UserVisibleName()); 611 const String& src_type_name = String::Handle(src_type.UserVisibleName());
613 String& dst_type_name = String::Handle(); 612 String& dst_type_name = String::Handle();
614 if (!dst_type.IsInstantiated()) { 613 if (!dst_type.IsInstantiated()) {
615 // Instantiate dst_type before reporting the error. 614 // Instantiate dst_type before reporting the error.
616 const AbstractType& instantiated_dst_type = AbstractType::Handle( 615 const AbstractType& instantiated_dst_type = AbstractType::Handle(
617 dst_type.InstantiateFrom(instantiator_type_arguments, NULL)); 616 dst_type.InstantiateFrom(instantiator_type_arguments, NULL));
618 // Note that instantiated_dst_type may be malformed. 617 // Note that instantiated_dst_type may be malbounded.
619 dst_type_name = instantiated_dst_type.UserVisibleName(); 618 dst_type_name = instantiated_dst_type.UserVisibleName();
620 } else { 619 } else {
621 dst_type_name = dst_type.UserVisibleName(); 620 dst_type_name = dst_type.UserVisibleName();
622 } 621 }
623 String& malformed_error_message = String::Handle(); 622 String& bound_error_message = String::Handle();
624 if (!malformed_error.IsNull()) { 623 if (!bound_error.IsNull()) {
625 ASSERT(FLAG_enable_type_checks); 624 ASSERT(FLAG_enable_type_checks);
626 malformed_error_message = String::New(malformed_error.ToErrorCString()); 625 bound_error_message = String::New(bound_error.ToErrorCString());
627 } 626 }
628 Exceptions::CreateAndThrowTypeError(location, src_type_name, dst_type_name, 627 Exceptions::CreateAndThrowTypeError(location, src_type_name, dst_type_name,
629 dst_name, malformed_error_message); 628 dst_name, bound_error_message);
630 UNREACHABLE(); 629 UNREACHABLE();
631 } 630 }
632 UpdateTypeTestCache(src_instance, dst_type, 631 UpdateTypeTestCache(src_instance, dst_type,
633 dst_instantiator, instantiator_type_arguments, 632 dst_instantiator, instantiator_type_arguments,
634 Bool::True(), cache); 633 Bool::True(), cache);
635 arguments.SetReturn(src_instance); 634 arguments.SetReturn(src_instance);
636 } 635 }
637 636
638 637
639 // Report that the type of the given object is not bool in conditional context. 638 // Report that the type of the given object is not bool in conditional context.
640 // Arg0: bad object. 639 // Arg0: bad object.
641 // Return value: none, throws a TypeError. 640 // Return value: none, throws a TypeError.
642 DEFINE_RUNTIME_ENTRY(ConditionTypeError, 1) { 641 DEFINE_RUNTIME_ENTRY(ConditionTypeError, 1) {
643 const intptr_t location = GetCallerLocation(); 642 const intptr_t location = GetCallerLocation();
644 const Instance& src_instance = Instance::CheckedHandle(arguments.ArgAt(0)); 643 const Instance& src_instance = Instance::CheckedHandle(arguments.ArgAt(0));
645 ASSERT(src_instance.IsNull() || !src_instance.IsBool()); 644 ASSERT(src_instance.IsNull() || !src_instance.IsBool());
646 const Type& bool_interface = Type::Handle(Type::BoolType()); 645 const Type& bool_interface = Type::Handle(Type::BoolType());
647 const AbstractType& src_type = AbstractType::Handle(src_instance.GetType()); 646 const AbstractType& src_type = AbstractType::Handle(src_instance.GetType());
648 const String& src_type_name = String::Handle(src_type.UserVisibleName()); 647 const String& src_type_name = String::Handle(src_type.UserVisibleName());
649 const String& bool_type_name = 648 const String& bool_type_name =
650 String::Handle(bool_interface.UserVisibleName()); 649 String::Handle(bool_interface.UserVisibleName());
651 const String& no_malformed_type_error = String::Handle(); 650 const String& no_bound_error = String::Handle();
652 Exceptions::CreateAndThrowTypeError(location, src_type_name, bool_type_name, 651 Exceptions::CreateAndThrowTypeError(location, src_type_name, bool_type_name,
653 Symbols::BooleanExpression(), 652 Symbols::BooleanExpression(),
654 no_malformed_type_error); 653 no_bound_error);
655 UNREACHABLE(); 654 UNREACHABLE();
656 } 655 }
657 656
658 657
658 // TODO(regis): Is this entry still used for malformed types or just malbounded
659 // types? Revisit.
659 // Report that the type of the type check is malformed. 660 // Report that the type of the type check is malformed.
660 // Arg0: src value. 661 // Arg0: src value.
661 // Arg1: name of instance being assigned to. 662 // Arg1: name of instance being assigned to.
662 // Arg2: malformed type error message. 663 // Arg2: malformed type error message.
663 // Return value: none, throws an exception. 664 // Return value: none, throws an exception.
664 DEFINE_RUNTIME_ENTRY(MalformedTypeError, 3) { 665 DEFINE_RUNTIME_ENTRY(MalformedTypeError, 3) {
665 const intptr_t location = GetCallerLocation(); 666 const intptr_t location = GetCallerLocation();
666 const Instance& src_value = Instance::CheckedHandle(arguments.ArgAt(0)); 667 const Instance& src_value = Instance::CheckedHandle(arguments.ArgAt(0));
667 const String& dst_name = String::CheckedHandle(arguments.ArgAt(1)); 668 const String& dst_name = String::CheckedHandle(arguments.ArgAt(1));
668 const String& malformed_error = String::CheckedHandle(arguments.ArgAt(2)); 669 const String& bound_error = String::CheckedHandle(arguments.ArgAt(2));
669 const AbstractType& src_type = AbstractType::Handle(src_value.GetType()); 670 const AbstractType& src_type = AbstractType::Handle(src_value.GetType());
670 const String& src_type_name = String::Handle(src_type.UserVisibleName()); 671 const String& src_type_name = String::Handle(src_type.UserVisibleName());
671 Exceptions::CreateAndThrowTypeError(location, src_type_name, 672 Exceptions::CreateAndThrowTypeError(location, src_type_name,
672 Symbols::Malformed(), 673 Symbols::Malformed(),
673 dst_name, malformed_error); 674 dst_name, bound_error);
674 UNREACHABLE(); 675 UNREACHABLE();
675 } 676 }
676 677
677 678
678 DEFINE_RUNTIME_ENTRY(Throw, 1) { 679 DEFINE_RUNTIME_ENTRY(Throw, 1) {
679 const Instance& exception = Instance::CheckedHandle(arguments.ArgAt(0)); 680 const Instance& exception = Instance::CheckedHandle(arguments.ArgAt(0));
680 Exceptions::Throw(exception); 681 Exceptions::Throw(exception);
681 } 682 }
682 683
683 684
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 field.UpdateCid(cid); 1703 field.UpdateCid(cid);
1703 intptr_t list_length = Field::kNoFixedLength; 1704 intptr_t list_length = Field::kNoFixedLength;
1704 if ((field.guarded_cid() != kDynamicCid) && 1705 if ((field.guarded_cid() != kDynamicCid) &&
1705 field.is_final() && RawObject::IsBuiltinListClassId(cid)) { 1706 field.is_final() && RawObject::IsBuiltinListClassId(cid)) {
1706 list_length = GetListLength(value); 1707 list_length = GetListLength(value);
1707 } 1708 }
1708 field.UpdateLength(list_length); 1709 field.UpdateLength(list_length);
1709 } 1710 }
1710 1711
1711 } // namespace dart 1712 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/object.cc ('k') | runtime/vm/exceptions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698