diff --git a/src/env.cc b/src/env.cc index 4fdfcafaa142b6..a39c51c26d17d7 100644 --- a/src/env.cc +++ b/src/env.cc @@ -15,6 +15,8 @@ namespace node { using v8::Context; +using v8::EmbedderGraph; +using v8::External; using v8::Function; using v8::FunctionTemplate; using v8::HandleScope; @@ -22,13 +24,19 @@ using v8::Integer; using v8::Isolate; using v8::Local; using v8::Message; +using v8::NewStringType; using v8::Number; +using v8::Object; using v8::Private; +using v8::Promise; +using v8::PromiseHookType; using v8::StackFrame; using v8::StackTrace; using v8::String; using v8::Symbol; +using v8::TracingController; using v8::TryCatch; +using v8::Undefined; using v8::Value; using worker::Worker; @@ -89,7 +97,7 @@ IsolateData::IsolateData(Isolate* isolate, String::NewFromOneByte( \ isolate, \ reinterpret_cast(StringValue), \ - v8::NewStringType::kInternalized, \ + NewStringType::kInternalized, \ sizeof(StringValue) - 1).ToLocalChecked())); PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(V) #undef V @@ -101,7 +109,7 @@ IsolateData::IsolateData(Isolate* isolate, String::NewFromOneByte( \ isolate, \ reinterpret_cast(StringValue), \ - v8::NewStringType::kInternalized, \ + NewStringType::kInternalized, \ sizeof(StringValue) - 1).ToLocalChecked())); PER_ISOLATE_SYMBOL_PROPERTIES(V) #undef V @@ -111,7 +119,7 @@ IsolateData::IsolateData(Isolate* isolate, String::NewFromOneByte( \ isolate, \ reinterpret_cast(StringValue), \ - v8::NewStringType::kInternalized, \ + NewStringType::kInternalized, \ sizeof(StringValue) - 1).ToLocalChecked()); PER_ISOLATE_STRING_PROPERTIES(V) #undef V @@ -149,7 +157,7 @@ void Environment::TrackingTraceStateObserver::UpdateTraceCategoryState() { return; TryCatch try_catch(isolate); try_catch.SetVerbose(true); - cb->Call(env_->context(), v8::Undefined(isolate), + cb->Call(env_->context(), Undefined(isolate), 0, nullptr).ToLocalChecked(); } @@ -173,9 +181,9 @@ Environment::Environment(IsolateData* isolate_data, fs_stats_field_bigint_array_(isolate_, kFsStatsBufferLength), context_(context->GetIsolate(), context) { // We'll be creating new objects so make sure we've entered the context. - v8::HandleScope handle_scope(isolate()); - v8::Context::Scope context_scope(context); - set_as_external(v8::External::New(isolate(), this)); + HandleScope handle_scope(isolate()); + Context::Scope context_scope(context); + set_as_external(External::New(isolate(), this)); // We create new copies of the per-Environment option sets, so that it is // easier to modify them after Environment creation. The defaults are @@ -194,7 +202,7 @@ Environment::Environment(IsolateData* isolate_data, if (tracing::AgentWriterHandle* writer = GetTracingAgentWriter()) { trace_state_observer_ = std::make_unique(this); - v8::TracingController* tracing_controller = writer->GetTracingController(); + TracingController* tracing_controller = writer->GetTracingController(); if (tracing_controller != nullptr) tracing_controller->AddTraceStateObserver(trace_state_observer_.get()); } @@ -232,7 +240,7 @@ Environment::~Environment() { // CleanupHandles() should have removed all of them. CHECK(file_handle_read_wrap_freelist_.empty()); - v8::HandleScope handle_scope(isolate()); + HandleScope handle_scope(isolate()); #if HAVE_INSPECTOR // Destroy inspector agent before erasing the context. The inspector @@ -246,7 +254,7 @@ Environment::~Environment() { if (trace_state_observer_) { tracing::AgentWriterHandle* writer = GetTracingAgentWriter(); CHECK_NOT_NULL(writer); - v8::TracingController* tracing_controller = writer->GetTracingController(); + TracingController* tracing_controller = writer->GetTracingController(); if (tracing_controller != nullptr) tracing_controller->RemoveTraceStateObserver(trace_state_observer_.get()); } @@ -410,7 +418,7 @@ void Environment::PrintSyncTrace() const { return; HandleScope handle_scope(isolate()); - Local stack = + Local stack = StackTrace::CurrentStackTrace(isolate(), 10, StackTrace::kDetailed); fprintf(stderr, "(node:%d) WARNING: Detected use of sync API\n", @@ -545,10 +553,10 @@ bool Environment::RemovePromiseHook(promise_hook_func fn, void* arg) { return true; } -void Environment::EnvPromiseHook(v8::PromiseHookType type, - v8::Local promise, - v8::Local parent) { - Local context = promise->CreationContext(); +void Environment::EnvPromiseHook(PromiseHookType type, + Local promise, + Local parent) { + Local context = promise->CreationContext(); Environment* env = Environment::GetCurrent(context); if (env == nullptr) return; @@ -568,7 +576,7 @@ void Environment::RunAndClearNativeImmediates() { std::vector list; native_immediate_callbacks_.swap(list); auto drain_list = [&]() { - v8::TryCatch try_catch(isolate()); + TryCatch try_catch(isolate()); for (auto it = list.begin(); it != list.end(); ++it) { #ifdef DEBUG v8::SealHandleScope seal_handle_scope(isolate()); @@ -748,7 +756,7 @@ void Environment::set_debug_categories(const std::string& cats, bool enabled) { } void CollectExceptionInfo(Environment* env, - v8::Local obj, + Local obj, int errorno, const char* err_string, const char* syscall, @@ -757,7 +765,7 @@ void CollectExceptionInfo(Environment* env, const char* dest) { obj->Set(env->context(), env->errno_string(), - v8::Integer::New(env->isolate(), errorno)).FromJust(); + Integer::New(env->isolate(), errorno)).FromJust(); obj->Set(env->context(), env->code_string(), OneByteString(env->isolate(), err_string)).FromJust(); @@ -767,14 +775,14 @@ void CollectExceptionInfo(Environment* env, OneByteString(env->isolate(), message)).FromJust(); } - v8::Local path_buffer; + Local path_buffer; if (path != nullptr) { path_buffer = Buffer::Copy(env->isolate(), path, strlen(path)).ToLocalChecked(); obj->Set(env->context(), env->path_string(), path_buffer).FromJust(); } - v8::Local dest_buffer; + Local dest_buffer; if (dest != nullptr) { dest_buffer = Buffer::Copy(env->isolate(), dest, strlen(dest)).ToLocalChecked(); @@ -787,7 +795,7 @@ void CollectExceptionInfo(Environment* env, } } -void Environment::CollectExceptionInfo(v8::Local object, +void Environment::CollectExceptionInfo(Local object, int errorno, const char* syscall, const char* message, @@ -795,7 +803,7 @@ void Environment::CollectExceptionInfo(v8::Local object, if (!object->IsObject() || errorno == 0) return; - v8::Local obj = object.As(); + Local obj = object.As(); const char* err_string = node::errno_string(errorno); if (message == nullptr || message[0] == '\0') { @@ -806,7 +814,7 @@ void Environment::CollectExceptionInfo(v8::Local object, syscall, message, path, nullptr); } -void Environment::CollectUVExceptionInfo(v8::Local object, +void Environment::CollectUVExceptionInfo(Local object, int errorno, const char* syscall, const char* message, @@ -815,7 +823,7 @@ void Environment::CollectUVExceptionInfo(v8::Local object, if (!object->IsObject() || errorno == 0) return; - v8::Local obj = object.As(); + Local obj = object.As(); const char* err_string = uv_err_name(errorno); if (message == nullptr || message[0] == '\0') { @@ -854,8 +862,8 @@ void Environment::stop_sub_worker_contexts() { } } -void Environment::BuildEmbedderGraph(v8::Isolate* isolate, - v8::EmbedderGraph* graph, +void Environment::BuildEmbedderGraph(Isolate* isolate, + EmbedderGraph* graph, void* data) { MemoryTracker tracker(isolate, graph); static_cast(data)->ForEachBaseObject([&](BaseObject* obj) { diff --git a/src/exceptions.cc b/src/exceptions.cc index 7bbee45467ff35..c0804798e1aad6 100644 --- a/src/exceptions.cc +++ b/src/exceptions.cc @@ -14,6 +14,7 @@ using v8::Integer; using v8::Isolate; using v8::Local; using v8::Message; +using v8::NewStringType; using v8::Object; using v8::String; using v8::Value; @@ -39,7 +40,7 @@ Local ErrnoException(Isolate* isolate, Local path_string; if (path != nullptr) { // FIXME(bnoordhuis) It's questionable to interpret the file path as UTF-8. - path_string = String::NewFromUtf8(isolate, path, v8::NewStringType::kNormal) + path_string = String::NewFromUtf8(isolate, path, NewStringType::kNormal) .ToLocalChecked(); } @@ -75,15 +76,15 @@ static Local StringFromPath(Isolate* isolate, const char* path) { return String::Concat( isolate, FIXED_ONE_BYTE_STRING(isolate, "\\\\"), - String::NewFromUtf8(isolate, path + 8, v8::NewStringType::kNormal) + String::NewFromUtf8(isolate, path + 8, NewStringType::kNormal) .ToLocalChecked()); } else if (strncmp(path, "\\\\?\\", 4) == 0) { - return String::NewFromUtf8(isolate, path + 4, v8::NewStringType::kNormal) + return String::NewFromUtf8(isolate, path + 4, NewStringType::kNormal) .ToLocalChecked(); } #endif - return String::NewFromUtf8(isolate, path, v8::NewStringType::kNormal) + return String::NewFromUtf8(isolate, path, NewStringType::kNormal) .ToLocalChecked(); } @@ -196,7 +197,7 @@ Local WinapiErrnoException(Isolate* isolate, Local cons2 = String::Concat( isolate, cons1, - String::NewFromUtf8(isolate, path, v8::NewStringType::kNormal) + String::NewFromUtf8(isolate, path, NewStringType::kNormal) .ToLocalChecked()); Local cons3 = String::Concat(isolate, cons2, FIXED_ONE_BYTE_STRING(isolate, "'")); @@ -210,7 +211,7 @@ Local WinapiErrnoException(Isolate* isolate, if (path != nullptr) { obj->Set(env->path_string(), - String::NewFromUtf8(isolate, path, v8::NewStringType::kNormal) + String::NewFromUtf8(isolate, path, NewStringType::kNormal) .ToLocalChecked()); }