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

Side by Side Diff: src/api.cc

Issue 306053003: Add API support for passing a C++ function as a microtask callback (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | src/isolate.h » ('j') | src/isolate.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "api.h" 5 #include "api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 6646 matching lines...) Expand 10 before | Expand all | Expand 10 after
6657 reinterpret_cast<i::Isolate*>(this)->RunMicrotasks(); 6657 reinterpret_cast<i::Isolate*>(this)->RunMicrotasks();
6658 } 6658 }
6659 6659
6660 6660
6661 void Isolate::EnqueueMicrotask(Handle<Function> microtask) { 6661 void Isolate::EnqueueMicrotask(Handle<Function> microtask) {
6662 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 6662 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6663 isolate->EnqueueMicrotask(Utils::OpenHandle(*microtask)); 6663 isolate->EnqueueMicrotask(Utils::OpenHandle(*microtask));
6664 } 6664 }
6665 6665
6666 6666
6667 void Isolate::EnqueueMicrotask(MicrotaskCallback microtask, void* data) {
6668 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6669 i::HandleScope scope(isolate);
6670 i::Handle<i::CallHandlerInfo> callback_info =
dcarney 2014/06/02 07:22:10 if you're going to reuse the CallHandlerInfo struc
adamk 2014/06/02 16:41:50 I'm guessing this might be the source of my try jo
6671 i::Handle<i::CallHandlerInfo>::cast(
6672 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE));
6673 SET_FIELD_WRAPPED(callback_info, set_callback, microtask);
6674 SET_FIELD_WRAPPED(callback_info, set_data, data);
6675 isolate->EnqueueMicrotask(callback_info);
6676 }
6677
6678
6667 void Isolate::SetAutorunMicrotasks(bool autorun) { 6679 void Isolate::SetAutorunMicrotasks(bool autorun) {
6668 reinterpret_cast<i::Isolate*>(this)->set_autorun_microtasks(autorun); 6680 reinterpret_cast<i::Isolate*>(this)->set_autorun_microtasks(autorun);
6669 } 6681 }
6670 6682
6671 6683
6672 bool Isolate::WillAutorunMicrotasks() const { 6684 bool Isolate::WillAutorunMicrotasks() const {
6673 return reinterpret_cast<const i::Isolate*>(this)->autorun_microtasks(); 6685 return reinterpret_cast<const i::Isolate*>(this)->autorun_microtasks();
6674 } 6686 }
6675 6687
6676 6688
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
7566 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7578 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7567 Address callback_address = 7579 Address callback_address =
7568 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7580 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7569 VMState<EXTERNAL> state(isolate); 7581 VMState<EXTERNAL> state(isolate);
7570 ExternalCallbackScope call_scope(isolate, callback_address); 7582 ExternalCallbackScope call_scope(isolate, callback_address);
7571 callback(info); 7583 callback(info);
7572 } 7584 }
7573 7585
7574 7586
7575 } } // namespace v8::internal 7587 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/isolate.h » ('j') | src/isolate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698