| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/raw_object.h" | 10 #include "vm/raw_object.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 scalarlist_library_(Library::null()), | 80 scalarlist_library_(Library::null()), |
| 81 uri_library_(Library::null()), | 81 uri_library_(Library::null()), |
| 82 utf_library_(Library::null()), | 82 utf_library_(Library::null()), |
| 83 libraries_(GrowableObjectArray::null()), | 83 libraries_(GrowableObjectArray::null()), |
| 84 pending_classes_(GrowableObjectArray::null()), | 84 pending_classes_(GrowableObjectArray::null()), |
| 85 sticky_error_(Error::null()), | 85 sticky_error_(Error::null()), |
| 86 unhandled_exception_handler_(String::null()), | 86 unhandled_exception_handler_(String::null()), |
| 87 empty_context_(Context::null()), | 87 empty_context_(Context::null()), |
| 88 stack_overflow_(Instance::null()), | 88 stack_overflow_(Instance::null()), |
| 89 out_of_memory_(Instance::null()), | 89 out_of_memory_(Instance::null()), |
| 90 preallocated_stack_trace_(Stacktrace::null()), | |
| 91 keyword_symbols_(Array::null()), | 90 keyword_symbols_(Array::null()), |
| 92 receive_port_create_function_(Function::null()), | 91 receive_port_create_function_(Function::null()), |
| 93 lookup_receive_port_function_(Function::null()), | 92 lookup_receive_port_function_(Function::null()), |
| 94 handle_message_function_(Function::null()) { | 93 handle_message_function_(Function::null()) { |
| 95 } | 94 } |
| 96 | 95 |
| 97 | 96 |
| 98 ObjectStore::~ObjectStore() { | 97 ObjectStore::~ObjectStore() { |
| 99 } | 98 } |
| 100 | 99 |
| 101 | 100 |
| 102 void ObjectStore::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 101 void ObjectStore::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
| 103 ASSERT(visitor != NULL); | 102 ASSERT(visitor != NULL); |
| 104 visitor->VisitPointers(from(), to()); | 103 visitor->VisitPointers(from(), to()); |
| 105 } | 104 } |
| 106 | 105 |
| 107 | 106 |
| 108 void ObjectStore::Init(Isolate* isolate) { | 107 void ObjectStore::Init(Isolate* isolate) { |
| 109 ASSERT(isolate->object_store() == NULL); | 108 ASSERT(isolate->object_store() == NULL); |
| 110 ObjectStore* store = new ObjectStore(); | 109 ObjectStore* store = new ObjectStore(); |
| 111 isolate->set_object_store(store); | 110 isolate->set_object_store(store); |
| 112 } | 111 } |
| 113 | 112 |
| 114 | 113 |
| 115 bool ObjectStore::PreallocateObjects() { | 114 bool ObjectStore::PreallocateObjects() { |
| 116 Isolate* isolate = Isolate::Current(); | 115 Isolate* isolate = Isolate::Current(); |
| 117 ASSERT(isolate != NULL && isolate->object_store() == this); | 116 ASSERT(isolate != NULL && isolate->object_store() == this); |
| 118 if (this->stack_overflow() != Instance::null()) { | 117 if (this->stack_overflow() != Instance::null() && |
| 119 ASSERT(this->out_of_memory() != Instance::null()); | 118 this->out_of_memory() != Instance::null()) { |
| 120 ASSERT(this->preallocated_stack_trace() != Stacktrace::null()); | |
| 121 return true; | 119 return true; |
| 122 } | 120 } |
| 123 ASSERT(this->stack_overflow() == Instance::null()); | 121 ASSERT(this->stack_overflow() == Instance::null()); |
| 124 ASSERT(this->out_of_memory() == Instance::null()); | 122 ASSERT(this->out_of_memory() == Instance::null()); |
| 125 ASSERT(this->preallocated_stack_trace() == Stacktrace::null()); | |
| 126 // TODO(regis): Reenable this code for arm and mips when possible. | 123 // TODO(regis): Reenable this code for arm and mips when possible. |
| 127 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 124 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
| 128 Object& result = Object::Handle(); | 125 Object& result = Object::Handle(); |
| 129 | 126 |
| 130 result = Exceptions::Create(Exceptions::kStackOverflow, | 127 result = Exceptions::Create(Exceptions::kStackOverflow, |
| 131 Object::empty_array()); | 128 Object::empty_array()); |
| 132 if (result.IsError()) { | 129 if (result.IsError()) { |
| 133 return false; | 130 return false; |
| 134 } | 131 } |
| 135 set_stack_overflow(Instance::Cast(result)); | 132 set_stack_overflow(Instance::Cast(result)); |
| 136 | 133 |
| 137 result = Exceptions::Create(Exceptions::kOutOfMemory, Object::empty_array()); | 134 result = Exceptions::Create(Exceptions::kOutOfMemory, Object::empty_array()); |
| 138 if (result.IsError()) { | 135 if (result.IsError()) { |
| 139 return false; | 136 return false; |
| 140 } | 137 } |
| 141 set_out_of_memory(Instance::Cast(result)); | 138 set_out_of_memory(Instance::Cast(result)); |
| 142 const Array& func_array = Array::Handle( | |
| 143 isolate, | |
| 144 Array::New(Stacktrace::kPreallocatedStackdepth, Heap::kOld)); | |
| 145 const Array& code_array = Array::Handle( | |
| 146 isolate, | |
| 147 Array::New(Stacktrace::kPreallocatedStackdepth, Heap::kOld)); | |
| 148 const Array& pc_offset_array = Array::Handle( | |
| 149 isolate, | |
| 150 Array::New(Stacktrace::kPreallocatedStackdepth, Heap::kOld)); | |
| 151 result = Stacktrace::New(func_array, code_array, pc_offset_array); | |
| 152 set_preallocated_stack_trace(Stacktrace::Cast(result)); | |
| 153 #endif | 139 #endif |
| 154 return true; | 140 return true; |
| 155 } | 141 } |
| 156 | 142 |
| 157 | 143 |
| 158 void ObjectStore::InitKeywordTable() { | 144 void ObjectStore::InitKeywordTable() { |
| 159 // Set up the keywords symbol array so that we can access it while scanning. | 145 // Set up the keywords symbol array so that we can access it while scanning. |
| 160 Array& keywords = Array::Handle(keyword_symbols()); | 146 Array& keywords = Array::Handle(keyword_symbols()); |
| 161 ASSERT(keywords.IsNull()); | 147 ASSERT(keywords.IsNull()); |
| 162 keywords = Array::New(Token::numKeywords, Heap::kOld); | 148 keywords = Array::New(Token::numKeywords, Heap::kOld); |
| 163 ASSERT(!keywords.IsError() && !keywords.IsNull()); | 149 ASSERT(!keywords.IsError() && !keywords.IsNull()); |
| 164 set_keyword_symbols(keywords); | 150 set_keyword_symbols(keywords); |
| 165 } | 151 } |
| 166 | 152 |
| 167 } // namespace dart | 153 } // namespace dart |
| OLD | NEW |