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

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

Issue 1409113006: - Some cleanup of dynamic_type usage. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
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/cpu.h" 10 #include "vm/cpu.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 Instance* Object::sentinel_ = NULL; 110 Instance* Object::sentinel_ = NULL;
111 Instance* Object::transition_sentinel_ = NULL; 111 Instance* Object::transition_sentinel_ = NULL;
112 Instance* Object::unknown_constant_ = NULL; 112 Instance* Object::unknown_constant_ = NULL;
113 Instance* Object::non_constant_ = NULL; 113 Instance* Object::non_constant_ = NULL;
114 Bool* Object::bool_true_ = NULL; 114 Bool* Object::bool_true_ = NULL;
115 Bool* Object::bool_false_ = NULL; 115 Bool* Object::bool_false_ = NULL;
116 Smi* Object::smi_illegal_cid_ = NULL; 116 Smi* Object::smi_illegal_cid_ = NULL;
117 LanguageError* Object::snapshot_writer_error_ = NULL; 117 LanguageError* Object::snapshot_writer_error_ = NULL;
118 LanguageError* Object::branch_offset_error_ = NULL; 118 LanguageError* Object::branch_offset_error_ = NULL;
119 Array* Object::vm_isolate_snapshot_object_table_ = NULL; 119 Array* Object::vm_isolate_snapshot_object_table_ = NULL;
120 Type* Object::dynamic_type_ = NULL;
121 Type* Object::void_type_ = NULL;
120 122
121 RawObject* Object::null_ = reinterpret_cast<RawObject*>(RAW_NULL); 123 RawObject* Object::null_ = reinterpret_cast<RawObject*>(RAW_NULL);
122 RawClass* Object::class_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 124 RawClass* Object::class_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
123 RawClass* Object::dynamic_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 125 RawClass* Object::dynamic_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
124 RawClass* Object::void_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 126 RawClass* Object::void_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
125 RawType* Object::dynamic_type_ = reinterpret_cast<RawType*>(RAW_NULL);
126 RawType* Object::void_type_ = reinterpret_cast<RawType*>(RAW_NULL);
127 RawClass* Object::unresolved_class_class_ = 127 RawClass* Object::unresolved_class_class_ =
128 reinterpret_cast<RawClass*>(RAW_NULL); 128 reinterpret_cast<RawClass*>(RAW_NULL);
129 RawClass* Object::type_arguments_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 129 RawClass* Object::type_arguments_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
130 RawClass* Object::patch_class_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 130 RawClass* Object::patch_class_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
131 RawClass* Object::function_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 131 RawClass* Object::function_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
132 RawClass* Object::closure_data_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 132 RawClass* Object::closure_data_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
133 RawClass* Object::redirection_data_class_ = 133 RawClass* Object::redirection_data_class_ =
134 reinterpret_cast<RawClass*>(RAW_NULL); 134 reinterpret_cast<RawClass*>(RAW_NULL);
135 RawClass* Object::field_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 135 RawClass* Object::field_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
136 RawClass* Object::literal_token_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 136 RawClass* Object::literal_token_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 sentinel_ = Instance::ReadOnlyHandle(); 483 sentinel_ = Instance::ReadOnlyHandle();
484 transition_sentinel_ = Instance::ReadOnlyHandle(); 484 transition_sentinel_ = Instance::ReadOnlyHandle();
485 unknown_constant_ = Instance::ReadOnlyHandle(); 485 unknown_constant_ = Instance::ReadOnlyHandle();
486 non_constant_ = Instance::ReadOnlyHandle(); 486 non_constant_ = Instance::ReadOnlyHandle();
487 bool_true_ = Bool::ReadOnlyHandle(); 487 bool_true_ = Bool::ReadOnlyHandle();
488 bool_false_ = Bool::ReadOnlyHandle(); 488 bool_false_ = Bool::ReadOnlyHandle();
489 smi_illegal_cid_ = Smi::ReadOnlyHandle(); 489 smi_illegal_cid_ = Smi::ReadOnlyHandle();
490 snapshot_writer_error_ = LanguageError::ReadOnlyHandle(); 490 snapshot_writer_error_ = LanguageError::ReadOnlyHandle();
491 branch_offset_error_ = LanguageError::ReadOnlyHandle(); 491 branch_offset_error_ = LanguageError::ReadOnlyHandle();
492 vm_isolate_snapshot_object_table_ = Array::ReadOnlyHandle(); 492 vm_isolate_snapshot_object_table_ = Array::ReadOnlyHandle();
493 dynamic_type_ = Type::ReadOnlyHandle();
494 void_type_ = Type::ReadOnlyHandle();
493 495
494 *null_object_ = Object::null(); 496 *null_object_ = Object::null();
495 *null_array_ = Array::null(); 497 *null_array_ = Array::null();
496 *null_string_ = String::null(); 498 *null_string_ = String::null();
497 *null_instance_ = Instance::null(); 499 *null_instance_ = Instance::null();
498 *null_type_arguments_ = TypeArguments::null(); 500 *null_type_arguments_ = TypeArguments::null();
499 501
500 // Initialize the empty and zero array handles to null_ in order to be able to 502 // Initialize the empty and zero array handles to null_ in order to be able to
501 // check if the empty and zero arrays were allocated (RAW_NULL is not 503 // check if the empty and zero arrays were allocated (RAW_NULL is not
502 // available). 504 // available).
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 cls.set_num_own_type_arguments(0); 798 cls.set_num_own_type_arguments(0);
797 cls.set_is_type_finalized(); 799 cls.set_is_type_finalized();
798 cls.set_is_finalized(); 800 cls.set_is_finalized();
799 void_class_ = cls.raw(); 801 void_class_ = cls.raw();
800 802
801 cls = Class::New<Type>(); 803 cls = Class::New<Type>();
802 cls.set_is_type_finalized(); 804 cls.set_is_type_finalized();
803 cls.set_is_finalized(); 805 cls.set_is_finalized();
804 806
805 cls = dynamic_class_; 807 cls = dynamic_class_;
806 dynamic_type_ = Type::NewNonParameterizedType(cls); 808 *dynamic_type_ = Type::NewNonParameterizedType(cls);
807 809
808 cls = void_class_; 810 cls = void_class_;
809 void_type_ = Type::NewNonParameterizedType(cls); 811 *void_type_ = Type::NewNonParameterizedType(cls);
810 812
811 // Allocate and initialize singleton true and false boolean objects. 813 // Allocate and initialize singleton true and false boolean objects.
812 cls = Class::New<Bool>(); 814 cls = Class::New<Bool>();
813 isolate->object_store()->set_bool_class(cls); 815 isolate->object_store()->set_bool_class(cls);
814 *bool_true_ = Bool::New(true); 816 *bool_true_ = Bool::New(true);
815 *bool_false_ = Bool::New(false); 817 *bool_false_ = Bool::New(false);
816 818
817 *smi_illegal_cid_ = Smi::New(kIllegalCid); 819 *smi_illegal_cid_ = Smi::New(kIllegalCid);
818 820
819 String& error_str = String::Handle(); 821 String& error_str = String::Handle();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 #define SET_CLASS_NAME(class_name, name) \ 896 #define SET_CLASS_NAME(class_name, name) \
895 cls = class_name##_class(); \ 897 cls = class_name##_class(); \
896 cls.set_name(Symbols::name()); \ 898 cls.set_name(Symbols::name()); \
897 899
898 void Object::FinalizeVMIsolate(Isolate* isolate) { 900 void Object::FinalizeVMIsolate(Isolate* isolate) {
899 // Should only be run by the vm isolate. 901 // Should only be run by the vm isolate.
900 ASSERT(isolate == Dart::vm_isolate()); 902 ASSERT(isolate == Dart::vm_isolate());
901 903
902 // Allocate the parameter arrays for method extractor types and names. 904 // Allocate the parameter arrays for method extractor types and names.
903 *extractor_parameter_types_ = Array::New(1, Heap::kOld); 905 *extractor_parameter_types_ = Array::New(1, Heap::kOld);
904 extractor_parameter_types_->SetAt(0, Type::Handle(Type::DynamicType())); 906 extractor_parameter_types_->SetAt(0, Object::dynamic_type());
905 *extractor_parameter_names_ = Array::New(1, Heap::kOld); 907 *extractor_parameter_names_ = Array::New(1, Heap::kOld);
906 extractor_parameter_names_->SetAt(0, Symbols::This()); 908 extractor_parameter_names_->SetAt(0, Symbols::This());
907 909
908 ASSERT(!extractor_parameter_types_->IsSmi()); 910 ASSERT(!extractor_parameter_types_->IsSmi());
909 ASSERT(extractor_parameter_types_->IsArray()); 911 ASSERT(extractor_parameter_types_->IsArray());
910 ASSERT(!extractor_parameter_names_->IsSmi()); 912 ASSERT(!extractor_parameter_names_->IsSmi());
911 ASSERT(extractor_parameter_names_->IsArray()); 913 ASSERT(extractor_parameter_names_->IsArray());
912 914
913 915
914 // Set up names for all VM singleton classes. 916 // Set up names for all VM singleton classes.
(...skipping 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after
2737 0)); // No token position. 2739 0)); // No token position.
2738 ArgumentsDescriptor desc(args_desc); 2740 ArgumentsDescriptor desc(args_desc);
2739 invocation.set_num_fixed_parameters(desc.PositionalCount()); 2741 invocation.set_num_fixed_parameters(desc.PositionalCount());
2740 invocation.SetNumOptionalParameters(desc.NamedCount(), 2742 invocation.SetNumOptionalParameters(desc.NamedCount(),
2741 false); // Not positional. 2743 false); // Not positional.
2742 invocation.set_parameter_types(Array::Handle(Array::New(desc.Count(), 2744 invocation.set_parameter_types(Array::Handle(Array::New(desc.Count(),
2743 Heap::kOld))); 2745 Heap::kOld)));
2744 invocation.set_parameter_names(Array::Handle(Array::New(desc.Count(), 2746 invocation.set_parameter_names(Array::Handle(Array::New(desc.Count(),
2745 Heap::kOld))); 2747 Heap::kOld)));
2746 // Receiver. 2748 // Receiver.
2747 invocation.SetParameterTypeAt(0, Type::Handle(Type::DynamicType())); 2749 invocation.SetParameterTypeAt(0, Object::dynamic_type());
2748 invocation.SetParameterNameAt(0, Symbols::This()); 2750 invocation.SetParameterNameAt(0, Symbols::This());
2749 // Remaining positional parameters. 2751 // Remaining positional parameters.
2750 intptr_t i = 1; 2752 intptr_t i = 1;
2751 for (; i < desc.PositionalCount(); i++) { 2753 for (; i < desc.PositionalCount(); i++) {
2752 invocation.SetParameterTypeAt(i, Type::Handle(Type::DynamicType())); 2754 invocation.SetParameterTypeAt(i, Object::dynamic_type());
2753 char name[64]; 2755 char name[64];
2754 OS::SNPrint(name, 64, ":p%" Pd, i); 2756 OS::SNPrint(name, 64, ":p%" Pd, i);
2755 invocation.SetParameterNameAt(i, String::Handle(Symbols::New(name))); 2757 invocation.SetParameterNameAt(i, String::Handle(Symbols::New(name)));
2756 } 2758 }
2757 2759
2758 // Named parameters. 2760 // Named parameters.
2759 for (; i < desc.Count(); i++) { 2761 for (; i < desc.Count(); i++) {
2760 invocation.SetParameterTypeAt(i, Type::Handle(Type::DynamicType())); 2762 invocation.SetParameterTypeAt(i, Object::dynamic_type());
2761 intptr_t index = i - desc.PositionalCount(); 2763 intptr_t index = i - desc.PositionalCount();
2762 invocation.SetParameterNameAt(i, String::Handle(desc.NameAt(index))); 2764 invocation.SetParameterNameAt(i, String::Handle(desc.NameAt(index)));
2763 } 2765 }
2764 invocation.set_result_type(Type::Handle(Type::DynamicType())); 2766 invocation.set_result_type(Object::dynamic_type());
2765 invocation.set_is_debuggable(false); 2767 invocation.set_is_debuggable(false);
2766 invocation.set_is_visible(false); 2768 invocation.set_is_visible(false);
2767 invocation.set_is_reflectable(false); 2769 invocation.set_is_reflectable(false);
2768 invocation.set_saved_args_desc(args_desc); 2770 invocation.set_saved_args_desc(args_desc);
2769 2771
2770 return invocation.raw(); 2772 return invocation.raw();
2771 } 2773 }
2772 2774
2773 2775
2774 // Method extractors are used to create implicit closures from methods. 2776 // Method extractors are used to create implicit closures from methods.
(...skipping 17 matching lines...) Expand all
2792 false, // Not native. 2794 false, // Not native.
2793 owner, 2795 owner,
2794 0)); // No token position. 2796 0)); // No token position.
2795 2797
2796 // Initialize signature: receiver is a single fixed parameter. 2798 // Initialize signature: receiver is a single fixed parameter.
2797 const intptr_t kNumParameters = 1; 2799 const intptr_t kNumParameters = 1;
2798 extractor.set_num_fixed_parameters(kNumParameters); 2800 extractor.set_num_fixed_parameters(kNumParameters);
2799 extractor.SetNumOptionalParameters(0, 0); 2801 extractor.SetNumOptionalParameters(0, 0);
2800 extractor.set_parameter_types(Object::extractor_parameter_types()); 2802 extractor.set_parameter_types(Object::extractor_parameter_types());
2801 extractor.set_parameter_names(Object::extractor_parameter_names()); 2803 extractor.set_parameter_names(Object::extractor_parameter_names());
2802 extractor.set_result_type(Type::Handle(Type::DynamicType())); 2804 extractor.set_result_type(Object::dynamic_type());
2803 2805
2804 extractor.set_extracted_method_closure(closure_function); 2806 extractor.set_extracted_method_closure(closure_function);
2805 extractor.set_is_debuggable(false); 2807 extractor.set_is_debuggable(false);
2806 extractor.set_is_visible(false); 2808 extractor.set_is_visible(false);
2807 2809
2808 owner.AddFunction(extractor); 2810 owner.AddFunction(extractor);
2809 2811
2810 return extractor.raw(); 2812 return extractor.raw();
2811 } 2813 }
2812 2814
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
3075 RawScript::kEvaluateTag); 3077 RawScript::kEvaluateTag);
3076 // In order to tokenize the source, we need to get the key to mangle 3078 // In order to tokenize the source, we need to get the key to mangle
3077 // private names from the library from which the class originates. 3079 // private names from the library from which the class originates.
3078 const Library& lib = Library::Handle(cls.library()); 3080 const Library& lib = Library::Handle(cls.library());
3079 ASSERT(!lib.IsNull()); 3081 ASSERT(!lib.IsNull());
3080 const String& lib_key = String::Handle(lib.private_key()); 3082 const String& lib_key = String::Handle(lib.private_key());
3081 script.Tokenize(lib_key); 3083 script.Tokenize(lib_key);
3082 3084
3083 const Function& func = Function::Handle( 3085 const Function& func = Function::Handle(
3084 Function::NewEvalFunction(cls, script, is_static)); 3086 Function::NewEvalFunction(cls, script, is_static));
3085 func.set_result_type(Type::Handle(Type::DynamicType())); 3087 func.set_result_type(Object::dynamic_type());
3086 const intptr_t num_implicit_params = is_static ? 0 : 1; 3088 const intptr_t num_implicit_params = is_static ? 0 : 1;
3087 func.set_num_fixed_parameters(num_implicit_params + param_names.Length()); 3089 func.set_num_fixed_parameters(num_implicit_params + param_names.Length());
3088 func.SetNumOptionalParameters(0, true); 3090 func.SetNumOptionalParameters(0, true);
3089 func.SetIsOptimizable(false); 3091 func.SetIsOptimizable(false);
3090 return func.raw(); 3092 return func.raw();
3091 } 3093 }
3092 3094
3093 3095
3094 RawObject* Class::Evaluate(const String& expr, 3096 RawObject* Class::Evaluate(const String& expr,
3095 const Array& param_names, 3097 const Array& param_names,
(...skipping 4584 matching lines...) Expand 10 before | Expand all | Expand 10 after
7680 result = Object::Clone(result, Heap::kOld); 7682 result = Object::Clone(result, Heap::kOld);
7681 7683
7682 closure_field = Field::New(closure_name, 7684 closure_field = Field::New(closure_name,
7683 true, // is_static 7685 true, // is_static
7684 true, // is_final 7686 true, // is_final
7685 true, // is_const 7687 true, // is_const
7686 false, // is_reflectable 7688 false, // is_reflectable
7687 field_owner, 7689 field_owner,
7688 this->token_pos()); 7690 this->token_pos());
7689 closure_field.SetStaticValue(Instance::Cast(result), true); 7691 closure_field.SetStaticValue(Instance::Cast(result), true);
7690 closure_field.set_type(Type::Handle(Type::DynamicType())); 7692 closure_field.set_type(Object::dynamic_type());
7691 field_owner.AddField(closure_field); 7693 field_owner.AddField(closure_field);
7692 7694
7693 return Instance::RawCast(result.raw()); 7695 return Instance::RawCast(result.raw());
7694 } 7696 }
7695 7697
7696 7698
7697 RawInstance* Field::GetterClosure() const { 7699 RawInstance* Field::GetterClosure() const {
7698 return AccessorClosure(false); 7700 return AccessorClosure(false);
7699 } 7701 }
7700 7702
(...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after
9297 const String& name, 9299 const String& name,
9298 intptr_t token_pos) const { 9300 intptr_t token_pos) const {
9299 const String& metaname = String::Handle(Symbols::New(name)); 9301 const String& metaname = String::Handle(Symbols::New(name));
9300 Field& field = Field::Handle(Field::New(metaname, 9302 Field& field = Field::Handle(Field::New(metaname,
9301 true, // is_static 9303 true, // is_static
9302 false, // is_final 9304 false, // is_final
9303 false, // is_const 9305 false, // is_const
9304 false, // is_reflectable 9306 false, // is_reflectable
9305 cls, 9307 cls,
9306 token_pos)); 9308 token_pos));
9307 field.set_type(Type::Handle(Type::DynamicType())); 9309 field.set_type(Object::dynamic_type());
9308 field.SetStaticValue(Array::empty_array(), true); 9310 field.SetStaticValue(Array::empty_array(), true);
9309 GrowableObjectArray& metadata = 9311 GrowableObjectArray& metadata =
9310 GrowableObjectArray::Handle(this->metadata()); 9312 GrowableObjectArray::Handle(this->metadata());
9311 metadata.Add(field, Heap::kOld); 9313 metadata.Add(field, Heap::kOld);
9312 cls.AddField(field); 9314 cls.AddField(field);
9313 } 9315 }
9314 9316
9315 9317
9316 void Library::AddClassMetadata(const Class& cls, 9318 void Library::AddClassMetadata(const Class& cls,
9317 const Class& toplevel_class, 9319 const Class& toplevel_class,
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
10810 10812
10811 void Namespace::AddMetadata(intptr_t token_pos, const Class& owner_class) { 10813 void Namespace::AddMetadata(intptr_t token_pos, const Class& owner_class) {
10812 ASSERT(Field::Handle(metadata_field()).IsNull()); 10814 ASSERT(Field::Handle(metadata_field()).IsNull());
10813 Field& field = Field::Handle(Field::New(Symbols::TopLevel(), 10815 Field& field = Field::Handle(Field::New(Symbols::TopLevel(),
10814 true, // is_static 10816 true, // is_static
10815 false, // is_final 10817 false, // is_final
10816 false, // is_const 10818 false, // is_const
10817 false, // is_reflectable 10819 false, // is_reflectable
10818 owner_class, 10820 owner_class,
10819 token_pos)); 10821 token_pos));
10820 field.set_type(Type::Handle(Type::DynamicType())); 10822 field.set_type(Object::dynamic_type());
10821 field.SetStaticValue(Array::empty_array(), true); 10823 field.SetStaticValue(Array::empty_array(), true);
10822 set_metadata_field(field); 10824 set_metadata_field(field);
10823 owner_class.AddField(field); 10825 owner_class.AddField(field);
10824 } 10826 }
10825 10827
10826 10828
10827 RawObject* Namespace::GetMetadata() const { 10829 RawObject* Namespace::GetMetadata() const {
10828 Field& field = Field::Handle(metadata_field()); 10830 Field& field = Field::Handle(metadata_field());
10829 if (field.IsNull()) { 10831 if (field.IsNull()) {
10830 // There is no metadata for this object. 10832 // There is no metadata for this object.
(...skipping 4685 matching lines...) Expand 10 before | Expand all | Expand 10 after
15516 UNREACHABLE(); 15518 UNREACHABLE();
15517 } 15519 }
15518 15520
15519 15521
15520 RawType* Type::NullType() { 15522 RawType* Type::NullType() {
15521 return Isolate::Current()->object_store()->null_type(); 15523 return Isolate::Current()->object_store()->null_type();
15522 } 15524 }
15523 15525
15524 15526
15525 RawType* Type::DynamicType() { 15527 RawType* Type::DynamicType() {
15526 return Object::dynamic_type(); 15528 return Object::dynamic_type().raw();
15527 } 15529 }
15528 15530
15529 15531
15530 RawType* Type::VoidType() { 15532 RawType* Type::VoidType() {
15531 return Object::void_type(); 15533 return Object::void_type().raw();
15532 } 15534 }
15533 15535
15534 15536
15535 RawType* Type::ObjectType() { 15537 RawType* Type::ObjectType() {
15536 return Isolate::Current()->object_store()->object_type(); 15538 return Isolate::Current()->object_store()->object_type();
15537 } 15539 }
15538 15540
15539 15541
15540 RawType* Type::BoolType() { 15542 RawType* Type::BoolType() {
15541 return Isolate::Current()->object_store()->bool_type(); 15543 return Isolate::Current()->object_store()->bool_type();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
15592 } 15594 }
15593 15595
15594 15596
15595 RawType* Type::Function() { 15597 RawType* Type::Function() {
15596 return Isolate::Current()->object_store()->function_type(); 15598 return Isolate::Current()->object_store()->function_type();
15597 } 15599 }
15598 15600
15599 15601
15600 RawType* Type::NewNonParameterizedType(const Class& type_class) { 15602 RawType* Type::NewNonParameterizedType(const Class& type_class) {
15601 ASSERT(type_class.NumTypeArguments() == 0); 15603 ASSERT(type_class.NumTypeArguments() == 0);
15602 if (type_class.raw() == Object::dynamic_class()) {
15603 // If the dynamic type has not been setup in the VM isolate, then we need
15604 // to allocate it here.
15605 if (Object::dynamic_type() != reinterpret_cast<RawType*>(RAW_NULL)) {
15606 ASSERT(Type::Handle(Object::dynamic_type()).IsFinalized());
15607 return Object::dynamic_type();
15608 }
15609 ASSERT(Isolate::Current() == Dart::vm_isolate());
15610 }
15611 Type& type = Type::Handle(type_class.CanonicalType()); 15604 Type& type = Type::Handle(type_class.CanonicalType());
15612 if (type.IsNull()) { 15605 if (type.IsNull()) {
15613 const TypeArguments& no_type_arguments = TypeArguments::Handle(); 15606 const TypeArguments& no_type_arguments = TypeArguments::Handle();
15614 type ^= Type::New(Object::Handle(type_class.raw()), 15607 type ^= Type::New(Object::Handle(type_class.raw()),
15615 no_type_arguments, 15608 no_type_arguments,
15616 Scanner::kNoSourcePos); 15609 Scanner::kNoSourcePos);
15617 type.SetIsFinalized(); 15610 type.SetIsFinalized();
15618 type ^= type.Canonicalize(); 15611 type ^= type.Canonicalize();
15619 } 15612 }
15620 ASSERT(type.IsFinalized()); 15613 ASSERT(type.IsFinalized());
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
15940 if (IsCanonical() || IsMalformed()) { 15933 if (IsCanonical() || IsMalformed()) {
15941 ASSERT(IsMalformed() || TypeArguments::Handle(arguments()).IsOld()); 15934 ASSERT(IsMalformed() || TypeArguments::Handle(arguments()).IsOld());
15942 return this->raw(); 15935 return this->raw();
15943 } 15936 }
15944 Thread* thread = Thread::Current(); 15937 Thread* thread = Thread::Current();
15945 Zone* zone = thread->zone(); 15938 Zone* zone = thread->zone();
15946 Isolate* isolate = thread->isolate(); 15939 Isolate* isolate = thread->isolate();
15947 Type& type = Type::Handle(zone); 15940 Type& type = Type::Handle(zone);
15948 const Class& cls = Class::Handle(zone, type_class()); 15941 const Class& cls = Class::Handle(zone, type_class());
15949 if (cls.raw() == Object::dynamic_class() && (isolate != Dart::vm_isolate())) { 15942 if (cls.raw() == Object::dynamic_class() && (isolate != Dart::vm_isolate())) {
15950 return Object::dynamic_type(); 15943 return Object::dynamic_type().raw();
15951 } 15944 }
15952 // Fast canonical lookup/registry for simple types. 15945 // Fast canonical lookup/registry for simple types.
15953 if (cls.NumTypeArguments() == 0) { 15946 if (cls.NumTypeArguments() == 0) {
15954 type = cls.CanonicalType(); 15947 type = cls.CanonicalType();
15955 if (type.IsNull()) { 15948 if (type.IsNull()) {
15956 ASSERT(!cls.raw()->IsVMHeapObject() || (isolate == Dart::vm_isolate())); 15949 ASSERT(!cls.raw()->IsVMHeapObject() || (isolate == Dart::vm_isolate()));
15957 cls.set_canonical_types(*this); 15950 cls.set_canonical_types(*this);
15958 SetCanonical(); 15951 SetCanonical();
15959 return this->raw(); 15952 return this->raw();
15960 } 15953 }
(...skipping 5802 matching lines...) Expand 10 before | Expand all | Expand 10 after
21763 return tag_label.ToCString(); 21756 return tag_label.ToCString();
21764 } 21757 }
21765 21758
21766 21759
21767 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21760 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21768 Instance::PrintJSONImpl(stream, ref); 21761 Instance::PrintJSONImpl(stream, ref);
21769 } 21762 }
21770 21763
21771 21764
21772 } // namespace dart 21765 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.cc » ('j') | runtime/vm/scopes.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698