| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 int os_error; | 213 int os_error; |
| 214 heap_stats.os_error = &os_error; | 214 heap_stats.os_error = &os_error; |
| 215 int end_marker; | 215 int end_marker; |
| 216 heap_stats.end_marker = &end_marker; | 216 heap_stats.end_marker = &end_marker; |
| 217 i::Isolate* isolate = i::Isolate::Current(); | 217 i::Isolate* isolate = i::Isolate::Current(); |
| 218 if (isolate->heap()->HasBeenSetUp()) { | 218 if (isolate->heap()->HasBeenSetUp()) { |
| 219 // BUG(1718): Don't use the take_snapshot since we don't support | 219 // BUG(1718): Don't use the take_snapshot since we don't support |
| 220 // HeapIterator here without doing a special GC. | 220 // HeapIterator here without doing a special GC. |
| 221 isolate->heap()->RecordStats(&heap_stats, false); | 221 isolate->heap()->RecordStats(&heap_stats, false); |
| 222 } | 222 } |
| 223 i::V8::SetFatalError(); | 223 isolate->SignalFatalError(); |
| 224 FatalErrorCallback callback = GetFatalErrorHandler(); | 224 FatalErrorCallback callback = GetFatalErrorHandler(); |
| 225 const char* message = "Allocation failed - process out of memory"; | 225 const char* message = "Allocation failed - process out of memory"; |
| 226 callback(location, message); | 226 callback(location, message); |
| 227 // If the callback returns, we stop execution. | 227 // If the callback returns, we stop execution. |
| 228 UNREACHABLE(); | 228 UNREACHABLE(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 | 231 |
| 232 bool Utils::ReportApiFailure(const char* location, const char* message) { | 232 bool Utils::ReportApiFailure(const char* location, const char* message) { |
| 233 FatalErrorCallback callback = GetFatalErrorHandler(); | 233 FatalErrorCallback callback = GetFatalErrorHandler(); |
| 234 callback(location, message); | 234 callback(location, message); |
| 235 i::V8::SetFatalError(); | 235 i::Isolate* isolate = i::Isolate::Current(); |
| 236 isolate->SignalFatalError(); |
| 236 return false; | 237 return false; |
| 237 } | 238 } |
| 238 | 239 |
| 239 | 240 |
| 240 bool V8::IsDead() { | 241 bool V8::IsDead() { |
| 241 return i::V8::IsDead(); | 242 i::Isolate* isolate = i::Isolate::Current(); |
| 243 return isolate->IsDead(); |
| 242 } | 244 } |
| 243 | 245 |
| 244 | 246 |
| 245 static inline bool ApiCheck(bool condition, | 247 static inline bool ApiCheck(bool condition, |
| 246 const char* location, | 248 const char* location, |
| 247 const char* message) { | 249 const char* message) { |
| 248 return condition ? true : Utils::ReportApiFailure(location, message); | 250 return condition ? true : Utils::ReportApiFailure(location, message); |
| 249 } | 251 } |
| 250 | 252 |
| 251 | 253 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 270 * which you sometimes can't avoid calling after the vm has crashed. Functions | 272 * which you sometimes can't avoid calling after the vm has crashed. Functions |
| 271 * that call EnsureInitialized or ON_BAILOUT don't have to also call | 273 * that call EnsureInitialized or ON_BAILOUT don't have to also call |
| 272 * IsDeadCheck. ON_BAILOUT has the advantage over EnsureInitialized that you | 274 * IsDeadCheck. ON_BAILOUT has the advantage over EnsureInitialized that you |
| 273 * can arrange to return if the VM is dead. This is needed to ensure that no VM | 275 * can arrange to return if the VM is dead. This is needed to ensure that no VM |
| 274 * heap allocations are attempted on a dead VM. EnsureInitialized has the | 276 * heap allocations are attempted on a dead VM. EnsureInitialized has the |
| 275 * advantage over ON_BAILOUT that it actually initializes the VM if this has not | 277 * advantage over ON_BAILOUT that it actually initializes the VM if this has not |
| 276 * yet been done. | 278 * yet been done. |
| 277 */ | 279 */ |
| 278 static inline bool IsDeadCheck(i::Isolate* isolate, const char* location) { | 280 static inline bool IsDeadCheck(i::Isolate* isolate, const char* location) { |
| 279 return !isolate->IsInitialized() | 281 return !isolate->IsInitialized() |
| 280 && i::V8::IsDead() ? ReportV8Dead(location) : false; | 282 && isolate->IsDead() ? ReportV8Dead(location) : false; |
| 281 } | 283 } |
| 282 | 284 |
| 283 | 285 |
| 284 static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) { | 286 static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) { |
| 285 if (!isolate->IsInitialized()) return false; | 287 if (!isolate->IsInitialized()) return false; |
| 286 if (isolate->has_scheduled_exception()) { | 288 if (isolate->has_scheduled_exception()) { |
| 287 return isolate->scheduled_exception() == | 289 return isolate->scheduled_exception() == |
| 288 isolate->heap()->termination_exception(); | 290 isolate->heap()->termination_exception(); |
| 289 } | 291 } |
| 290 return false; | 292 return false; |
| (...skipping 2545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2836 EXCEPTION_PREAMBLE(isolate); | 2838 EXCEPTION_PREAMBLE(isolate); |
| 2837 num = i::Execution::ToInteger(obj, &has_pending_exception); | 2839 num = i::Execution::ToInteger(obj, &has_pending_exception); |
| 2838 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>()); | 2840 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>()); |
| 2839 } | 2841 } |
| 2840 return ToApiHandle<Integer>(num); | 2842 return ToApiHandle<Integer>(num); |
| 2841 } | 2843 } |
| 2842 | 2844 |
| 2843 | 2845 |
| 2844 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) { | 2846 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) { |
| 2845 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); | 2847 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); |
| 2846 ApiCheck(isolate != NULL && isolate->IsInitialized() && !i::V8::IsDead(), | 2848 ApiCheck(isolate != NULL && isolate->IsInitialized() && !isolate->IsDead(), |
| 2847 "v8::internal::Internals::CheckInitialized()", | 2849 "v8::internal::Internals::CheckInitialized()", |
| 2848 "Isolate is not initialized or V8 has died"); | 2850 "Isolate is not initialized or V8 has died"); |
| 2849 } | 2851 } |
| 2850 | 2852 |
| 2851 | 2853 |
| 2852 void External::CheckCast(v8::Value* that) { | 2854 void External::CheckCast(v8::Value* that) { |
| 2853 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Cast()")) return; | 2855 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Cast()")) return; |
| 2854 ApiCheck(Utils::OpenHandle(that)->IsExternal(), | 2856 ApiCheck(Utils::OpenHandle(that)->IsExternal(), |
| 2855 "v8::External::Cast()", | 2857 "v8::External::Cast()", |
| 2856 "Could not convert to external"); | 2858 "Could not convert to external"); |
| (...skipping 5006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7863 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7865 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7864 Address callback_address = | 7866 Address callback_address = |
| 7865 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7867 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7866 VMState<EXTERNAL> state(isolate); | 7868 VMState<EXTERNAL> state(isolate); |
| 7867 ExternalCallbackScope call_scope(isolate, callback_address); | 7869 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7868 return callback(info); | 7870 return callback(info); |
| 7869 } | 7871 } |
| 7870 | 7872 |
| 7871 | 7873 |
| 7872 } } // namespace v8::internal | 7874 } } // namespace v8::internal |
| OLD | NEW |