| Index: src/api.cc
|
| ===================================================================
|
| --- src/api.cc (revision 7186)
|
| +++ src/api.cc (working copy)
|
| @@ -203,12 +203,6 @@
|
| }
|
|
|
|
|
| -void V8::SetFatalErrorHandler(FatalErrorCallback that) {
|
| - i::Isolate* isolate = i::Isolate::Current();
|
| - isolate->set_exception_behavior(that);
|
| -}
|
| -
|
| -
|
| bool Utils::ReportApiFailure(const char* location, const char* message) {
|
| FatalErrorCallback callback = GetFatalErrorHandler();
|
| callback(location, message);
|
| @@ -293,6 +287,30 @@
|
| return EnsureInitializedForIsolate(isolate, location);
|
| }
|
|
|
| +// Some initializing API functions are called early and may be
|
| +// called on a thread different from static initializer thread.
|
| +// If Isolate API is used, Isolate::Enter() will initialize TLS so
|
| +// Isolate::Current() works. If it's a legacy case, then the thread
|
| +// may not have TLS initialized yet. However, in initializing APIs it
|
| +// may be too early to call EnsureInitialized() - some pre-init
|
| +// parameters still have to be configured.
|
| +static inline i::Isolate* EnterIsolateIfNeeded() {
|
| + i::Isolate* isolate = i::Isolate::UncheckedCurrent();
|
| + if (isolate != NULL)
|
| + return isolate;
|
| +
|
| + i::Isolate::EnterDefaultIsolate();
|
| + isolate = i::Isolate::Current();
|
| + return isolate;
|
| +}
|
| +
|
| +
|
| +void V8::SetFatalErrorHandler(FatalErrorCallback that) {
|
| + i::Isolate* isolate = EnterIsolateIfNeeded();
|
| + isolate->set_exception_behavior(that);
|
| +}
|
| +
|
| +
|
| #ifdef DEBUG
|
| void ImplementationUtilities::ZapHandleRange(i::Object** begin,
|
| i::Object** end) {
|
| @@ -414,12 +432,14 @@
|
|
|
|
|
| bool SetResourceConstraints(ResourceConstraints* constraints) {
|
| - i::Isolate* isolate = i::Isolate::Current();
|
| + i::Isolate* isolate = EnterIsolateIfNeeded();
|
|
|
| int young_space_size = constraints->max_young_space_size();
|
| int old_gen_size = constraints->max_old_space_size();
|
| int max_executable_size = constraints->max_executable_size();
|
| if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) {
|
| + // After initialization it's too late to change Heap constraints.
|
| + ASSERT(!isolate->IsInitialized());
|
| bool result = isolate->heap()->ConfigureHeap(young_space_size / 2,
|
| old_gen_size,
|
| max_executable_size);
|
| @@ -4032,7 +4052,7 @@
|
|
|
|
|
| void V8::IgnoreOutOfMemoryException() {
|
| - i::Isolate::Current()->handle_scope_implementer()->set_ignore_out_of_memory(
|
| + EnterIsolateIfNeeded()->handle_scope_implementer()->set_ignore_out_of_memory(
|
| true);
|
| }
|
|
|
|
|