Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 736f0b00d7ac833ca3409ebd703a90f8ef49a5bc..29fc635541d76214837b51889ce929bd03360ee0 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -40,6 +40,9 @@ |
#include "counters.h" |
#include "cpu-profiler.h" |
#include "debug.h" |
+#ifdef V8_USE_DEFAULT_PLATFORM |
+#include "default-platform.h" |
+#endif |
#include "deoptimizer.h" |
#include "execution.h" |
#include "global-handles.h" |
@@ -5042,11 +5045,47 @@ static void* ExternalValue(i::Object* obj) { |
// --- E n v i r o n m e n t --- |
+namespace { |
+ |
+Platform* g_platform = NULL; |
+ |
+} // namespace |
+ |
+ |
+void Platform::Initialize(Platform* platform) { |
+#ifdef V8_USE_DEFAULT_PLATFORM |
+ FATAL("Can't override v8::Platform when using default implementation"); |
+#else |
+ ASSERT(!g_platform); |
+ g_platform = platform; |
+#endif |
+} |
+ |
+ |
+void Platform::Shutdown() { |
+#ifdef V8_USE_DEFAULT_PLATFORM |
+ FATAL("Can't override v8::Platform when using default implementation"); |
+#else |
+ ASSERT(g_platform); |
+ g_platform = NULL; |
+#endif |
+} |
+ |
+ |
+Platform* Platform::GetCurrent() { |
+ ASSERT(g_platform); |
+ return g_platform; |
+} |
+ |
+ |
bool v8::V8::Initialize() { |
i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
if (isolate != NULL && isolate->IsInitialized()) { |
return true; |
} |
+#ifdef V8_USE_DEFAULT_PLATFORM |
+ g_platform = new i::DefaultPlatform; |
Benedikt Meurer
2013/11/18 15:34:44
I think platform initialization should be first in
jochen (gone - plz use gerrit)
2013/11/18 16:27:56
Done (except for the default magic)
|
+#endif |
return InitializeHelper(isolate); |
} |
@@ -5111,6 +5150,11 @@ bool v8::V8::Dispose() { |
return false; |
} |
i::V8::TearDown(); |
+#ifdef V8_USE_DEFAULT_PLATFORM |
+ i::DefaultPlatform* platform = static_cast<i::DefaultPlatform*>(g_platform); |
+ g_platform = NULL; |
+ delete platform; |
+#endif |
return true; |
} |