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

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

Issue 11299020: Make creation of list literal more resilient to changes in the underlying (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 cls = Class::New<Bool>(); 617 cls = Class::New<Bool>();
618 object_store->set_bool_class(cls); 618 object_store->set_bool_class(cls);
619 name = Symbols::Bool(); 619 name = Symbols::Bool();
620 RegisterClass(cls, name, core_lib); 620 RegisterClass(cls, name, core_lib);
621 pending_classes.Add(cls, Heap::kOld); 621 pending_classes.Add(cls, Heap::kOld);
622 622
623 cls = object_store->array_class(); // Was allocated above. 623 cls = object_store->array_class(); // Was allocated above.
624 name = Symbols::ObjectArray(); 624 name = Symbols::ObjectArray();
625 RegisterPrivateClass(cls, name, core_lib); 625 RegisterPrivateClass(cls, name, core_lib);
626 pending_classes.Add(cls, Heap::kOld); 626 pending_classes.Add(cls, Heap::kOld);
627 // We cannot use NewNonParameterizedType(cls), because Array is parameterized.
628 type ^= Type::New(Object::Handle(cls.raw()),
629 TypeArguments::Handle(),
630 Scanner::kDummyTokenIndex);
631 type.set_is_finalized_instantiated();
632 type ^= type.Canonicalize();
633 object_store->set_array_type(type);
627 634
628 cls = object_store->growable_object_array_class(); // Was allocated above. 635 cls = object_store->growable_object_array_class(); // Was allocated above.
629 name = Symbols::GrowableObjectArray(); 636 name = Symbols::GrowableObjectArray();
630 RegisterPrivateClass(cls, name, core_lib); 637 RegisterPrivateClass(cls, name, core_lib);
631 pending_classes.Add(cls, Heap::kOld); 638 pending_classes.Add(cls, Heap::kOld);
632 639
633 cls = Class::New<ImmutableArray>(); 640 cls = Class::New<ImmutableArray>();
634 object_store->set_immutable_array_class(cls); 641 object_store->set_immutable_array_class(cls);
635 cls.set_type_arguments_instance_field_offset(Array::type_arguments_offset()); 642 cls.set_type_arguments_instance_field_offset(Array::type_arguments_offset());
636 ASSERT(object_store->immutable_array_class() != object_store->array_class()); 643 ASSERT(object_store->immutable_array_class() != object_store->array_class());
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 881
875 name = Symbols::New("String"); 882 name = Symbols::New("String");
876 cls = Class::New<Instance>(name, script, Scanner::kDummyTokenIndex); 883 cls = Class::New<Instance>(name, script, Scanner::kDummyTokenIndex);
877 RegisterClass(cls, name, core_lib); 884 RegisterClass(cls, name, core_lib);
878 pending_classes.Add(cls, Heap::kOld); 885 pending_classes.Add(cls, Heap::kOld);
879 type = Type::NewNonParameterizedType(cls); 886 type = Type::NewNonParameterizedType(cls);
880 object_store->set_string_type(type); 887 object_store->set_string_type(type);
881 888
882 cls = CreateAndRegisterInterface("List", script, core_lib); 889 cls = CreateAndRegisterInterface("List", script, core_lib);
883 pending_classes.Add(cls, Heap::kOld); 890 pending_classes.Add(cls, Heap::kOld);
884 type = Type::NewNonParameterizedType(cls); 891 object_store->set_list_class(cls);
885 object_store->set_list_interface(type);
886 892
887 cls = object_store->bool_class(); 893 cls = object_store->bool_class();
888 type = Type::NewNonParameterizedType(cls); 894 type = Type::NewNonParameterizedType(cls);
889 object_store->set_bool_type(type); 895 object_store->set_bool_type(type);
890 896
891 cls = object_store->smi_class(); 897 cls = object_store->smi_class();
892 type = Type::NewNonParameterizedType(cls); 898 type = Type::NewNonParameterizedType(cls);
893 object_store->set_smi_type(type); 899 object_store->set_smi_type(type);
894 900
895 cls = object_store->mint_class(); 901 cls = object_store->mint_class();
(...skipping 7653 matching lines...) Expand 10 before | Expand all | Expand 10 after
8549 (type_class() == Type::Handle(Type::StringType()).type_class()); 8555 (type_class() == Type::Handle(Type::StringType()).type_class());
8550 } 8556 }
8551 8557
8552 8558
8553 bool AbstractType::IsFunctionType() const { 8559 bool AbstractType::IsFunctionType() const {
8554 return HasResolvedTypeClass() && 8560 return HasResolvedTypeClass() &&
8555 (type_class() == Type::Handle(Type::Function()).type_class()); 8561 (type_class() == Type::Handle(Type::Function()).type_class());
8556 } 8562 }
8557 8563
8558 8564
8559 bool AbstractType::IsListInterface() const {
8560 return HasResolvedTypeClass() &&
8561 (type_class() == Type::Handle(Type::ListInterface()).type_class());
8562 }
8563
8564
8565 bool AbstractType::TypeTest(TypeTestKind test_kind, 8565 bool AbstractType::TypeTest(TypeTestKind test_kind,
8566 const AbstractType& other, 8566 const AbstractType& other,
8567 Error* malformed_error) const { 8567 Error* malformed_error) const {
8568 ASSERT(IsFinalized()); 8568 ASSERT(IsFinalized());
8569 ASSERT(other.IsFinalized()); 8569 ASSERT(other.IsFinalized());
8570 // In case the type checked in a type test is malformed, the code generator 8570 // In case the type checked in a type test is malformed, the code generator
8571 // may compile a throw instead of a run time call performing the type check. 8571 // may compile a throw instead of a run time call performing the type check.
8572 // However, in checked mode, a function type may include malformed result type 8572 // However, in checked mode, a function type may include malformed result type
8573 // and/or malformed parameter types, which will then be encountered here at 8573 // and/or malformed parameter types, which will then be encountered here at
8574 // run time. 8574 // run time.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
8681 RawType* Type::Number() { 8681 RawType* Type::Number() {
8682 return Isolate::Current()->object_store()->number_type(); 8682 return Isolate::Current()->object_store()->number_type();
8683 } 8683 }
8684 8684
8685 8685
8686 RawType* Type::StringType() { 8686 RawType* Type::StringType() {
8687 return Isolate::Current()->object_store()->string_type(); 8687 return Isolate::Current()->object_store()->string_type();
8688 } 8688 }
8689 8689
8690 8690
8691 RawType* Type::ArrayType() {
8692 return Isolate::Current()->object_store()->array_type();
8693 }
8694
8695
8691 RawType* Type::Function() { 8696 RawType* Type::Function() {
8692 return Isolate::Current()->object_store()->function_type(); 8697 return Isolate::Current()->object_store()->function_type();
8693 } 8698 }
8694 8699
8695 8700
8696 RawType* Type::ListInterface() {
8697 return Isolate::Current()->object_store()->list_interface();
8698 }
8699
8700
8701 RawType* Type::NewNonParameterizedType(const Class& type_class) { 8701 RawType* Type::NewNonParameterizedType(const Class& type_class) {
8702 ASSERT(!type_class.HasTypeArguments()); 8702 ASSERT(!type_class.HasTypeArguments());
8703 const TypeArguments& no_type_arguments = TypeArguments::Handle(); 8703 const TypeArguments& no_type_arguments = TypeArguments::Handle();
8704 Type& type = Type::Handle(); 8704 Type& type = Type::Handle();
8705 type ^= Type::New(Object::Handle(type_class.raw()), 8705 type ^= Type::New(Object::Handle(type_class.raw()),
8706 no_type_arguments, 8706 no_type_arguments,
8707 Scanner::kDummyTokenIndex); 8707 Scanner::kDummyTokenIndex);
8708 type.set_is_finalized_instantiated(); 8708 type.set_is_finalized_instantiated();
8709 type ^= type.Canonicalize(); 8709 type ^= type.Canonicalize();
8710 return type.raw(); 8710 return type.raw();
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
9129 9129
9130 void TypeParameter::set_type_state(int8_t state) const { 9130 void TypeParameter::set_type_state(int8_t state) const {
9131 ASSERT((state == RawTypeParameter::kAllocated) || 9131 ASSERT((state == RawTypeParameter::kAllocated) ||
9132 (state == RawTypeParameter::kBeingFinalized) || 9132 (state == RawTypeParameter::kBeingFinalized) ||
9133 (state == RawTypeParameter::kFinalizedUninstantiated)); 9133 (state == RawTypeParameter::kFinalizedUninstantiated));
9134 raw_ptr()->type_state_ = state; 9134 raw_ptr()->type_state_ = state;
9135 } 9135 }
9136 9136
9137 9137
9138 const char* TypeParameter::ToCString() const { 9138 const char* TypeParameter::ToCString() const {
9139 const char* format = "TypeParameter: name %s; index: %d"; 9139 const char* format = "TypeParameter: name %s; index: %d; class: %s";
9140 const char* name_cstr = String::Handle(Name()).ToCString(); 9140 const char* name_cstr = String::Handle(Name()).ToCString();
9141 intptr_t len = OS::SNPrint(NULL, 0, format, name_cstr, index()) + 1; 9141 const Class& cls = Class::Handle(parameterized_class());
9142 const char* cls_cstr =
9143 cls.IsNull() ? " null" : String::Handle(cls.Name()).ToCString();
9144 intptr_t len = OS::SNPrint(NULL, 0, format, name_cstr, index(), cls_cstr) + 1;
9142 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 9145 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
9143 OS::SNPrint(chars, len, format, name_cstr, index()); 9146 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr);
9144 return chars; 9147 return chars;
9145 } 9148 }
9146 9149
9147 9150
9148 const char* Number::ToCString() const { 9151 const char* Number::ToCString() const {
9149 // Number is an interface. No instances of Number should exist. 9152 // Number is an interface. No instances of Number should exist.
9150 UNREACHABLE(); 9153 UNREACHABLE();
9151 return "Number"; 9154 return "Number";
9152 } 9155 }
9153 9156
(...skipping 2937 matching lines...) Expand 10 before | Expand all | Expand 10 after
12091 } 12094 }
12092 return result.raw(); 12095 return result.raw();
12093 } 12096 }
12094 12097
12095 12098
12096 const char* WeakProperty::ToCString() const { 12099 const char* WeakProperty::ToCString() const {
12097 return "_WeakProperty"; 12100 return "_WeakProperty";
12098 } 12101 }
12099 12102
12100 } // namespace dart 12103 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698