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/dart_entry.h" | 8 #include "vm/dart_entry.h" |
9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 | 110 |
111 void ObjectStore::Init(Isolate* isolate) { | 111 void ObjectStore::Init(Isolate* isolate) { |
112 ASSERT(isolate->object_store() == NULL); | 112 ASSERT(isolate->object_store() == NULL); |
113 ObjectStore* store = new ObjectStore(); | 113 ObjectStore* store = new ObjectStore(); |
114 isolate->set_object_store(store); | 114 isolate->set_object_store(store); |
115 } | 115 } |
116 | 116 |
117 | 117 |
118 bool ObjectStore::PreallocateObjects() { | 118 bool ObjectStore::PreallocateObjects() { |
119 Isolate* isolate = Isolate::Current(); | 119 Thread* thread = Thread::Current(); |
| 120 Isolate* isolate = thread->isolate(); |
| 121 Zone* zone = thread->zone(); |
120 ASSERT(isolate != NULL && isolate->object_store() == this); | 122 ASSERT(isolate != NULL && isolate->object_store() == this); |
121 if (this->stack_overflow() != Instance::null()) { | 123 if (this->stack_overflow() != Instance::null()) { |
122 ASSERT(this->out_of_memory() != Instance::null()); | 124 ASSERT(this->out_of_memory() != Instance::null()); |
123 ASSERT(this->preallocated_stack_trace() != Stacktrace::null()); | 125 ASSERT(this->preallocated_stack_trace() != Stacktrace::null()); |
124 return true; | 126 return true; |
125 } | 127 } |
126 ASSERT(this->stack_overflow() == Instance::null()); | 128 ASSERT(this->stack_overflow() == Instance::null()); |
127 ASSERT(this->out_of_memory() == Instance::null()); | 129 ASSERT(this->out_of_memory() == Instance::null()); |
128 ASSERT(this->preallocated_stack_trace() == Stacktrace::null()); | 130 ASSERT(this->preallocated_stack_trace() == Stacktrace::null()); |
129 | 131 |
(...skipping 23 matching lines...) Expand all Loading... |
153 Object::empty_array()); | 155 Object::empty_array()); |
154 if (result.IsError()) { | 156 if (result.IsError()) { |
155 return false; | 157 return false; |
156 } | 158 } |
157 set_out_of_memory(Instance::Cast(result)); | 159 set_out_of_memory(Instance::Cast(result)); |
158 | 160 |
159 // Allocate pre-allocated unhandled exception object initialized with the | 161 // Allocate pre-allocated unhandled exception object initialized with the |
160 // pre-allocated OutOfMemoryError. | 162 // pre-allocated OutOfMemoryError. |
161 const UnhandledException& unhandled_exception = UnhandledException::Handle( | 163 const UnhandledException& unhandled_exception = UnhandledException::Handle( |
162 UnhandledException::New(Instance::Cast(result), | 164 UnhandledException::New(Instance::Cast(result), |
163 Stacktrace::Handle(isolate))); | 165 Stacktrace::Handle(zone))); |
164 set_preallocated_unhandled_exception(unhandled_exception); | 166 set_preallocated_unhandled_exception(unhandled_exception); |
165 | 167 |
166 const Array& code_array = Array::Handle(isolate, | 168 const Array& code_array = Array::Handle(zone, |
167 Array::New(Stacktrace::kPreallocatedStackdepth, Heap::kOld)); | 169 Array::New(Stacktrace::kPreallocatedStackdepth, Heap::kOld)); |
168 const Array& pc_offset_array = Array::Handle(isolate, | 170 const Array& pc_offset_array = Array::Handle(zone, |
169 Array::New(Stacktrace::kPreallocatedStackdepth, Heap::kOld)); | 171 Array::New(Stacktrace::kPreallocatedStackdepth, Heap::kOld)); |
170 const Stacktrace& stack_trace = Stacktrace::Handle(isolate, | 172 const Stacktrace& stack_trace = Stacktrace::Handle(zone, |
171 Stacktrace::New(code_array, pc_offset_array)); | 173 Stacktrace::New(code_array, pc_offset_array)); |
172 // Expansion of inlined functions requires additional memory at run time, | 174 // Expansion of inlined functions requires additional memory at run time, |
173 // avoid it. | 175 // avoid it. |
174 stack_trace.set_expand_inlined(false); | 176 stack_trace.set_expand_inlined(false); |
175 set_preallocated_stack_trace(stack_trace); | 177 set_preallocated_stack_trace(stack_trace); |
176 | 178 |
177 return true; | 179 return true; |
178 } | 180 } |
179 | 181 |
180 | 182 |
181 void ObjectStore::InitKnownObjects() { | 183 void ObjectStore::InitKnownObjects() { |
182 Isolate* isolate = Isolate::Current(); | 184 Thread* thread = Thread::Current(); |
| 185 Zone* zone = thread->zone(); |
| 186 Isolate* isolate = thread->isolate(); |
183 ASSERT(isolate != NULL && isolate->object_store() == this); | 187 ASSERT(isolate != NULL && isolate->object_store() == this); |
184 | 188 |
185 const Library& async_lib = Library::Handle(async_library()); | 189 const Library& async_lib = Library::Handle(async_library()); |
186 ASSERT(!async_lib.IsNull()); | 190 ASSERT(!async_lib.IsNull()); |
187 Class& cls = Class::Handle(isolate); | 191 Class& cls = Class::Handle(zone); |
188 cls = async_lib.LookupClass(Symbols::Future()); | 192 cls = async_lib.LookupClass(Symbols::Future()); |
189 ASSERT(!cls.IsNull()); | 193 ASSERT(!cls.IsNull()); |
190 set_future_class(cls); | 194 set_future_class(cls); |
191 cls = async_lib.LookupClass(Symbols::Completer()); | 195 cls = async_lib.LookupClass(Symbols::Completer()); |
192 ASSERT(!cls.IsNull()); | 196 ASSERT(!cls.IsNull()); |
193 set_completer_class(cls); | 197 set_completer_class(cls); |
194 cls = async_lib.LookupClass(Symbols::StreamIterator()); | 198 cls = async_lib.LookupClass(Symbols::StreamIterator()); |
195 ASSERT(!cls.IsNull()); | 199 ASSERT(!cls.IsNull()); |
196 set_stream_iterator_class(cls); | 200 set_stream_iterator_class(cls); |
197 | 201 |
198 const Library& internal_lib = Library::Handle(internal_library()); | 202 const Library& internal_lib = Library::Handle(internal_library()); |
199 cls = internal_lib.LookupClass(Symbols::Symbol()); | 203 cls = internal_lib.LookupClass(Symbols::Symbol()); |
200 set_symbol_class(cls); | 204 set_symbol_class(cls); |
201 } | 205 } |
202 | 206 |
203 } // namespace dart | 207 } // namespace dart |
OLD | NEW |