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