Skip to content

src: replace some FIXED_ONE_BYTE_STRING call with env->something_string() in src/ #30266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ Environment* CreateEnvironment(IsolateData* isolate_data,

std::vector<Local<String>> parameters = {
env->require_string(),
FIXED_ONE_BYTE_STRING(env->isolate(), "markBootstrapComplete")};
env->mark_bootstrap_complete_string()};
std::vector<Local<Value>> arguments = {
env->native_module_require(),
env->NewFunctionTemplate(MarkBootstrapComplete)
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int EmitExit(Environment* env) {
Local<Object> process_object = env->process_object();
process_object
->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "_exiting"),
env->exiting_string(),
True(env->isolate()))
.Check();

Expand Down
10 changes: 5 additions & 5 deletions src/async_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,12 @@ static void SetupHooks(const FunctionCallbackInfo<Value>& args) {
{
Local<FunctionTemplate> ctor =
FunctionTemplate::New(env->isolate());
ctor->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "PromiseWrap"));
ctor->SetClassName(env->promise_wrap_string());
Local<ObjectTemplate> promise_wrap_template = ctor->InstanceTemplate();
promise_wrap_template->SetInternalFieldCount(
PromiseWrap::kInternalFieldCount);
promise_wrap_template->SetAccessor(
FIXED_ONE_BYTE_STRING(env->isolate(), "isChainedPromise"),
env->ischained_promise_string(),
PromiseWrap::getIsChainedPromise);
env->set_promise_wrap_template(promise_wrap_template);
}
Expand Down Expand Up @@ -447,7 +447,7 @@ Local<FunctionTemplate> AsyncWrap::GetConstructorTemplate(Environment* env) {
Local<FunctionTemplate> tmpl = env->async_wrap_ctor_template();
if (tmpl.IsEmpty()) {
tmpl = env->NewFunctionTemplate(nullptr);
tmpl->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "AsyncWrap"));
tmpl->SetClassName(env->async_wrap_string());
env->SetProtoMethod(tmpl, "getAsyncId", AsyncWrap::GetAsyncId);
env->SetProtoMethod(tmpl, "asyncReset", AsyncWrap::AsyncReset);
env->SetProtoMethod(tmpl, "getProviderType", AsyncWrap::GetProviderType);
Expand Down Expand Up @@ -508,7 +508,7 @@ void AsyncWrap::Initialize(Local<Object> target,
env->async_hooks()->async_ids_stack().GetJSArray()).Check();

target->Set(context,
FIXED_ONE_BYTE_STRING(env->isolate(), "owner_symbol"),
env->owner_symbol_string(),
env->owner_symbol()).Check();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could actually drop this property altogether and use internalBinding ('symbols') in JS land instead

Copy link
Member

@joyeecheung joyeecheung Nov 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To elaborate: you can replace the owner_symbol here:

const { async_hook_fields, async_id_fields, owner_symbol } = async_wrap;

with const { owner_symbol } = internalBinding('symbols')

And remove this part in C++.


Local<Object> constants = Object::New(isolate);
Expand Down Expand Up @@ -552,7 +552,7 @@ void AsyncWrap::Initialize(Local<Object> target,
// AsyncWrapObject::Initialize() or AsyncWrapObject::GetConstructorTemplate()
// function.
{
auto class_name = FIXED_ONE_BYTE_STRING(env->isolate(), "AsyncWrap");
auto class_name = env->async_wrap_string();
auto function_template = env->NewFunctionTemplate(AsyncWrapObject::New);
function_template->SetClassName(class_name);
function_template->Inherit(AsyncWrap::GetConstructorTemplate(env));
Expand Down
6 changes: 6 additions & 0 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ constexpr size_t kFsStatsBufferLength =
V(args_string, "args") \
V(asn1curve_string, "asn1Curve") \
V(async_ids_stack_string, "async_ids_stack") \
V(async_wrap_string, "AsyncWrap") \
V(bits_string, "bits") \
V(buffer_string, "buffer") \
V(bytes_parsed_string, "bytesParsed") \
Expand Down Expand Up @@ -226,6 +227,7 @@ constexpr size_t kFsStatsBufferLength =
V(error_string, "error") \
V(exchange_string, "exchange") \
V(exit_code_string, "exitCode") \
V(exiting_string, "_exiting") \
V(expire_string, "expire") \
V(exponent_string, "exponent") \
V(exports_string, "exports") \
Expand Down Expand Up @@ -259,6 +261,7 @@ constexpr size_t kFsStatsBufferLength =
V(internal_string, "internal") \
V(ipv4_string, "IPv4") \
V(ipv6_string, "IPv6") \
V(ischained_promise_string, "isChainedPromise") \
V(isclosing_string, "isClosing") \
V(issuer_string, "issuer") \
V(issuercert_string, "issuerCertificate") \
Expand All @@ -267,6 +270,7 @@ constexpr size_t kFsStatsBufferLength =
V(library_string, "library") \
V(mac_string, "mac") \
V(main_string, "main") \
V(mark_bootstrap_complete_string, "markBootstrapComplete") \
V(max_buffer_string, "maxBuffer") \
V(message_port_constructor_string, "MessagePort") \
V(message_port_string, "messagePort") \
Expand Down Expand Up @@ -304,6 +308,7 @@ constexpr size_t kFsStatsBufferLength =
V(options_string, "options") \
V(order_string, "order") \
V(output_string, "output") \
V(owner_symbol_string, "owner_symbol") \
V(parse_error_string, "Parse Error") \
V(password_string, "password") \
V(path_string, "path") \
Expand All @@ -320,6 +325,7 @@ constexpr size_t kFsStatsBufferLength =
V(priority_string, "priority") \
V(process_string, "process") \
V(promise_string, "promise") \
V(promise_wrap_string, "PromiseWrap") \
V(pubkey_string, "pubkey") \
V(query_string, "query") \
V(raw_string, "raw") \
Expand Down