diff --git a/src/api/environment.cc b/src/api/environment.cc index 77c20a4b6b9db4..9451a43d6a11d7 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -30,7 +30,7 @@ using v8::Function; using v8::FunctionCallbackInfo; using v8::HandleScope; using v8::Isolate; -using v8::Just; +using v8::JustVoid; using v8::Local; using v8::Maybe; using v8::MaybeLocal; @@ -635,7 +635,7 @@ void ProtoThrower(const FunctionCallbackInfo& info) { // This runs at runtime, regardless of whether the context // is created from a snapshot. -Maybe InitializeContextRuntime(Local context) { +Maybe InitializeContextRuntime(Local context) { Isolate* isolate = context->GetIsolate(); HandleScope handle_scope(isolate); @@ -653,7 +653,7 @@ Maybe InitializeContextRuntime(Local context) { Boolean::New(isolate, is_code_generation_from_strings_allowed)); if (per_process::cli_options->disable_proto == "") { - return Just(true); + return JustVoid(); } // Remove __proto__ @@ -669,14 +669,14 @@ Maybe InitializeContextRuntime(Local context) { if (!context->Global() ->Get(context, object_string) .ToLocal(&object_v)) { - return Nothing(); + return Nothing(); } Local prototype_v; if (!object_v.As() ->Get(context, prototype_string) .ToLocal(&prototype_v)) { - return Nothing(); + return Nothing(); } prototype = prototype_v.As(); @@ -689,13 +689,13 @@ Maybe InitializeContextRuntime(Local context) { if (prototype ->Delete(context, proto_string) .IsNothing()) { - return Nothing(); + return Nothing(); } } else if (per_process::cli_options->disable_proto == "throw") { Local thrower; if (!Function::New(context, ProtoThrower) .ToLocal(&thrower)) { - return Nothing(); + return Nothing(); } PropertyDescriptor descriptor(thrower, thrower); @@ -704,17 +704,17 @@ Maybe InitializeContextRuntime(Local context) { if (prototype ->DefineProperty(context, proto_string, descriptor) .IsNothing()) { - return Nothing(); + return Nothing(); } } else if (per_process::cli_options->disable_proto != "") { // Validated in ProcessGlobalArgs UNREACHABLE("invalid --disable-proto mode"); } - return Just(true); + return JustVoid(); } -Maybe InitializeBaseContextForSnapshot(Local context) { +Maybe InitializeBaseContextForSnapshot(Local context) { Isolate* isolate = context->GetIsolate(); HandleScope handle_scope(isolate); @@ -728,18 +728,18 @@ Maybe InitializeBaseContextForSnapshot(Local context) { Local intl_v; if (!context->Global()->Get(context, intl_string).ToLocal(&intl_v)) { - return Nothing(); + return Nothing(); } if (intl_v->IsObject() && intl_v.As()->Delete(context, break_iter_string).IsNothing()) { - return Nothing(); + return Nothing(); } } - return Just(true); + return JustVoid(); } -Maybe InitializeMainContextForSnapshot(Local context) { +Maybe InitializeMainContextForSnapshot(Local context) { Isolate* isolate = context->GetIsolate(); HandleScope handle_scope(isolate); @@ -750,12 +750,12 @@ Maybe InitializeMainContextForSnapshot(Local context) { ContextEmbedderIndex::kAllowCodeGenerationFromStrings, True(isolate)); if (InitializeBaseContextForSnapshot(context).IsNothing()) { - return Nothing(); + return Nothing(); } return InitializePrimordials(context); } -Maybe InitializePrimordials(Local context) { +Maybe InitializePrimordials(Local context) { // Run per-context JS files. Isolate* isolate = context->GetIsolate(); Context::Scope context_scope(context); @@ -769,7 +769,7 @@ Maybe InitializePrimordials(Local context) { if (primordials->SetPrototype(context, Null(isolate)).IsNothing() || !GetPerContextExports(context).ToLocal(&exports) || exports->Set(context, primordials_string, primordials).IsNothing()) { - return Nothing(); + return Nothing(); } static const char* context_files[] = {"internal/per_context/primordials", @@ -793,17 +793,17 @@ Maybe InitializePrimordials(Local context) { context, *module, arraysize(arguments), arguments, nullptr) .IsEmpty()) { // Execution failed during context creation. - return Nothing(); + return Nothing(); } } - return Just(true); + return JustVoid(); } // This initializes the main context (i.e. vm contexts are not included). -Maybe InitializeContext(Local context) { +Maybe InitializeContext(Local context) { if (InitializeMainContextForSnapshot(context).IsNothing()) { - return Nothing(); + return Nothing(); } return InitializeContextRuntime(context); diff --git a/src/api/hooks.cc b/src/api/hooks.cc index 65d39e6b9ff921..c23bc2d3c9a5b0 100644 --- a/src/api/hooks.cc +++ b/src/api/hooks.cc @@ -10,6 +10,7 @@ using v8::HandleScope; using v8::Integer; using v8::Isolate; using v8::Just; +using v8::JustVoid; using v8::Local; using v8::Maybe; using v8::NewStringType; @@ -30,7 +31,7 @@ void EmitBeforeExit(Environment* env) { USE(EmitProcessBeforeExit(env)); } -Maybe EmitProcessBeforeExit(Environment* env) { +Maybe EmitProcessBeforeExit(Environment* env) { TRACE_EVENT0(TRACING_CATEGORY_NODE1(environment), "BeforeExit"); if (!env->destroy_async_id_list()->empty()) AsyncWrap::DestroyAsyncIdsCallback(env); @@ -40,14 +41,14 @@ Maybe EmitProcessBeforeExit(Environment* env) { Context::Scope context_scope(env->context()); if (!env->can_call_into_js()) { - return Nothing(); + return Nothing(); } Local exit_code = Integer::New( isolate, static_cast(env->exit_code(ExitCode::kNoFailure))); - return ProcessEmit(env, "beforeExit", exit_code).IsEmpty() ? - Nothing() : Just(true); + return ProcessEmit(env, "beforeExit", exit_code).IsEmpty() ? Nothing() + : JustVoid(); } static ExitCode EmitExitInternal(Environment* env) { diff --git a/src/base_object.cc b/src/base_object.cc index 58ceecca2f91d7..c8798fc572d389 100644 --- a/src/base_object.cc +++ b/src/base_object.cc @@ -10,6 +10,7 @@ using v8::FunctionCallbackInfo; using v8::FunctionTemplate; using v8::HandleScope; using v8::Just; +using v8::JustVoid; using v8::Local; using v8::Maybe; using v8::Object; @@ -110,9 +111,9 @@ Maybe>> BaseObject::NestedTransferables() return Just(std::vector>{}); } -Maybe BaseObject::FinalizeTransferRead(Local context, +Maybe BaseObject::FinalizeTransferRead(Local context, ValueDeserializer* deserializer) { - return Just(true); + return JustVoid(); } BaseObject::PointerData* BaseObject::pointer_data() { diff --git a/src/base_object.h b/src/base_object.h index 9a93e41b918ee3..a23fd400d79a37 100644 --- a/src/base_object.h +++ b/src/base_object.h @@ -178,7 +178,7 @@ class BaseObject : public MemoryRetainer { virtual std::unique_ptr CloneForMessaging() const; virtual v8::Maybe>> NestedTransferables() const; - virtual v8::Maybe FinalizeTransferRead( + virtual v8::Maybe FinalizeTransferRead( v8::Local context, v8::ValueDeserializer* deserializer); // Indicates whether this object is expected to use a strong reference during diff --git a/src/node.h b/src/node.h index b447d4bf5a4eb4..20dd8e006abdbe 100644 --- a/src/node.h +++ b/src/node.h @@ -598,7 +598,7 @@ NODE_EXTERN v8::Local NewContext( // Runs Node.js-specific tweaks on an already constructed context // Return value indicates success of operation -NODE_EXTERN v8::Maybe InitializeContext(v8::Local context); +NODE_EXTERN v8::Maybe InitializeContext(v8::Local context); // If `platform` is passed, it will be used to register new Worker instances. // It can be `nullptr`, in which case creating new Workers inside of @@ -850,7 +850,7 @@ NODE_EXTERN void SetTracingController(v8::TracingController* controller); // Run `process.emit('beforeExit')` as it would usually happen when Node.js is // run in standalone mode. -NODE_EXTERN v8::Maybe EmitProcessBeforeExit(Environment* env); +NODE_EXTERN v8::Maybe EmitProcessBeforeExit(Environment* env); NODE_DEPRECATED("Use Maybe version (EmitProcessBeforeExit) instead", NODE_EXTERN void EmitBeforeExit(Environment* env)); // Run `process.emit('exit')` as it would usually happen when Node.js is run diff --git a/src/node_env_var.cc b/src/node_env_var.cc index fdf86f17d460f5..d19d11dc714e08 100644 --- a/src/node_env_var.cc +++ b/src/node_env_var.cc @@ -19,7 +19,6 @@ using v8::HandleScope; using v8::Integer; using v8::Intercepted; using v8::Isolate; -using v8::Just; using v8::JustVoid; using v8::Local; using v8::Maybe; @@ -320,7 +319,7 @@ 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, +Maybe KVStore::AssignToObject(v8::Isolate* isolate, v8::Local context, v8::Local object) { HandleScope scope(isolate); @@ -333,9 +332,9 @@ Maybe KVStore::AssignToObject(v8::Isolate* isolate, ok = ok && key->IsString(); ok = ok && Get(isolate, key.As()).ToLocal(&value); ok = ok && object->Set(context, key, value).To(&ok); - if (!ok) return Nothing(); + if (!ok) return Nothing(); } - return Just(true); + return JustVoid(); } static Intercepted EnvGetter(Local property, diff --git a/src/node_internals.h b/src/node_internals.h index fe2d25decd8830..85b666e11f5654 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -110,10 +110,10 @@ void SignalExit(int signal, siginfo_t* info, void* ucontext); std::string GetProcessTitle(const char* default_title); std::string GetHumanReadableProcessName(); -v8::Maybe InitializeBaseContextForSnapshot( +v8::Maybe InitializeBaseContextForSnapshot( v8::Local context); -v8::Maybe InitializeContextRuntime(v8::Local context); -v8::Maybe InitializePrimordials(v8::Local context); +v8::Maybe InitializeContextRuntime(v8::Local context); +v8::Maybe InitializePrimordials(v8::Local context); class NodeArrayBufferAllocator : public ArrayBufferAllocator { public: diff --git a/src/node_messaging.cc b/src/node_messaging.cc index 19633f786727bf..2a3938d77f12c5 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -25,6 +25,7 @@ using v8::Global; using v8::HandleScope; using v8::Isolate; using v8::Just; +using v8::JustVoid; using v8::Local; using v8::Maybe; using v8::MaybeLocal; @@ -337,7 +338,11 @@ class SerializerDelegate : public ValueSerializer::Delegate { // methods like toString(). It's probably confusing if that gets lost // in transmission. Local normal_object = Object::New(isolate); - env_->env_vars()->AssignToObject(isolate, env_->context(), normal_object); + if (env_->env_vars() + ->AssignToObject(isolate, env_->context(), normal_object) + .IsNothing()) { + return Nothing(); + } serializer->WriteUint32(kNormalObject); // Instead of a BaseObject. return serializer->WriteValue(env_->context(), normal_object); } @@ -1388,25 +1393,25 @@ JSTransferable::NestedTransferables() const { return Just(ret); } -Maybe JSTransferable::FinalizeTransferRead( +Maybe JSTransferable::FinalizeTransferRead( Local context, ValueDeserializer* deserializer) { // Call `this[kDeserialize](data)` where `data` comes from the return value // of `this[kTransfer]()` or `this[kClone]()`. HandleScope handle_scope(env()->isolate()); Local data; - if (!deserializer->ReadValue(context).ToLocal(&data)) return Nothing(); + if (!deserializer->ReadValue(context).ToLocal(&data)) return Nothing(); Local method_name = env()->messaging_deserialize_symbol(); Local method; if (!target()->Get(context, method_name).ToLocal(&method)) { - return Nothing(); + return Nothing(); } - if (!method->IsFunction()) return Just(true); + if (!method->IsFunction()) return JustVoid(); if (method.As()->Call(context, target(), 1, &data).IsEmpty()) { - return Nothing(); + return Nothing(); } - return Just(true); + return JustVoid(); } JSTransferable::Data::Data(std::string&& deserialize_info, diff --git a/src/node_messaging.h b/src/node_messaging.h index 6dd34b8bd5a407..169ff0ba19e909 100644 --- a/src/node_messaging.h +++ b/src/node_messaging.h @@ -340,7 +340,7 @@ class JSTransferable : public BaseObject { std::unique_ptr CloneForMessaging() const override; v8::Maybe>> NestedTransferables() const override; - v8::Maybe FinalizeTransferRead( + v8::Maybe FinalizeTransferRead( v8::Local context, v8::ValueDeserializer* deserializer) override; diff --git a/src/string_bytes.h b/src/string_bytes.h index fde5070ffb66a7..53bc003fbda436 100644 --- a/src/string_bytes.h +++ b/src/string_bytes.h @@ -37,19 +37,19 @@ class StringBytes { public: class InlineDecoder : public MaybeStackBuffer { public: - inline v8::Maybe Decode(Environment* env, + inline v8::Maybe Decode(Environment* env, v8::Local string, enum encoding enc) { size_t storage; if (!StringBytes::StorageSize(env->isolate(), string, enc).To(&storage)) - return v8::Nothing(); + return v8::Nothing(); AllocateSufficientStorage(storage); const size_t length = StringBytes::Write(env->isolate(), out(), storage, string, enc); // No zero terminator is included when using this method. SetLength(length); - return v8::Just(true); + return v8::JustVoid(); } inline size_t size() const { return length(); } diff --git a/src/util.h b/src/util.h index a6da8720c499df..7b0d4f2abe7cc3 100644 --- a/src/util.h +++ b/src/util.h @@ -320,7 +320,7 @@ class KVStore { virtual std::shared_ptr Clone(v8::Isolate* isolate) const; virtual v8::Maybe AssignFromObject(v8::Local context, v8::Local entries); - v8::Maybe AssignToObject(v8::Isolate* isolate, + v8::Maybe AssignToObject(v8::Isolate* isolate, v8::Local context, v8::Local object);