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/exceptions.h" |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/longjump.h" | |
10 #include "vm/object.h" | 9 #include "vm/object.h" |
11 #include "vm/raw_object.h" | 10 #include "vm/raw_object.h" |
12 #include "vm/visitor.h" | 11 #include "vm/visitor.h" |
13 | 12 |
14 namespace dart { | 13 namespace dart { |
15 | 14 |
16 ObjectStore::ObjectStore() | 15 ObjectStore::ObjectStore() |
17 : object_class_(Class::null()), | 16 : object_class_(Class::null()), |
18 function_interface_(Type::null()), | 17 function_interface_(Type::null()), |
19 number_interface_(Type::null()), | 18 number_interface_(Type::null()), |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 ASSERT(isolate->object_store() == NULL); | 72 ASSERT(isolate->object_store() == NULL); |
74 ObjectStore* store = new ObjectStore(); | 73 ObjectStore* store = new ObjectStore(); |
75 isolate->set_object_store(store); | 74 isolate->set_object_store(store); |
76 } | 75 } |
77 | 76 |
78 | 77 |
79 bool ObjectStore::PreallocateObjects() { | 78 bool ObjectStore::PreallocateObjects() { |
80 if (preallocate_objects_called_) { | 79 if (preallocate_objects_called_) { |
81 return true; | 80 return true; |
82 } | 81 } |
83 | |
84 Isolate* isolate = Isolate::Current(); | 82 Isolate* isolate = Isolate::Current(); |
85 ASSERT(isolate != NULL && isolate->object_store() == this); | 83 ASSERT(isolate != NULL && isolate->object_store() == this); |
86 LongJump* base = isolate->long_jump_base(); | 84 GrowableArray<const Object*> args; |
87 LongJump jump; | 85 Object& result = Object::Handle(); |
88 isolate->set_long_jump_base(&jump); | 86 Instance& exception = Instance::Handle(); |
89 if (setjmp(*jump.Set()) == 0) { | 87 |
90 GrowableArray<const Object*> args; | 88 result = Exceptions::Create(Exceptions::kStackOverflow, args); |
91 Instance& exception =Instance::Handle(); | 89 if (result.IsError()) { |
92 exception = Exceptions::Create(Exceptions::kStackOverflow, args); | |
93 set_stack_overflow(exception); | |
94 exception = Exceptions::Create(Exceptions::kOutOfMemory, args); | |
95 set_out_of_memory(exception); | |
96 } else { | |
97 return false; | 90 return false; |
98 } | 91 } |
99 isolate->set_long_jump_base(base); | 92 exception ^= result.raw(); |
| 93 set_stack_overflow(exception); |
| 94 |
| 95 result = Exceptions::Create(Exceptions::kOutOfMemory, args); |
| 96 if (result.IsError()) { |
| 97 return false; |
| 98 } |
| 99 exception ^= result.raw(); |
| 100 set_out_of_memory(exception); |
| 101 |
100 preallocate_objects_called_ = true; | 102 preallocate_objects_called_ = true; |
101 return true; | 103 return true; |
102 } | 104 } |
103 | 105 |
104 | 106 |
105 RawClass* ObjectStore::GetClass(int index) { | 107 RawClass* ObjectStore::GetClass(int index) { |
106 switch (index) { | 108 switch (index) { |
107 case kObjectClass: return object_class_; | 109 case kObjectClass: return object_class_; |
108 case kSmiClass: return smi_class_; | 110 case kSmiClass: return smi_class_; |
109 case kMintClass: return mint_class_; | 111 case kMintClass: return mint_class_; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 return kStringInterface; | 219 return kStringInterface; |
218 } else if (raw_type == list_interface()) { | 220 } else if (raw_type == list_interface()) { |
219 return kListInterface; | 221 return kListInterface; |
220 } else if (raw_type == byte_array_interface()) { | 222 } else if (raw_type == byte_array_interface()) { |
221 return kByteArrayInterface; | 223 return kByteArrayInterface; |
222 } | 224 } |
223 return kInvalidIndex; | 225 return kInvalidIndex; |
224 } | 226 } |
225 | 227 |
226 } // namespace dart | 228 } // namespace dart |
OLD | NEW |