OLD | NEW |
---|---|
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_store.h" | 5 #include "vm/object_store.h" |
6 | 6 |
7 #include "vm/exceptions.h" | |
7 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
8 #include "vm/object.h" | 9 #include "vm/object.h" |
9 #include "vm/raw_object.h" | 10 #include "vm/raw_object.h" |
10 #include "vm/visitor.h" | 11 #include "vm/visitor.h" |
11 | 12 |
12 namespace dart { | 13 namespace dart { |
13 | 14 |
14 ObjectStore::ObjectStore() | 15 ObjectStore::ObjectStore() |
15 : object_class_(Class::null()), | 16 : object_class_(Class::null()), |
16 function_interface_(Type::null()), | 17 function_interface_(Type::null()), |
(...skipping 24 matching lines...) Expand all Loading... | |
41 false_value_(Bool::null()), | 42 false_value_(Bool::null()), |
42 empty_array_(Array::null()), | 43 empty_array_(Array::null()), |
43 symbol_table_(Array::null()), | 44 symbol_table_(Array::null()), |
44 core_library_(Library::null()), | 45 core_library_(Library::null()), |
45 core_impl_library_(Library::null()), | 46 core_impl_library_(Library::null()), |
46 native_wrappers_library_(Library::null()), | 47 native_wrappers_library_(Library::null()), |
47 root_library_(Library::null()), | 48 root_library_(Library::null()), |
48 registered_libraries_(Library::null()), | 49 registered_libraries_(Library::null()), |
49 pending_classes_(Array::null()), | 50 pending_classes_(Array::null()), |
50 sticky_error_(String::null()), | 51 sticky_error_(String::null()), |
51 empty_context_(Context::null()) { | 52 empty_context_(Context::null()), |
53 stack_overflow_(Instance::null()), | |
54 preallocate_objects_called_(false) { | |
52 } | 55 } |
53 | 56 |
54 | 57 |
55 ObjectStore::~ObjectStore() { | 58 ObjectStore::~ObjectStore() { |
56 } | 59 } |
57 | 60 |
58 | 61 |
59 void ObjectStore::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 62 void ObjectStore::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
60 ASSERT(visitor != NULL); | 63 ASSERT(visitor != NULL); |
61 visitor->VisitPointers(from(), to()); | 64 visitor->VisitPointers(from(), to()); |
62 } | 65 } |
63 | 66 |
64 | 67 |
65 void ObjectStore::Init(Isolate* isolate) { | 68 void ObjectStore::Init(Isolate* isolate) { |
66 ASSERT(isolate->object_store() == NULL); | 69 ASSERT(isolate->object_store() == NULL); |
67 ObjectStore* store = new ObjectStore(); | 70 ObjectStore* store = new ObjectStore(); |
68 isolate->set_object_store(store); | 71 isolate->set_object_store(store); |
69 } | 72 } |
70 | 73 |
71 | 74 |
75 void ObjectStore::PreallocateObjects() { | |
76 if (preallocate_objects_called_) { | |
77 return; | |
78 } | |
79 preallocate_objects_called_ = true; | |
80 | |
81 GrowableArray<const Object*> args; | |
82 const Instance& exception = | |
83 Instance::Handle(Exceptions::Create(Exceptions::kStackOverflow, args)); | |
siva
2011/12/06 20:44:05
Since this runs dart code there is a possibility t
turnidge
2011/12/06 22:51:09
Added LongJump around the call. The error is prop
| |
84 set_stack_overflow(exception); | |
85 } | |
86 | |
87 | |
72 RawClass* ObjectStore::GetClass(int index) { | 88 RawClass* ObjectStore::GetClass(int index) { |
73 switch (index) { | 89 switch (index) { |
74 case kObjectClass: return object_class_; | 90 case kObjectClass: return object_class_; |
75 case kSmiClass: return smi_class_; | 91 case kSmiClass: return smi_class_; |
76 case kMintClass: return mint_class_; | 92 case kMintClass: return mint_class_; |
77 case kBigintClass: return bigint_class_; | 93 case kBigintClass: return bigint_class_; |
78 case kDoubleClass: return double_class_; | 94 case kDoubleClass: return double_class_; |
79 case kOneByteStringClass: return one_byte_string_class_; | 95 case kOneByteStringClass: return one_byte_string_class_; |
80 case kTwoByteStringClass: return two_byte_string_class_; | 96 case kTwoByteStringClass: return two_byte_string_class_; |
81 case kFourByteStringClass: return four_byte_string_class_; | 97 case kFourByteStringClass: return four_byte_string_class_; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 return kBoolInterface; | 197 return kBoolInterface; |
182 } else if (raw_type == string_interface()) { | 198 } else if (raw_type == string_interface()) { |
183 return kStringInterface; | 199 return kStringInterface; |
184 } else if (raw_type == list_interface()) { | 200 } else if (raw_type == list_interface()) { |
185 return kListInterface; | 201 return kListInterface; |
186 } | 202 } |
187 return kInvalidIndex; | 203 return kInvalidIndex; |
188 } | 204 } |
189 | 205 |
190 } // namespace dart | 206 } // namespace dart |
OLD | NEW |