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

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

Issue 10832199: Add a weak property type to the virtual machine. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address final review comments 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 | « runtime/vm/object.h ('k') | runtime/vm/object_store.h » ('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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 RegisterClass(cls, name, core_impl_lib); 617 RegisterClass(cls, name, core_impl_lib);
618 pending_classes.Add(cls, Heap::kOld); 618 pending_classes.Add(cls, Heap::kOld);
619 // Super type set below, after Object is allocated. 619 // Super type set below, after Object is allocated.
620 620
621 cls = Class::New<JSRegExp>(); 621 cls = Class::New<JSRegExp>();
622 object_store->set_jsregexp_class(cls); 622 object_store->set_jsregexp_class(cls);
623 name = Symbols::JSSyntaxRegExp(); 623 name = Symbols::JSSyntaxRegExp();
624 RegisterClass(cls, name, core_impl_lib); 624 RegisterClass(cls, name, core_impl_lib);
625 pending_classes.Add(cls, Heap::kOld); 625 pending_classes.Add(cls, Heap::kOld);
626 626
627 cls = Class::New<WeakProperty>();
628 object_store->set_weak_property_class(cls);
629 RegisterClass(cls, "WeakProperty", impl_script, core_impl_lib);
630 pending_classes.Add(cls, Heap::kOld);
631
627 // Initialize the base interfaces used by the core VM classes. 632 // Initialize the base interfaces used by the core VM classes.
628 const Script& script = Script::Handle(Bootstrap::LoadCoreScript(false)); 633 const Script& script = Script::Handle(Bootstrap::LoadCoreScript(false));
629 634
630 // Allocate and initialize the Object class and type. The Object 635 // Allocate and initialize the Object class and type. The Object
631 // class and ByteArray subclasses are the only pre-allocated, 636 // class and ByteArray subclasses are the only pre-allocated,
632 // non-interface classes in the core library. 637 // non-interface classes in the core library.
633 cls = Class::New<Instance>(); 638 cls = Class::New<Instance>();
634 object_store->set_object_class(cls); 639 object_store->set_object_class(cls);
635 name = Symbols::Object(); 640 name = Symbols::Object();
636 cls.set_name(name); 641 cls.set_name(name);
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 1022
1018 cls = Class::New<Bool>(); 1023 cls = Class::New<Bool>();
1019 object_store->set_bool_class(cls); 1024 object_store->set_bool_class(cls);
1020 1025
1021 cls = Class::New<Stacktrace>(); 1026 cls = Class::New<Stacktrace>();
1022 object_store->set_stacktrace_class(cls); 1027 object_store->set_stacktrace_class(cls);
1023 1028
1024 cls = Class::New<JSRegExp>(); 1029 cls = Class::New<JSRegExp>();
1025 object_store->set_jsregexp_class(cls); 1030 object_store->set_jsregexp_class(cls);
1026 1031
1032 cls = Class::New<WeakProperty>();
1033 object_store->set_weak_property_class(cls);
1034
1027 // Allocate pre-initialized values. 1035 // Allocate pre-initialized values.
1028 Bool& bool_value = Bool::Handle(); 1036 Bool& bool_value = Bool::Handle();
1029 bool_value = Bool::New(true); 1037 bool_value = Bool::New(true);
1030 object_store->set_true_value(bool_value); 1038 object_store->set_true_value(bool_value);
1031 bool_value = Bool::New(false); 1039 bool_value = Bool::New(false);
1032 object_store->set_false_value(bool_value); 1040 object_store->set_false_value(bool_value);
1033 } 1041 }
1034 1042
1035 1043
1036 void Object::Print() const { 1044 void Object::Print() const {
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 const Type& signature_type = Type::Handle(result.SignatureType()); 1759 const Type& signature_type = Type::Handle(result.SignatureType());
1752 ASSERT(!signature_type.IsFinalized()); 1760 ASSERT(!signature_type.IsFinalized());
1753 const Array& new_canonical_types = Array::Handle(Array::New(1, Heap::kOld)); 1761 const Array& new_canonical_types = Array::Handle(Array::New(1, Heap::kOld));
1754 new_canonical_types.SetAt(0, signature_type); 1762 new_canonical_types.SetAt(0, signature_type);
1755 result.set_canonical_types(new_canonical_types); 1763 result.set_canonical_types(new_canonical_types);
1756 return result.raw(); 1764 return result.raw();
1757 } 1765 }
1758 1766
1759 1767
1760 RawClass* Class::GetClass(intptr_t class_id, bool is_signature_class) { 1768 RawClass* Class::GetClass(intptr_t class_id, bool is_signature_class) {
1761 if (class_id >= kIntegerCid && class_id <= kJSRegExpCid) { 1769 if (class_id >= kIntegerCid && class_id <= kWeakPropertyCid) {
1762 return Isolate::Current()->class_table()->At(class_id); 1770 return Isolate::Current()->class_table()->At(class_id);
1763 } 1771 }
1764 if (class_id >= kNumPredefinedCids) { 1772 if (class_id >= kNumPredefinedCids) {
1765 if (is_signature_class) { 1773 if (is_signature_class) {
1766 return Class::New<Closure>(); 1774 return Class::New<Closure>();
1767 } 1775 }
1768 return Class::New<Instance>(); 1776 return Class::New<Instance>();
1769 } 1777 }
1770 OS::Print("Class::GetClass id unknown: %d\n", class_id); 1778 OS::Print("Class::GetClass id unknown: %d\n", class_id);
1771 UNREACHABLE(); 1779 UNREACHABLE();
(...skipping 9532 matching lines...) Expand 10 before | Expand all | Expand 10 after
11304 11312
11305 const char* JSRegExp::ToCString() const { 11313 const char* JSRegExp::ToCString() const {
11306 const String& str = String::Handle(pattern()); 11314 const String& str = String::Handle(pattern());
11307 const char* format = "JSRegExp: pattern=%s flags=%s"; 11315 const char* format = "JSRegExp: pattern=%s flags=%s";
11308 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 11316 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
11309 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); 11317 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
11310 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 11318 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
11311 return chars; 11319 return chars;
11312 } 11320 }
11313 11321
11322
11323 RawWeakProperty* WeakProperty::New(Heap::Space space) {
11324 ASSERT(Isolate::Current()->object_store()->weak_property_class()
11325 != Class::null());
11326 WeakProperty& result = WeakProperty::Handle();
11327 {
11328 RawObject* raw = Object::Allocate(WeakProperty::kClassId,
11329 WeakProperty::InstanceSize(),
11330 space);
11331 NoGCScope no_gc;
11332 result ^= raw;
11333 }
11334 return result.raw();
11335 }
11336
11337
11338 const char* WeakProperty::ToCString() const {
11339 return "WeakProperty";
11340 }
11341
11314 } // namespace dart 11342 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698