Skip to content

Commit

Permalink
fs: move fs_use_promises_symbol to per-isolate symbols
Browse files Browse the repository at this point in the history
PR-URL: #47768
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
  • Loading branch information
joyeecheung authored and targos committed May 12, 2023
1 parent d6d12bf commit a0da234
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
15 changes: 10 additions & 5 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ void IsolateData::DeserializeProperties(const IsolateDataSerializeInfo* info) {
size_t i = 0;
HandleScope handle_scope(isolate_);

if (per_process::enabled_debug_list.enabled(DebugCategory::MKSNAPSHOT)) {
fprintf(stderr, "deserializing IsolateDataSerializeInfo...\n");
std::cerr << *info << "\n";
}

#define VP(PropertyName, StringValue) V(Private, PropertyName)
#define VY(PropertyName, StringValue) V(Symbol, PropertyName)
#define VS(PropertyName, StringValue) V(String, PropertyName)
Expand Down Expand Up @@ -1704,6 +1709,11 @@ void Environment::RunDeserializeRequests() {
void Environment::DeserializeProperties(const EnvSerializeInfo* info) {
Local<Context> ctx = context();

if (enabled_debug_list_.enabled(DebugCategory::MKSNAPSHOT)) {
fprintf(stderr, "deserializing EnvSerializeInfo...\n");
std::cerr << *info << "\n";
}

RunDeserializeRequests();

async_hooks_.Deserialize(ctx);
Expand All @@ -1716,11 +1726,6 @@ void Environment::DeserializeProperties(const EnvSerializeInfo* info) {
should_abort_on_uncaught_toggle_.Deserialize(ctx);

principal_realm_->DeserializeProperties(&info->principal_realm);

if (enabled_debug_list_.enabled(DebugCategory::MKSNAPSHOT)) {
fprintf(stderr, "deserializing...\n");
std::cerr << *info << "\n";
}
}

uint64_t GuessMemoryAvailableToTheProcess() {
Expand Down
2 changes: 1 addition & 1 deletion src/env_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
// Symbols are per-isolate primitives but Environment proxies them
// for the sake of convenience.
#define PER_ISOLATE_SYMBOL_PROPERTIES(V) \
V(fs_use_promises_symbol, "fs_use_promises_symbol") \
V(async_id_symbol, "async_id_symbol") \
V(handle_onclose_symbol, "handle_onclose") \
V(no_message_symbol, "no_message_symbol") \
Expand Down Expand Up @@ -390,7 +391,6 @@
V(domexception_function, v8::Function) \
V(enhance_fatal_stack_after_inspector, v8::Function) \
V(enhance_fatal_stack_before_inspector, v8::Function) \
V(fs_use_promises_symbol, v8::Symbol) \
V(get_source_map_error_source, v8::Function) \
V(host_import_module_dynamically_callback, v8::Function) \
V(host_initialize_import_meta_object_callback, v8::Function) \
Expand Down
6 changes: 1 addition & 5 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2939,13 +2939,9 @@ void Initialize(Local<Object> target,
fdcloset->SetInternalFieldCount(FSReqBase::kInternalFieldCount);
env->set_fdclose_constructor_template(fdcloset);

Local<Symbol> use_promises_symbol =
Symbol::New(isolate,
FIXED_ONE_BYTE_STRING(isolate, "use promises"));
env->set_fs_use_promises_symbol(use_promises_symbol);
target->Set(context,
FIXED_ONE_BYTE_STRING(isolate, "kUsePromises"),
use_promises_symbol).Check();
env->fs_use_promises_symbol()).Check();
}

BindingData* FSReqBase::binding_data() {
Expand Down

0 comments on commit a0da234

Please sign in to comment.