| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "api.h" | 5 #include "api.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
| 8 #include <cmath> // For isnan. | 8 #include <cmath> // For isnan. |
| 9 #ifdef V8_USE_ADDRESS_SANITIZER | 9 #ifdef V8_USE_ADDRESS_SANITIZER |
| 10 #include <sanitizer/asan_interface.h> | 10 #include <sanitizer/asan_interface.h> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) | 52 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) |
| 53 | 53 |
| 54 #define ENTER_V8(isolate) \ | 54 #define ENTER_V8(isolate) \ |
| 55 ASSERT((isolate)->IsInitialized()); \ | 55 ASSERT((isolate)->IsInitialized()); \ |
| 56 i::VMState<i::OTHER> __state__((isolate)) | 56 i::VMState<i::OTHER> __state__((isolate)) |
| 57 | 57 |
| 58 namespace v8 { | 58 namespace v8 { |
| 59 | 59 |
| 60 #define ON_BAILOUT(isolate, location, code) \ | 60 #define ON_BAILOUT(isolate, location, code) \ |
| 61 if (IsExecutionTerminatingCheck(isolate)) { \ | 61 if (isolate->IsExecutionTerminating()) { \ |
| 62 code; \ | 62 code; \ |
| 63 UNREACHABLE(); \ | 63 UNREACHABLE(); \ |
| 64 } | 64 } |
| 65 | 65 |
| 66 | 66 |
| 67 #define EXCEPTION_PREAMBLE(isolate) \ | 67 #define EXCEPTION_PREAMBLE(isolate) \ |
| 68 (isolate)->handle_scope_implementer()->IncrementCallDepth(); \ | 68 (isolate)->handle_scope_implementer()->IncrementCallDepth(); \ |
| 69 ASSERT(!(isolate)->external_caught_exception()); \ | 69 ASSERT(!(isolate)->external_caught_exception()); \ |
| 70 bool has_pending_exception = false | 70 bool has_pending_exception = false |
| 71 | 71 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 isolate->SignalFatalError(); | 185 isolate->SignalFatalError(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 | 188 |
| 189 bool V8::IsDead() { | 189 bool V8::IsDead() { |
| 190 i::Isolate* isolate = i::Isolate::Current(); | 190 i::Isolate* isolate = i::Isolate::Current(); |
| 191 return isolate->IsDead(); | 191 return isolate->IsDead(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 | 194 |
| 195 static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) { | |
| 196 if (!isolate->IsInitialized()) return false; | |
| 197 if (isolate->has_scheduled_exception()) { | |
| 198 return isolate->scheduled_exception() == | |
| 199 isolate->heap()->termination_exception(); | |
| 200 } | |
| 201 return false; | |
| 202 } | |
| 203 | |
| 204 | |
| 205 // --- S t a t i c s --- | 195 // --- S t a t i c s --- |
| 206 | 196 |
| 207 | 197 |
| 208 static bool InitializeHelper(i::Isolate* isolate) { | 198 static bool InitializeHelper(i::Isolate* isolate) { |
| 209 // If the isolate has a function entry hook, it needs to re-build all its | 199 // If the isolate has a function entry hook, it needs to re-build all its |
| 210 // code stubs with entry hooks embedded, so let's deserialize a snapshot. | 200 // code stubs with entry hooks embedded, so let's deserialize a snapshot. |
| 211 if (isolate == NULL || isolate->function_entry_hook() == NULL) { | 201 if (isolate == NULL || isolate->function_entry_hook() == NULL) { |
| 212 if (i::Snapshot::Initialize()) | 202 if (i::Snapshot::Initialize()) |
| 213 return true; | 203 return true; |
| 214 } | 204 } |
| (...skipping 6256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6471 | 6461 |
| 6472 void V8::TerminateExecution(Isolate* isolate) { | 6462 void V8::TerminateExecution(Isolate* isolate) { |
| 6473 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6463 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6474 i_isolate->stack_guard()->RequestTerminateExecution(); | 6464 i_isolate->stack_guard()->RequestTerminateExecution(); |
| 6475 } | 6465 } |
| 6476 | 6466 |
| 6477 | 6467 |
| 6478 bool V8::IsExecutionTerminating(Isolate* isolate) { | 6468 bool V8::IsExecutionTerminating(Isolate* isolate) { |
| 6479 i::Isolate* i_isolate = isolate != NULL ? | 6469 i::Isolate* i_isolate = isolate != NULL ? |
| 6480 reinterpret_cast<i::Isolate*>(isolate) : i::Isolate::Current(); | 6470 reinterpret_cast<i::Isolate*>(isolate) : i::Isolate::Current(); |
| 6481 return IsExecutionTerminatingCheck(i_isolate); | 6471 return i_isolate->IsExecutionTerminating(); |
| 6482 } | 6472 } |
| 6483 | 6473 |
| 6484 | 6474 |
| 6485 void V8::CancelTerminateExecution(Isolate* isolate) { | 6475 void V8::CancelTerminateExecution(Isolate* isolate) { |
| 6486 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6476 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6487 i_isolate->stack_guard()->ClearTerminateExecution(); | 6477 i_isolate->stack_guard()->ClearTerminateExecution(); |
| 6488 i_isolate->CancelTerminateExecution(); | 6478 i_isolate->CancelTerminateExecution(); |
| 6489 } | 6479 } |
| 6490 | 6480 |
| 6491 | 6481 |
| (...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7560 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7550 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7561 Address callback_address = | 7551 Address callback_address = |
| 7562 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7552 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7563 VMState<EXTERNAL> state(isolate); | 7553 VMState<EXTERNAL> state(isolate); |
| 7564 ExternalCallbackScope call_scope(isolate, callback_address); | 7554 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7565 callback(info); | 7555 callback(info); |
| 7566 } | 7556 } |
| 7567 | 7557 |
| 7568 | 7558 |
| 7569 } } // namespace v8::internal | 7559 } } // namespace v8::internal |
| OLD | NEW |