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

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

Issue 2509013002: Allocate generic types in new-space before canonicalizing. (Closed)
Patch Set: formatting Created 4 years, 1 month 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
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/dart_api_impl.cc » ('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/code_patcher.h" 9 #include "vm/code_patcher.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 // Helper routine for tracing a type check. 331 // Helper routine for tracing a type check.
332 static void PrintTypeCheck(const char* message, 332 static void PrintTypeCheck(const char* message,
333 const Instance& instance, 333 const Instance& instance,
334 const AbstractType& type, 334 const AbstractType& type,
335 const TypeArguments& instantiator_type_arguments, 335 const TypeArguments& instantiator_type_arguments,
336 const Bool& result) { 336 const Bool& result) {
337 DartFrameIterator iterator; 337 DartFrameIterator iterator;
338 StackFrame* caller_frame = iterator.NextFrame(); 338 StackFrame* caller_frame = iterator.NextFrame();
339 ASSERT(caller_frame != NULL); 339 ASSERT(caller_frame != NULL);
340 340
341 const AbstractType& instance_type = AbstractType::Handle(instance.GetType()); 341 const AbstractType& instance_type =
342 AbstractType::Handle(instance.GetType(Heap::kNew));
342 ASSERT(instance_type.IsInstantiated()); 343 ASSERT(instance_type.IsInstantiated());
343 if (type.IsInstantiated()) { 344 if (type.IsInstantiated()) {
344 OS::PrintErr("%s: '%s' %" Pd " %s '%s' %" Pd " (pc: %#" Px ").\n", message, 345 OS::PrintErr("%s: '%s' %" Pd " %s '%s' %" Pd " (pc: %#" Px ").\n", message,
345 String::Handle(instance_type.Name()).ToCString(), 346 String::Handle(instance_type.Name()).ToCString(),
346 Class::Handle(instance_type.type_class()).id(), 347 Class::Handle(instance_type.type_class()).id(),
347 (result.raw() == Bool::True().raw()) ? "is" : "is !", 348 (result.raw() == Bool::True().raw()) ? "is" : "is !",
348 String::Handle(type.Name()).ToCString(), 349 String::Handle(type.Name()).ToCString(),
349 Class::Handle(type.type_class()).id(), caller_frame->pc()); 350 Class::Handle(type.type_class()).id(), caller_frame->pc());
350 } else { 351 } else {
351 // Instantiate type before printing. 352 // Instantiate type before printing.
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 dst_type, instantiator_type_arguments, &bound_error); 545 dst_type, instantiator_type_arguments, &bound_error);
545 546
546 if (FLAG_trace_type_checks) { 547 if (FLAG_trace_type_checks) {
547 PrintTypeCheck("TypeCheck", src_instance, dst_type, 548 PrintTypeCheck("TypeCheck", src_instance, dst_type,
548 instantiator_type_arguments, Bool::Get(is_instance_of)); 549 instantiator_type_arguments, Bool::Get(is_instance_of));
549 } 550 }
550 if (!is_instance_of) { 551 if (!is_instance_of) {
551 // Throw a dynamic type error. 552 // Throw a dynamic type error.
552 const TokenPosition location = GetCallerLocation(); 553 const TokenPosition location = GetCallerLocation();
553 const AbstractType& src_type = 554 const AbstractType& src_type =
554 AbstractType::Handle(zone, src_instance.GetType()); 555 AbstractType::Handle(zone, src_instance.GetType(Heap::kNew));
555 if (!dst_type.IsInstantiated()) { 556 if (!dst_type.IsInstantiated()) {
556 // Instantiate dst_type before reporting the error. 557 // Instantiate dst_type before reporting the error.
557 dst_type = dst_type.InstantiateFrom(instantiator_type_arguments, NULL, 558 dst_type = dst_type.InstantiateFrom(instantiator_type_arguments, NULL,
558 NULL, NULL, Heap::kNew); 559 NULL, NULL, Heap::kNew);
559 // Note that instantiated dst_type may be malbounded. 560 // Note that instantiated dst_type may be malbounded.
560 } 561 }
561 String& bound_error_message = String::Handle(zone); 562 String& bound_error_message = String::Handle(zone);
562 if (!bound_error.IsNull()) { 563 if (!bound_error.IsNull()) {
563 ASSERT(isolate->type_checks()); 564 ASSERT(isolate->type_checks());
564 bound_error_message = String::New(bound_error.ToErrorCString()); 565 bound_error_message = String::New(bound_error.ToErrorCString());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 args.SetAt(2, Smi::Handle(zone, Smi::New(0))); 597 args.SetAt(2, Smi::Handle(zone, Smi::New(0)));
597 args.SetAt(3, Smi::Handle(zone, Smi::New(0))); 598 args.SetAt(3, Smi::Handle(zone, Smi::New(0)));
598 599
599 Exceptions::ThrowByType(Exceptions::kAssertion, args); 600 Exceptions::ThrowByType(Exceptions::kAssertion, args);
600 UNREACHABLE(); 601 UNREACHABLE();
601 } 602 }
602 603
603 ASSERT(!src_instance.IsBool()); 604 ASSERT(!src_instance.IsBool());
604 const Type& bool_interface = Type::Handle(Type::BoolType()); 605 const Type& bool_interface = Type::Handle(Type::BoolType());
605 const AbstractType& src_type = 606 const AbstractType& src_type =
606 AbstractType::Handle(zone, src_instance.GetType()); 607 AbstractType::Handle(zone, src_instance.GetType(Heap::kNew));
607 const String& no_bound_error = String::Handle(zone); 608 const String& no_bound_error = String::Handle(zone);
608 Exceptions::CreateAndThrowTypeError(location, src_type, bool_interface, 609 Exceptions::CreateAndThrowTypeError(location, src_type, bool_interface,
609 Symbols::BooleanExpression(), 610 Symbols::BooleanExpression(),
610 no_bound_error); 611 no_bound_error);
611 UNREACHABLE(); 612 UNREACHABLE();
612 } 613 }
613 614
614 615
615 // Report that the type of the type check is malformed or malbounded. 616 // Report that the type of the type check is malformed or malbounded.
616 // Arg0: src value. 617 // Arg0: src value.
617 // Arg1: name of destination being assigned to. 618 // Arg1: name of destination being assigned to.
618 // Arg2: type of destination being assigned to. 619 // Arg2: type of destination being assigned to.
619 // Return value: none, throws an exception. 620 // Return value: none, throws an exception.
620 DEFINE_RUNTIME_ENTRY(BadTypeError, 3) { 621 DEFINE_RUNTIME_ENTRY(BadTypeError, 3) {
621 const TokenPosition location = GetCallerLocation(); 622 const TokenPosition location = GetCallerLocation();
622 const Instance& src_value = Instance::CheckedHandle(zone, arguments.ArgAt(0)); 623 const Instance& src_value = Instance::CheckedHandle(zone, arguments.ArgAt(0));
623 const String& dst_name = String::CheckedHandle(zone, arguments.ArgAt(1)); 624 const String& dst_name = String::CheckedHandle(zone, arguments.ArgAt(1));
624 const AbstractType& dst_type = 625 const AbstractType& dst_type =
625 AbstractType::CheckedHandle(zone, arguments.ArgAt(2)); 626 AbstractType::CheckedHandle(zone, arguments.ArgAt(2));
626 const AbstractType& src_type = 627 const AbstractType& src_type =
627 AbstractType::Handle(zone, src_value.GetType()); 628 AbstractType::Handle(zone, src_value.GetType(Heap::kNew));
628 Exceptions::CreateAndThrowTypeError(location, src_type, dst_type, dst_name, 629 Exceptions::CreateAndThrowTypeError(location, src_type, dst_type, dst_name,
629 String::Handle(zone)); 630 String::Handle(zone));
630 UNREACHABLE(); 631 UNREACHABLE();
631 } 632 }
632 633
633 634
634 DEFINE_RUNTIME_ENTRY(Throw, 1) { 635 DEFINE_RUNTIME_ENTRY(Throw, 1) {
635 const Instance& exception = Instance::CheckedHandle(zone, arguments.ArgAt(0)); 636 const Instance& exception = Instance::CheckedHandle(zone, arguments.ArgAt(0));
636 Exceptions::Throw(thread, exception); 637 Exceptions::Throw(thread, exception);
637 } 638 }
(...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after
2281 const intptr_t elm_size = old_data.ElementSizeInBytes(); 2282 const intptr_t elm_size = old_data.ElementSizeInBytes();
2282 const TypedData& new_data = 2283 const TypedData& new_data =
2283 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); 2284 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld));
2284 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); 2285 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size);
2285 typed_data_cell.SetAt(0, new_data); 2286 typed_data_cell.SetAt(0, new_data);
2286 arguments.SetReturn(new_data); 2287 arguments.SetReturn(new_data);
2287 } 2288 }
2288 2289
2289 2290
2290 } // namespace dart 2291 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698