OLD | NEW |
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 "src/api.h" | 5 #include "src/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 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 } while (false) | 1380 } while (false) |
1381 | 1381 |
1382 void FunctionTemplate::SetCallHandler(FunctionCallback callback, | 1382 void FunctionTemplate::SetCallHandler(FunctionCallback callback, |
1383 v8::Local<Value> data) { | 1383 v8::Local<Value> data) { |
1384 auto info = Utils::OpenHandle(this); | 1384 auto info = Utils::OpenHandle(this); |
1385 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetCallHandler"); | 1385 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetCallHandler"); |
1386 i::Isolate* isolate = info->GetIsolate(); | 1386 i::Isolate* isolate = info->GetIsolate(); |
1387 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); | 1387 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); |
1388 i::HandleScope scope(isolate); | 1388 i::HandleScope scope(isolate); |
1389 i::Handle<i::Struct> struct_obj = | 1389 i::Handle<i::Struct> struct_obj = |
1390 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); | 1390 isolate->factory()->NewStruct(i::TUPLE2_TYPE); |
1391 i::Handle<i::CallHandlerInfo> obj = | 1391 i::Handle<i::CallHandlerInfo> obj = |
1392 i::Handle<i::CallHandlerInfo>::cast(struct_obj); | 1392 i::Handle<i::CallHandlerInfo>::cast(struct_obj); |
1393 SET_FIELD_WRAPPED(obj, set_callback, callback); | 1393 SET_FIELD_WRAPPED(obj, set_callback, callback); |
1394 if (data.IsEmpty()) { | 1394 if (data.IsEmpty()) { |
1395 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1395 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
1396 } | 1396 } |
1397 obj->set_data(*Utils::OpenHandle(*data)); | 1397 obj->set_data(*Utils::OpenHandle(*data)); |
1398 info->set_call_code(*obj); | 1398 info->set_call_code(*obj); |
1399 } | 1399 } |
1400 | 1400 |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1837 | 1837 |
1838 | 1838 |
1839 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback, | 1839 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback, |
1840 Local<Value> data) { | 1840 Local<Value> data) { |
1841 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1841 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1842 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); | 1842 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); |
1843 i::HandleScope scope(isolate); | 1843 i::HandleScope scope(isolate); |
1844 auto cons = EnsureConstructor(isolate, this); | 1844 auto cons = EnsureConstructor(isolate, this); |
1845 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetCallAsFunctionHandler"); | 1845 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetCallAsFunctionHandler"); |
1846 i::Handle<i::Struct> struct_obj = | 1846 i::Handle<i::Struct> struct_obj = |
1847 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); | 1847 isolate->factory()->NewStruct(i::TUPLE2_TYPE); |
1848 i::Handle<i::CallHandlerInfo> obj = | 1848 i::Handle<i::CallHandlerInfo> obj = |
1849 i::Handle<i::CallHandlerInfo>::cast(struct_obj); | 1849 i::Handle<i::CallHandlerInfo>::cast(struct_obj); |
1850 SET_FIELD_WRAPPED(obj, set_callback, callback); | 1850 SET_FIELD_WRAPPED(obj, set_callback, callback); |
1851 if (data.IsEmpty()) { | 1851 if (data.IsEmpty()) { |
1852 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1852 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
1853 } | 1853 } |
1854 obj->set_data(*Utils::OpenHandle(*data)); | 1854 obj->set_data(*Utils::OpenHandle(*data)); |
1855 cons->set_instance_call_handler(*obj); | 1855 cons->set_instance_call_handler(*obj); |
1856 } | 1856 } |
1857 | 1857 |
(...skipping 6752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8610 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 8610 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
8611 isolate->EnqueueMicrotask(Utils::OpenHandle(*microtask)); | 8611 isolate->EnqueueMicrotask(Utils::OpenHandle(*microtask)); |
8612 } | 8612 } |
8613 | 8613 |
8614 | 8614 |
8615 void Isolate::EnqueueMicrotask(MicrotaskCallback microtask, void* data) { | 8615 void Isolate::EnqueueMicrotask(MicrotaskCallback microtask, void* data) { |
8616 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 8616 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
8617 i::HandleScope scope(isolate); | 8617 i::HandleScope scope(isolate); |
8618 i::Handle<i::CallHandlerInfo> callback_info = | 8618 i::Handle<i::CallHandlerInfo> callback_info = |
8619 i::Handle<i::CallHandlerInfo>::cast( | 8619 i::Handle<i::CallHandlerInfo>::cast( |
8620 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE)); | 8620 isolate->factory()->NewStruct(i::TUPLE2_TYPE)); |
8621 SET_FIELD_WRAPPED(callback_info, set_callback, microtask); | 8621 SET_FIELD_WRAPPED(callback_info, set_callback, microtask); |
8622 SET_FIELD_WRAPPED(callback_info, set_data, data); | 8622 SET_FIELD_WRAPPED(callback_info, set_data, data); |
8623 isolate->EnqueueMicrotask(callback_info); | 8623 isolate->EnqueueMicrotask(callback_info); |
8624 } | 8624 } |
8625 | 8625 |
8626 | 8626 |
8627 void Isolate::SetAutorunMicrotasks(bool autorun) { | 8627 void Isolate::SetAutorunMicrotasks(bool autorun) { |
8628 SetMicrotasksPolicy( | 8628 SetMicrotasksPolicy( |
8629 autorun ? MicrotasksPolicy::kAuto : MicrotasksPolicy::kExplicit); | 8629 autorun ? MicrotasksPolicy::kAuto : MicrotasksPolicy::kExplicit); |
8630 } | 8630 } |
(...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10431 Address callback_address = | 10431 Address callback_address = |
10432 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10432 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10433 VMState<EXTERNAL> state(isolate); | 10433 VMState<EXTERNAL> state(isolate); |
10434 ExternalCallbackScope call_scope(isolate, callback_address); | 10434 ExternalCallbackScope call_scope(isolate, callback_address); |
10435 callback(info); | 10435 callback(info); |
10436 } | 10436 } |
10437 | 10437 |
10438 | 10438 |
10439 } // namespace internal | 10439 } // namespace internal |
10440 } // namespace v8 | 10440 } // namespace v8 |
OLD | NEW |