|
28 | 28 | #include "v8-profiler.h" |
29 | 29 |
|
30 | 30 | using v8::Context; |
| 31 | +using v8::DontDelete; |
| 32 | +using v8::EscapableHandleScope; |
31 | 33 | using v8::Function; |
32 | 34 | using v8::FunctionCallbackInfo; |
33 | 35 | using v8::FunctionTemplate; |
@@ -36,16 +38,22 @@ using v8::Integer; |
36 | 38 | using v8::Isolate; |
37 | 39 | using v8::Local; |
38 | 40 | using v8::MaybeLocal; |
| 41 | +using v8::NewStringType; |
39 | 42 | using v8::Number; |
40 | 43 | using v8::Object; |
41 | 44 | using v8::ObjectTemplate; |
42 | 45 | using v8::Promise; |
43 | 46 | using v8::PromiseHookType; |
| 47 | +using v8::PropertyAttribute; |
44 | 48 | using v8::PropertyCallbackInfo; |
| 49 | +using v8::ReadOnly; |
45 | 50 | using v8::String; |
| 51 | +using v8::TryCatch; |
46 | 52 | using v8::Uint32; |
47 | 53 | using v8::Undefined; |
48 | 54 | using v8::Value; |
| 55 | +using v8::WeakCallbackInfo; |
| 56 | +using v8::WeakCallbackType; |
49 | 57 |
|
50 | 58 | using AsyncHooks = node::Environment::AsyncHooks; |
51 | 59 |
|
@@ -115,7 +123,7 @@ void Emit(Environment* env, double async_id, AsyncHooks::Fields type, |
115 | 123 | if (async_hooks->fields()[type] == 0 || !env->can_call_into_js()) |
116 | 124 | return; |
117 | 125 |
|
118 | | - v8::HandleScope handle_scope(env->isolate()); |
| 126 | + HandleScope handle_scope(env->isolate()); |
119 | 127 | Local<Value> async_id_value = Number::New(env->isolate(), async_id); |
120 | 128 | FatalTryCatch try_catch(env); |
121 | 129 | USE(fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value)); |
@@ -351,8 +359,7 @@ class DestroyParam { |
351 | 359 | Persistent<Object> propBag; |
352 | 360 | }; |
353 | 361 |
|
354 | | - |
355 | | -void AsyncWrap::WeakCallback(const v8::WeakCallbackInfo<DestroyParam>& info) { |
| 362 | +void AsyncWrap::WeakCallback(const WeakCallbackInfo<DestroyParam>& info) { |
356 | 363 | HandleScope scope(info.GetIsolate()); |
357 | 364 |
|
358 | 365 | std::unique_ptr<DestroyParam> p{info.GetParameter()}; |
@@ -377,8 +384,7 @@ static void RegisterDestroyHook(const FunctionCallbackInfo<Value>& args) { |
377 | 384 | p->env = Environment::GetCurrent(args); |
378 | 385 | p->target.Reset(isolate, args[0].As<Object>()); |
379 | 386 | p->propBag.Reset(isolate, args[2].As<Object>()); |
380 | | - p->target.SetWeak( |
381 | | - p, AsyncWrap::WeakCallback, v8::WeakCallbackType::kParameter); |
| 387 | + p->target.SetWeak(p, AsyncWrap::WeakCallback, WeakCallbackType::kParameter); |
382 | 388 | } |
383 | 389 |
|
384 | 390 |
|
@@ -452,8 +458,8 @@ void AsyncWrap::Initialize(Local<Object> target, |
452 | 458 | env->SetMethod(target, "disablePromiseHook", DisablePromiseHook); |
453 | 459 | env->SetMethod(target, "registerDestroyHook", RegisterDestroyHook); |
454 | 460 |
|
455 | | - v8::PropertyAttribute ReadOnlyDontDelete = |
456 | | - static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); |
| 461 | + PropertyAttribute ReadOnlyDontDelete = |
| 462 | + static_cast<PropertyAttribute>(ReadOnly | DontDelete); |
457 | 463 |
|
458 | 464 | #define FORCE_SET_TARGET_FIELD(obj, str, field) \ |
459 | 465 | (obj)->DefineOwnProperty(context, \ |
@@ -695,7 +701,7 @@ MaybeLocal<Value> AsyncWrap::MakeCallback(const Local<Function> cb, |
695 | 701 |
|
696 | 702 | async_id AsyncHooksGetExecutionAsyncId(Isolate* isolate) { |
697 | 703 | // Environment::GetCurrent() allocates a Local<> handle. |
698 | | - v8::HandleScope handle_scope(isolate); |
| 704 | + HandleScope handle_scope(isolate); |
699 | 705 | Environment* env = Environment::GetCurrent(isolate); |
700 | 706 | if (env == nullptr) return -1; |
701 | 707 | return env->execution_async_id(); |
@@ -704,7 +710,7 @@ async_id AsyncHooksGetExecutionAsyncId(Isolate* isolate) { |
704 | 710 |
|
705 | 711 | async_id AsyncHooksGetTriggerAsyncId(Isolate* isolate) { |
706 | 712 | // Environment::GetCurrent() allocates a Local<> handle. |
707 | | - v8::HandleScope handle_scope(isolate); |
| 713 | + HandleScope handle_scope(isolate); |
708 | 714 | Environment* env = Environment::GetCurrent(isolate); |
709 | 715 | if (env == nullptr) return -1; |
710 | 716 | return env->trigger_async_id(); |
@@ -715,18 +721,18 @@ async_context EmitAsyncInit(Isolate* isolate, |
715 | 721 | Local<Object> resource, |
716 | 722 | const char* name, |
717 | 723 | async_id trigger_async_id) { |
718 | | - v8::HandleScope handle_scope(isolate); |
| 724 | + HandleScope handle_scope(isolate); |
719 | 725 | Local<String> type = |
720 | | - String::NewFromUtf8(isolate, name, v8::NewStringType::kInternalized) |
| 726 | + String::NewFromUtf8(isolate, name, NewStringType::kInternalized) |
721 | 727 | .ToLocalChecked(); |
722 | 728 | return EmitAsyncInit(isolate, resource, type, trigger_async_id); |
723 | 729 | } |
724 | 730 |
|
725 | 731 | async_context EmitAsyncInit(Isolate* isolate, |
726 | 732 | Local<Object> resource, |
727 | | - v8::Local<v8::String> name, |
| 733 | + Local<String> name, |
728 | 734 | async_id trigger_async_id) { |
729 | | - v8::HandleScope handle_scope(isolate); |
| 735 | + HandleScope handle_scope(isolate); |
730 | 736 | Environment* env = Environment::GetCurrent(isolate); |
731 | 737 | CHECK_NOT_NULL(env); |
732 | 738 |
|
@@ -748,7 +754,7 @@ async_context EmitAsyncInit(Isolate* isolate, |
748 | 754 |
|
749 | 755 | void EmitAsyncDestroy(Isolate* isolate, async_context asyncContext) { |
750 | 756 | // Environment::GetCurrent() allocates a Local<> handle. |
751 | | - v8::HandleScope handle_scope(isolate); |
| 757 | + HandleScope handle_scope(isolate); |
752 | 758 | AsyncWrap::EmitDestroy( |
753 | 759 | Environment::GetCurrent(isolate), asyncContext.async_id); |
754 | 760 | } |
@@ -767,10 +773,10 @@ Local<Object> AsyncWrap::GetOwner() { |
767 | 773 | } |
768 | 774 |
|
769 | 775 | Local<Object> AsyncWrap::GetOwner(Environment* env, Local<Object> obj) { |
770 | | - v8::EscapableHandleScope handle_scope(env->isolate()); |
| 776 | + EscapableHandleScope handle_scope(env->isolate()); |
771 | 777 | CHECK(!obj.IsEmpty()); |
772 | 778 |
|
773 | | - v8::TryCatch ignore_exceptions(env->isolate()); |
| 779 | + TryCatch ignore_exceptions(env->isolate()); |
774 | 780 | while (true) { |
775 | 781 | Local<Value> owner; |
776 | 782 | if (!obj->Get(env->context(), |
|