From 6d72c96cc229bde56538a222ca1bf781eb598592 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sun, 12 Jan 2025 15:19:31 -0800 Subject: [PATCH] src: cleanup v8 namespace uses in c++ files --- src/api/callback.cc | 7 +- src/api/embed_helpers.cc | 7 +- src/api/encoding.cc | 3 +- src/api/environment.cc | 34 +-- src/api/exceptions.cc | 3 +- src/compile_cache.cc | 48 ++-- src/crypto/crypto_hash.cc | 9 +- src/crypto/crypto_keys.cc | 7 +- src/crypto/crypto_timing.cc | 3 +- src/crypto/crypto_tls.cc | 5 +- src/crypto/crypto_util.cc | 11 +- src/crypto/crypto_x509.cc | 6 +- src/dataqueue/queue.cc | 5 +- src/debug_utils.cc | 3 +- src/encoding_binding.cc | 15 +- src/env.cc | 43 +-- src/heap_utils.cc | 13 +- src/inspector/main_thread_interface.cc | 5 +- src/inspector/tracing_agent.cc | 4 +- src/inspector_agent.cc | 11 +- src/inspector_js_api.cc | 18 +- src/inspector_profiler.cc | 11 +- src/internal_only_v8.cc | 3 +- src/json_parser.cc | 18 +- src/node_blob.cc | 26 +- src/node_buffer.cc | 41 ++- src/node_builtins.cc | 14 +- src/node_contextify.cc | 63 ++-- src/node_debug.cc | 5 +- src/node_dotenv.cc | 14 +- src/node_env_var.cc | 13 +- src/node_errors.cc | 29 +- src/node_file.cc | 11 +- src/node_messaging.cc | 15 +- src/node_metadata.cc | 4 +- src/node_modules.cc | 18 +- src/node_perf.cc | 11 +- src/node_platform.cc | 61 ++-- src/node_process_events.cc | 3 +- src/node_process_object.cc | 3 +- src/node_realm.cc | 13 +- src/node_report.cc | 5 +- src/node_sea.cc | 4 +- src/node_shadow_realm.cc | 22 +- src/node_snapshotable.cc | 31 +- src/node_sockaddr.cc | 2 +- src/node_sqlite.cc | 14 +- src/node_task_queue.cc | 6 +- src/node_trace_events.cc | 2 +- src/node_url.cc | 36 +-- src/node_util.cc | 12 +- src/node_v8.cc | 39 +-- src/node_wasi.cc | 9 +- src/node_watchdog.cc | 16 +- src/node_zlib.cc | 5 +- src/permission/permission.cc | 6 +- src/pipe_wrap.cc | 2 +- src/quic/application.cc | 3 +- src/quic/data.cc | 24 +- src/quic/endpoint.cc | 2 +- src/quic/http3.cc | 3 +- src/quic/logstream.cc | 2 +- src/quic/preferredaddress.cc | 4 +- src/quic/sessionticket.cc | 2 +- src/quic/streams.cc | 10 +- src/quic/tlscontext.cc | 21 +- src/quic/transportparams.cc | 6 +- src/signal_wrap.cc | 2 +- src/stream_base.cc | 20 +- src/stream_wrap.cc | 7 +- src/string_bytes.cc | 22 +- src/string_decoder.cc | 7 +- src/timers.cc | 27 +- src/tracing/agent.cc | 11 +- src/tracing/trace_event.cc | 1 + src/util.cc | 384 +++++++++++++------------ src/uv.cc | 5 +- 77 files changed, 746 insertions(+), 664 deletions(-) diff --git a/src/api/callback.cc b/src/api/callback.cc index 26628b31543e03..b7a04185a1f0a5 100644 --- a/src/api/callback.cc +++ b/src/api/callback.cc @@ -13,6 +13,7 @@ using v8::HandleScope; using v8::Isolate; using v8::Local; using v8::MaybeLocal; +using v8::Number; using v8::Object; using v8::String; using v8::Undefined; @@ -51,7 +52,7 @@ InternalCallbackScope::InternalCallbackScope(Environment* env, Local object, const async_context& asyncContext, int flags, - v8::Local context_frame) + Local context_frame) : env_(env), async_context_(asyncContext), object_(object), @@ -216,7 +217,7 @@ MaybeLocal InternalMakeCallback(Environment* env, Local context = env->context(); if (use_async_hooks_trampoline) { MaybeStackBuffer, 16> args(3 + argc); - args[0] = v8::Number::New(env->isolate(), asyncContext.async_id); + args[0] = Number::New(env->isolate(), asyncContext.async_id); args[1] = resource; args[2] = callback; for (int i = 0; i < argc; i++) { @@ -345,7 +346,7 @@ MaybeLocal MakeSyncCallback(Isolate* isolate, argc, argv, async_context{0, 0}, - v8::Undefined(isolate)); + Undefined(isolate)); return ret; } diff --git a/src/api/embed_helpers.cc b/src/api/embed_helpers.cc index 34de89a8dc0398..281511f63f6710 100644 --- a/src/api/embed_helpers.cc +++ b/src/api/embed_helpers.cc @@ -15,6 +15,7 @@ using v8::Maybe; using v8::Nothing; using v8::SealHandleScope; using v8::SnapshotCreator; +using v8::StackTrace; using v8::TryCatch; namespace node { @@ -133,7 +134,7 @@ CommonEnvironmentSetup::CommonEnvironmentSetup( platform->RegisterIsolate(isolate, loop); impl_->snapshot_creator.emplace(isolate, external_references.data()); isolate->SetCaptureStackTraceForUncaughtExceptions( - true, 10, v8::StackTrace::StackTraceOptions::kDetailed); + true, 10, StackTrace::StackTraceOptions::kDetailed); SetIsolateMiscHandlers(isolate, {}); } else { impl_->allocator = ArrayBufferAllocator::Create(); @@ -290,11 +291,11 @@ Environment* CommonEnvironmentSetup::env() const { return impl_->env.get(); } -v8::Local CommonEnvironmentSetup::context() const { +Local CommonEnvironmentSetup::context() const { return impl_->main_context.Get(impl_->isolate); } -v8::SnapshotCreator* CommonEnvironmentSetup::snapshot_creator() { +SnapshotCreator* CommonEnvironmentSetup::snapshot_creator() { return impl_->snapshot_creator ? &impl_->snapshot_creator.value() : nullptr; } diff --git a/src/api/encoding.cc b/src/api/encoding.cc index 0bc3b23a344fa8..483e4ca4ed4e69 100644 --- a/src/api/encoding.cc +++ b/src/api/encoding.cc @@ -8,6 +8,7 @@ namespace node { using v8::HandleScope; using v8::Isolate; using v8::Local; +using v8::Uint32; using v8::Value; enum encoding ParseEncoding(const char* encoding, @@ -114,7 +115,7 @@ enum encoding ParseEncoding(Isolate* isolate, Local encoding_id, enum encoding default_encoding) { if (encoding_id->IsUint32()) { - return static_cast(encoding_id.As()->Value()); + return static_cast(encoding_id.As()->Value()); } return ParseEncoding(isolate, encoding_v, default_encoding); diff --git a/src/api/environment.cc b/src/api/environment.cc index 2641ea7d7f84f4..4644400ba4e549 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -25,6 +25,9 @@ using errors::TryCatchScope; using v8::Array; using v8::Boolean; using v8::Context; +using v8::CpuProfiler; +using v8::DeserializeContextDataCallback; +using v8::DeserializeInternalFieldsCallback; using v8::EscapableHandleScope; using v8::Function; using v8::FunctionCallbackInfo; @@ -39,10 +42,12 @@ using v8::Nothing; using v8::Null; using v8::Object; using v8::ObjectTemplate; +using v8::PageAllocator; using v8::Private; using v8::PropertyDescriptor; using v8::SealHandleScope; using v8::String; +using v8::TracingController; using v8::Value; bool AllowWasmCodeGenerationCallback(Local context, @@ -218,7 +223,7 @@ void SetIsolateCreateParamsForNode(Isolate::CreateParams* params) { #endif } -void SetIsolateErrorHandlers(v8::Isolate* isolate, const IsolateSettings& s) { +void SetIsolateErrorHandlers(Isolate* isolate, const IsolateSettings& s) { if (s.flags & MESSAGE_LISTENER_WITH_ERROR_LEVEL) isolate->AddMessageListenerWithErrorLevel( errors::PerIsolateMessageListener, @@ -242,7 +247,7 @@ void SetIsolateErrorHandlers(v8::Isolate* isolate, const IsolateSettings& s) { } } -void SetIsolateMiscHandlers(v8::Isolate* isolate, const IsolateSettings& s) { +void SetIsolateMiscHandlers(Isolate* isolate, const IsolateSettings& s) { isolate->SetMicrotasksPolicy(s.policy); auto* allow_wasm_codegen_cb = s.allow_wasm_code_generation_callback ? @@ -278,18 +283,17 @@ void SetIsolateMiscHandlers(v8::Isolate* isolate, const IsolateSettings& s) { } if (s.flags & DETAILED_SOURCE_POSITIONS_FOR_PROFILING) - v8::CpuProfiler::UseDetailedSourcePositionsForProfiling(isolate); + CpuProfiler::UseDetailedSourcePositionsForProfiling(isolate); } -void SetIsolateUpForNode(v8::Isolate* isolate, - const IsolateSettings& settings) { +void SetIsolateUpForNode(Isolate* isolate, const IsolateSettings& settings) { Isolate::Scope isolate_scope(isolate); SetIsolateErrorHandlers(isolate, settings); SetIsolateMiscHandlers(isolate, settings); } -void SetIsolateUpForNode(v8::Isolate* isolate) { +void SetIsolateUpForNode(Isolate* isolate) { IsolateSettings settings; SetIsolateUpForNode(isolate, settings); } @@ -427,12 +431,12 @@ Environment* CreateEnvironment( if (use_snapshot) { context = Context::FromSnapshot(isolate, SnapshotData::kNodeMainContextIndex, - v8::DeserializeInternalFieldsCallback( + DeserializeInternalFieldsCallback( DeserializeNodeInternalFields, env), nullptr, MaybeLocal(), nullptr, - v8::DeserializeContextDataCallback( + DeserializeContextDataCallback( DeserializeNodeContextData, env)) .ToLocalChecked(); @@ -570,14 +574,12 @@ MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env) { MultiIsolatePlatform* CreatePlatform( int thread_pool_size, node::tracing::TracingController* tracing_controller) { - return CreatePlatform( - thread_pool_size, - static_cast(tracing_controller)); + return CreatePlatform(thread_pool_size, + static_cast(tracing_controller)); } -MultiIsolatePlatform* CreatePlatform( - int thread_pool_size, - v8::TracingController* tracing_controller) { +MultiIsolatePlatform* CreatePlatform(int thread_pool_size, + TracingController* tracing_controller) { return MultiIsolatePlatform::Create(thread_pool_size, tracing_controller) .release(); @@ -589,8 +591,8 @@ void FreePlatform(MultiIsolatePlatform* platform) { std::unique_ptr MultiIsolatePlatform::Create( int thread_pool_size, - v8::TracingController* tracing_controller, - v8::PageAllocator* page_allocator) { + TracingController* tracing_controller, + PageAllocator* page_allocator) { return std::make_unique(thread_pool_size, tracing_controller, page_allocator); diff --git a/src/api/exceptions.cc b/src/api/exceptions.cc index 871fe78de95154..610304107e24ab 100644 --- a/src/api/exceptions.cc +++ b/src/api/exceptions.cc @@ -18,6 +18,7 @@ using v8::Isolate; using v8::Local; using v8::Object; using v8::String; +using v8::TryCatch; using v8::Value; Local ErrnoException(Isolate* isolate, @@ -243,7 +244,7 @@ Local WinapiErrnoException(Isolate* isolate, // fatal any more, as the user can handle the exception in the // TryCatch by listening to `uncaughtException`. // TODO(joyeecheung): deprecate it in favor of a more accurate name. -void FatalException(Isolate* isolate, const v8::TryCatch& try_catch) { +void FatalException(Isolate* isolate, const TryCatch& try_catch) { errors::TriggerUncaughtException(isolate, try_catch); } diff --git a/src/compile_cache.cc b/src/compile_cache.cc index 50697bcfe1671d..08181a5cbf5357 100644 --- a/src/compile_cache.cc +++ b/src/compile_cache.cc @@ -14,6 +14,13 @@ #endif namespace node { + +using v8::Function; +using v8::Local; +using v8::Module; +using v8::ScriptCompiler; +using v8::String; + std::string Uint32ToHex(uint32_t crc) { std::string str; str.reserve(8); @@ -40,8 +47,7 @@ std::string GetCacheVersionTag() { // This should be fine on Windows, as there local directories tend to be // user-specific. std::string tag = std::string(NODE_VERSION) + '-' + std::string(NODE_ARCH) + - '-' + - Uint32ToHex(v8::ScriptCompiler::CachedDataVersionTag()); + '-' + Uint32ToHex(ScriptCompiler::CachedDataVersionTag()); #ifdef NODE_IMPLEMENTS_POSIX_CREDENTIALS tag += '-' + std::to_string(getuid()); #endif @@ -64,13 +70,13 @@ inline void CompileCacheHandler::Debug(const char* format, } } -v8::ScriptCompiler::CachedData* CompileCacheEntry::CopyCache() const { +ScriptCompiler::CachedData* CompileCacheEntry::CopyCache() const { DCHECK_NOT_NULL(cache); int cache_size = cache->length; uint8_t* data = new uint8_t[cache_size]; memcpy(data, cache->data, cache_size); - return new v8::ScriptCompiler::CachedData( - data, cache_size, v8::ScriptCompiler::CachedData::BufferOwned); + return new ScriptCompiler::CachedData( + data, cache_size, ScriptCompiler::CachedData::BufferOwned); } // Used for identifying and verifying a file is a compile cache file. @@ -193,15 +199,14 @@ void CompileCacheHandler::ReadCacheFile(CompileCacheEntry* entry) { return; } - entry->cache.reset(new v8::ScriptCompiler::CachedData( - buffer, total_read, v8::ScriptCompiler::CachedData::BufferOwned)); + entry->cache.reset(new ScriptCompiler::CachedData( + buffer, total_read, ScriptCompiler::CachedData::BufferOwned)); Debug(" success, size=%d\n", total_read); } -CompileCacheEntry* CompileCacheHandler::GetOrInsert( - v8::Local code, - v8::Local filename, - CachedCodeType type) { +CompileCacheEntry* CompileCacheHandler::GetOrInsert(Local code, + Local filename, + CachedCodeType type) { DCHECK(!compile_cache_dir_.empty()); Utf8Value filename_utf8(isolate_, filename); @@ -242,18 +247,17 @@ CompileCacheEntry* CompileCacheHandler::GetOrInsert( return result; } -v8::ScriptCompiler::CachedData* SerializeCodeCache( - v8::Local func) { - return v8::ScriptCompiler::CreateCodeCacheForFunction(func); +ScriptCompiler::CachedData* SerializeCodeCache(Local func) { + return ScriptCompiler::CreateCodeCacheForFunction(func); } -v8::ScriptCompiler::CachedData* SerializeCodeCache(v8::Local mod) { - return v8::ScriptCompiler::CreateCodeCache(mod->GetUnboundModuleScript()); +ScriptCompiler::CachedData* SerializeCodeCache(Local mod) { + return ScriptCompiler::CreateCodeCache(mod->GetUnboundModuleScript()); } template void CompileCacheHandler::MaybeSaveImpl(CompileCacheEntry* entry, - v8::Local func_or_mod, + Local func_or_mod, bool rejected) { DCHECK_NOT_NULL(entry); Debug("[compile cache] cache for %s was %s, ", @@ -268,21 +272,21 @@ void CompileCacheHandler::MaybeSaveImpl(CompileCacheEntry* entry, Debug("%s the in-memory entry\n", entry->cache == nullptr ? "initializing" : "refreshing"); - v8::ScriptCompiler::CachedData* data = SerializeCodeCache(func_or_mod); - DCHECK_EQ(data->buffer_policy, v8::ScriptCompiler::CachedData::BufferOwned); + ScriptCompiler::CachedData* data = SerializeCodeCache(func_or_mod); + DCHECK_EQ(data->buffer_policy, ScriptCompiler::CachedData::BufferOwned); entry->refreshed = true; entry->cache.reset(data); } void CompileCacheHandler::MaybeSave(CompileCacheEntry* entry, - v8::Local mod, + Local mod, bool rejected) { DCHECK(mod->IsSourceTextModule()); MaybeSaveImpl(entry, mod, rejected); } void CompileCacheHandler::MaybeSave(CompileCacheEntry* entry, - v8::Local func, + Local func, bool rejected) { MaybeSaveImpl(entry, func, rejected); } @@ -333,7 +337,7 @@ void CompileCacheHandler::Persist() { } DCHECK_EQ(entry->cache->buffer_policy, - v8::ScriptCompiler::CachedData::BufferOwned); + ScriptCompiler::CachedData::BufferOwned); char* cache_ptr = reinterpret_cast(const_cast(entry->cache->data)); uint32_t cache_size = static_cast(entry->cache->length); diff --git a/src/crypto/crypto_hash.cc b/src/crypto/crypto_hash.cc index 58856397cdff92..81af7950780ded 100644 --- a/src/crypto/crypto_hash.cc +++ b/src/crypto/crypto_hash.cc @@ -24,6 +24,7 @@ using v8::Maybe; using v8::MaybeLocal; using v8::Name; using v8::Nothing; +using v8::Null; using v8::Object; using v8::Uint32; using v8::Value; @@ -153,12 +154,12 @@ void Hash::GetCachedAliases(const FunctionCallbackInfo& args) { values.reserve(size); for (auto& [alias, id] : env->alias_to_md_id_map) { names.push_back(OneByteString(isolate, alias)); - values.push_back(v8::Uint32::New(isolate, id)); + values.push_back(Uint32::New(isolate, id)); } #else CHECK(env->alias_to_md_id_map.empty()); #endif - Local prototype = v8::Null(isolate); + Local prototype = Null(isolate); Local result = Object::New(isolate, prototype, names.data(), values.data(), size); args.GetReturnValue().Set(result); @@ -191,7 +192,7 @@ const EVP_MD* GetDigestImplementation(Environment* env, if (algorithm_cache.As() ->Set(isolate->GetCurrentContext(), algorithm, - v8::Int32::New(isolate, result.cache_id)) + Int32::New(isolate, result.cache_id)) .IsNothing()) { return nullptr; } @@ -532,7 +533,7 @@ bool HashTraits::DeriveBits( return true; } -void InternalVerifyIntegrity(const v8::FunctionCallbackInfo& args) { +void InternalVerifyIntegrity(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); CHECK_EQ(args.Length(), 3); diff --git a/src/crypto/crypto_keys.cc b/src/crypto/crypto_keys.cc index 4a686a77b2a0ac..2bedf9523b6152 100644 --- a/src/crypto/crypto_keys.cc +++ b/src/crypto/crypto_keys.cc @@ -383,7 +383,7 @@ KeyObjectData::GetPublicKeyEncodingFromJs( } KeyObjectData KeyObjectData::GetPrivateKeyFromJs( - const v8::FunctionCallbackInfo& args, + const FunctionCallbackInfo& args, unsigned int* offset, bool allow_key_object) { if (args[*offset]->IsString() || IsAnyBufferSource(args[*offset])) { @@ -592,7 +592,7 @@ bool KeyObjectHandle::HasInstance(Environment* env, Local value) { return !t.IsEmpty() && t->HasInstance(value); } -v8::Local KeyObjectHandle::Initialize(Environment* env) { +Local KeyObjectHandle::Initialize(Environment* env) { Local templ = env->crypto_key_object_handle_constructor(); if (templ.IsEmpty()) { Isolate* isolate = env->isolate(); @@ -1031,8 +1031,7 @@ MaybeLocal KeyObjectHandle::ExportPrivateKey( return WritePrivateKey(env(), data_.GetAsymmetricKey(), config); } -void KeyObjectHandle::ExportJWK( - const v8::FunctionCallbackInfo& args) { +void KeyObjectHandle::ExportJWK(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); KeyObjectHandle* key; ASSIGN_OR_RETURN_UNWRAP(&key, args.This()); diff --git a/src/crypto/crypto_timing.cc b/src/crypto/crypto_timing.cc index 5c23e830d1e9e8..5dc787a72e77bf 100644 --- a/src/crypto/crypto_timing.cc +++ b/src/crypto/crypto_timing.cc @@ -10,6 +10,7 @@ namespace node { +using v8::CFunction; using v8::FastApiCallbackOptions; using v8::FastApiTypedArray; using v8::FunctionCallbackInfo; @@ -69,7 +70,7 @@ bool FastTimingSafeEqual(Local receiver, return CRYPTO_memcmp(data_a, data_b, a.length()) == 0; } -static v8::CFunction fast_equal(v8::CFunction::Make(FastTimingSafeEqual)); +static CFunction fast_equal(CFunction::Make(FastTimingSafeEqual)); void Initialize(Environment* env, Local target) { SetFastMethodNoSideEffect( diff --git a/src/crypto/crypto_tls.cc b/src/crypto/crypto_tls.cc index 21a4e7538366be..8395e87b0296d2 100644 --- a/src/crypto/crypto_tls.cc +++ b/src/crypto/crypto_tls.cc @@ -54,6 +54,7 @@ using v8::Isolate; using v8::Local; using v8::MaybeLocal; using v8::Null; +using v8::Number; using v8::Object; using v8::PropertyAttribute; using v8::ReadOnly; @@ -274,7 +275,7 @@ int SelectALPNCallback( } CHECK(callback_result->IsNumber()); - unsigned int result_int = callback_result.As()->Value(); + unsigned int result_int = callback_result.As()->Value(); // The callback returns an offset into the given buffer, for the selected // protocol that should be returned. We then set outlen & out to point @@ -1868,7 +1869,7 @@ void TLSWrap::VerifyError(const FunctionCallbackInfo& args) { if (reason->IsUndefined()) [[unlikely]] return; - Local error = Exception::Error(reason.As()) + Local error = Exception::Error(reason.As()) ->ToObject(env->isolate()->GetCurrentContext()) .FromMaybe(Local()); diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc index 49ef332dfac7e0..0783da47ccc60d 100644 --- a/src/crypto/crypto_util.cc +++ b/src/crypto/crypto_util.cc @@ -26,6 +26,7 @@ namespace node { +using v8::Array; using v8::ArrayBuffer; using v8::BackingStore; using v8::BigInt; @@ -190,7 +191,7 @@ void SetFipsCrypto(const FunctionCallbackInfo& args) { } } -void TestFipsCrypto(const v8::FunctionCallbackInfo& args) { +void TestFipsCrypto(const FunctionCallbackInfo& args) { Mutex::ScopedLock lock(per_process::cli_options_mutex); Mutex::ScopedLock fips_lock(fips_mutex); args.GetReturnValue().Set(ncrypto::testFipsEnabled() ? 1 : 0); @@ -253,8 +254,8 @@ MaybeLocal cryptoErrorListToException( ++current; } - Local stackArray = - v8::Array::New(env->isolate(), stack.data(), stack.size()); + Local stackArray = + Array::New(env->isolate(), stack.data(), stack.size()); if (exception_obj ->Set(env->context(), env->openssl_error_stack(), stackArray) @@ -640,9 +641,9 @@ bool SetRsaOaepLabel(const EVPKeyCtxPointer& ctx, const ByteSource& label) { return true; } -CryptoJobMode GetCryptoJobMode(v8::Local args) { +CryptoJobMode GetCryptoJobMode(Local args) { CHECK(args->IsUint32()); - uint32_t mode = args.As()->Value(); + uint32_t mode = args.As()->Value(); CHECK_LE(mode, kCryptoJobSync); return static_cast(mode); } diff --git a/src/crypto/crypto_x509.cc b/src/crypto/crypto_x509.cc index a19b1d07e02609..085b9f5a833e10 100644 --- a/src/crypto/crypto_x509.cc +++ b/src/crypto/crypto_x509.cc @@ -936,12 +936,12 @@ MaybeLocal X509Certificate::GetPeerCert(Environment* env, : New(env, std::move(cert)); } -v8::MaybeLocal X509Certificate::toObject(Environment* env) { +MaybeLocal X509Certificate::toObject(Environment* env) { return toObject(env, view()); } -v8::MaybeLocal X509Certificate::toObject( - Environment* env, const ncrypto::X509View& cert) { +MaybeLocal X509Certificate::toObject(Environment* env, + const ncrypto::X509View& cert) { if (!cert) return {}; return X509ToObject(env, cert).FromMaybe(Local()); } diff --git a/src/dataqueue/queue.cc b/src/dataqueue/queue.cc index 64643680903a78..f4855d52bc4e8c 100644 --- a/src/dataqueue/queue.cc +++ b/src/dataqueue/queue.cc @@ -938,8 +938,7 @@ class FdEntry final : public EntryImpl { } void OnStreamRead(ssize_t nread, const uv_buf_t& buf) override { - std::shared_ptr store = - env_->release_managed_buffer(buf); + std::shared_ptr store = env_->release_managed_buffer(buf); if (ended_) { // If we got here and ended_ is true, it means we ended and drained @@ -1137,7 +1136,7 @@ std::unique_ptr DataQueue::CreateFdEntry(Environment* env, return FdEntry::Create(env, path); } -void DataQueue::Initialize(Environment* env, v8::Local target) { +void DataQueue::Initialize(Environment* env, Local target) { // Nothing to do here currently. } diff --git a/src/debug_utils.cc b/src/debug_utils.cc index c8b3b11ee34d7a..cda33792a07be7 100644 --- a/src/debug_utils.cc +++ b/src/debug_utils.cc @@ -59,6 +59,7 @@ namespace per_process { EnabledDebugList enabled_debug_list; } +using v8::Isolate; using v8::Local; using v8::StackTrace; @@ -327,7 +328,7 @@ void DumpNativeBacktrace(FILE* fp) { } void DumpJavaScriptBacktrace(FILE* fp) { - v8::Isolate* isolate = v8::Isolate::TryGetCurrent(); + Isolate* isolate = Isolate::TryGetCurrent(); if (isolate == nullptr) { return; } diff --git a/src/encoding_binding.cc b/src/encoding_binding.cc index 885a0d072312e9..33b92604a68485 100644 --- a/src/encoding_binding.cc +++ b/src/encoding_binding.cc @@ -17,11 +17,14 @@ using v8::ArrayBuffer; using v8::BackingStore; using v8::Context; using v8::FunctionCallbackInfo; +using v8::HandleScope; using v8::Isolate; using v8::Local; using v8::MaybeLocal; +using v8::NewStringType; using v8::Object; using v8::ObjectTemplate; +using v8::SnapshotCreator; using v8::String; using v8::Uint8Array; using v8::Value; @@ -32,7 +35,7 @@ void BindingData::MemoryInfo(MemoryTracker* tracker) const { } BindingData::BindingData(Realm* realm, - v8::Local object, + Local object, InternalFieldInfo* info) : SnapshotableObject(realm, object, type_int), encode_into_results_buffer_( @@ -52,7 +55,7 @@ BindingData::BindingData(Realm* realm, } bool BindingData::PrepareForSerialization(Local context, - v8::SnapshotCreator* creator) { + SnapshotCreator* creator) { DCHECK_NULL(internal_field_info_); internal_field_info_ = InternalFieldInfoBase::New(type()); internal_field_info_->encode_into_results_buffer = @@ -74,7 +77,7 @@ void BindingData::Deserialize(Local context, int index, InternalFieldInfoBase* info) { DCHECK_IS_SNAPSHOT_SLOT(index); - v8::HandleScope scope(context->GetIsolate()); + HandleScope scope(context->GetIsolate()); Realm* realm = Realm::GetCurrent(context); // Recreate the buffer in the constructor. InternalFieldInfo* casted_info = static_cast(info); @@ -197,7 +200,7 @@ void BindingData::DecodeUTF8(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(ret); } -void BindingData::ToASCII(const v8::FunctionCallbackInfo& args) { +void BindingData::ToASCII(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); CHECK_GE(args.Length(), 1); CHECK(args[0]->IsString()); @@ -208,7 +211,7 @@ void BindingData::ToASCII(const v8::FunctionCallbackInfo& args) { String::NewFromUtf8(env->isolate(), out.c_str()).ToLocalChecked()); } -void BindingData::ToUnicode(const v8::FunctionCallbackInfo& args) { +void BindingData::ToUnicode(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); CHECK_GE(args.Length(), 1); CHECK(args[0]->IsString()); @@ -288,7 +291,7 @@ void BindingData::DecodeLatin1(const FunctionCallbackInfo& args) { Local output = String::NewFromUtf8( - env->isolate(), result.c_str(), v8::NewStringType::kNormal, written) + env->isolate(), result.c_str(), NewStringType::kNormal, written) .ToLocalChecked(); args.GetReturnValue().Set(output); } diff --git a/src/env.cc b/src/env.cc index f0f97244fdef63..a08387d3f43a2b 100644 --- a/src/env.cc +++ b/src/env.cc @@ -39,10 +39,13 @@ namespace node { using errors::TryCatchScope; using v8::Array; +using v8::ArrayBuffer; +using v8::BackingStore; using v8::Boolean; using v8::Context; using v8::CppHeap; using v8::CppHeapCreateParams; +using v8::CppHeapPointerTag; using v8::EmbedderGraph; using v8::EscapableHandleScope; using v8::Function; @@ -51,10 +54,13 @@ using v8::HeapProfiler; using v8::HeapSpaceStatistics; using v8::Integer; using v8::Isolate; +using v8::Just; using v8::Local; +using v8::LocalVector; using v8::Maybe; using v8::MaybeLocal; using v8::NewStringType; +using v8::Nothing; using v8::Number; using v8::Object; using v8::ObjectTemplate; @@ -88,7 +94,7 @@ void AsyncHooks::ResetPromiseHooks(Local init, } Local AsyncHooks::GetPromiseHooks(Isolate* isolate) const { - v8::LocalVector values(isolate, js_promise_hooks_.size()); + LocalVector values(isolate, js_promise_hooks_.size()); for (size_t i = 0; i < js_promise_hooks_.size(); ++i) { if (js_promise_hooks_[i].IsEmpty()) { values[i] = Undefined(isolate); @@ -453,7 +459,7 @@ void IsolateData::CreateProperties() { // One byte because our strings are ASCII and we can safely skip V8's UTF-8 // decoding step. - v8::Isolate::Scope isolate_scope(isolate_); + Isolate::Scope isolate_scope(isolate_); HandleScope handle_scope(isolate_); #define V(PropertyName, StringValue) \ @@ -569,14 +575,14 @@ IsolateData::IsolateData(Isolate* isolate, platform_(platform), snapshot_data_(snapshot_data), options_(std::move(options)) { - v8::CppHeap* cpp_heap = isolate->GetCppHeap(); + CppHeap* cpp_heap = isolate->GetCppHeap(); uint16_t cppgc_id = kDefaultCppGCEmbedderID; // We do not care about overflow since we just want this to be different // from the cppgc id. uint16_t non_cppgc_id = cppgc_id + 1; if (cpp_heap == nullptr) { - cpp_heap_ = CppHeap::Create(platform, v8::CppHeapCreateParams{{}}); + cpp_heap_ = CppHeap::Create(platform, CppHeapCreateParams{{}}); // TODO(joyeecheung): pass it into v8::Isolate::CreateParams and let V8 // own it when we can keep the isolate registered/task runner discoverable // during isolate disposal. @@ -617,8 +623,7 @@ IsolateData::~IsolateData() { void SetCppgcReference(Isolate* isolate, Local object, void* wrappable) { - v8::Object::Wrap( - isolate, object, wrappable); + Object::Wrap(isolate, object, wrappable); } void IsolateData::MemoryInfo(MemoryTracker* tracker) const { @@ -669,7 +674,7 @@ void TrackingTraceStateObserver::UpdateTraceCategoryState() { USE(cb->Call(env_->context(), Undefined(isolate), arraysize(args), args)); } -void Environment::AssignToContext(Local context, +void Environment::AssignToContext(Local context, Realm* realm, const ContextInfo& info) { context->SetAlignedPointerInEmbedderData(ContextEmbedderIndex::kEnvironment, @@ -691,7 +696,7 @@ void Environment::AssignToContext(Local context, TrackContext(context); } -void Environment::UnassignFromContext(Local context) { +void Environment::UnassignFromContext(Local context) { if (!context.IsEmpty()) { context->SetAlignedPointerInEmbedderData(ContextEmbedderIndex::kEnvironment, nullptr); @@ -738,16 +743,16 @@ void Environment::add_refs(int64_t diff) { uv_buf_t Environment::allocate_managed_buffer(const size_t suggested_size) { NoArrayBufferZeroFillScope no_zero_fill_scope(isolate_data()); - std::unique_ptr bs = - v8::ArrayBuffer::NewBackingStore(isolate(), suggested_size); + std::unique_ptr bs = + ArrayBuffer::NewBackingStore(isolate(), suggested_size); uv_buf_t buf = uv_buf_init(static_cast(bs->Data()), bs->ByteLength()); released_allocated_buffers_.emplace(buf.base, std::move(bs)); return buf; } -std::unique_ptr Environment::release_managed_buffer( +std::unique_ptr Environment::release_managed_buffer( const uv_buf_t& buf) { - std::unique_ptr bs; + std::unique_ptr bs; if (buf.base != nullptr) { auto it = released_allocated_buffers_.find(buf.base); CHECK_NE(it, released_allocated_buffers_.end()); @@ -1252,7 +1257,7 @@ MaybeLocal Environment::RunSnapshotSerializeCallback() const { if (!snapshot_serialize_callback().IsEmpty()) { Context::Scope context_scope(context()); return handle_scope.EscapeMaybe(snapshot_serialize_callback()->Call( - context(), v8::Undefined(isolate()), 0, nullptr)); + context(), Undefined(isolate()), 0, nullptr)); } return handle_scope.Escape(Undefined(isolate())); } @@ -1262,7 +1267,7 @@ MaybeLocal Environment::RunSnapshotDeserializeMain() const { if (!snapshot_deserialize_main().IsEmpty()) { Context::Scope context_scope(context()); return handle_scope.EscapeMaybe(snapshot_deserialize_main()->Call( - context(), v8::Undefined(isolate()), 0, nullptr)); + context(), Undefined(isolate()), 0, nullptr)); } return handle_scope.Escape(Undefined(isolate())); } @@ -1318,23 +1323,23 @@ Maybe Environment::CheckUnsettledTopLevelAwait() const { if (!ctx->Global() ->GetPrivate(ctx, entry_point_promise_private_symbol()) .ToLocal(&entry_point_promise)) { - return v8::Nothing(); + return Nothing(); } if (!entry_point_promise->IsPromise()) { - return v8::Just(true); + return Just(true); } if (entry_point_promise.As()->State() != Promise::PromiseState::kPending) { - return v8::Just(true); + return Just(true); } if (!ctx->Global() ->GetPrivate(ctx, entry_point_module_private_symbol()) .ToLocal(&value)) { - return v8::Nothing(); + return Nothing(); } if (!value->IsObject()) { - return v8::Just(true); + return Just(true); } Local object = value.As(); CHECK(BaseObject::IsBaseObject(isolate_data_, object)); diff --git a/src/heap_utils.cc b/src/heap_utils.cc index 7b93698c7fe125..3e110866712158 100644 --- a/src/heap_utils.cc +++ b/src/heap_utils.cc @@ -39,6 +39,7 @@ using v8::Nothing; using v8::Number; using v8::Object; using v8::ObjectTemplate; +using v8::OutputStream; using v8::String; using v8::Uint8Array; using v8::Value; @@ -79,7 +80,7 @@ class JSGraph : public EmbedderGraph { public: explicit JSGraph(Isolate* isolate) : isolate_(isolate) {} - Node* V8Node(const Local& value) override { + Node* V8Node(const Local& value) override { std::unique_ptr n { new JSGraphJSNode(isolate_, value) }; auto it = engine_nodes_.find(n.get()); if (it != engine_nodes_.end()) @@ -88,8 +89,8 @@ class JSGraph : public EmbedderGraph { return AddNode(std::unique_ptr(n.release())); } - Node* V8Node(const Local& value) override { - return V8Node(value.As()); + Node* V8Node(const Local& value) override { + return V8Node(value.As()); } Node* AddNode(std::unique_ptr node) override { @@ -220,7 +221,7 @@ void BuildEmbedderGraph(const FunctionCallbackInfo& args) { } namespace { -class FileOutputStream : public v8::OutputStream { +class FileOutputStream : public OutputStream { public: FileOutputStream(const int fd, uv_fs_t* req) : fd_(fd), req_(req) {} @@ -264,7 +265,7 @@ class FileOutputStream : public v8::OutputStream { class HeapSnapshotStream : public AsyncWrap, public StreamBase, - public v8::OutputStream { + public OutputStream { public: HeapSnapshotStream( Environment* env, @@ -343,7 +344,7 @@ class HeapSnapshotStream : public AsyncWrap, }; inline void TakeSnapshot(Environment* env, - v8::OutputStream* out, + OutputStream* out, HeapProfiler::HeapSnapshotOptions options) { HeapSnapshotPointer snapshot{ env->isolate()->GetHeapProfiler()->TakeHeapSnapshot(options)}; diff --git a/src/inspector/main_thread_interface.cc b/src/inspector/main_thread_interface.cc index 0fca7483e95c65..77fe3e809d74fa 100644 --- a/src/inspector/main_thread_interface.cc +++ b/src/inspector/main_thread_interface.cc @@ -8,6 +8,9 @@ #include namespace node { + +using v8::SealHandleScope; + namespace inspector { namespace { @@ -255,7 +258,7 @@ void MainThreadInterface::DispatchMessages() { std::swap(dispatching_message_queue_.front(), task); dispatching_message_queue_.pop_front(); - v8::SealHandleScope seal_handle_scope(agent_->env()->isolate()); + SealHandleScope seal_handle_scope(agent_->env()->isolate()); task->Call(this); } } while (had_messages); diff --git a/src/inspector/tracing_agent.cc b/src/inspector/tracing_agent.cc index e7b6d3b3ea63bd..0fde7bab1b87e9 100644 --- a/src/inspector/tracing_agent.cc +++ b/src/inspector/tracing_agent.cc @@ -12,6 +12,7 @@ namespace inspector { namespace protocol { namespace { +using v8::platform::tracing::TraceObject; using v8::platform::tracing::TraceWriter; class DeletableFrontendWrapper : public Deletable { @@ -85,8 +86,7 @@ class InspectorTraceWriter : public node::tracing::AsyncTraceWriter { std::shared_ptr main_thread) : frontend_object_id_(frontend_object_id), main_thread_(main_thread) {} - void AppendTraceEvent( - v8::platform::tracing::TraceObject* trace_event) override { + void AppendTraceEvent(TraceObject* trace_event) override { if (!json_writer_) json_writer_.reset(TraceWriter::CreateJSONTraceWriter(stream_, "value")); json_writer_->AppendTraceEvent(trace_event); diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index bb39a0cb42a7be..23a14033a8f6ae 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -44,6 +44,9 @@ using v8::Isolate; using v8::Local; using v8::Message; using v8::Object; +using v8::StackTrace; +using v8::String; +using v8::TryCatch; using v8::Value; using v8_inspector::StringBuffer; @@ -412,7 +415,7 @@ void ThrowUninitializedInspectorError(Environment* env) { const char* msg = "This Environment was initialized without a V8::Inspector"; Local exception = - v8::String::NewFromUtf8(env->isolate(), msg).ToLocalChecked(); + String::NewFromUtf8(env->isolate(), msg).ToLocalChecked(); env->isolate()->ThrowException(exception); } @@ -571,7 +574,7 @@ class NodeInspectorClient : public V8InspectorClient { int script_id = message->GetScriptOrigin().ScriptId(); - Local stack_trace = message->GetStackTrace(); + Local stack_trace = message->GetStackTrace(); if (!stack_trace.IsEmpty() && stack_trace->GetFrameCount() > 0 && script_id == stack_trace->GetFrame(isolate, 0)->GetScriptId()) { @@ -924,7 +927,7 @@ void Agent::ToggleNetworkTracking(Isolate* isolate, Local fn) { auto context = parent_env_->context(); HandleScope scope(isolate); CHECK(!fn.IsEmpty()); - v8::TryCatch try_catch(isolate); + TryCatch try_catch(isolate); USE(fn->Call(context, Undefined(isolate), 0, nullptr)); if (try_catch.HasCaught() && !try_catch.HasTerminated()) { PrintCaughtException(isolate, context, try_catch); @@ -1023,7 +1026,7 @@ void Agent::ToggleAsyncHook(Isolate* isolate, Local fn) { HandleScope handle_scope(isolate); CHECK(!fn.IsEmpty()); auto context = parent_env_->context(); - v8::TryCatch try_catch(isolate); + TryCatch try_catch(isolate); USE(fn->Call(context, Undefined(isolate), 0, nullptr)); if (try_catch.HasCaught() && !try_catch.HasTerminated()) { PrintCaughtException(isolate, context, try_catch); diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc index 63ceaccdf2406b..d537dcbeb93b61 100644 --- a/src/inspector_js_api.cc +++ b/src/inspector_js_api.cc @@ -13,6 +13,7 @@ namespace node { namespace inspector { namespace { +using v8::ConstructorBehavior; using v8::Context; using v8::Function; using v8::FunctionCallbackInfo; @@ -24,6 +25,8 @@ using v8::Local; using v8::MaybeLocal; using v8::NewStringType; using v8::Object; +using v8::SideEffectType; +using v8::Signature; using v8::String; using v8::Uint32; using v8::Value; @@ -179,7 +182,7 @@ void SetConsoleExtensionInstaller(const FunctionCallbackInfo& info) { realm->set_inspector_console_extension_installer(info[0].As()); } -void CallAndPauseOnStart(const FunctionCallbackInfo& args) { +void CallAndPauseOnStart(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); THROW_IF_INSUFFICIENT_PERMISSIONS(env, permission::PermissionScope::kInspector, @@ -188,9 +191,8 @@ void CallAndPauseOnStart(const FunctionCallbackInfo& args) { CHECK(args[0]->IsFunction()); SlicedArguments call_args(args, /* start */ 2); env->inspector_agent()->PauseOnNextJavascriptStatement("Break on start"); - v8::MaybeLocal retval = - args[0].As()->Call(env->context(), args[1], - call_args.length(), call_args.out()); + MaybeLocal retval = args[0].As()->Call( + env->context(), args[1], call_args.length(), call_args.out()); if (!retval.IsEmpty()) { args.GetReturnValue().Set(retval.ToLocalChecked()); } @@ -341,12 +343,12 @@ void Initialize(Local target, Local unused, Environment* env = Environment::GetCurrent(context); Isolate* isolate = env->isolate(); - v8::Local consoleCallFunc = + Local consoleCallFunc = NewFunctionTemplate(isolate, InspectorConsoleCall, - v8::Local(), - v8::ConstructorBehavior::kThrow, - v8::SideEffectType::kHasSideEffect) + Local(), + ConstructorBehavior::kThrow, + SideEffectType::kHasSideEffect) ->GetFunction(context) .ToLocalChecked(); auto name_string = FIXED_ONE_BYTE_STRING(isolate, "consoleCall"); diff --git a/src/inspector_profiler.cc b/src/inspector_profiler.cc index f09dd04ccd7f6e..512a2932cd54ac 100644 --- a/src/inspector_profiler.cc +++ b/src/inspector_profiler.cc @@ -24,6 +24,7 @@ using v8::Function; using v8::FunctionCallbackInfo; using v8::HandleScope; using v8::Isolate; +using v8::JSON; using v8::Local; using v8::NewStringType; using v8::Object; @@ -312,16 +313,14 @@ void V8CoverageConnection::WriteProfile(simdjson::ondemand::object* result) { // map cache in front of it, but source map cache is still experimental // anyway so just re-parse it with V8 for now. Local profile_str; - if (!v8::String::NewFromUtf8(isolate, - profile.data(), - v8::NewStringType::kNormal, - profile.length()) + if (!String::NewFromUtf8( + isolate, profile.data(), NewStringType::kNormal, profile.length()) .ToLocal(&profile_str)) { fprintf(stderr, "Failed to re-parse %s profile as UTF8\n", type()); return; } Local profile_value; - if (!v8::JSON::Parse(context, profile_str).ToLocal(&profile_value) || + if (!JSON::Parse(context, profile_str).ToLocal(&profile_value) || !profile_value->IsObject()) { fprintf(stderr, "Failed to re-parse %s profile from JSON\n", type()); return; @@ -337,7 +336,7 @@ void V8CoverageConnection::WriteProfile(simdjson::ondemand::object* result) { return; } Local result_s; - if (!v8::JSON::Stringify(context, profile_value).ToLocal(&result_s)) { + if (!JSON::Stringify(context, profile_value).ToLocal(&result_s)) { fprintf(stderr, "Failed to stringify %s profile result\n", type()); return; } diff --git a/src/internal_only_v8.cc b/src/internal_only_v8.cc index 6a3c4e6952a8f3..eeeab1a9d05db0 100644 --- a/src/internal_only_v8.cc +++ b/src/internal_only_v8.cc @@ -12,12 +12,13 @@ using v8::Isolate; using v8::Local; using v8::LocalVector; using v8::Object; +using v8::QueryObjectPredicate; using v8::Value; namespace node { namespace internal_only_v8 { -class PrototypeChainHas : public v8::QueryObjectPredicate { +class PrototypeChainHas : public QueryObjectPredicate { public: PrototypeChainHas(Local context, Local search) : context_(context), search_(search) {} diff --git a/src/json_parser.cc b/src/json_parser.cc index 878028d0d2dd61..6d74557a8c1d86 100644 --- a/src/json_parser.cc +++ b/src/json_parser.cc @@ -6,7 +6,9 @@ namespace node { using v8::Array; using v8::Context; +using v8::HandleScope; using v8::Isolate; +using v8::JSON; using v8::Local; using v8::Object; using v8::String; @@ -18,8 +20,8 @@ bool JSONParser::Parse(const std::string& content) { DCHECK(!parsed_); Isolate* isolate = isolate_.get(); - v8::Isolate::Scope isolate_scope(isolate); - v8::HandleScope handle_scope(isolate); + Isolate::Scope isolate_scope(isolate); + HandleScope handle_scope(isolate); Local context = Context::New(isolate); Context::Scope context_scope(context); @@ -31,7 +33,7 @@ bool JSONParser::Parse(const std::string& content) { Local result_value; if (!ToV8Value(context, content).ToLocal(&json_string_value) || !json_string_value->IsString() || - !v8::JSON::Parse(context, json_string_value.As()) + !JSON::Parse(context, json_string_value.As()) .ToLocal(&result_value) || !result_value->IsObject()) { return false; @@ -47,8 +49,8 @@ bool JSONParser::Parse(const std::string& content) { std::optional JSONParser::GetTopLevelStringField( std::string_view field) { Isolate* isolate = isolate_.get(); - v8::Isolate::Scope isolate_scope(isolate); - v8::HandleScope handle_scope(isolate); + Isolate::Scope isolate_scope(isolate); + HandleScope handle_scope(isolate); Local context = context_.Get(isolate); Context::Scope context_scope(context); @@ -73,8 +75,8 @@ std::optional JSONParser::GetTopLevelStringField( std::optional JSONParser::GetTopLevelBoolField(std::string_view field) { Isolate* isolate = isolate_.get(); - v8::Isolate::Scope isolate_scope(isolate); - v8::HandleScope handle_scope(isolate); + Isolate::Scope isolate_scope(isolate); + HandleScope handle_scope(isolate); Local context = context_.Get(isolate); Context::Scope context_scope(context); @@ -105,7 +107,7 @@ std::optional JSONParser::GetTopLevelBoolField(std::string_view field) { std::optional JSONParser::GetTopLevelStringDict( std::string_view field) { Isolate* isolate = isolate_.get(); - v8::HandleScope handle_scope(isolate); + HandleScope handle_scope(isolate); Local context = context_.Get(isolate); Local content_object = content_.Get(isolate); Local value; diff --git a/src/node_blob.cc b/src/node_blob.cc index 8afc6d3aa0d76f..b2cc16c0db2c4e 100644 --- a/src/node_blob.cc +++ b/src/node_blob.cc @@ -30,8 +30,10 @@ using v8::HandleScope; using v8::Int32; using v8::Isolate; using v8::Local; +using v8::NewStringType; using v8::Object; using v8::ObjectTemplate; +using v8::SnapshotCreator; using v8::String; using v8::Uint32; using v8::Undefined; @@ -58,7 +60,7 @@ void Concat(const FunctionCallbackInfo& args) { std::vector views; size_t total = 0; - std::vector> buffers; + std::vector> buffers; if (FromV8Array(context, array, &buffers).IsNothing()) { return; } @@ -159,7 +161,7 @@ Local Blob::GetConstructorTemplate(Environment* env) { return tmpl; } -bool Blob::HasInstance(Environment* env, v8::Local object) { +bool Blob::HasInstance(Environment* env, Local object) { return GetConstructorTemplate(env)->HasInstance(object); } @@ -188,7 +190,7 @@ void Blob::New(const FunctionCallbackInfo& args) { Local array = args[0].As(); std::vector> entries(array->Length()); - std::vector> sources; + std::vector> sources; if (FromV8Array(context, array, &sources).IsNothing()) { return; } @@ -197,7 +199,7 @@ void Blob::New(const FunctionCallbackInfo& args) { for (size_t i = 0; i < count; i++) { Local entry = sources[i].Get(isolate); - const auto entryFromArrayBuffer = [isolate](v8::Local buf, + const auto entryFromArrayBuffer = [isolate](Local buf, size_t byte_length, size_t byte_offset = 0) { if (buf->IsDetachable()) { @@ -279,14 +281,14 @@ BaseObjectPtr Blob::Slice(Environment* env, size_t start, size_t end) { } Blob::Blob(Environment* env, - v8::Local obj, + Local obj, std::shared_ptr data_queue) : BaseObject(env, obj), data_queue_(data_queue) { MakeWeak(); } Blob::Reader::Reader(Environment* env, - v8::Local obj, + Local obj, BaseObjectPtr strong_ptr) : AsyncWrap(env, obj, AsyncWrap::PROVIDER_BLOBREADER), inner_(strong_ptr->data_queue_->get_reader()), @@ -294,7 +296,7 @@ Blob::Reader::Reader(Environment* env, MakeWeak(); } -bool Blob::Reader::HasInstance(Environment* env, v8::Local value) { +bool Blob::Reader::HasInstance(Environment* env, Local value) { return GetConstructorTemplate(env)->HasInstance(value); } @@ -370,7 +372,7 @@ void Blob::Reader::Pull(const FunctionCallbackInfo& args) { for (size_t n = 0; n < count; n++) total += vecs[n].len; std::shared_ptr store = - v8::ArrayBuffer::NewBackingStore(env->isolate(), total); + ArrayBuffer::NewBackingStore(env->isolate(), total); auto ptr = static_cast(store->Data()); for (size_t n = 0; n < count; n++) { std::copy(vecs[n].base, vecs[n].base + vecs[n].len, ptr); @@ -415,7 +417,7 @@ std::unique_ptr Blob::CloneForMessaging() const { return std::make_unique(data_queue_); } -void Blob::StoreDataObject(const v8::FunctionCallbackInfo& args) { +void Blob::StoreDataObject(const FunctionCallbackInfo& args) { Realm* realm = Realm::GetCurrent(args); CHECK(args[0]->IsString()); // ID key @@ -468,7 +470,7 @@ void Blob::RevokeObjectURL(const FunctionCallbackInfo& args) { } } -void Blob::GetDataObject(const v8::FunctionCallbackInfo& args) { +void Blob::GetDataObject(const FunctionCallbackInfo& args) { CHECK(args[0]->IsString()); Realm* realm = Realm::GetCurrent(args); BlobBindingData* binding_data = realm->GetBindingData(); @@ -482,7 +484,7 @@ void Blob::GetDataObject(const v8::FunctionCallbackInfo& args) { Local type; if (!String::NewFromUtf8(isolate, stored.type.c_str(), - v8::NewStringType::kNormal, + NewStringType::kNormal, static_cast(stored.type.length())) .ToLocal(&type)) { return; @@ -554,7 +556,7 @@ void BlobBindingData::Deserialize(Local context, } bool BlobBindingData::PrepareForSerialization(Local context, - v8::SnapshotCreator* creator) { + SnapshotCreator* creator) { // Stored blob objects are not actually persisted. // Return true because we need to maintain the reference to the binding from // JS land. diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 2e0e8d4746fb61..cecc44c9b136a1 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -58,9 +58,11 @@ namespace Buffer { using v8::ArrayBuffer; using v8::ArrayBufferView; using v8::BackingStore; +using v8::CFunction; using v8::Context; using v8::EscapableHandleScope; using v8::FastApiTypedArray; +using v8::FastOneByteString; using v8::FunctionCallbackInfo; using v8::Global; using v8::HandleScope; @@ -518,9 +520,9 @@ MaybeLocal New(Environment* env, free(data); }; std::unique_ptr bs = - v8::ArrayBuffer::NewBackingStore(data, length, free_callback, nullptr); + ArrayBuffer::NewBackingStore(data, length, free_callback, nullptr); - Local ab = v8::ArrayBuffer::New(env->isolate(), std::move(bs)); + Local ab = ArrayBuffer::New(env->isolate(), std::move(bs)); Local obj; if (Buffer::New(env, ab, 0, length).ToLocal(&obj)) @@ -582,8 +584,8 @@ void SlowCopy(const FunctionCallbackInfo& args) { // Assume caller has properly validated args. uint32_t FastCopy(Local receiver, - const v8::FastApiTypedArray& source, - const v8::FastApiTypedArray& target, + const FastApiTypedArray& source, + const FastApiTypedArray& target, uint32_t target_start, uint32_t source_start, uint32_t to_copy) { @@ -598,7 +600,7 @@ uint32_t FastCopy(Local receiver, return to_copy; } -static v8::CFunction fast_copy(v8::CFunction::Make(FastCopy)); +static CFunction fast_copy(CFunction::Make(FastCopy)); void Fill(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); @@ -735,7 +737,7 @@ void SlowByteLengthUtf8(const FunctionCallbackInfo& args) { } uint32_t FastByteLengthUtf8(Local receiver, - const v8::FastOneByteString& source) { + const FastOneByteString& source) { // For short inputs, the function call overhead to simdutf is maybe // not worth it, reserve simdutf for long strings. if (source.length > 128) { @@ -777,8 +779,7 @@ uint32_t FastByteLengthUtf8(Local receiver, return answer; } -static v8::CFunction fast_byte_length_utf8( - v8::CFunction::Make(FastByteLengthUtf8)); +static CFunction fast_byte_length_utf8(CFunction::Make(FastByteLengthUtf8)); // Normalize val to be an integer in the range of [1, -1] since // implementations of memcmp() can vary by platform. @@ -857,7 +858,7 @@ void Compare(const FunctionCallbackInfo &args) { args.GetReturnValue().Set(val); } -int32_t FastCompare(v8::Local, +int32_t FastCompare(Local, const FastApiTypedArray& a, const FastApiTypedArray& b) { uint8_t* data_a; @@ -873,7 +874,7 @@ int32_t FastCompare(v8::Local, b.length()); } -static v8::CFunction fast_compare(v8::CFunction::Make(FastCompare)); +static CFunction fast_compare(CFunction::Make(FastCompare)); // Computes the offset for starting an indexOf or lastIndexOf search. // Returns either a valid offset in [0...], ie inside the Buffer, @@ -1141,7 +1142,7 @@ void SlowIndexOfNumber(const FunctionCallbackInfo& args) { buffer.data(), buffer.length(), needle, offset_i64, is_forward)); } -int32_t FastIndexOfNumber(v8::Local, +int32_t FastIndexOfNumber(Local, const FastApiTypedArray& buffer, uint32_t needle, int64_t offset_i64, @@ -1152,8 +1153,7 @@ int32_t FastIndexOfNumber(v8::Local, buffer_data, buffer.length(), needle, offset_i64, is_forward); } -static v8::CFunction fast_index_of_number( - v8::CFunction::Make(FastIndexOfNumber)); +static CFunction fast_index_of_number(CFunction::Make(FastIndexOfNumber)); void Swap16(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); @@ -1502,8 +1502,8 @@ void SlowWriteString(const FunctionCallbackInfo& args) { template uint32_t FastWriteString(Local receiver, - const v8::FastApiTypedArray& dst, - const v8::FastOneByteString& src, + const FastApiTypedArray& dst, + const FastOneByteString& src, uint32_t offset, uint32_t max_length) { uint8_t* dst_data; @@ -1519,12 +1519,11 @@ uint32_t FastWriteString(Local receiver, std::min(dst.length() - offset, max_length)); } -static v8::CFunction fast_write_string_ascii( - v8::CFunction::Make(FastWriteString)); -static v8::CFunction fast_write_string_latin1( - v8::CFunction::Make(FastWriteString)); -static v8::CFunction fast_write_string_utf8( - v8::CFunction::Make(FastWriteString)); +static CFunction fast_write_string_ascii( + CFunction::Make(FastWriteString)); +static CFunction fast_write_string_latin1( + CFunction::Make(FastWriteString)); +static CFunction fast_write_string_utf8(CFunction::Make(FastWriteString)); void Initialize(Local target, Local unused, diff --git a/src/node_builtins.cc b/src/node_builtins.cc index 4b3cfd786aaaf2..e4f7168ada52c1 100644 --- a/src/node_builtins.cc +++ b/src/node_builtins.cc @@ -10,8 +10,10 @@ namespace node { namespace builtins { +using v8::Boolean; using v8::Context; using v8::EscapableHandleScope; +using v8::Exception; using v8::Function; using v8::FunctionCallbackInfo; using v8::IntegrityLevel; @@ -19,6 +21,7 @@ using v8::Isolate; using v8::Local; using v8::MaybeLocal; using v8::Name; +using v8::NewStringType; using v8::None; using v8::Object; using v8::ObjectTemplate; @@ -28,6 +31,7 @@ using v8::ScriptOrigin; using v8::Set; using v8::SideEffectType; using v8::String; +using v8::TryCatch; using v8::Undefined; using v8::Value; @@ -209,11 +213,11 @@ MaybeLocal BuiltinLoader::LoadBuiltinSource(Isolate* isolate, uv_strerror(r), filename); Local message = OneByteString(isolate, buf); - isolate->ThrowException(v8::Exception::Error(message)); + isolate->ThrowException(Exception::Error(message)); return MaybeLocal(); } return String::NewFromUtf8( - isolate, contents.c_str(), v8::NewStringType::kNormal, contents.length()); + isolate, contents.c_str(), NewStringType::kNormal, contents.length()); #endif // NODE_BUILTIN_MODULES_PATH } @@ -538,7 +542,7 @@ bool BuiltinLoader::CompileAllBuiltinsAndCopyCodeCache( to_eager_compile_.emplace(id); } - v8::TryCatch bootstrapCatch(context->GetIsolate()); + TryCatch bootstrapCatch(context->GetIsolate()); auto fn = LookupAndCompile(context, id.data(), nullptr); if (bootstrapCatch.HasCaught()) { per_process::Debug(DebugCategory::CODE_CACHE, @@ -703,8 +707,8 @@ void BuiltinLoader::CompileFunction(const FunctionCallbackInfo& args) { void BuiltinLoader::HasCachedBuiltins(const FunctionCallbackInfo& args) { auto instance = Environment::GetCurrent(args)->builtin_loader(); RwLock::ScopedReadLock lock(instance->code_cache_->mutex); - args.GetReturnValue().Set(v8::Boolean::New( - args.GetIsolate(), instance->code_cache_->has_code_cache)); + args.GetReturnValue().Set( + Boolean::New(args.GetIsolate(), instance->code_cache_->has_code_cache)); } void SetInternalLoaders(const FunctionCallbackInfo& args) { diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 77d35675827c67..47a110940f3868 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -45,10 +45,13 @@ using v8::Array; using v8::ArrayBufferView; using v8::Boolean; using v8::Context; +using v8::DeserializeInternalFieldsCallback; +using v8::DontEnum; using v8::EscapableHandleScope; using v8::Function; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; +using v8::Global; using v8::HandleScope; using v8::IndexedPropertyHandlerConfiguration; using v8::IndexFilter; @@ -62,14 +65,17 @@ using v8::Local; using v8::LocalVector; using v8::Maybe; using v8::MaybeLocal; +using v8::MeasureMemoryDelegate; using v8::MeasureMemoryExecution; using v8::MeasureMemoryMode; using v8::Message; using v8::MicrotaskQueue; using v8::MicrotasksPolicy; +using v8::Module; using v8::Name; using v8::NamedPropertyHandlerConfiguration; using v8::Nothing; +using v8::Null; using v8::Object; using v8::ObjectTemplate; using v8::PrimitiveArray; @@ -86,6 +92,7 @@ using v8::String; using v8::Symbol; using v8::Uint32; using v8::UnboundScript; +using v8::Undefined; using v8::Value; // The vm module executes code in a sandboxed environment with a different @@ -230,8 +237,8 @@ MaybeLocal ContextifyContext::CreateV8Context( isolate, nullptr, // extensions object_template, - {}, // global object - v8::DeserializeInternalFieldsCallback(), // deserialization callback + {}, // global object + DeserializeInternalFieldsCallback(), // deserialization callback queue); if (ctx.IsEmpty() || InitializeBaseContextForSnapshot(ctx).IsNothing()) { return MaybeLocal(); @@ -239,10 +246,10 @@ MaybeLocal ContextifyContext::CreateV8Context( } else if (!Context::FromSnapshot( isolate, SnapshotData::kNodeVMContextIndex, - v8::DeserializeInternalFieldsCallback(), // deserialization - // callback - nullptr, // extensions - {}, // global object + DeserializeInternalFieldsCallback(), // deserialization + // callback + nullptr, // extensions + {}, // global object queue) .ToLocal(&ctx)) { return MaybeLocal(); @@ -278,7 +285,7 @@ BaseObjectPtr ContextifyContext::New( // the context from its constructor. if (sandbox_obj.IsEmpty()) { v8_context->SetEmbedderData(ContextEmbedderIndex::kSandboxObject, - v8::Undefined(env->isolate())); + Undefined(env->isolate())); } else { v8_context->SetEmbedderData(ContextEmbedderIndex::kSandboxObject, sandbox_obj); @@ -309,11 +316,10 @@ BaseObjectPtr ContextifyContext::New( if (!ctor_name->Equals(v8_context, env->object_string()) .FromMaybe(false) && new_context_global - ->DefineOwnProperty( - v8_context, - v8::Symbol::GetToStringTag(env->isolate()), - ctor_name, - static_cast(v8::DontEnum)) + ->DefineOwnProperty(v8_context, + Symbol::GetToStringTag(env->isolate()), + ctor_name, + static_cast(DontEnum)) .IsNothing()) { return BaseObjectPtr(); } @@ -826,7 +832,7 @@ void ContextifyContext::IndexedPropertyEnumeratorCallback( .ToLocal(&properties)) return; - std::vector> properties_vec; + std::vector> properties_vec; if (FromV8Array(context, properties, &properties_vec).IsNothing()) { return; } @@ -1113,7 +1119,7 @@ Maybe StoreCodeCacheResult( Environment* env, Local target, ScriptCompiler::CompileOptions compile_options, - const v8::ScriptCompiler::Source& source, + const ScriptCompiler::Source& source, bool produce_cached_data, std::unique_ptr new_cached_data) { Local context; @@ -1202,7 +1208,7 @@ void ContextifyScript::RunInContext(const FunctionCallbackInfo& args) { CHECK(args[0]->IsObject() || args[0]->IsNull()); Local context; - v8::MicrotaskQueue* microtask_queue = nullptr; + MicrotaskQueue* microtask_queue = nullptr; if (args[0]->IsObject()) { Local sandbox = args[0].As(); @@ -1537,7 +1543,7 @@ Local ContextifyContext::CompileFunctionAndCacheResult( context_extensions.size(), context_extensions.data(), options, - v8::ScriptCompiler::NoCacheReason::kNoCacheNoReason); + ScriptCompiler::NoCacheReason::kNoCacheNoReason); Local fn; if (!maybe_fn.ToLocal(&fn)) { @@ -1737,7 +1743,7 @@ static void CompileFunctionForCJSLoader( cached_data = new ScriptCompiler::CachedData( reinterpret_cast(data.data()), static_cast(data.size()), - v8::ScriptCompiler::CachedData::BufferNotOwned); + ScriptCompiler::CachedData::BufferNotOwned); } } #endif @@ -1790,7 +1796,7 @@ static void CompileFunctionForCJSLoader( } } - Local undefined = v8::Undefined(isolate); + Local undefined = Undefined(isolate); Local names[] = { env->cached_data_rejected_string(), env->source_map_url_string(), @@ -1804,7 +1810,7 @@ static void CompileFunctionForCJSLoader( Boolean::New(isolate, can_parse_as_esm), }; Local result = Object::New( - isolate, v8::Null(isolate), &names[0], &values[0], arraysize(names)); + isolate, Null(isolate), &names[0], &values[0], arraysize(names)); args.GetReturnValue().Set(result); } @@ -1841,7 +1847,7 @@ bool ShouldRetryAsESM(Realm* realm, bool cache_rejected = false; TryCatchScope try_catch(realm->env()); ShouldNotAbortOnUncaughtScope no_abort_scope(realm->env()); - Local module; + Local module; Local hdo = loader::ModuleWrap::GetHostDefinedOptions( isolate, realm->isolate_data()->source_text_module_default_hdo()); if (loader::ModuleWrap::CompileSourceTextModule( @@ -1932,21 +1938,20 @@ static void WatchdogHasPendingSigint(const FunctionCallbackInfo& args) { static void MeasureMemory(const FunctionCallbackInfo& args) { CHECK(args[0]->IsInt32()); CHECK(args[1]->IsInt32()); - int32_t mode = args[0].As()->Value(); - int32_t execution = args[1].As()->Value(); + int32_t mode = args[0].As()->Value(); + int32_t execution = args[1].As()->Value(); Isolate* isolate = args.GetIsolate(); Local current_context = isolate->GetCurrentContext(); Local resolver; if (!Promise::Resolver::New(current_context).ToLocal(&resolver)) return; - std::unique_ptr delegate = - v8::MeasureMemoryDelegate::Default( - isolate, - current_context, - resolver, - static_cast(mode)); + std::unique_ptr delegate = + MeasureMemoryDelegate::Default(isolate, + current_context, + resolver, + static_cast(mode)); isolate->MeasureMemory(std::move(delegate), - static_cast(execution)); + static_cast(execution)); Local promise = resolver->GetPromise(); args.GetReturnValue().Set(promise); diff --git a/src/node_debug.cc b/src/node_debug.cc index 0f254b1fbfe820..da46700b2886e3 100644 --- a/src/node_debug.cc +++ b/src/node_debug.cc @@ -15,6 +15,7 @@ namespace node::debug { #ifdef DEBUG +using v8::CFunction; using v8::Context; using v8::FastApiCallbackOptions; using v8::FunctionCallbackInfo; @@ -79,8 +80,8 @@ bool FastIsOdd(Local receiver, return value % 2 != 0; } -static v8::CFunction fast_is_even(v8::CFunction::Make(FastIsEven)); -static v8::CFunction fast_is_odd(v8::CFunction::Make(FastIsOdd)); +static CFunction fast_is_even(CFunction::Make(FastIsEven)); +static CFunction fast_is_odd(CFunction::Make(FastIsOdd)); void Initialize(Local target, Local unused, diff --git a/src/node_dotenv.cc b/src/node_dotenv.cc index 049f5cfcb77b9c..543dccc32df602 100644 --- a/src/node_dotenv.cc +++ b/src/node_dotenv.cc @@ -71,10 +71,10 @@ void Dotenv::SetEnvironment(node::Environment* env) { if (!existing.has_value()) { env->env_vars()->Set( isolate, - v8::String::NewFromUtf8( + String::NewFromUtf8( isolate, key.data(), NewStringType::kNormal, key.size()) .ToLocalChecked(), - v8::String::NewFromUtf8( + String::NewFromUtf8( isolate, value.data(), NewStringType::kNormal, value.size()) .ToLocalChecked()); } @@ -91,13 +91,13 @@ Local Dotenv::ToObject(Environment* env) const { result ->Set( env->context(), - v8::String::NewFromUtf8( + String::NewFromUtf8( env->isolate(), key.data(), NewStringType::kNormal, key.size()) .ToLocalChecked(), - v8::String::NewFromUtf8(env->isolate(), - value.data(), - NewStringType::kNormal, - value.size()) + String::NewFromUtf8(env->isolate(), + value.data(), + NewStringType::kNormal, + value.size()) .ToLocalChecked()) .Check(); } diff --git a/src/node_env_var.cc b/src/node_env_var.cc index 70ff9da2537e93..af7399109c5bbb 100644 --- a/src/node_env_var.cc +++ b/src/node_env_var.cc @@ -27,6 +27,7 @@ using v8::MaybeLocal; using v8::Name; using v8::NamedPropertyHandlerConfiguration; using v8::NewStringType; +using v8::None; using v8::Nothing; using v8::Object; using v8::ObjectTemplate; @@ -320,9 +321,9 @@ Maybe KVStore::AssignFromObject(Local context, // TODO(bnoordhuis) Not super efficient but called infrequently. Not worth // the trouble yet of specializing for RealEnvStore and MapKVStore. -Maybe KVStore::AssignToObject(v8::Isolate* isolate, - v8::Local context, - v8::Local object) { +Maybe KVStore::AssignToObject(Isolate* isolate, + Local context, + Local object) { HandleScope scope(isolate); Local keys = Enumerate(isolate); uint32_t keys_length = keys->Length(); @@ -390,9 +391,7 @@ void TraceEnvVar(Environment* env, const char* message, const char* key) { key); } -void TraceEnvVar(Environment* env, - const char* message, - v8::Local key) { +void TraceEnvVar(Environment* env, const char* message, Local key) { TraceEnvVarOptions options = GetTraceEnvVarOptions(env); if (options.print_message) { Utf8Value key_utf8(env->isolate(), key); @@ -473,7 +472,7 @@ static Intercepted EnvQuery(Local property, TraceEnvVar(env, "query", property.As()); if (has_env) { // Return attributes for the property. - info.GetReturnValue().Set(v8::None); + info.GetReturnValue().Set(None); return Intercepted::kYes; } } diff --git a/src/node_errors.cc b/src/node_errors.cc index 609601328f7f5f..0400130f0ab94e 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc @@ -29,11 +29,14 @@ using v8::Local; using v8::Maybe; using v8::MaybeLocal; using v8::Message; +using v8::ModifyCodeGenerationFromStringsResult; using v8::Object; +using v8::OOMDetails; using v8::ScriptOrigin; using v8::StackFrame; using v8::StackTrace; using v8::String; +using v8::TryCatch; using v8::Undefined; using v8::Value; @@ -56,7 +59,7 @@ static std::string GetSourceMapErrorSource(Isolate* isolate, Local context, Local message, bool* added_exception_line) { - v8::TryCatch try_catch(isolate); + TryCatch try_catch(isolate); HandleScope handle_scope(isolate); Environment* env = Environment::GetCurrent(context); @@ -68,8 +71,8 @@ static std::string GetSourceMapErrorSource(Isolate* isolate, int columnum = message->GetStartColumn(context).FromJust(); Local argv[] = {script_resource_name, - v8::Int32::New(isolate, linenum), - v8::Int32::New(isolate, columnum)}; + Int32::New(isolate, linenum), + Int32::New(isolate, columnum)}; MaybeLocal maybe_ret = env->get_source_map_error_source()->Call( context, Undefined(isolate), arraysize(argv), argv); Local ret; @@ -331,14 +334,14 @@ std::string FormatErrorMessage(Isolate* isolate, } result += reason + '\n'; - Local stack = message->GetStackTrace(); + Local stack = message->GetStackTrace(); if (!stack.IsEmpty()) result += FormatStackTrace(isolate, stack); return result; } std::string FormatCaughtException(Isolate* isolate, Local context, - const v8::TryCatch& try_catch) { + const TryCatch& try_catch) { CHECK(try_catch.HasCaught()); return FormatCaughtException( isolate, context, try_catch.Exception(), try_catch.Message()); @@ -346,7 +349,7 @@ std::string FormatCaughtException(Isolate* isolate, void PrintCaughtException(Isolate* isolate, Local context, - const v8::TryCatch& try_catch) { + const TryCatch& try_catch) { PrintToStderrAndFlush(FormatCaughtException(isolate, context, try_catch)); } @@ -593,7 +596,7 @@ static void ReportFatalException(Environment* env, ABORT(); } -void OOMErrorHandler(const char* location, const v8::OOMDetails& details) { +void OOMErrorHandler(const char* location, const OOMDetails& details) { // We should never recover from this handler so once it's true it's always // true. is_in_oom.store(true); @@ -629,10 +632,8 @@ void OOMErrorHandler(const char* location, const v8::OOMDetails& details) { ABORT(); } -v8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings( - v8::Local context, - v8::Local source, - bool is_code_like) { +ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings( + Local context, Local source, bool is_code_like) { HandleScope scope(context->GetIsolate()); if (context->GetNumberOfEmbedderDataFields() <= @@ -676,7 +677,7 @@ namespace errors { TryCatchScope::~TryCatchScope() { if (HasCaught() && !HasTerminated() && mode_ == CatchMode::kFatal) { HandleScope scope(env_->isolate()); - Local exception = Exception(); + Local exception = Exception(); Local message = Message(); EnhanceFatalException enhance = CanContinue() ? EnhanceFatalException::kEnhance : EnhanceFatalException::kDontEnhance; @@ -1030,7 +1031,7 @@ void PerIsolateMessageListener(Local message, Local error) { warning << ":"; warning << message->GetLineNumber(env->context()).FromMaybe(-1); warning << " "; - v8::String::Utf8Value msg(isolate, message->Get()); + String::Utf8Value msg(isolate, message->Get()); warning << *msg; USE(ProcessEmitWarningGeneric(env, warning.str().c_str(), "V8")); break; @@ -1274,7 +1275,7 @@ void TriggerUncaughtException(Isolate* isolate, env->Exit(env->exit_code(ExitCode::kGenericUserError)); } -void TriggerUncaughtException(Isolate* isolate, const v8::TryCatch& try_catch) { +void TriggerUncaughtException(Isolate* isolate, const TryCatch& try_catch) { // If the try_catch is verbose, the per-isolate message listener is going to // handle it (which is going to call into another overload of // TriggerUncaughtException()). diff --git a/src/node_file.cc b/src/node_file.cc index 1b56d2323c9526..1ab74dc1feed16 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -60,6 +60,7 @@ namespace fs { using v8::Array; using v8::BigInt; +using v8::CFunction; using v8::Context; using v8::EscapableHandleScope; using v8::FastApiCallbackOptions; @@ -81,6 +82,7 @@ using v8::Number; using v8::Object; using v8::ObjectTemplate; using v8::Promise; +using v8::SnapshotCreator; using v8::String; using v8::Undefined; using v8::Value; @@ -311,7 +313,7 @@ FileHandle::TransferData::~TransferData() { BaseObjectPtr FileHandle::TransferData::Deserialize( Environment* env, - v8::Local context, + Local context, std::unique_ptr self) { BindingData* bd = Realm::GetBindingData(context); if (bd == nullptr) return {}; @@ -1081,8 +1083,7 @@ static int32_t FastInternalModuleStat( } } -v8::CFunction fast_internal_module_stat_( - v8::CFunction::Make(FastInternalModuleStat)); +CFunction fast_internal_module_stat_(CFunction::Make(FastInternalModuleStat)); constexpr bool is_uv_error_except_no_entry(int result) { return result < 0 && result != UV_ENOENT; @@ -3510,7 +3511,7 @@ void BindingData::MemoryInfo(MemoryTracker* tracker) const { } BindingData::BindingData(Realm* realm, - v8::Local wrap, + Local wrap, InternalFieldInfo* info) : SnapshotableObject(realm, wrap, type_int), stats_field_array(realm->isolate(), @@ -3575,7 +3576,7 @@ void BindingData::Deserialize(Local context, } bool BindingData::PrepareForSerialization(Local context, - v8::SnapshotCreator* creator) { + SnapshotCreator* creator) { CHECK(file_handle_read_wrap_freelist.empty()); DCHECK_NULL(internal_field_info_); internal_field_info_ = InternalFieldInfoBase::New(type()); diff --git a/src/node_messaging.cc b/src/node_messaging.cc index 73c0c38dc7bf45..c644f3f737138e 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -36,6 +36,7 @@ using v8::SharedArrayBuffer; using v8::SharedValueConveyor; using v8::String; using v8::Symbol; +using v8::Uint32; using v8::Value; using v8::ValueDeserializer; using v8::ValueSerializer; @@ -699,7 +700,7 @@ void MessagePort::TriggerAsync() { CHECK_EQ(uv_async_send(&async_), 0); } -void MessagePort::Close(v8::Local close_callback) { +void MessagePort::Close(Local close_callback) { Debug(this, "Closing message port, data set = %d", static_cast(!!data_)); if (data_) { @@ -1265,8 +1266,8 @@ BaseObjectPtr JSTransferable::Wrap(Environment* env, // static bool JSTransferable::IsJSTransferable(Environment* env, - v8::Local context, - v8::Local object) { + Local context, + Local object) { return object->HasPrivate(context, env->transfer_mode_private_symbol()) .ToChecked(); } @@ -1302,7 +1303,7 @@ BaseObject::TransferMode JSTransferable::GetTransferMode() const { if (!transfer_mode_val->IsUint32()) { return TransferMode::kDisallowCloneAndTransfer; } - return static_cast(transfer_mode_val.As()->Value()); + return static_cast(transfer_mode_val.As()->Value()); } std::unique_ptr JSTransferable::TransferForMessaging() { @@ -1415,10 +1416,8 @@ Maybe JSTransferable::FinalizeTransferRead( return JustVoid(); } -JSTransferable::Data::Data(std::string&& deserialize_info, - v8::Global&& data) - : deserialize_info_(std::move(deserialize_info)), - data_(std::move(data)) {} +JSTransferable::Data::Data(std::string&& deserialize_info, Global&& data) + : deserialize_info_(std::move(deserialize_info)), data_(std::move(data)) {} BaseObjectPtr JSTransferable::Data::Deserialize( Environment* env, diff --git a/src/node_metadata.cc b/src/node_metadata.cc index db30578fb3014b..8585081066769e 100644 --- a/src/node_metadata.cc +++ b/src/node_metadata.cc @@ -46,6 +46,8 @@ namespace node { +using v8::V8; + namespace per_process { Metadata metadata; } @@ -95,7 +97,7 @@ void Metadata::Versions::InitializeIntlVersions() { Metadata::Versions::Versions() { node = NODE_VERSION_STRING; - v8 = v8::V8::GetVersion(); + v8 = V8::GetVersion(); uv = uv_version_string(); #ifdef NODE_BUNDLED_ZLIB zlib = ZLIB_VERSION; diff --git a/src/node_modules.cc b/src/node_modules.cc index 4b522a91323c9f..2cebec814d61ef 100644 --- a/src/node_modules.cc +++ b/src/node_modules.cc @@ -23,6 +23,7 @@ using v8::Array; using v8::Context; using v8::FunctionCallbackInfo; using v8::HandleScope; +using v8::Integer; using v8::Isolate; using v8::Local; using v8::LocalVector; @@ -30,6 +31,7 @@ using v8::NewStringType; using v8::Object; using v8::ObjectTemplate; using v8::Primitive; +using v8::SnapshotCreator; using v8::String; using v8::Undefined; using v8::Value; @@ -39,12 +41,12 @@ void BindingData::MemoryInfo(MemoryTracker* tracker) const { } BindingData::BindingData(Realm* realm, - v8::Local object, + Local object, InternalFieldInfo* info) : SnapshotableObject(realm, object, type_int) {} -bool BindingData::PrepareForSerialization(v8::Local context, - v8::SnapshotCreator* creator) { +bool BindingData::PrepareForSerialization(Local context, + SnapshotCreator* creator) { // Return true because we need to maintain the reference to the binding from // JS land. return true; @@ -57,8 +59,8 @@ InternalFieldInfoBase* BindingData::Serialize(int index) { return info; } -void BindingData::Deserialize(v8::Local context, - v8::Local holder, +void BindingData::Deserialize(Local context, + Local holder, int index, InternalFieldInfoBase* info) { DCHECK_IS_SNAPSHOT_SLOT(index); @@ -327,7 +329,7 @@ const BindingData::PackageConfig* BindingData::TraverseParent( } void BindingData::GetNearestParentPackageJSON( - const v8::FunctionCallbackInfo& args) { + const FunctionCallbackInfo& args) { CHECK_GE(args.Length(), 1); CHECK(args[0]->IsString()); @@ -479,7 +481,7 @@ void EnableCompileCache(const FunctionCallbackInfo& args) { Utf8Value value(isolate, args[0]); CompileCacheEnableResult result = env->EnableCompileCache(*value); Local values[] = { - v8::Integer::New(isolate, static_cast(result.status)), + Integer::New(isolate, static_cast(result.status)), ToV8Value(context, result.message).ToLocalChecked(), ToV8Value(context, result.cache_directory).ToLocalChecked()}; args.GetReturnValue().Set(Array::New(isolate, &values[0], arraysize(values))); @@ -490,7 +492,7 @@ void GetCompileCacheDir(const FunctionCallbackInfo& args) { Local context = isolate->GetCurrentContext(); Environment* env = Environment::GetCurrent(context); if (!env->use_compile_cache()) { - args.GetReturnValue().Set(v8::String::Empty(isolate)); + args.GetReturnValue().Set(String::Empty(isolate)); return; } args.GetReturnValue().Set( diff --git a/src/node_perf.cc b/src/node_perf.cc index d8b26f5c845be1..cfdb64d39fd051 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -15,6 +15,7 @@ namespace node { namespace performance { using v8::Array; +using v8::CFunction; using v8::Context; using v8::DontDelete; using v8::Function; @@ -29,6 +30,7 @@ using v8::Object; using v8::ObjectTemplate; using v8::PropertyAttribute; using v8::ReadOnly; +using v8::SnapshotCreator; using v8::Value; // Microseconds in a millisecond, as a float. @@ -76,7 +78,7 @@ void PerformanceState::ResetMilestones() { } PerformanceState::SerializeInfo PerformanceState::Serialize( - v8::Local context, v8::SnapshotCreator* creator) { + Local context, SnapshotCreator* creator) { // Reset all the milestones to improve determinism in the snapshot. // We'll re-initialize them after deserialization. ResetMilestones(); @@ -98,7 +100,7 @@ void PerformanceState::Initialize(uint64_t time_origin, time_origin_timestamp; } -void PerformanceState::Deserialize(v8::Local context, +void PerformanceState::Deserialize(Local context, uint64_t time_origin, double time_origin_timestamp) { // Resets the pointers. @@ -311,7 +313,7 @@ static double PerformanceNowImpl() { NANOS_PER_MILLIS; } -static double FastPerformanceNow(v8::Local receiver) { +static double FastPerformanceNow(Local receiver) { return PerformanceNowImpl(); } @@ -319,8 +321,7 @@ static void SlowPerformanceNow(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(PerformanceNowImpl()); } -static v8::CFunction fast_performance_now( - v8::CFunction::Make(FastPerformanceNow)); +static CFunction fast_performance_now(CFunction::Make(FastPerformanceNow)); static void CreatePerIsolateProperties(IsolateData* isolate_data, Local target) { diff --git a/src/node_platform.cc b/src/node_platform.cc index 632217b088ee52..f87fe3e26a124a 100644 --- a/src/node_platform.cc +++ b/src/node_platform.cc @@ -9,10 +9,19 @@ namespace node { +using v8::HandleScope; +using v8::IdleTask; using v8::Isolate; +using v8::JobHandle; +using v8::JobTask; using v8::Object; +using v8::PageAllocator; using v8::Platform; +using v8::SourceLocation; using v8::Task; +using v8::TaskPriority; +using v8::TaskRunner; +using v8::TracingController; namespace { @@ -235,8 +244,7 @@ PerIsolatePlatformData::PerIsolatePlatformData( uv_unref(reinterpret_cast(flush_tasks_)); } -std::shared_ptr -PerIsolatePlatformData::GetForegroundTaskRunner() { +std::shared_ptr PerIsolatePlatformData::GetForegroundTaskRunner() { return shared_from_this(); } @@ -245,13 +253,13 @@ void PerIsolatePlatformData::FlushTasks(uv_async_t* handle) { platform_data->FlushForegroundTasksInternal(); } -void PerIsolatePlatformData::PostIdleTaskImpl( - std::unique_ptr task, const v8::SourceLocation& location) { +void PerIsolatePlatformData::PostIdleTaskImpl(std::unique_ptr task, + const SourceLocation& location) { UNREACHABLE(); } void PerIsolatePlatformData::PostTaskImpl(std::unique_ptr task, - const v8::SourceLocation& location) { + const SourceLocation& location) { if (flush_tasks_ == nullptr) { // V8 may post tasks during Isolate disposal. In that case, the only // sensible path forward is to discard the task. @@ -264,7 +272,7 @@ void PerIsolatePlatformData::PostTaskImpl(std::unique_ptr task, void PerIsolatePlatformData::PostDelayedTaskImpl( std::unique_ptr task, double delay_in_seconds, - const v8::SourceLocation& location) { + const SourceLocation& location) { if (flush_tasks_ == nullptr) { // V8 may post tasks during Isolate disposal. In that case, the only // sensible path forward is to discard the task. @@ -279,14 +287,14 @@ void PerIsolatePlatformData::PostDelayedTaskImpl( } void PerIsolatePlatformData::PostNonNestableTaskImpl( - std::unique_ptr task, const v8::SourceLocation& location) { + std::unique_ptr task, const SourceLocation& location) { PostTaskImpl(std::move(task), location); } void PerIsolatePlatformData::PostNonNestableDelayedTaskImpl( std::unique_ptr task, double delay_in_seconds, - const v8::SourceLocation& location) { + const SourceLocation& location) { PostDelayedTaskImpl(std::move(task), delay_in_seconds, location); } @@ -337,12 +345,12 @@ void PerIsolatePlatformData::DecreaseHandleCount() { } NodePlatform::NodePlatform(int thread_pool_size, - v8::TracingController* tracing_controller, - v8::PageAllocator* page_allocator) { + TracingController* tracing_controller, + PageAllocator* page_allocator) { if (tracing_controller != nullptr) { tracing_controller_ = tracing_controller; } else { - tracing_controller_ = new v8::TracingController(); + tracing_controller_ = new TracingController(); } // V8 will default to its built in allocator if none is provided. @@ -425,7 +433,7 @@ void PerIsolatePlatformData::RunForegroundTask(std::unique_ptr task) { DebugSealHandleScope scope(isolate_); Environment* env = Environment::GetCurrent(isolate_); if (env != nullptr) { - v8::HandleScope scope(isolate_); + HandleScope scope(isolate_); InternalCallbackScope cb_scope(env, Object::New(isolate_), { 0, 0 }, InternalCallbackScope::kNoFlags); task->Run(); @@ -507,18 +515,17 @@ bool PerIsolatePlatformData::FlushForegroundTasksInternal() { return did_work; } -void NodePlatform::PostTaskOnWorkerThreadImpl( - v8::TaskPriority priority, - std::unique_ptr task, - const v8::SourceLocation& location) { +void NodePlatform::PostTaskOnWorkerThreadImpl(TaskPriority priority, + std::unique_ptr task, + const SourceLocation& location) { worker_thread_task_runner_->PostTask(std::move(task)); } void NodePlatform::PostDelayedTaskOnWorkerThreadImpl( - v8::TaskPriority priority, - std::unique_ptr task, + TaskPriority priority, + std::unique_ptr task, double delay_in_seconds, - const v8::SourceLocation& location) { + const SourceLocation& location) { worker_thread_task_runner_->PostDelayedTask(std::move(task), delay_in_seconds); } @@ -544,10 +551,10 @@ bool NodePlatform::FlushForegroundTasks(Isolate* isolate) { return per_isolate->FlushForegroundTasksInternal(); } -std::unique_ptr NodePlatform::CreateJobImpl( - v8::TaskPriority priority, - std::unique_ptr job_task, - const v8::SourceLocation& location) { +std::unique_ptr NodePlatform::CreateJobImpl( + TaskPriority priority, + std::unique_ptr job_task, + const SourceLocation& location) { return v8::platform::NewDefaultJobHandle( this, priority, std::move(job_task), NumberOfWorkerThreads()); } @@ -556,8 +563,8 @@ bool NodePlatform::IdleTasksEnabled(Isolate* isolate) { return ForIsolate(isolate)->IdleTasksEnabled(); } -std::shared_ptr -NodePlatform::GetForegroundTaskRunner(Isolate* isolate) { +std::shared_ptr NodePlatform::GetForegroundTaskRunner( + Isolate* isolate) { return ForIsolate(isolate)->GetForegroundTaskRunner(); } @@ -570,7 +577,7 @@ double NodePlatform::CurrentClockTimeMillis() { return SystemClockTimeMillis(); } -v8::TracingController* NodePlatform::GetTracingController() { +TracingController* NodePlatform::GetTracingController() { CHECK_NOT_NULL(tracing_controller_); return tracing_controller_; } @@ -583,7 +590,7 @@ Platform::StackTracePrinter NodePlatform::GetStackTracePrinter() { }; } -v8::PageAllocator* NodePlatform::GetPageAllocator() { +PageAllocator* NodePlatform::GetPageAllocator() { return page_allocator_; } diff --git a/src/node_process_events.cc b/src/node_process_events.cc index 8aac953b3e0db5..19f51af7a4c193 100644 --- a/src/node_process_events.cc +++ b/src/node_process_events.cc @@ -16,6 +16,7 @@ using v8::MaybeLocal; using v8::Nothing; using v8::Object; using v8::String; +using v8::Undefined; using v8::Value; Maybe ProcessEmitWarningSync(Environment* env, std::string_view message) { @@ -29,7 +30,7 @@ Maybe ProcessEmitWarningSync(Environment* env, std::string_view message) { // finished. CHECK(!emit_function.IsEmpty()); if (emit_function.As() - ->Call(context, v8::Undefined(isolate), arraysize(argv), argv) + ->Call(context, Undefined(isolate), arraysize(argv), argv) .IsEmpty()) { return Nothing(); } diff --git a/src/node_process_object.cc b/src/node_process_object.cc index bbbc2403b6fa6d..c8a930d28cd8c3 100644 --- a/src/node_process_object.cc +++ b/src/node_process_object.cc @@ -26,6 +26,7 @@ using v8::NewStringType; using v8::None; using v8::Object; using v8::PropertyCallbackInfo; +using v8::ReadOnly; using v8::SideEffectType; using v8::String; using v8::Value; @@ -107,7 +108,7 @@ static void SetVersions(Isolate* isolate, Local versions) { ->DefineOwnProperty(context, OneByteString(isolate, version.first), OneByteString(isolate, version.second), - v8::ReadOnly) + ReadOnly) .Check(); } } diff --git a/src/node_realm.cc b/src/node_realm.cc index ead7f02f6cbd5a..1d6a983b42e2b2 100644 --- a/src/node_realm.cc +++ b/src/node_realm.cc @@ -16,9 +16,10 @@ using v8::MaybeLocal; using v8::Object; using v8::SnapshotCreator; using v8::String; +using v8::True; using v8::Value; -Realm::Realm(Environment* env, v8::Local context, Kind kind) +Realm::Realm(Environment* env, Local context, Kind kind) : env_(env), isolate_(context->GetIsolate()), kind_(kind) { context_.Reset(isolate_, context); env->AssignToContext(context, this, ContextInfo("")); @@ -275,17 +276,17 @@ void Realm::VerifyNoStrongBaseObjects() { }); } -v8::Local Realm::context() const { +Local Realm::context() const { return PersistentToLocal::Strong(context_); } // Per-realm strong value accessors. The per-realm values should avoid being // accessed across realms. #define V(PropertyName, TypeName) \ - v8::Local PrincipalRealm::PropertyName() const { \ + Local PrincipalRealm::PropertyName() const { \ return PersistentToLocal::Strong(PropertyName##_); \ } \ - void PrincipalRealm::set_##PropertyName(v8::Local value) { \ + void PrincipalRealm::set_##PropertyName(Local value) { \ DCHECK_IMPLIES(!value.IsEmpty(), \ isolate()->GetCurrentContext() == context()); \ PropertyName##_.Reset(isolate(), value); \ @@ -294,7 +295,7 @@ PER_REALM_STRONG_PERSISTENT_VALUES(V) #undef V PrincipalRealm::PrincipalRealm(Environment* env, - v8::Local context, + Local context, const RealmSerializeInfo* realm_info) : Realm(env, context, kPrincipal) { // Create properties if not deserializing from snapshot. @@ -353,7 +354,7 @@ MaybeLocal PrincipalRealm::BootstrapRealm() { return MaybeLocal(); } - return v8::True(isolate_); + return True(isolate_); } } // namespace node diff --git a/src/node_report.cc b/src/node_report.cc index 9ab66162ec32a6..ebb52bc9961986 100644 --- a/src/node_report.cc +++ b/src/node_report.cc @@ -47,6 +47,7 @@ using v8::SampleInfo; using v8::StackFrame; using v8::StackTrace; using v8::String; +using v8::Symbol; using v8::TryCatch; using v8::V8; using v8::Value; @@ -435,7 +436,7 @@ static Maybe ErrorToString(Isolate* isolate, MaybeLocal maybe_str; // `ToString` is not available to Symbols. if (error->IsSymbol()) { - maybe_str = error.As()->ToDetailString(context); + maybe_str = error.As()->ToDetailString(context); } else if (!error->IsObject()) { maybe_str = error->ToString(context); } else if (error->IsObject()) { @@ -469,7 +470,7 @@ static void PrintJavaScriptStack(JSONWriter* writer, Isolate* isolate, const char* trigger) { HandleScope scope(isolate); - Local stack; + Local stack; if (!GetCurrentStackTrace(isolate, MAX_FRAME_COUNT).ToLocal(&stack)) { PrintEmptyJavaScriptStack(writer); return; diff --git a/src/node_sea.cc b/src/node_sea.cc index fb9f933a19fa70..50ac36e8e8ffd1 100644 --- a/src/node_sea.cc +++ b/src/node_sea.cc @@ -423,7 +423,7 @@ std::optional GenerateCodeCache(std::string_view main_path, RAIIIsolate raii_isolate(SnapshotBuilder::GetEmbeddedSnapshotData()); Isolate* isolate = raii_isolate.get(); - v8::Isolate::Scope isolate_scope(isolate); + Isolate::Scope isolate_scope(isolate); HandleScope handle_scope(isolate); Local context = Context::New(isolate); @@ -592,7 +592,7 @@ void GetAsset(const FunctionCallbackInfo& args) { } // We cast away the constness here, the JS land should ensure that // the data is not mutated. - std::unique_ptr store = ArrayBuffer::NewBackingStore( + std::unique_ptr store = ArrayBuffer::NewBackingStore( const_cast(it->second.data()), it->second.size(), [](void*, size_t, void*) {}, diff --git a/src/node_shadow_realm.cc b/src/node_shadow_realm.cc index 1273555b50c80b..3775519da942b4 100644 --- a/src/node_shadow_realm.cc +++ b/src/node_shadow_realm.cc @@ -12,7 +12,11 @@ using v8::Local; using v8::MaybeLocal; using v8::Object; using v8::String; +using v8::True; +using v8::Undefined; using v8::Value; +using v8::WeakCallbackInfo; +using v8::WeakCallbackType; using TryCatchScope = node::errors::TryCatchScope; @@ -52,7 +56,7 @@ MaybeLocal HostCreateShadowRealmContextCallback( } // static -void ShadowRealm::WeakCallback(const v8::WeakCallbackInfo& data) { +void ShadowRealm::WeakCallback(const WeakCallbackInfo& data) { ShadowRealm* realm = data.GetParameter(); realm->context_.Reset(); @@ -76,7 +80,7 @@ void ShadowRealm::DeleteMe(void* data) { ShadowRealm::ShadowRealm(Environment* env) : Realm(env, NewContext(env->isolate()), kShadowRealm) { - context_.SetWeak(this, WeakCallback, v8::WeakCallbackType::kParameter); + context_.SetWeak(this, WeakCallback, WeakCallbackType::kParameter); CreateProperties(); env->TrackShadowRealm(this); @@ -101,7 +105,7 @@ ShadowRealm::~ShadowRealm() { } } -v8::Local ShadowRealm::context() const { +Local ShadowRealm::context() const { Local ctx = PersistentToLocal::Default(isolate_, context_); DCHECK(!ctx.IsEmpty()); return ctx; @@ -113,18 +117,18 @@ v8::Local ShadowRealm::context() const { // global object to avoid the strong global references to the per-realm objects // keep the context alive indefinitely. #define V(PropertyName, TypeName) \ - v8::Local ShadowRealm::PropertyName() const { \ + Local ShadowRealm::PropertyName() const { \ return PersistentToLocal::Default(isolate_, PropertyName##_); \ } \ - void ShadowRealm::set_##PropertyName(v8::Local value) { \ + void ShadowRealm::set_##PropertyName(Local value) { \ HandleScope scope(isolate_); \ PropertyName##_.Reset(isolate_, value); \ - v8::Local ctx = context(); \ + Local ctx = context(); \ if (value.IsEmpty()) { \ ctx->Global() \ ->SetPrivate(ctx, \ isolate_data()->per_realm_##PropertyName(), \ - v8::Undefined(isolate_)) \ + Undefined(isolate_)) \ .ToChecked(); \ } else { \ PropertyName##_.SetWeak(); \ @@ -136,7 +140,7 @@ v8::Local ShadowRealm::context() const { PER_REALM_STRONG_PERSISTENT_VALUES(V) #undef V -v8::MaybeLocal ShadowRealm::BootstrapRealm() { +MaybeLocal ShadowRealm::BootstrapRealm() { HandleScope scope(isolate_); // Skip "internal/bootstrap/node" as it installs node globals and per-isolate @@ -171,7 +175,7 @@ v8::MaybeLocal ShadowRealm::BootstrapRealm() { return MaybeLocal(); } - return v8::True(isolate_); + return True(isolate_); } } // namespace shadow_realm diff --git a/src/node_snapshotable.cc b/src/node_snapshotable.cc index f9acb7b1d1618e..4580114edbf3e9 100644 --- a/src/node_snapshotable.cc +++ b/src/node_snapshotable.cc @@ -41,8 +41,11 @@ using v8::FunctionCallbackInfo; using v8::HandleScope; using v8::Isolate; using v8::Local; +using v8::Locker; using v8::Object; using v8::ObjectTemplate; +using v8::SerializeContextDataCallback; +using v8::SerializeInternalFieldsCallback; using v8::SnapshotCreator; using v8::StartupData; using v8::String; @@ -177,7 +180,7 @@ class SnapshotSerializer : public BlobSerializer { // [ 4/8 bytes ] raw_size // [ |raw_size| bytes ] contents template <> -v8::StartupData SnapshotDeserializer::Read() { +StartupData SnapshotDeserializer::Read() { Debug("Read()\n"); int raw_size = ReadArithmetic(); @@ -188,11 +191,11 @@ v8::StartupData SnapshotDeserializer::Read() { std::unique_ptr buf = std::unique_ptr(new char[raw_size]); ReadArithmetic(buf.get(), raw_size); - return v8::StartupData{buf.release(), raw_size}; + return StartupData{buf.release(), raw_size}; } template <> -size_t SnapshotSerializer::Write(const v8::StartupData& data) { +size_t SnapshotSerializer::Write(const StartupData& data) { Debug("\nWrite() size=%d\n", data.raw_size); CHECK_GT(data.raw_size, 0); // There should be no startup data of size 0. @@ -599,7 +602,7 @@ std::vector SnapshotData::ToBlob() const { w.Debug("0x%x: Write metadata\n", w.sink.size()); written_total += w.Write(metadata); w.Debug("0x%x: Write snapshot blob\n", w.sink.size()); - written_total += w.Write(v8_snapshot_blob_data); + written_total += w.Write(v8_snapshot_blob_data); w.Debug("0x%x: Write IsolateDataSerializeInfo\n", w.sink.size()); written_total += w.Write(isolate_data_info); w.Debug("0x%x: Write EnvSerializeInfo\n", w.sink.size()); @@ -653,7 +656,7 @@ bool SnapshotData::FromBlob(SnapshotData* out, std::string_view in) { return false; } - out->v8_snapshot_blob_data = r.Read(); + out->v8_snapshot_blob_data = r.Read(); r.Debug("Read isolate_data_info\n"); out->isolate_data_info = r.Read(); out->env_info = r.Read(); @@ -867,7 +870,7 @@ void SnapshotBuilder::InitializeIsolateParams(const SnapshotData* data, CHECK_NULL(params->snapshot_blob); params->external_references = CollectExternalReferences().data(); params->snapshot_blob = - const_cast(&(data->v8_snapshot_blob_data)); + const_cast(&(data->v8_snapshot_blob_data)); } SnapshotFlags operator|(SnapshotFlags x, SnapshotFlags y) { @@ -962,7 +965,7 @@ ExitCode BuildSnapshotWithoutCodeCache( } Isolate* isolate = setup->isolate(); - v8::Locker locker(isolate); + Locker locker(isolate); { HandleScope scope(isolate); @@ -1009,7 +1012,7 @@ ExitCode BuildCodeCacheFromSnapshot(SnapshotData* out, const std::vector& exec_args) { RAIIIsolate raii_isolate(out); Isolate* isolate = raii_isolate.get(); - v8::Locker locker(isolate); + Locker locker(isolate); Isolate::Scope isolate_scope(isolate); HandleScope handle_scope(isolate); TryCatch bootstrapCatch(isolate); @@ -1142,9 +1145,9 @@ ExitCode SnapshotBuilder::CreateSnapshot(SnapshotData* out, CHECK_EQ(index, SnapshotData::kNodeBaseContextIndex); index = creator->AddContext( main_context, - v8::SerializeInternalFieldsCallback(SerializeNodeContextInternalFields, - env), - v8::SerializeContextDataCallback(SerializeNodeContextData, env)); + SerializeInternalFieldsCallback(SerializeNodeContextInternalFields, + env), + SerializeContextDataCallback(SerializeNodeContextData, env)); CHECK_EQ(index, SnapshotData::kNodeMainContextIndex); } @@ -1521,7 +1524,7 @@ std::string GetAnonymousMainPath() { namespace mksnapshot { BindingData::BindingData(Realm* realm, - v8::Local object, + Local object, InternalFieldInfo* info) : SnapshotableObject(realm, object, type_int), is_building_snapshot_buffer_( @@ -1547,7 +1550,7 @@ BindingData::BindingData(Realm* realm, } bool BindingData::PrepareForSerialization(Local context, - v8::SnapshotCreator* creator) { + SnapshotCreator* creator) { DCHECK_NULL(internal_field_info_); internal_field_info_ = InternalFieldInfoBase::New(type()); internal_field_info_->is_building_snapshot_buffer = @@ -1569,7 +1572,7 @@ void BindingData::Deserialize(Local context, int index, InternalFieldInfoBase* info) { DCHECK_IS_SNAPSHOT_SLOT(index); - v8::HandleScope scope(context->GetIsolate()); + HandleScope scope(context->GetIsolate()); Realm* realm = Realm::GetCurrent(context); // Recreate the buffer in the constructor. InternalFieldInfo* casted_info = static_cast(info); diff --git a/src/node_sockaddr.cc b/src/node_sockaddr.cc index 8cfef3726def8c..3296c2db7c7497 100644 --- a/src/node_sockaddr.cc +++ b/src/node_sockaddr.cc @@ -873,7 +873,7 @@ void SocketAddressBase::TransferData::MemoryInfo(MemoryTracker* tracker) const { BaseObjectPtr SocketAddressBase::TransferData::Deserialize( Environment* env, - v8::Local context, + Local context, std::unique_ptr self) { return SocketAddressBase::Create(env, std::move(address_)); } diff --git a/src/node_sqlite.cc b/src/node_sqlite.cc index 0b8f7ef2a21763..7339ce4068c5ef 100644 --- a/src/node_sqlite.cc +++ b/src/node_sqlite.cc @@ -40,7 +40,9 @@ using v8::NewStringType; using v8::Null; using v8::Number; using v8::Object; +using v8::PropertyDescriptor; using v8::SideEffectType; +using v8::Signature; using v8::String; using v8::TryCatch; using v8::Uint8Array; @@ -1334,23 +1336,21 @@ void StatementSync::Iterate(const FunctionCallbackInfo& args) { Local iterable_iterator = Object::New( isolate, js_iterator_prototype, keys.data(), values.data(), keys.size()); - auto num_cols_pd = v8::PropertyDescriptor( - v8::Integer::New(isolate, sqlite3_column_count(stmt->statement_)), false); + auto num_cols_pd = PropertyDescriptor( + Integer::New(isolate, sqlite3_column_count(stmt->statement_)), false); num_cols_pd.set_enumerable(false); num_cols_pd.set_configurable(false); iterable_iterator ->DefineProperty(context, env->num_cols_string(), num_cols_pd) .ToChecked(); - auto stmt_pd = - v8::PropertyDescriptor(v8::External::New(isolate, stmt), false); + auto stmt_pd = PropertyDescriptor(External::New(isolate, stmt), false); stmt_pd.set_enumerable(false); stmt_pd.set_configurable(false); iterable_iterator->DefineProperty(context, env->statement_string(), stmt_pd) .ToChecked(); - auto is_finished_pd = - v8::PropertyDescriptor(v8::Boolean::New(isolate, false), true); + auto is_finished_pd = PropertyDescriptor(Boolean::New(isolate, false), true); stmt_pd.set_enumerable(false); stmt_pd.set_configurable(false); iterable_iterator @@ -1539,7 +1539,7 @@ static inline void SetSideEffectFreeGetter( FunctionTemplate::New(isolate, fn, Local(), - v8::Signature::New(isolate, class_template), + Signature::New(isolate, class_template), /* length */ 0, ConstructorBehavior::kThrow, SideEffectType::kHasNoSideEffect); diff --git a/src/node_task_queue.cc b/src/node_task_queue.cc index 0a5aba6e31fa79..d272cd29a5f375 100644 --- a/src/node_task_queue.cc +++ b/src/node_task_queue.cc @@ -36,11 +36,11 @@ static Maybe GetAssignedPromiseAsyncId(Environment* env, Local id_symbol) { Local maybe_async_id; if (!promise->Get(env->context(), id_symbol).ToLocal(&maybe_async_id)) { - return v8::Just(AsyncWrap::kInvalidAsyncId); + return Just(AsyncWrap::kInvalidAsyncId); } return maybe_async_id->IsNumber() - ? maybe_async_id->NumberValue(env->context()) - : v8::Just(AsyncWrap::kInvalidAsyncId); + ? maybe_async_id->NumberValue(env->context()) + : Just(AsyncWrap::kInvalidAsyncId); } void PromiseRejectCallback(PromiseRejectMessage message) { diff --git a/src/node_trace_events.cc b/src/node_trace_events.cc index 9787b14352753c..ea1052f8b6e60e 100644 --- a/src/node_trace_events.cc +++ b/src/node_trace_events.cc @@ -139,7 +139,7 @@ static void GetCategoryEnabledBuffer(const FunctionCallbackInfo& args) { [](void*, size_t, void*) {}, nullptr); auto ab = ArrayBuffer::New(isolate, std::move(bs)); - v8::Local u8 = v8::Uint8Array::New(ab, 0, 1); + Local u8 = Uint8Array::New(ab, 0, 1); args.GetReturnValue().Set(u8); } diff --git a/src/node_url.cc b/src/node_url.cc index 5b854cd9aeaa8b..a945c0299d65dc 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -29,6 +29,7 @@ using v8::Local; using v8::NewStringType; using v8::Object; using v8::ObjectTemplate; +using v8::SnapshotCreator; using v8::String; using v8::Value; @@ -36,7 +37,7 @@ void BindingData::MemoryInfo(MemoryTracker* tracker) const { tracker->TrackField("url_components_buffer", url_components_buffer_); } -BindingData::BindingData(Realm* realm, v8::Local object) +BindingData::BindingData(Realm* realm, Local object) : SnapshotableObject(realm, object, type_int), url_components_buffer_(realm->isolate(), kURLComponentsLength) { object @@ -47,8 +48,8 @@ BindingData::BindingData(Realm* realm, v8::Local object) url_components_buffer_.MakeWeak(); } -bool BindingData::PrepareForSerialization(v8::Local context, - v8::SnapshotCreator* creator) { +bool BindingData::PrepareForSerialization(Local context, + SnapshotCreator* creator) { // We'll just re-initialize the buffers in the constructor since their // contents can be thrown away once consumed in the previous call. url_components_buffer_.Release(); @@ -64,12 +65,12 @@ InternalFieldInfoBase* BindingData::Serialize(int index) { return info; } -void BindingData::Deserialize(v8::Local context, - v8::Local holder, +void BindingData::Deserialize(Local context, + Local holder, int index, InternalFieldInfoBase* info) { DCHECK_IS_SNAPSHOT_SLOT(index); - v8::HandleScope scope(context->GetIsolate()); + HandleScope scope(context->GetIsolate()); Realm* realm = Realm::GetCurrent(context); BindingData* binding = realm->AddBindingData(holder); CHECK_NOT_NULL(binding); @@ -227,7 +228,7 @@ void BindingData::DomainToUnicode(const FunctionCallbackInfo& args) { .ToLocalChecked()); } -void BindingData::GetOrigin(const v8::FunctionCallbackInfo& args) { +void BindingData::GetOrigin(const FunctionCallbackInfo& args) { CHECK_GE(args.Length(), 1); CHECK(args[0]->IsString()); // input @@ -513,21 +514,20 @@ void ThrowInvalidURL(node::Environment* env, auto err_object = err.As(); - USE(err_object->Set(env->context(), - env->input_string(), - v8::String::NewFromUtf8(env->isolate(), - input.data(), - v8::NewStringType::kNormal, - input.size()) - .ToLocalChecked())); + USE(err_object->Set( + env->context(), + env->input_string(), + String::NewFromUtf8( + env->isolate(), input.data(), NewStringType::kNormal, input.size()) + .ToLocalChecked())); if (base.has_value()) { USE(err_object->Set(env->context(), env->base_string(), - v8::String::NewFromUtf8(env->isolate(), - base.value().c_str(), - v8::NewStringType::kNormal, - base.value().size()) + String::NewFromUtf8(env->isolate(), + base.value().c_str(), + NewStringType::kNormal, + base.value().size()) .ToLocalChecked())); } diff --git a/src/node_util.cc b/src/node_util.cc index 9bf5418bf61dfa..df24847740d733 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -18,12 +18,14 @@ using v8::Context; using v8::External; using v8::FunctionCallbackInfo; using v8::IndexFilter; +using v8::Int32; using v8::Integer; using v8::Isolate; using v8::KeyCollectionMode; using v8::Local; using v8::LocalVector; using v8::Name; +using v8::Null; using v8::Object; using v8::ObjectTemplate; using v8::ONLY_CONFIGURABLE; @@ -267,12 +269,12 @@ static void GetCallSites(const FunctionCallbackInfo& args) { Local function_name = stack_frame->GetFunctionName(); if (function_name.IsEmpty()) { - function_name = v8::String::Empty(isolate); + function_name = String::Empty(isolate); } Local script_name = stack_frame->GetScriptName(); if (script_name.IsEmpty()) { - script_name = v8::String::Empty(isolate); + script_name = String::Empty(isolate); } Local names[] = { @@ -287,8 +289,8 @@ static void GetCallSites(const FunctionCallbackInfo& args) { Integer::NewFromUnsigned(isolate, stack_frame->GetLineNumber()), Integer::NewFromUnsigned(isolate, stack_frame->GetColumn()), }; - Local obj = Object::New( - isolate, v8::Null(isolate), names, values, arraysize(names)); + Local obj = + Object::New(isolate, Null(isolate), names, values, arraysize(names)); callsite_objects.push_back(obj); } @@ -304,7 +306,7 @@ static void IsInsideNodeModules(const FunctionCallbackInfo& args) { CHECK(args[0]->IsInt32()); // frame_limit // The second argument is the default value. - int frames_limit = args[0].As()->Value(); + int frames_limit = args[0].As()->Value(); Local stack = StackTrace::CurrentStackTrace(isolate, frames_limit); int frame_count = stack->GetFrameCount(); diff --git a/src/node_v8.cc b/src/node_v8.cc index a7f0ba7973498e..bb2a90b0e15cf2 100644 --- a/src/node_v8.cc +++ b/src/node_v8.cc @@ -35,6 +35,8 @@ using v8::Array; using v8::Context; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; +using v8::GCCallbackFlags; +using v8::GCType; using v8::HandleScope; using v8::HeapCodeStatistics; using v8::HeapSpaceStatistics; @@ -42,8 +44,10 @@ using v8::HeapStatistics; using v8::Integer; using v8::Isolate; using v8::Local; +using v8::NewStringType; using v8::Object; using v8::ScriptCompiler; +using v8::SnapshotCreator; using v8::String; using v8::Uint32; using v8::V8; @@ -134,7 +138,7 @@ BindingData::BindingData(Realm* realm, } bool BindingData::PrepareForSerialization(Local context, - v8::SnapshotCreator* creator) { + SnapshotCreator* creator) { DCHECK_NULL(internal_field_info_); internal_field_info_ = InternalFieldInfoBase::New(type()); internal_field_info_->heap_statistics_buffer = @@ -188,7 +192,7 @@ void CachedDataVersionTag(const FunctionCallbackInfo& args) { void SetHeapSnapshotNearHeapLimit(const FunctionCallbackInfo& args) { CHECK(args[0]->IsUint32()); Environment* env = Environment::GetCurrent(args); - uint32_t limit = args[0].As()->Value(); + uint32_t limit = args[0].As()->Value(); CHECK_GT(limit, 0); env->AddHeapSnapshotNearHeapLimitCallback(); env->set_heap_snapshot_near_heap_limit(limit); @@ -210,7 +214,7 @@ void UpdateHeapSpaceStatisticsBuffer(const FunctionCallbackInfo& args) { HeapSpaceStatistics s; Isolate* const isolate = args.GetIsolate(); CHECK(args[0]->IsUint32()); - size_t space_index = static_cast(args[0].As()->Value()); + size_t space_index = static_cast(args[0].As()->Value()); isolate->GetHeapSpaceStatistics(&s, space_index); AliasedFloat64Array& buffer = data->heap_space_statistics_buffer; @@ -238,15 +242,15 @@ void SetFlagsFromString(const FunctionCallbackInfo& args) { V8::SetFlagsFromString(*flags, static_cast(flags.length())); } -static const char* GetGCTypeName(v8::GCType gc_type) { +static const char* GetGCTypeName(GCType gc_type) { switch (gc_type) { - case v8::GCType::kGCTypeScavenge: + case GCType::kGCTypeScavenge: return "Scavenge"; - case v8::GCType::kGCTypeMarkSweepCompact: + case GCType::kGCTypeMarkSweepCompact: return "MarkSweepCompact"; - case v8::GCType::kGCTypeIncrementalMarking: + case GCType::kGCTypeIncrementalMarking: return "IncrementalMarking"; - case v8::GCType::kGCTypeProcessWeakCallbacks: + case GCType::kGCTypeProcessWeakCallbacks: return "ProcessWeakCallbacks"; default: return "Unknown"; @@ -296,8 +300,8 @@ static void SetHeapStatistics(JSONWriter* writer, Isolate* isolate) { } static void BeforeGCCallback(Isolate* isolate, - v8::GCType gc_type, - v8::GCCallbackFlags flags, + GCType gc_type, + GCCallbackFlags flags, void* data) { GCProfiler* profiler = static_cast(data); if (profiler->current_gc_type != 0) { @@ -314,8 +318,8 @@ static void BeforeGCCallback(Isolate* isolate, } static void AfterGCCallback(Isolate* isolate, - v8::GCType gc_type, - v8::GCCallbackFlags flags, + GCType gc_type, + GCCallbackFlags flags, void* data) { GCProfiler* profiler = static_cast(data); if (profiler->current_gc_type != gc_type) { @@ -391,7 +395,7 @@ void GCProfiler::Start(const FunctionCallbackInfo& args) { profiler->state = GCProfiler::GCProfilerState::kStarted; } -void GCProfiler::Stop(const FunctionCallbackInfo& args) { +void GCProfiler::Stop(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); GCProfiler* profiler; ASSIGN_OR_RETURN_UNWRAP(&profiler, args.This()); @@ -409,11 +413,10 @@ void GCProfiler::Stop(const FunctionCallbackInfo& args) { profiler->writer()->json_end(); profiler->state = GCProfiler::GCProfilerState::kStopped; auto string = profiler->out_stream()->str(); - args.GetReturnValue().Set(String::NewFromUtf8(env->isolate(), - string.data(), - v8::NewStringType::kNormal, - string.size()) - .ToLocalChecked()); + args.GetReturnValue().Set( + String::NewFromUtf8( + env->isolate(), string.data(), NewStringType::kNormal, string.size()) + .ToLocalChecked()); } void Initialize(Local target, diff --git a/src/node_wasi.cc b/src/node_wasi.cc index e4503a8c6a70dc..2d4b39348bf363 100644 --- a/src/node_wasi.cc +++ b/src/node_wasi.cc @@ -30,6 +30,7 @@ using v8::Array; using v8::ArrayBuffer; using v8::BigInt; using v8::CFunction; +using v8::ConstructorBehavior; using v8::Context; using v8::Exception; using v8::FastApiCallbackOptions; @@ -40,7 +41,9 @@ using v8::Integer; using v8::Isolate; using v8::Local; using v8::MaybeLocal; +using v8::NewStringType; using v8::Object; +using v8::SideEffectType; using v8::Signature; using v8::String; using v8::Uint32; @@ -217,10 +220,10 @@ void WASI::WasiFunction::SetFunction( Local(), Local(), sizeof...(Args), - v8::ConstructorBehavior::kThrow, - v8::SideEffectType::kHasSideEffect, + ConstructorBehavior::kThrow, + SideEffectType::kHasSideEffect, &c_function); - const v8::NewStringType type = v8::NewStringType::kInternalized; + const NewStringType type = NewStringType::kInternalized; Local name_string = String::NewFromUtf8(env->isolate(), name, type).ToLocalChecked(); tmpl->PrototypeTemplate()->Set(name_string, t); diff --git a/src/node_watchdog.cc b/src/node_watchdog.cc index 4403bd4f157bff..03b11d3098cca1 100644 --- a/src/node_watchdog.cc +++ b/src/node_watchdog.cc @@ -37,11 +37,11 @@ using v8::FunctionTemplate; using v8::Isolate; using v8::Local; using v8::Object; +using v8::StackTrace; using v8::Value; -Watchdog::Watchdog(v8::Isolate* isolate, uint64_t ms, bool* timed_out) +Watchdog::Watchdog(Isolate* isolate, uint64_t ms, bool* timed_out) : isolate_(isolate), timed_out_(timed_out) { - int rc; rc = uv_loop_init(&loop_); if (rc != 0) { @@ -65,7 +65,6 @@ Watchdog::Watchdog(v8::Isolate* isolate, uint64_t ms, bool* timed_out) CHECK_EQ(0, rc); } - Watchdog::~Watchdog() { uv_async_send(&async_); uv_thread_join(&thread_); @@ -98,9 +97,7 @@ void Watchdog::Timer(uv_timer_t* timer) { uv_stop(&w->loop_); } - -SigintWatchdog::SigintWatchdog( - v8::Isolate* isolate, bool* received_signal) +SigintWatchdog::SigintWatchdog(Isolate* isolate, bool* received_signal) : isolate_(isolate), received_signal_(received_signal) { Mutex::ScopedLock lock(SigintWatchdogHelper::GetInstanceActionMutex()); // Register this watchdog with the global SIGINT/Ctrl+C listener. @@ -109,7 +106,6 @@ SigintWatchdog::SigintWatchdog( SigintWatchdogHelper::GetInstance()->Start(); } - SigintWatchdog::~SigintWatchdog() { Mutex::ScopedLock lock(SigintWatchdogHelper::GetInstanceActionMutex()); SigintWatchdogHelper::GetInstance()->Unregister(this); @@ -186,7 +182,7 @@ SignalPropagation TraceSigintWatchdog::HandleSigint() { */ CHECK_EQ(uv_async_send(&handle_), 0); env()->isolate()->RequestInterrupt( - [](v8::Isolate* isolate, void* data) { + [](Isolate* isolate, void* data) { TraceSigintWatchdog* self = static_cast(data); if (self->signal_flag_ == SignalFlags::None) { self->signal_flag_ = SignalFlags::FromInterrupt; @@ -215,8 +211,8 @@ void TraceSigintWatchdog::HandleInterrupt() { "KEYBOARD_INTERRUPT: Script execution was interrupted by `SIGINT`\n"); if (signal_flag_ == SignalFlags::FromInterrupt) { PrintStackTrace(env_->isolate(), - v8::StackTrace::CurrentStackTrace( - env_->isolate(), 10, v8::StackTrace::kDetailed)); + StackTrace::CurrentStackTrace( + env_->isolate(), 10, StackTrace::kDetailed)); } signal_flag_ = SignalFlags::None; interrupting = false; diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 90307cd4984ae5..b11a8beafd2b4e 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -56,6 +56,7 @@ using v8::Integer; using v8::Isolate; using v8::Local; using v8::Object; +using v8::Uint32; using v8::Uint32Array; using v8::Value; @@ -1297,7 +1298,7 @@ struct MakeClass { }; template -T CallOnSequence(v8::Isolate* isolate, Local value, F callback) { +T CallOnSequence(Isolate* isolate, Local value, F callback) { if (value->IsString()) { Utf8Value data(isolate, value); return callback(data.out(), data.length()); @@ -1311,7 +1312,7 @@ T CallOnSequence(v8::Isolate* isolate, Local value, F callback) { static void CRC32(const FunctionCallbackInfo& args) { CHECK(args[0]->IsArrayBufferView() || args[0]->IsString()); CHECK(args[1]->IsUint32()); - uint32_t value = args[1].As()->Value(); + uint32_t value = args[1].As()->Value(); uint32_t result = CallOnSequence( args.GetIsolate(), diff --git a/src/permission/permission.cc b/src/permission/permission.cc index 7c84aa044dbbf5..d631cf3f654dc3 100644 --- a/src/permission/permission.cc +++ b/src/permission/permission.cc @@ -17,6 +17,8 @@ namespace node { using v8::Context; using v8::FunctionCallbackInfo; +using v8::IntegrityLevel; +using v8::Isolate; using v8::Local; using v8::MaybeLocal; using v8::NewStringType; @@ -32,7 +34,7 @@ namespace { // permission.has('fs.in') static void Has(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - v8::Isolate* isolate = env->isolate(); + Isolate* isolate = env->isolate(); CHECK(args[0]->IsString()); String::Utf8Value utf8_deny_scope(isolate, args[0]); @@ -167,7 +169,7 @@ void Initialize(Local target, void* priv) { SetMethodNoSideEffect(context, target, "has", Has); - target->SetIntegrityLevel(context, v8::IntegrityLevel::kFrozen).FromJust(); + target->SetIntegrityLevel(context, IntegrityLevel::kFrozen).FromJust(); } void RegisterExternalReferences(ExternalReferenceRegistry* registry) { diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 38a08432616e9b..51bed6ce538376 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -177,7 +177,7 @@ void PipeWrap::SetPendingInstances(const FunctionCallbackInfo& args) { } #endif -void PipeWrap::Fchmod(const v8::FunctionCallbackInfo& args) { +void PipeWrap::Fchmod(const FunctionCallbackInfo& args) { PipeWrap* wrap; ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This()); CHECK(args[0]->IsInt32()); diff --git a/src/quic/application.cc b/src/quic/application.cc index 4c126a64ed7138..ccc93bf1a47982 100644 --- a/src/quic/application.cc +++ b/src/quic/application.cc @@ -17,6 +17,7 @@ namespace node { +using v8::Array; using v8::Just; using v8::Local; using v8::Maybe; @@ -155,7 +156,7 @@ bool Session::Application::CanAddHeader(size_t current_count, bool Session::Application::SendHeaders(const Stream& stream, HeadersKind kind, - const v8::Local& headers, + const Local& headers, HeadersFlags flags) { // By default do nothing. return false; diff --git a/src/quic/data.cc b/src/quic/data.cc index 06120dd69591b1..7f4702c9bf6458 100644 --- a/src/quic/data.cc +++ b/src/quic/data.cc @@ -13,6 +13,9 @@ namespace node { using v8::Array; +using v8::ArrayBuffer; +using v8::ArrayBufferView; +using v8::BackingStore; using v8::BigInt; using v8::Integer; using v8::Local; @@ -72,30 +75,26 @@ bool PathStorage::operator!=(const PathStorage& other) const { // ============================================================================ -Store::Store(std::shared_ptr store, - size_t length, - size_t offset) +Store::Store(std::shared_ptr store, size_t length, size_t offset) : store_(std::move(store)), length_(length), offset_(offset) { CHECK_LE(offset_, store_->ByteLength()); CHECK_LE(length_, store_->ByteLength() - offset_); } -Store::Store(std::unique_ptr store, - size_t length, - size_t offset) +Store::Store(std::unique_ptr store, size_t length, size_t offset) : store_(std::move(store)), length_(length), offset_(offset) { CHECK_LE(offset_, store_->ByteLength()); CHECK_LE(length_, store_->ByteLength() - offset_); } -Store::Store(v8::Local buffer, Option option) +Store::Store(Local buffer, Option option) : Store(buffer->GetBackingStore(), buffer->ByteLength()) { if (option == Option::DETACH) { USE(buffer->Detach(Local())); } } -Store::Store(v8::Local view, Option option) +Store::Store(Local view, Option option) : Store(view->Buffer()->GetBackingStore(), view->ByteLength(), view->ByteOffset()) { @@ -104,12 +103,11 @@ Store::Store(v8::Local view, Option option) } } -v8::Local Store::ToUint8Array(Environment* env) const { +Local Store::ToUint8Array(Environment* env) const { return !store_ - ? Uint8Array::New(v8::ArrayBuffer::New(env->isolate(), 0), 0, 0) - : Uint8Array::New(v8::ArrayBuffer::New(env->isolate(), store_), - offset_, - length_); + ? Uint8Array::New(ArrayBuffer::New(env->isolate(), 0), 0, 0) + : Uint8Array::New( + ArrayBuffer::New(env->isolate(), store_), offset_, length_); } Store::operator bool() const { diff --git a/src/quic/endpoint.cc b/src/quic/endpoint.cc index bff3ced8a2b8ab..b956d91ebe3c6d 100644 --- a/src/quic/endpoint.cc +++ b/src/quic/endpoint.cc @@ -213,7 +213,7 @@ Maybe Endpoint::Options::From(Environment* env, "The address option must be a SocketAddress"); return Nothing(); } - auto addr = FromJSObject(address.As()); + auto addr = FromJSObject(address.As()); options.local_address = addr->address(); } else { options.local_address = std::make_shared(); diff --git a/src/quic/http3.cc b/src/quic/http3.cc index 6160596be1867b..c46b6c8abea5db 100644 --- a/src/quic/http3.cc +++ b/src/quic/http3.cc @@ -19,6 +19,7 @@ namespace node { +using v8::Array; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; using v8::Local; @@ -403,7 +404,7 @@ class Http3ApplicationImpl final : public Session::Application { bool SendHeaders(const Stream& stream, HeadersKind kind, - const v8::Local& headers, + const Local& headers, HeadersFlags flags = HeadersFlags::NONE) override { Session::SendPendingDataScope send_scope(&session()); Http3Headers nva(env(), headers); diff --git a/src/quic/logstream.cc b/src/quic/logstream.cc index ed84cad15ec950..4fc92f388ee973 100644 --- a/src/quic/logstream.cc +++ b/src/quic/logstream.cc @@ -35,7 +35,7 @@ Local LogStream::GetConstructorTemplate(Environment* env) { } BaseObjectPtr LogStream::Create(Environment* env) { - v8::Local obj; + Local obj; if (!GetConstructorTemplate(env) ->InstanceTemplate() ->NewInstance(env->context()) diff --git a/src/quic/preferredaddress.cc b/src/quic/preferredaddress.cc index 42788d4afc136b..4b5335039be20b 100644 --- a/src/quic/preferredaddress.cc +++ b/src/quic/preferredaddress.cc @@ -15,6 +15,7 @@ using v8::Just; using v8::Local; using v8::Maybe; using v8::Nothing; +using v8::Object; using v8::Uint32; using v8::Value; @@ -157,8 +158,7 @@ Maybe PreferredAddress::tryGetPolicy( return Nothing(); } -void PreferredAddress::Initialize(Environment* env, - v8::Local target) { +void PreferredAddress::Initialize(Environment* env, Local target) { NODE_DEFINE_CONSTANT(target, PREFERRED_ADDRESS_IGNORE); NODE_DEFINE_CONSTANT(target, PREFERRED_ADDRESS_USE); NODE_DEFINE_CONSTANT(target, DEFAULT_PREFERRED_ADDRESS_POLICY); diff --git a/src/quic/sessionticket.cc b/src/quic/sessionticket.cc index 701d6d2eb16856..efaeb51c456e3d 100644 --- a/src/quic/sessionticket.cc +++ b/src/quic/sessionticket.cc @@ -38,7 +38,7 @@ SessionTicket::SessionTicket(Store&& ticket, Store&& transport_params) transport_params_(std::move(transport_params)) {} Maybe SessionTicket::FromV8Value(Environment* env, - v8::Local value) { + Local value) { if (!value->IsArrayBufferView()) { THROW_ERR_INVALID_ARG_TYPE(env, "The ticket must be an ArrayBufferView."); return Nothing(); diff --git a/src/quic/streams.cc b/src/quic/streams.cc index f7b2ed275f9e15..f4c68049d287c7 100644 --- a/src/quic/streams.cc +++ b/src/quic/streams.cc @@ -123,11 +123,9 @@ void PendingStream::reject(QuicError error) { struct Stream::PendingHeaders { HeadersKind kind; - v8::Global headers; + Global headers; HeadersFlags flags; - PendingHeaders(HeadersKind kind_, - v8::Global headers_, - HeadersFlags flags_) + PendingHeaders(HeadersKind kind_, Global headers_, HeadersFlags flags_) : kind(kind_), headers(std::move(headers_)), flags(flags_) {} DISALLOW_COPY_AND_MOVE(PendingHeaders) }; @@ -813,7 +811,7 @@ BaseObjectPtr Stream::Create(Session* session, } Stream::Stream(BaseObjectWeakPtr session, - v8::Local object, + Local object, int64_t id, std::shared_ptr source) : AsyncWrap(session->env(), object, AsyncWrap::PROVIDER_QUIC_STREAM), @@ -846,7 +844,7 @@ Stream::Stream(BaseObjectWeakPtr session, } Stream::Stream(BaseObjectWeakPtr session, - v8::Local object, + Local object, Direction direction, std::shared_ptr source) : AsyncWrap(session->env(), object, AsyncWrap::PROVIDER_QUIC_STREAM), diff --git a/src/quic/tlscontext.cc b/src/quic/tlscontext.cc index 8e2995589c9116..d9a9c24714e493 100644 --- a/src/quic/tlscontext.cc +++ b/src/quic/tlscontext.cc @@ -20,13 +20,16 @@ namespace node { +using v8::Array; using v8::ArrayBuffer; +using v8::ArrayBufferView; using v8::Just; using v8::Local; using v8::Maybe; using v8::MaybeLocal; using v8::Nothing; using v8::Object; +using v8::String; using v8::Value; namespace quic { @@ -74,9 +77,9 @@ void EnableTrace(Environment* env, crypto::BIOPointer* bio, SSL* ssl) { template Opt::*member> bool SetOption(Environment* env, Opt* options, - const v8::Local& object, - const v8::Local& name) { - v8::Local value; + const Local& object, + const Local& name) { + Local value; if (!object->Get(env->context(), name).ToLocal(&value)) return false; if (value->IsUndefined()) return true; @@ -85,10 +88,10 @@ bool SetOption(Environment* env, if (value->IsArray()) { auto context = env->context(); - auto values = value.As(); + auto values = value.As(); uint32_t count = values->Length(); for (uint32_t n = 0; n < count; n++) { - v8::Local item; + Local item; if (!values->Get(context, n).ToLocal(&item)) { return false; } @@ -105,9 +108,9 @@ bool SetOption(Environment* env, } } else if constexpr (std::is_same::value) { if (item->IsArrayBufferView()) { - (options->*member).emplace_back(item.As()); + (options->*member).emplace_back(item.As()); } else if (item->IsArrayBuffer()) { - (options->*member).emplace_back(item.As()); + (options->*member).emplace_back(item.As()); } else { Utf8Value namestr(env->isolate(), name); THROW_ERR_INVALID_ARG_TYPE( @@ -130,9 +133,9 @@ bool SetOption(Environment* env, } } else if constexpr (std::is_same::value) { if (value->IsArrayBufferView()) { - (options->*member).emplace_back(value.As()); + (options->*member).emplace_back(value.As()); } else if (value->IsArrayBuffer()) { - (options->*member).emplace_back(value.As()); + (options->*member).emplace_back(value.As()); } else { Utf8Value namestr(env->isolate(), name); THROW_ERR_INVALID_ARG_TYPE( diff --git a/src/quic/transportparams.cc b/src/quic/transportparams.cc index 0f54fe2d499060..f4f5475ae3d6da 100644 --- a/src/quic/transportparams.cc +++ b/src/quic/transportparams.cc @@ -15,6 +15,7 @@ namespace node { using v8::ArrayBuffer; +using v8::BackingStoreInitializationMode; using v8::Just; using v8::Local; using v8::Maybe; @@ -193,7 +194,7 @@ Store TransportParams::Encode(Environment* env, int version) const { } auto result = ArrayBuffer::NewBackingStore( - env->isolate(), size, v8::BackingStoreInitializationMode::kUninitialized); + env->isolate(), size, BackingStoreInitializationMode::kUninitialized); auto ret = ngtcp2_transport_params_encode_versioned( static_cast(result->Data()), size, version, ¶ms_); @@ -279,8 +280,7 @@ const QuicError& TransportParams::error() const { return error_; } -void TransportParams::Initialize(Environment* env, - v8::Local target) { +void TransportParams::Initialize(Environment* env, Local target) { NODE_DEFINE_CONSTANT(target, DEFAULT_MAX_STREAM_DATA); NODE_DEFINE_CONSTANT(target, DEFAULT_MAX_DATA); NODE_DEFINE_CONSTANT(target, DEFAULT_MAX_IDLE_TIMEOUT); diff --git a/src/signal_wrap.cc b/src/signal_wrap.cc index d4fe8a3bcdd9ff..b0b25d50b0e7f5 100644 --- a/src/signal_wrap.cc +++ b/src/signal_wrap.cc @@ -94,7 +94,7 @@ class SignalWrap : public HandleWrap { CHECK_EQ(r, 0); } - void Close(v8::Local close_callback) override { + void Close(Local close_callback) override { if (active_) { DecreaseSignalHandlerCount(handle_.signum); active_ = false; diff --git a/src/stream_base.cc b/src/stream_base.cc index 9d855c2992492d..3e16b76e9ebcee 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -40,10 +40,10 @@ using v8::Signature; using v8::String; using v8::Value; -int StreamBase::Shutdown(v8::Local req_wrap_obj) { +int StreamBase::Shutdown(Local req_wrap_obj) { Environment* env = stream_env(); - v8::HandleScope handle_scope(env->isolate()); + HandleScope handle_scope(env->isolate()); if (req_wrap_obj.IsEmpty()) { if (!env->shutdown_wrap_template() @@ -82,7 +82,7 @@ int StreamBase::Shutdown(v8::Local req_wrap_obj) { StreamWriteResult StreamBase::Write(uv_buf_t* bufs, size_t count, uv_stream_t* send_handle, - v8::Local req_wrap_obj, + Local req_wrap_obj, bool skip_try_write) { Environment* env = stream_env(); int err; @@ -98,7 +98,7 @@ StreamWriteResult StreamBase::Write(uv_buf_t* bufs, } } - v8::HandleScope handle_scope(env->isolate()); + HandleScope handle_scope(env->isolate()); if (req_wrap_obj.IsEmpty()) { if (!env->write_wrap_template() @@ -492,13 +492,13 @@ Local StreamBase::GetObject() { return GetAsyncWrap()->object(); } -void StreamBase::AddAccessor(v8::Isolate* isolate, - v8::Local signature, - enum v8::PropertyAttribute attributes, - v8::Local t, +void StreamBase::AddAccessor(Isolate* isolate, + Local signature, + enum PropertyAttribute attributes, + Local t, JSMethodFunction* getter, JSMethodFunction* setter, - v8::Local string) { + Local string) { Local getter_templ = NewFunctionTemplate(isolate, getter, @@ -869,7 +869,7 @@ void StreamReq::Done(int status, const char* error_str) { AsyncWrap* async_wrap = GetAsyncWrap(); Environment* env = async_wrap->env(); if (error_str != nullptr) { - v8::HandleScope handle_scope(env->isolate()); + HandleScope handle_scope(env->isolate()); if (async_wrap->object() ->Set(env->context(), env->error_string(), diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index d7fa2bb48b5883..96240178b0a1e2 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -52,6 +52,7 @@ using v8::Local; using v8::Maybe; using v8::MaybeLocal; using v8::Nothing; +using v8::Null; using v8::Object; using v8::PropertyAttribute; using v8::ReadOnly; @@ -81,11 +82,11 @@ void LibuvStreamWrap::Initialize(Local target, // - oncomplete // - callback // - handle - sw->InstanceTemplate()->Set(env->oncomplete_string(), v8::Null(isolate)); + sw->InstanceTemplate()->Set(env->oncomplete_string(), Null(isolate)); sw->InstanceTemplate()->Set(FIXED_ONE_BYTE_STRING(isolate, "callback"), - v8::Null(isolate)); + Null(isolate)); sw->InstanceTemplate()->Set(FIXED_ONE_BYTE_STRING(isolate, "handle"), - v8::Null(isolate)); + Null(isolate)); sw->Inherit(AsyncWrap::GetConstructorTemplate(env)); diff --git a/src/string_bytes.cc b/src/string_bytes.cc index 8a94d0eb63245c..15b4fb3f916cd1 100644 --- a/src/string_bytes.cc +++ b/src/string_bytes.cc @@ -46,7 +46,9 @@ using v8::Just; using v8::Local; using v8::Maybe; using v8::MaybeLocal; +using v8::NewStringType; using v8::Nothing; +using v8::Object; using v8::String; using v8::Value; @@ -171,7 +173,7 @@ MaybeLocal ExternOneByteString::NewSimpleFromCopy(Isolate* isolate, MaybeLocal str = String::NewFromOneByte(isolate, reinterpret_cast(data), - v8::NewStringType::kNormal, + NewStringType::kNormal, length); if (str.IsEmpty()) { *error = node::ERR_STRING_TOO_LONG(isolate); @@ -187,10 +189,7 @@ MaybeLocal ExternTwoByteString::NewSimpleFromCopy(Isolate* isolate, size_t length, Local* error) { MaybeLocal str = - String::NewFromTwoByte(isolate, - data, - v8::NewStringType::kNormal, - length); + String::NewFromTwoByte(isolate, data, NewStringType::kNormal, length); if (str.IsEmpty()) { *error = node::ERR_STRING_TOO_LONG(isolate); return MaybeLocal(); @@ -510,7 +509,7 @@ MaybeLocal StringBytes::Encode(Isolate* isolate, case BUFFER: { auto maybe_buf = Buffer::Copy(isolate, buf, buflen); - Local buf; + Local buf; if (!maybe_buf.ToLocal(&buf)) { *error = node::ERR_MEMORY_ALLOCATION_FAILED(isolate); } @@ -533,13 +532,10 @@ MaybeLocal StringBytes::Encode(Isolate* isolate, case UTF8: { - val = String::NewFromUtf8(isolate, - buf, - v8::NewStringType::kNormal, - buflen); - Local str; - if (!val.ToLocal(&str)) { - *error = node::ERR_STRING_TOO_LONG(isolate); + val = String::NewFromUtf8(isolate, buf, NewStringType::kNormal, buflen); + Local str; + if (!val.ToLocal(&str)) { + *error = node::ERR_STRING_TOO_LONG(isolate); } return str; } diff --git a/src/string_decoder.cc b/src/string_decoder.cc index 5493bc1d9cc871..95e28e1256eedd 100644 --- a/src/string_decoder.cc +++ b/src/string_decoder.cc @@ -16,6 +16,7 @@ using v8::Integer; using v8::Isolate; using v8::Local; using v8::MaybeLocal; +using v8::NewStringType; using v8::Object; using v8::String; using v8::Value; @@ -32,9 +33,9 @@ MaybeLocal MakeString(Isolate* isolate, MaybeLocal ret; if (encoding == UTF8) { MaybeLocal utf8_string; - if (length <= static_cast(v8::String::kMaxLength)) { - utf8_string = String::NewFromUtf8( - isolate, data, v8::NewStringType::kNormal, length); + if (length <= static_cast(String::kMaxLength)) { + utf8_string = + String::NewFromUtf8(isolate, data, NewStringType::kNormal, length); } if (utf8_string.IsEmpty()) { isolate->ThrowException(node::ERR_STRING_TOO_LONG(isolate)); diff --git a/src/timers.cc b/src/timers.cc index c7ba22a078fb5f..585e8f382e9643 100644 --- a/src/timers.cc +++ b/src/timers.cc @@ -9,14 +9,17 @@ namespace node { namespace timers { +using v8::CFunction; using v8::Context; using v8::Function; using v8::FunctionCallbackInfo; +using v8::HandleScope; using v8::Isolate; using v8::Local; using v8::Number; using v8::Object; using v8::ObjectTemplate; +using v8::SnapshotCreator; using v8::Value; void BindingData::SetupTimers(const FunctionCallbackInfo& args) { @@ -58,8 +61,7 @@ void BindingData::ScheduleTimerImpl(BindingData* data, int64_t duration) { data->env()->ScheduleTimer(duration); } -void BindingData::SlowToggleTimerRef( - const v8::FunctionCallbackInfo& args) { +void BindingData::SlowToggleTimerRef(const FunctionCallbackInfo& args) { ToggleTimerRefImpl(Realm::GetBindingData(args), args[0]->IsTrue()); } @@ -75,7 +77,7 @@ void BindingData::ToggleTimerRefImpl(BindingData* data, bool ref) { } void BindingData::SlowToggleImmediateRef( - const v8::FunctionCallbackInfo& args) { + const FunctionCallbackInfo& args) { ToggleImmediateRefImpl(Realm::GetBindingData(args), args[0]->IsTrue()); } @@ -94,7 +96,7 @@ BindingData::BindingData(Realm* realm, Local object) : SnapshotableObject(realm, object, type_int) {} bool BindingData::PrepareForSerialization(Local context, - v8::SnapshotCreator* creator) { + SnapshotCreator* creator) { // Return true because we need to maintain the reference to the binding from // JS land. return true; @@ -112,21 +114,20 @@ void BindingData::Deserialize(Local context, int index, InternalFieldInfoBase* info) { DCHECK_IS_SNAPSHOT_SLOT(index); - v8::HandleScope scope(context->GetIsolate()); + HandleScope scope(context->GetIsolate()); Realm* realm = Realm::GetCurrent(context); // Recreate the buffer in the constructor. BindingData* binding = realm->AddBindingData(holder); CHECK_NOT_NULL(binding); } -v8::CFunction BindingData::fast_get_libuv_now_( - v8::CFunction::Make(FastGetLibuvNow)); -v8::CFunction BindingData::fast_schedule_timers_( - v8::CFunction::Make(FastScheduleTimer)); -v8::CFunction BindingData::fast_toggle_timer_ref_( - v8::CFunction::Make(FastToggleTimerRef)); -v8::CFunction BindingData::fast_toggle_immediate_ref_( - v8::CFunction::Make(FastToggleImmediateRef)); +CFunction BindingData::fast_get_libuv_now_(CFunction::Make(FastGetLibuvNow)); +CFunction BindingData::fast_schedule_timers_( + CFunction::Make(FastScheduleTimer)); +CFunction BindingData::fast_toggle_timer_ref_( + CFunction::Make(FastToggleTimerRef)); +CFunction BindingData::fast_toggle_immediate_ref_( + CFunction::Make(FastToggleImmediateRef)); void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data, Local target) { diff --git a/src/tracing/agent.cc b/src/tracing/agent.cc index 7ce59674356f97..83ad45423155bb 100644 --- a/src/tracing/agent.cc +++ b/src/tracing/agent.cc @@ -7,6 +7,11 @@ #include "env-inl.h" namespace node { + +using v8::ConvertableToTraceFormat; +using v8::platform::tracing::TraceConfig; +using v8::platform::tracing::TraceWriter; + namespace tracing { class Agent::ScopedSuspendTracing { @@ -45,10 +50,6 @@ std::set flatten( } // namespace -using v8::platform::tracing::TraceConfig; -using v8::platform::tracing::TraceWriter; -using std::string; - Agent::Agent() : tracing_controller_(new TracingController()) { tracing_controller_->Initialize(nullptr); @@ -230,7 +231,7 @@ void TracingController::AddMetadataEvent( const char** arg_names, const unsigned char* arg_types, const uint64_t* arg_values, - std::unique_ptr* convertable_values, + std::unique_ptr* convertable_values, unsigned int flags) { std::unique_ptr trace_event(new TraceObject); trace_event->Initialize( diff --git a/src/tracing/trace_event.cc b/src/tracing/trace_event.cc index 35acb8a9a8fd10..d9b3d8f02d8121 100644 --- a/src/tracing/trace_event.cc +++ b/src/tracing/trace_event.cc @@ -2,6 +2,7 @@ #include "node.h" namespace node { + namespace tracing { Agent* g_agent = nullptr; diff --git a/src/util.cc b/src/util.cc index 8bf239db6e47d4..811bfb09489488 100644 --- a/src/util.cc +++ b/src/util.cc @@ -87,12 +87,28 @@ namespace node { using v8::ArrayBuffer; using v8::ArrayBufferView; +using v8::CFunction; +using v8::ConstructorBehavior; using v8::Context; +using v8::Function; +using v8::FunctionCallback; using v8::FunctionTemplate; +using v8::Int32; using v8::Isolate; +using v8::JSON; +using v8::Just; using v8::Local; +using v8::Maybe; +using v8::MaybeLocal; +using v8::MemorySpan; +using v8::NewStringType; +using v8::Nothing; +using v8::Number; using v8::Object; +using v8::SideEffectType; +using v8::Signature; using v8::String; +using v8::Symbol; using v8::Template; using v8::Value; @@ -277,9 +293,7 @@ int WriteFileSync(const char* path, uv_buf_t* bufs, size_t buf_count) { return err; } -int WriteFileSync(v8::Isolate* isolate, - const char* path, - v8::Local string) { +int WriteFileSync(Isolate* isolate, const char* path, Local string) { node::Utf8Value utf8(isolate, string); uv_buf_t buf = uv_buf_init(utf8.out(), utf8.length()); return WriteFileSync(path, buf); @@ -394,59 +408,57 @@ std::string DiagnosticFilename::MakeFilename( return oss.str(); } -Local NewFunctionTemplate( - v8::Isolate* isolate, - v8::FunctionCallback callback, - Local signature, - v8::ConstructorBehavior behavior, - v8::SideEffectType side_effect_type, - const v8::CFunction* c_function) { - return v8::FunctionTemplate::New(isolate, - callback, - Local(), - signature, - 0, - behavior, - side_effect_type, - c_function); -} - -void SetMethod(Local context, - Local that, +Local NewFunctionTemplate(Isolate* isolate, + FunctionCallback callback, + Local signature, + ConstructorBehavior behavior, + SideEffectType side_effect_type, + const CFunction* c_function) { + return FunctionTemplate::New(isolate, + callback, + Local(), + signature, + 0, + behavior, + side_effect_type, + c_function); +} + +void SetMethod(Local context, + Local that, const std::string_view name, - v8::FunctionCallback callback) { + FunctionCallback callback) { Isolate* isolate = context->GetIsolate(); - Local function = - NewFunctionTemplate(isolate, - callback, - Local(), - v8::ConstructorBehavior::kThrow, - v8::SideEffectType::kHasSideEffect) - ->GetFunction(context) - .ToLocalChecked(); + Local function = NewFunctionTemplate(isolate, + callback, + Local(), + ConstructorBehavior::kThrow, + SideEffectType::kHasSideEffect) + ->GetFunction(context) + .ToLocalChecked(); // kInternalized strings are created in the old space. - const v8::NewStringType type = v8::NewStringType::kInternalized; - Local name_string = - v8::String::NewFromUtf8(isolate, name.data(), type, name.size()) + const NewStringType type = NewStringType::kInternalized; + Local name_string = + String::NewFromUtf8(isolate, name.data(), type, name.size()) .ToLocalChecked(); that->Set(context, name_string, function).Check(); function->SetName(name_string); // NODE_SET_METHOD() compatibility. } -void SetMethod(v8::Isolate* isolate, - v8::Local that, +void SetMethod(Isolate* isolate, + Local