OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 "Entering the V8 API without proper locking in place"); \ | 121 "Entering the V8 API without proper locking in place"); \ |
122 } \ | 122 } \ |
123 } while (false) | 123 } while (false) |
124 | 124 |
125 | 125 |
126 // --- E x c e p t i o n B e h a v i o r --- | 126 // --- E x c e p t i o n B e h a v i o r --- |
127 | 127 |
128 | 128 |
129 static void DefaultFatalErrorHandler(const char* location, | 129 static void DefaultFatalErrorHandler(const char* location, |
130 const char* message) { | 130 const char* message) { |
131 i::VMState __state__(i::Isolate::Current(), i::OTHER); | 131 i::Isolate* isolate = i::Isolate::Current(); |
132 API_Fatal(location, message); | 132 if (isolate->IsInitialized()) { |
| 133 i::VMState __state__(isolate, i::OTHER); |
| 134 API_Fatal(location, message); |
| 135 } else { |
| 136 API_Fatal(location, message); |
| 137 } |
133 } | 138 } |
134 | 139 |
135 | 140 |
136 static FatalErrorCallback GetFatalErrorHandler() { | 141 static FatalErrorCallback GetFatalErrorHandler() { |
137 i::Isolate* isolate = i::Isolate::Current(); | 142 i::Isolate* isolate = i::Isolate::Current(); |
138 if (isolate->exception_behavior() == NULL) { | 143 if (isolate->exception_behavior() == NULL) { |
139 isolate->set_exception_behavior(DefaultFatalErrorHandler); | 144 isolate->set_exception_behavior(DefaultFatalErrorHandler); |
140 } | 145 } |
141 return isolate->exception_behavior(); | 146 return isolate->exception_behavior(); |
142 } | 147 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 heap_stats.memory_allocator_capacity = &memory_allocator_capacity; | 200 heap_stats.memory_allocator_capacity = &memory_allocator_capacity; |
196 int objects_per_type[LAST_TYPE + 1] = {0}; | 201 int objects_per_type[LAST_TYPE + 1] = {0}; |
197 heap_stats.objects_per_type = objects_per_type; | 202 heap_stats.objects_per_type = objects_per_type; |
198 int size_per_type[LAST_TYPE + 1] = {0}; | 203 int size_per_type[LAST_TYPE + 1] = {0}; |
199 heap_stats.size_per_type = size_per_type; | 204 heap_stats.size_per_type = size_per_type; |
200 int os_error; | 205 int os_error; |
201 heap_stats.os_error = &os_error; | 206 heap_stats.os_error = &os_error; |
202 int end_marker; | 207 int end_marker; |
203 heap_stats.end_marker = &end_marker; | 208 heap_stats.end_marker = &end_marker; |
204 i::Isolate* isolate = i::Isolate::Current(); | 209 i::Isolate* isolate = i::Isolate::Current(); |
205 // BUG(1718): | 210 if (isolate->heap()->HasBeenSetUp()) { |
206 // Don't use the take_snapshot since we don't support HeapIterator here | 211 // BUG(1718): Don't use the take_snapshot since we don't support |
207 // without doing a special GC. | 212 // HeapIterator here without doing a special GC. |
208 isolate->heap()->RecordStats(&heap_stats, false); | 213 isolate->heap()->RecordStats(&heap_stats, false); |
| 214 } |
209 i::V8::SetFatalError(); | 215 i::V8::SetFatalError(); |
210 FatalErrorCallback callback = GetFatalErrorHandler(); | 216 FatalErrorCallback callback = GetFatalErrorHandler(); |
| 217 const char* message = "Allocation failed - process out of memory"; |
211 { | 218 { |
212 LEAVE_V8(isolate); | 219 if (isolate->IsInitialized()) { |
213 callback(location, "Allocation failed - process out of memory"); | 220 LEAVE_V8(isolate); |
| 221 callback(location, message); |
| 222 } else { |
| 223 callback(location, message); |
| 224 } |
214 } | 225 } |
215 // If the callback returns, we stop execution. | 226 // If the callback returns, we stop execution. |
216 UNREACHABLE(); | 227 UNREACHABLE(); |
217 } | 228 } |
218 | 229 |
219 | 230 |
220 bool Utils::ReportApiFailure(const char* location, const char* message) { | 231 bool Utils::ReportApiFailure(const char* location, const char* message) { |
221 FatalErrorCallback callback = GetFatalErrorHandler(); | 232 FatalErrorCallback callback = GetFatalErrorHandler(); |
222 callback(location, message); | 233 callback(location, message); |
223 i::V8::SetFatalError(); | 234 i::V8::SetFatalError(); |
(...skipping 6512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6736 | 6747 |
6737 v->VisitPointers(blocks_.first(), first_block_limit_); | 6748 v->VisitPointers(blocks_.first(), first_block_limit_); |
6738 | 6749 |
6739 for (int i = 1; i < blocks_.length(); i++) { | 6750 for (int i = 1; i < blocks_.length(); i++) { |
6740 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 6751 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); |
6741 } | 6752 } |
6742 } | 6753 } |
6743 | 6754 |
6744 | 6755 |
6745 } } // namespace v8::internal | 6756 } } // namespace v8::internal |
OLD | NEW |