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

Unified Diff: src/api.cc

Issue 75283002: Introduce a v8::Platform class that bundles embedder callbacks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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
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;
}
« include/v8-platform.h ('K') | « include/v8-platform.h ('k') | src/default-platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698