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

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

Issue 8403005: Add support for 'Dynamic' type in the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 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
« no previous file with comments | « no previous file | tests/language/language.status » ('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) 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/assert.h" 8 #include "vm/assert.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 Instance& sentinel = Instance::Handle(); 251 Instance& sentinel = Instance::Handle();
252 sentinel ^= Object::Allocate(cls, Instance::InstanceSize(), Heap::kOld); 252 sentinel ^= Object::Allocate(cls, Instance::InstanceSize(), Heap::kOld);
253 sentinel_ = sentinel.raw(); 253 sentinel_ = sentinel.raw();
254 254
255 Instance& transition_sentinel = Instance::Handle(); 255 Instance& transition_sentinel = Instance::Handle();
256 transition_sentinel ^= 256 transition_sentinel ^=
257 Object::Allocate(cls, Instance::InstanceSize(), Heap::kOld); 257 Object::Allocate(cls, Instance::InstanceSize(), Heap::kOld);
258 transition_sentinel_ = transition_sentinel.raw(); 258 transition_sentinel_ = transition_sentinel.raw();
259 } 259 }
260 260
261 // The interface "Dynamic" is not a VM internal class. It is the type class of
262 // the "unknown type". For efficiency, we allocate it in the VM isolate.
263 // Therefore, it cannot have a heap allocated name (the name is hard coded,
264 // see GetSingletonClassIndex) and its array fields cannot be set to the empty
265 // array, but remain null.
266 cls = Class::New<Instance>();
267 cls.set_is_interface();
268 dynamic_class_ = cls.raw();
269
261 // Allocate the remaining VM internal classes. 270 // Allocate the remaining VM internal classes.
262 cls = Class::New<UnresolvedClass>(); 271 cls = Class::New<UnresolvedClass>();
263 unresolved_class_class_ = cls.raw(); 272 unresolved_class_class_ = cls.raw();
264 273
265 cls = Class::New<Instance>(); 274 cls = Class::New<Instance>();
266 dynamic_class_ = cls.raw();
267
268 cls = Class::New<Instance>();
269 void_class_ = cls.raw(); 275 void_class_ = cls.raw();
270 276
271 cls = Class::New<ParameterizedType>(); 277 cls = Class::New<ParameterizedType>();
272 parameterized_type_class_ = cls.raw(); 278 parameterized_type_class_ = cls.raw();
273 279
274 cls = Class::New<TypeParameter>(); 280 cls = Class::New<TypeParameter>();
275 type_parameter_class_ = cls.raw(); 281 type_parameter_class_ = cls.raw();
276 282
277 cls = Class::New<InstantiatedType>(); 283 cls = Class::New<InstantiatedType>();
278 instantiated_type_class_ = cls.raw(); 284 instantiated_type_class_ = cls.raw();
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 core_lib.AddClass(cls); 556 core_lib.AddClass(cls);
551 type = Type::NewNonParameterizedType(cls); 557 type = Type::NewNonParameterizedType(cls);
552 object_store->set_string_interface(type); 558 object_store->set_string_interface(type);
553 559
554 name = String::NewSymbol("bool"); 560 name = String::NewSymbol("bool");
555 cls = Class::NewInterface(name, script); 561 cls = Class::NewInterface(name, script);
556 core_lib.AddClass(cls); 562 core_lib.AddClass(cls);
557 type = Type::NewNonParameterizedType(cls); 563 type = Type::NewNonParameterizedType(cls);
558 object_store->set_bool_interface(type); 564 object_store->set_bool_interface(type);
559 565
560 // The classes 'Null', 'Dynamic', and 'void' are not registered in the class 566 // The classes 'Null' and 'void' are not registered in the class dictionary,
561 // dictionary and are not named, but corresponding types are stored in the 567 // because their names are reserved keywords. Their names are not heap
562 // object store. 568 // allocated, because the classes reside in the VM isolate.
569 // The corresponding types are stored in the object store.
563 cls = null_class_; 570 cls = null_class_;
564 type = Type::NewNonParameterizedType(cls); 571 type = Type::NewNonParameterizedType(cls);
565 object_store->set_null_type(type); 572 object_store->set_null_type(type);
566 573
567 cls = dynamic_class_;
568 type = Type::NewNonParameterizedType(cls);
569 object_store->set_dynamic_type(type);
570
571 cls = void_class_; 574 cls = void_class_;
572 type = Type::NewNonParameterizedType(cls); 575 type = Type::NewNonParameterizedType(cls);
573 object_store->set_void_type(type); 576 object_store->set_void_type(type);
574 577
578 // The class 'Dynamic' is registered in the class dictionary because its name
579 // is a built-in identifier, rather than a reserved keyword. Its name is not
580 // heap allocated, because the class resides in the VM isolate.
581 // The corresponding type, the "unknown type", is stored in the object store.
582 cls = dynamic_class_;
583 type = Type::NewNonParameterizedType(cls);
584 object_store->set_dynamic_type(type);
585 core_lib.AddClass(cls);
586
575 // Finish the initialization by compiling the bootstrap script containing the 587 // Finish the initialization by compiling the bootstrap script containing the
576 // implementation of the internal classes. 588 // implementation of the internal classes.
577 Bootstrap::Compile(Library::Handle(Library::CoreLibrary()), script); 589 Bootstrap::Compile(Library::Handle(Library::CoreLibrary()), script);
578 Bootstrap::Compile(Library::Handle(Library::CoreImplLibrary()), impl_script); 590 Bootstrap::Compile(Library::Handle(Library::CoreImplLibrary()), impl_script);
579 591
580 Bootstrap::SetupNativeResolver(); 592 Bootstrap::SetupNativeResolver();
581 593
582 // Remove the Object superclass cycle by setting the super type to null (not 594 // Remove the Object superclass cycle by setting the super type to null (not
583 // to the type of null). 595 // to the type of null).
584 cls = object_store->object_class(); 596 cls = object_store->object_class();
(...skipping 6202 matching lines...) Expand 10 before | Expand all | Expand 10 after
6787 const String& str = String::Handle(pattern()); 6799 const String& str = String::Handle(pattern());
6788 const char* format = "JSRegExp: pattern=%s flags=%s"; 6800 const char* format = "JSRegExp: pattern=%s flags=%s";
6789 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 6801 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
6790 char* chars = reinterpret_cast<char*>( 6802 char* chars = reinterpret_cast<char*>(
6791 Isolate::Current()->current_zone()->Allocate(len + 1)); 6803 Isolate::Current()->current_zone()->Allocate(len + 1));
6792 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 6804 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
6793 return chars; 6805 return chars;
6794 } 6806 }
6795 6807
6796 } // namespace dart 6808 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698