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

Unified Diff: Source/core/dom/Microtask.cpp

Issue 214563003: Revert of use v8 Microtask Queue (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | « Source/bindings/v8/V8PerIsolateData.cpp ('k') | Source/web/WebKit.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Microtask.cpp
diff --git a/Source/core/dom/Microtask.cpp b/Source/core/dom/Microtask.cpp
index bbfb00df0df387155ff21d0dc56ec1f724c3547b..a70aed8750b311b5d5d0b2637b65ae94d766596d 100644
--- a/Source/core/dom/Microtask.cpp
+++ b/Source/core/dom/Microtask.cpp
@@ -33,48 +33,39 @@
#include "bindings/v8/V8PerIsolateData.h"
#include "wtf/Vector.h"
-#include <v8.h>
namespace WebCore {
+typedef Vector<MicrotaskCallback> MicrotaskQueue;
+
+static MicrotaskQueue& microtaskQueue()
+{
+ DEFINE_STATIC_LOCAL(MicrotaskQueue, microtaskQueue, ());
+ return microtaskQueue;
+}
+
void Microtask::performCheckpoint()
{
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- V8PerIsolateData* isolateData = V8PerIsolateData::from(isolate);
+ V8PerIsolateData* isolateData = V8PerIsolateData::current();
ASSERT(isolateData);
if (isolateData->recursionLevel() || isolateData->performingMicrotaskCheckpoint())
return;
isolateData->setPerformingMicrotaskCheckpoint(true);
- v8::HandleScope handleScope(isolate);
- v8::Local<v8::Context> context = isolateData->ensureDomInJSContext();
- v8::Context::Scope scope(context);
- v8::V8::RunMicrotasks(isolate);
+ while (!microtaskQueue().isEmpty()) {
+ Vector<MicrotaskCallback> microtasks;
+ microtasks.swap(microtaskQueue());
+ for (size_t i = 0; i < microtasks.size(); ++i) {
+ microtasks[i]();
+ }
+ }
isolateData->setPerformingMicrotaskCheckpoint(false);
}
-COMPILE_ASSERT(sizeof(void*) == sizeof(MicrotaskCallback), VoidPtrAndFunctionPtrAreSameSize);
-
-static void microtaskFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
-{
- MicrotaskCallback callback =
- reinterpret_cast<MicrotaskCallback>(reinterpret_cast<intptr_t>(
- info.Data().As<v8::External>()->Value()));
- (*callback)();
-}
-
void Microtask::enqueueMicrotask(MicrotaskCallback callback)
{
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- V8PerIsolateData* isolateData = V8PerIsolateData::from(isolate);
- v8::HandleScope handleScope(isolate);
- v8::Local<v8::Context> context = isolateData->ensureDomInJSContext();
- v8::Context::Scope scope(context);
- v8::Local<v8::External> handler =
- v8::External::New(isolate,
- reinterpret_cast<void*>(reinterpret_cast<intptr_t>(callback)));
- v8::V8::EnqueueMicrotask(isolate, v8::Function::New(isolate, &microtaskFunctionCallback, handler));
+ microtaskQueue().append(callback);
}
} // namespace WebCore
« no previous file with comments | « Source/bindings/v8/V8PerIsolateData.cpp ('k') | Source/web/WebKit.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698