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

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: minor clean-up 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
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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 object_store->set_stacktrace_class(cls); 709 object_store->set_stacktrace_class(cls);
710 RegisterClass(cls, "Stacktrace", impl_script, core_impl_lib); 710 RegisterClass(cls, "Stacktrace", impl_script, core_impl_lib);
711 pending_classes.Add(cls, Heap::kOld); 711 pending_classes.Add(cls, Heap::kOld);
712 // Super type set below, after Object is allocated. 712 // Super type set below, after Object is allocated.
713 713
714 cls = Class::New<JSRegExp>(); 714 cls = Class::New<JSRegExp>();
715 object_store->set_jsregexp_class(cls); 715 object_store->set_jsregexp_class(cls);
716 RegisterClass(cls, "JSSyntaxRegExp", impl_script, core_impl_lib); 716 RegisterClass(cls, "JSSyntaxRegExp", impl_script, core_impl_lib);
717 pending_classes.Add(cls, Heap::kOld); 717 pending_classes.Add(cls, Heap::kOld);
718 718
719 cls = Class::New<WeakProperty>();
720 object_store->set_weak_property_class(cls);
721 RegisterClass(cls, "WeakProperty", impl_script, core_impl_lib);
722 pending_classes.Add(cls, Heap::kOld);
723
719 // Initialize the base interfaces used by the core VM classes. 724 // Initialize the base interfaces used by the core VM classes.
720 const Script& script = Script::Handle(Bootstrap::LoadScript()); 725 const Script& script = Script::Handle(Bootstrap::LoadScript());
721 726
722 // Allocate and initialize the Object class and type. The Object 727 // Allocate and initialize the Object class and type. The Object
723 // class and ByteArray subclasses are the only pre-allocated, 728 // class and ByteArray subclasses are the only pre-allocated,
724 // non-interface classes in the core library. 729 // non-interface classes in the core library.
725 cls = Class::New<Instance>(); 730 cls = Class::New<Instance>();
726 object_store->set_object_class(cls); 731 object_store->set_object_class(cls);
727 cls.set_name(String::Handle(Symbols::New("Object"))); 732 cls.set_name(String::Handle(Symbols::New("Object")));
728 cls.set_script(script); 733 cls.set_script(script);
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 1058
1054 cls = Class::New<Bool>(); 1059 cls = Class::New<Bool>();
1055 object_store->set_bool_class(cls); 1060 object_store->set_bool_class(cls);
1056 1061
1057 cls = Class::New<Stacktrace>(); 1062 cls = Class::New<Stacktrace>();
1058 object_store->set_stacktrace_class(cls); 1063 object_store->set_stacktrace_class(cls);
1059 1064
1060 cls = Class::New<JSRegExp>(); 1065 cls = Class::New<JSRegExp>();
1061 object_store->set_jsregexp_class(cls); 1066 object_store->set_jsregexp_class(cls);
1062 1067
1068 cls = Class::New<WeakProperty>();
1069 object_store->set_weak_property_class(cls);
1070
1063 // Allocate pre-initialized values. 1071 // Allocate pre-initialized values.
1064 Bool& bool_value = Bool::Handle(); 1072 Bool& bool_value = Bool::Handle();
1065 bool_value = Bool::New(true); 1073 bool_value = Bool::New(true);
1066 object_store->set_true_value(bool_value); 1074 object_store->set_true_value(bool_value);
1067 bool_value = Bool::New(false); 1075 bool_value = Bool::New(false);
1068 object_store->set_false_value(bool_value); 1076 object_store->set_false_value(bool_value);
1069 } 1077 }
1070 1078
1071 1079
1072 void Object::Print() const { 1080 void Object::Print() const {
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 return object_store->external_float32_array_class(); 1828 return object_store->external_float32_array_class();
1821 case kExternalFloat64Array: 1829 case kExternalFloat64Array:
1822 ASSERT(object_store->external_float64_array_class() != Class::null()); 1830 ASSERT(object_store->external_float64_array_class() != Class::null());
1823 return object_store->external_float64_array_class(); 1831 return object_store->external_float64_array_class();
1824 case kStacktrace: 1832 case kStacktrace:
1825 ASSERT(object_store->stacktrace_class() != Class::null()); 1833 ASSERT(object_store->stacktrace_class() != Class::null());
1826 return object_store->stacktrace_class(); 1834 return object_store->stacktrace_class();
1827 case kJSRegExp: 1835 case kJSRegExp:
1828 ASSERT(object_store->jsregexp_class() != Class::null()); 1836 ASSERT(object_store->jsregexp_class() != Class::null());
1829 return object_store->jsregexp_class(); 1837 return object_store->jsregexp_class();
1838 case kWeakProperty:
1839 ASSERT(object_store->weak_property_class() != Class::null());
1840 return object_store->weak_property_class();
1830 case kClosure: 1841 case kClosure:
1831 return Class::New<Closure>(); 1842 return Class::New<Closure>();
1832 case kInstance: 1843 case kInstance:
1833 return Class::New<Instance>(); 1844 return Class::New<Instance>();
1834 default: 1845 default:
1835 OS::Print("Class::GetClass kind unknown: %d\n", kind); 1846 OS::Print("Class::GetClass kind unknown: %d\n", kind);
1836 UNREACHABLE(); 1847 UNREACHABLE();
1837 } 1848 }
1838 return Class::null(); 1849 return Class::null();
1839 } 1850 }
(...skipping 9346 matching lines...) Expand 10 before | Expand all | Expand 10 after
11186 11197
11187 const char* JSRegExp::ToCString() const { 11198 const char* JSRegExp::ToCString() const {
11188 const String& str = String::Handle(pattern()); 11199 const String& str = String::Handle(pattern());
11189 const char* format = "JSRegExp: pattern=%s flags=%s"; 11200 const char* format = "JSRegExp: pattern=%s flags=%s";
11190 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 11201 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
11191 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); 11202 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
11192 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 11203 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
11193 return chars; 11204 return chars;
11194 } 11205 }
11195 11206
11207
11208 RawWeakProperty* WeakProperty::New(Heap::Space space) {
11209 ASSERT(Isolate::Current()->object_store()->weak_property_class()
11210 != Class::null());
11211 WeakProperty& result = WeakProperty::Handle();
11212 {
11213 RawObject* raw = Object::Allocate(WeakProperty::kInstanceKind,
11214 WeakProperty::InstanceSize(),
11215 space);
turnidge 2012/08/09 18:34:34 Just to double-check, does Object::Allocate set (k
cshapiro 2012/08/14 04:58:18 Yes, it should.
11216 NoGCScope no_gc;
11217 result ^= raw;
11218 }
11219 return result.raw();
11220 }
11221
11222
11223 const char* WeakProperty::ToCString() const {
11224 return "WeakProperty";
turnidge 2012/08/09 18:34:34 A thought: you could make the ToCString have some
cshapiro 2012/08/14 04:58:18 Yes, I could although I cannot think of anything n
11225 }
11226
11196 } // namespace dart 11227 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698