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()), |
90 keyword_symbols_(Array::null()), | 91 keyword_symbols_(Array::null()), |
91 receive_port_create_function_(Function::null()), | 92 receive_port_create_function_(Function::null()), |
92 lookup_receive_port_function_(Function::null()), | 93 lookup_receive_port_function_(Function::null()), |
93 handle_message_function_(Function::null()) { | 94 handle_message_function_(Function::null()) { |
94 } | 95 } |
95 | 96 |
96 | 97 |
97 ObjectStore::~ObjectStore() { | 98 ObjectStore::~ObjectStore() { |
98 } | 99 } |
99 | 100 |
100 | 101 |
101 void ObjectStore::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 102 void ObjectStore::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
102 ASSERT(visitor != NULL); | 103 ASSERT(visitor != NULL); |
103 visitor->VisitPointers(from(), to()); | 104 visitor->VisitPointers(from(), to()); |
104 } | 105 } |
105 | 106 |
106 | 107 |
107 void ObjectStore::Init(Isolate* isolate) { | 108 void ObjectStore::Init(Isolate* isolate) { |
108 ASSERT(isolate->object_store() == NULL); | 109 ASSERT(isolate->object_store() == NULL); |
109 ObjectStore* store = new ObjectStore(); | 110 ObjectStore* store = new ObjectStore(); |
110 isolate->set_object_store(store); | 111 isolate->set_object_store(store); |
111 } | 112 } |
112 | 113 |
113 | 114 |
114 bool ObjectStore::PreallocateObjects() { | 115 bool ObjectStore::PreallocateObjects() { |
115 Isolate* isolate = Isolate::Current(); | 116 Isolate* isolate = Isolate::Current(); |
116 ASSERT(isolate != NULL && isolate->object_store() == this); | 117 ASSERT(isolate != NULL && isolate->object_store() == this); |
117 if (this->stack_overflow() != Instance::null() && | 118 if (this->stack_overflow() != Instance::null()) { |
118 this->out_of_memory() != Instance::null()) { | 119 ASSERT(this->out_of_memory() != Instance::null()); |
| 120 ASSERT(this->preallocated_stack_trace() != Stacktrace::null()); |
119 return true; | 121 return true; |
120 } | 122 } |
121 ASSERT(this->stack_overflow() == Instance::null()); | 123 ASSERT(this->stack_overflow() == Instance::null()); |
122 ASSERT(this->out_of_memory() == Instance::null()); | 124 ASSERT(this->out_of_memory() == Instance::null()); |
| 125 ASSERT(this->preallocated_stack_trace() == Stacktrace::null()); |
123 // TODO(regis): Reenable this code for arm and mips when possible. | 126 // TODO(regis): Reenable this code for arm and mips when possible. |
124 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 127 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
125 Object& result = Object::Handle(); | 128 Object& result = Object::Handle(); |
126 | 129 |
127 result = Exceptions::Create(Exceptions::kStackOverflow, | 130 result = Exceptions::Create(Exceptions::kStackOverflow, |
128 Object::empty_array()); | 131 Object::empty_array()); |
129 if (result.IsError()) { | 132 if (result.IsError()) { |
130 return false; | 133 return false; |
131 } | 134 } |
132 set_stack_overflow(Instance::Cast(result)); | 135 set_stack_overflow(Instance::Cast(result)); |
133 | 136 |
134 result = Exceptions::Create(Exceptions::kOutOfMemory, Object::empty_array()); | 137 result = Exceptions::Create(Exceptions::kOutOfMemory, Object::empty_array()); |
135 if (result.IsError()) { | 138 if (result.IsError()) { |
136 return false; | 139 return false; |
137 } | 140 } |
138 set_out_of_memory(Instance::Cast(result)); | 141 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)); |
139 #endif | 153 #endif |
140 return true; | 154 return true; |
141 } | 155 } |
142 | 156 |
143 | 157 |
144 void ObjectStore::InitKeywordTable() { | 158 void ObjectStore::InitKeywordTable() { |
145 // Set up the keywords symbol array so that we can access it while scanning. | 159 // Set up the keywords symbol array so that we can access it while scanning. |
146 Array& keywords = Array::Handle(keyword_symbols()); | 160 Array& keywords = Array::Handle(keyword_symbols()); |
147 ASSERT(keywords.IsNull()); | 161 ASSERT(keywords.IsNull()); |
148 keywords = Array::New(Token::numKeywords, Heap::kOld); | 162 keywords = Array::New(Token::numKeywords, Heap::kOld); |
149 ASSERT(!keywords.IsError() && !keywords.IsNull()); | 163 ASSERT(!keywords.IsError() && !keywords.IsNull()); |
150 set_keyword_symbols(keywords); | 164 set_keyword_symbols(keywords); |
151 } | 165 } |
152 | 166 |
153 } // namespace dart | 167 } // namespace dart |
OLD | NEW |