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

Side by Side Diff: vm/object.cc

Issue 10866004: Revert change 11091. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 4 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 | « no previous file | vm/raw_object_snapshot.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) 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 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 name = Symbols::WeakProperty(); 629 name = Symbols::WeakProperty();
630 RegisterClass(cls, name, core_impl_lib); 630 RegisterClass(cls, name, core_impl_lib);
631 pending_classes.Add(cls, Heap::kOld); 631 pending_classes.Add(cls, Heap::kOld);
632 632
633 // Initialize the base interfaces used by the core VM classes. 633 // Initialize the base interfaces used by the core VM classes.
634 const Script& script = Script::Handle(Bootstrap::LoadCoreScript(false)); 634 const Script& script = Script::Handle(Bootstrap::LoadCoreScript(false));
635 635
636 // Allocate and initialize the Object class and type. The Object 636 // Allocate and initialize the Object class and type. The Object
637 // class and ByteArray subclasses are the only pre-allocated, 637 // class and ByteArray subclasses are the only pre-allocated,
638 // non-interface classes in the core library. 638 // non-interface classes in the core library.
639 cls = Class::New<Instance>(kInstanceCid); 639 cls = Class::New<Instance>();
640 object_store->set_object_class(cls); 640 object_store->set_object_class(cls);
641 name = Symbols::Object(); 641 name = Symbols::Object();
642 cls.set_name(name); 642 cls.set_name(name);
643 cls.set_script(script); 643 cls.set_script(script);
644 cls.set_is_prefinalized(); 644 cls.set_is_prefinalized();
645 core_lib.AddClass(cls); 645 core_lib.AddClass(cls);
646 pending_classes.Add(cls, Heap::kOld); 646 pending_classes.Add(cls, Heap::kOld);
647 type = Type::NewNonParameterizedType(cls); 647 type = Type::NewNonParameterizedType(cls);
648 object_store->set_object_type(type); 648 object_store->set_object_type(type);
649 649
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 912
913 void Object::InitFromSnapshot(Isolate* isolate) { 913 void Object::InitFromSnapshot(Isolate* isolate) {
914 TIMERSCOPE(time_bootstrap); 914 TIMERSCOPE(time_bootstrap);
915 ObjectStore* object_store = isolate->object_store(); 915 ObjectStore* object_store = isolate->object_store();
916 916
917 Class& cls = Class::Handle(); 917 Class& cls = Class::Handle();
918 918
919 // Set up empty classes in the object store, these will get 919 // Set up empty classes in the object store, these will get
920 // initialized correctly when we read from the snapshot. 920 // initialized correctly when we read from the snapshot.
921 // This is done to allow bootstrapping of reading classes from the snapshot. 921 // This is done to allow bootstrapping of reading classes from the snapshot.
922 cls = Class::New<Instance>(kInstanceCid);
923 object_store->set_object_class(cls);
924
925 cls = Class::New<Array>(); 922 cls = Class::New<Array>();
926 object_store->set_array_class(cls); 923 object_store->set_array_class(cls);
927 924
928 cls = Class::New<ImmutableArray>(); 925 cls = Class::New<ImmutableArray>();
929 object_store->set_immutable_array_class(cls); 926 object_store->set_immutable_array_class(cls);
930 927
931 cls = Class::New<GrowableObjectArray>(); 928 cls = Class::New<GrowableObjectArray>();
932 object_store->set_growable_object_array_class(cls); 929 object_store->set_growable_object_array_class(cls);
933 930
934 cls = Class::New<Int8Array>(); 931 cls = Class::New<Int8Array>();
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 RawObject* raw = Object::Allocate(Class::kClassId, 1243 RawObject* raw = Object::Allocate(Class::kClassId,
1247 Class::InstanceSize(), 1244 Class::InstanceSize(),
1248 Heap::kOld); 1245 Heap::kOld);
1249 NoGCScope no_gc; 1246 NoGCScope no_gc;
1250 result ^= raw; 1247 result ^= raw;
1251 } 1248 }
1252 FakeObject fake; 1249 FakeObject fake;
1253 result.set_handle_vtable(fake.vtable()); 1250 result.set_handle_vtable(fake.vtable());
1254 result.set_instance_size(FakeObject::InstanceSize()); 1251 result.set_instance_size(FakeObject::InstanceSize());
1255 result.set_next_field_offset(FakeObject::InstanceSize()); 1252 result.set_next_field_offset(FakeObject::InstanceSize());
1256 ASSERT((FakeObject::kClassId != kInstanceCid) && 1253 result.set_id((FakeObject::kClassId != kInstanceCid &&
1257 (FakeObject::kClassId != kClosureCid)); 1254 FakeObject::kClassId != kClosureCid) ?
1258 result.set_id(FakeObject::kClassId); 1255 FakeObject::kClassId : kIllegalCid);
1259 result.raw_ptr()->state_bits_ = 0; 1256 result.raw_ptr()->state_bits_ = 0;
1260 // VM backed classes are almost ready: run checks and resolve class 1257 // VM backed classes are almost ready: run checks and resolve class
1261 // references, but do not recompute size. 1258 // references, but do not recompute size.
1262 result.set_is_prefinalized(); 1259 result.set_is_prefinalized();
1263 result.raw_ptr()->type_arguments_instance_field_offset_ = kNoTypeArguments; 1260 result.raw_ptr()->type_arguments_instance_field_offset_ = kNoTypeArguments;
1264 result.raw_ptr()->num_native_fields_ = 0; 1261 result.raw_ptr()->num_native_fields_ = 0;
1265 result.raw_ptr()->token_pos_ = Scanner::kDummyTokenIndex; 1262 result.raw_ptr()->token_pos_ = Scanner::kDummyTokenIndex;
1266 result.InitEmptyFields(); 1263 result.InitEmptyFields();
1267 Isolate::Current()->class_table()->Register(result); 1264 Isolate::Current()->class_table()->Register(result);
1268 return result.raw(); 1265 return result.raw();
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 } 1667 }
1671 FakeInstance fake; 1668 FakeInstance fake;
1672 ASSERT(fake.IsInstance()); 1669 ASSERT(fake.IsInstance());
1673 result.set_handle_vtable(fake.vtable()); 1670 result.set_handle_vtable(fake.vtable());
1674 result.set_instance_size(FakeInstance::InstanceSize()); 1671 result.set_instance_size(FakeInstance::InstanceSize());
1675 result.set_next_field_offset(FakeInstance::InstanceSize()); 1672 result.set_next_field_offset(FakeInstance::InstanceSize());
1676 result.set_id(index); 1673 result.set_id(index);
1677 result.raw_ptr()->state_bits_ = 0; 1674 result.raw_ptr()->state_bits_ = 0;
1678 result.raw_ptr()->type_arguments_instance_field_offset_ = kNoTypeArguments; 1675 result.raw_ptr()->type_arguments_instance_field_offset_ = kNoTypeArguments;
1679 result.raw_ptr()->num_native_fields_ = 0; 1676 result.raw_ptr()->num_native_fields_ = 0;
1680 result.raw_ptr()->token_pos_ = Scanner::kDummyTokenIndex;
1681 result.InitEmptyFields(); 1677 result.InitEmptyFields();
1682 Isolate::Current()->class_table()->Register(result); 1678 Isolate::Current()->class_table()->Register(result);
1683 return result.raw(); 1679 return result.raw();
1684 } 1680 }
1685 1681
1686 1682
1687 template <class FakeInstance> 1683 template <class FakeInstance>
1688 RawClass* Class::New(const String& name, 1684 RawClass* Class::New(const String& name,
1689 const Script& script, 1685 const Script& script,
1690 intptr_t token_pos) { 1686 intptr_t token_pos) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 // Cache the signature type as the first canonicalized type in result. 1759 // Cache the signature type as the first canonicalized type in result.
1764 const Type& signature_type = Type::Handle(result.SignatureType()); 1760 const Type& signature_type = Type::Handle(result.SignatureType());
1765 ASSERT(!signature_type.IsFinalized()); 1761 ASSERT(!signature_type.IsFinalized());
1766 const Array& new_canonical_types = Array::Handle(Array::New(1, Heap::kOld)); 1762 const Array& new_canonical_types = Array::Handle(Array::New(1, Heap::kOld));
1767 new_canonical_types.SetAt(0, signature_type); 1763 new_canonical_types.SetAt(0, signature_type);
1768 result.set_canonical_types(new_canonical_types); 1764 result.set_canonical_types(new_canonical_types);
1769 return result.raw(); 1765 return result.raw();
1770 } 1766 }
1771 1767
1772 1768
1769 RawClass* Class::GetClass(intptr_t class_id, bool is_signature_class) {
1770 if (class_id >= kIntegerCid && class_id <= kWeakPropertyCid) {
1771 return Isolate::Current()->class_table()->At(class_id);
1772 }
1773 if (class_id >= kNumPredefinedCids) {
1774 if (is_signature_class) {
1775 return Class::New<Closure>();
1776 }
1777 return Class::New<Instance>();
1778 }
1779 OS::Print("Class::GetClass id unknown: %d\n", class_id);
1780 UNREACHABLE();
1781 return Class::null();
1782 }
1783
1784
1773 RawClass* Class::NewNativeWrapper(const Library& library, 1785 RawClass* Class::NewNativeWrapper(const Library& library,
1774 const String& name, 1786 const String& name,
1775 int field_count) { 1787 int field_count) {
1776 Class& cls = Class::Handle(library.LookupClass(name)); 1788 Class& cls = Class::Handle(library.LookupClass(name));
1777 if (cls.IsNull()) { 1789 if (cls.IsNull()) {
1778 const Array& empty_array = Array::Handle(Object::empty_array()); 1790 const Array& empty_array = Array::Handle(Object::empty_array());
1779 cls = New<Instance>(name, Script::Handle(), Scanner::kDummyTokenIndex); 1791 cls = New<Instance>(name, Script::Handle(), Scanner::kDummyTokenIndex);
1780 cls.SetFields(empty_array); 1792 cls.SetFields(empty_array);
1781 cls.SetFunctions(empty_array); 1793 cls.SetFunctions(empty_array);
1782 // Set super class to Object. 1794 // Set super class to Object.
(...skipping 9346 matching lines...) Expand 10 before | Expand all | Expand 10 after
11129 } 11141 }
11130 return result.raw(); 11142 return result.raw();
11131 } 11143 }
11132 11144
11133 11145
11134 const char* WeakProperty::ToCString() const { 11146 const char* WeakProperty::ToCString() const {
11135 return "WeakProperty"; 11147 return "WeakProperty";
11136 } 11148 }
11137 11149
11138 } // namespace dart 11150 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698