Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: src/api.cc

Issue 113121: Changed the flags that indicate the status of running vs dead... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | src/v8.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
===================================================================
--- src/api.cc (revision 1900)
+++ src/api.cc (working copy)
@@ -99,7 +99,6 @@
// --- E x c e p t i o n B e h a v i o r ---
-static bool has_shut_down = false;
static FatalErrorCallback exception_behavior = NULL;
@@ -123,7 +122,7 @@
// When V8 cannot allocated memory FatalProcessOutOfMemory is called.
// The default fatal error handler is called and execution is stopped.
void i::V8::FatalProcessOutOfMemory(const char* location) {
- has_shut_down = true;
+ i::V8::SetFatalError();
FatalErrorCallback callback = GetFatalErrorHandler();
{
LEAVE_V8;
@@ -142,13 +141,13 @@
bool Utils::ReportApiFailure(const char* location, const char* message) {
FatalErrorCallback callback = GetFatalErrorHandler();
callback(location, message);
- has_shut_down = true;
+ i::V8::SetFatalError();
return false;
}
bool V8::IsDead() {
- return has_shut_down;
+ return i::V8::IsDead();
}
@@ -186,7 +185,8 @@
* yet been done.
*/
static inline bool IsDeadCheck(const char* location) {
- return has_shut_down ? ReportV8Dead(location) : false;
+ return !i::V8::IsRunning()
+ && i::V8::IsDead() ? ReportV8Dead(location) : false;
}
@@ -205,9 +205,11 @@
static i::StringInputBuffer write_input_buffer;
-static void EnsureInitialized(const char* location) {
- if (IsDeadCheck(location)) return;
- ApiCheck(v8::V8::Initialize(), location, "Error initializing V8");
+static inline bool EnsureInitialized(const char* location) {
+ if (i::V8::IsRunning()) {
+ return true;
+ }
+ return ApiCheck(v8::V8::Initialize(), location, "Error initializing V8");
iposva 2009/05/07 23:04:06 Thinking about it further it might be helpful to c
}
@@ -225,29 +227,25 @@
v8::Handle<v8::Primitive> ImplementationUtilities::Undefined() {
- if (IsDeadCheck("v8::Undefined()")) return v8::Handle<v8::Primitive>();
- EnsureInitialized("v8::Undefined()");
+ if (!EnsureInitialized("v8::Undefined()")) return v8::Handle<v8::Primitive>();
return v8::Handle<Primitive>(ToApi<Primitive>(i::Factory::undefined_value()));
}
v8::Handle<v8::Primitive> ImplementationUtilities::Null() {
- if (IsDeadCheck("v8::Null()")) return v8::Handle<v8::Primitive>();
- EnsureInitialized("v8::Null()");
+ if (!EnsureInitialized("v8::Null()")) return v8::Handle<v8::Primitive>();
return v8::Handle<Primitive>(ToApi<Primitive>(i::Factory::null_value()));
}
v8::Handle<v8::Boolean> ImplementationUtilities::True() {
- if (IsDeadCheck("v8::True()")) return v8::Handle<v8::Boolean>();
- EnsureInitialized("v8::True()");
+ if (!EnsureInitialized("v8::True()")) return v8::Handle<v8::Boolean>();
return v8::Handle<v8::Boolean>(ToApi<Boolean>(i::Factory::true_value()));
}
v8::Handle<v8::Boolean> ImplementationUtilities::False() {
- if (IsDeadCheck("v8::False()")) return v8::Handle<v8::Boolean>();
- EnsureInitialized("v8::False()");
+ if (!EnsureInitialized("v8::False()")) return v8::Handle<v8::Boolean>();
return v8::Handle<v8::Boolean>(ToApi<Boolean>(i::Factory::false_value()));
}
@@ -373,21 +371,21 @@
bool V8::IsGlobalNearDeath(void** obj) {
LOG_API("IsGlobalNearDeath");
- if (has_shut_down) return false;
+ if (!i::V8::IsRunning()) return false;
return i::GlobalHandles::IsNearDeath(reinterpret_cast<i::Object**>(obj));
}
bool V8::IsGlobalWeak(void** obj) {
LOG_API("IsGlobalWeak");
- if (has_shut_down) return false;
+ if (!i::V8::IsRunning()) return false;
return i::GlobalHandles::IsWeak(reinterpret_cast<i::Object**>(obj));
}
void V8::DisposeGlobal(void** obj) {
LOG_API("DisposeGlobal");
- if (has_shut_down) return;
+ if (!i::V8::IsRunning()) return;
i::Object** ptr = reinterpret_cast<i::Object**>(obj);
if ((*ptr)->IsGlobalContext()) i::Heap::NotifyContextDisposed();
i::GlobalHandles::Destroy(ptr);
@@ -431,7 +429,7 @@
void Context::Exit() {
- if (has_shut_down) return;
+ if (!i::V8::IsRunning()) return;
if (!ApiCheck(thread_local.LeaveLastContext(),
"v8::Context::Exit()",
"Cannot exit non-entered context")) {
@@ -2450,7 +2448,7 @@
// --- E n v i r o n m e n t ---
bool v8::V8::Initialize() {
- if (i::V8::HasBeenSetup()) return true;
+ if (i::V8::IsRunning()) return true;
ENTER_V8;
HandleScope scope;
if (i::Snapshot::Initialize()) {
@@ -3058,17 +3056,14 @@
void V8::SetCounterFunction(CounterLookupCallback callback) {
- if (IsDeadCheck("v8::V8::SetCounterFunction()")) return;
i::StatsTable::SetCounterFunction(callback);
iposva 2009/05/07 23:04:06 Should we reintroduce the IsDeadCheck here?
}
void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) {
- if (IsDeadCheck("v8::V8::SetCreateHistogramFunction()")) return;
i::StatsTable::SetCreateHistogramFunction(callback);
iposva 2009/05/07 23:04:06 ditto
}
void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) {
- if (IsDeadCheck("v8::V8::SetAddHistogramSampleFunction()")) return;
i::StatsTable::SetAddHistogramSampleFunction(callback);
iposva 2009/05/07 23:04:06 ditto
}
@@ -3312,7 +3307,7 @@
void Debug::DebugBreak() {
- if (!i::V8::HasBeenSetup()) return;
+ if (!i::V8::IsRunning()) return;
i::StackGuard::DebugBreak();
}
@@ -3354,7 +3349,7 @@
void Debug::SendCommand(const uint16_t* command, int length,
ClientData* client_data) {
- if (!i::V8::HasBeenSetup()) return;
+ if (!i::V8::IsRunning()) return;
i::Debugger::ProcessCommand(i::Vector<const uint16_t>(command, length),
client_data);
}
@@ -3370,7 +3365,7 @@
Handle<Value> Debug::Call(v8::Handle<v8::Function> fun,
v8::Handle<v8::Value> data) {
- if (!i::V8::HasBeenSetup()) return Handle<Value>();
+ if (!i::V8::IsRunning()) return Handle<Value>();
ON_BAILOUT("v8::Debug::Call()", return Handle<Value>());
ENTER_V8;
i::Handle<i::Object> result;
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | src/v8.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698