-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
src: improve MakeCallback() performance #41331
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
Changes from all commits
bb0bd36
f97d04e
853853f
b98e4bd
069373e
a7787bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1096,20 +1096,29 @@ void AsyncHooks::Deserialize(Local<Context> context) { | |
async_ids_stack_.Deserialize(context); | ||
fields_.Deserialize(context); | ||
async_id_fields_.Deserialize(context); | ||
|
||
Local<Array> js_execution_async_resources; | ||
if (info_->js_execution_async_resources != 0) { | ||
Local<Array> arr = context->GetDataFromSnapshotOnce<Array>( | ||
info_->js_execution_async_resources) | ||
.ToLocalChecked(); | ||
js_execution_async_resources_.Reset(context->GetIsolate(), arr); | ||
js_execution_async_resources = | ||
context->GetDataFromSnapshotOnce<Array>( | ||
info_->js_execution_async_resources).ToLocalChecked(); | ||
} else { | ||
js_execution_async_resources = Array::New(context->GetIsolate()); | ||
} | ||
js_execution_async_resources_.Reset( | ||
context->GetIsolate(), js_execution_async_resources); | ||
|
||
native_execution_async_resources_.resize( | ||
info_->native_execution_async_resources.size()); | ||
// The native_execution_async_resources_ field requires v8::Local<> instances | ||
// for async calls whose resources were on the stack as JS objects when they | ||
// were entered. We cannot recreate this here; however, storing these values | ||
// on the JS equivalent gives the same result, so we do that instead. | ||
for (size_t i = 0; i < info_->native_execution_async_resources.size(); ++i) { | ||
if (info_->native_execution_async_resources[i] == SIZE_MAX) | ||
continue; | ||
Local<Object> obj = context->GetDataFromSnapshotOnce<Object>( | ||
info_->native_execution_async_resources[i]) | ||
.ToLocalChecked(); | ||
native_execution_async_resources_[i].Reset(context->GetIsolate(), obj); | ||
js_execution_async_resources->Set(context, i, obj).Check(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @joyeecheung This code is effectively doing the same thing as before, but I did want to ask – what exactly are the semantics of the async stack after a snapshot? Is it expected that you start out in a state where there is an active async context, even though the underlying async operation doesn’t even exist in the deserialized instance? (Or, another way: Should the AsyncHooks state be serialized/deserialized at all?) |
||
} | ||
info_ = nullptr; | ||
} | ||
|
@@ -1155,9 +1164,11 @@ AsyncHooks::SerializeInfo AsyncHooks::Serialize(Local<Context> context, | |
info.native_execution_async_resources.resize( | ||
native_execution_async_resources_.size()); | ||
for (size_t i = 0; i < native_execution_async_resources_.size(); i++) { | ||
info.native_execution_async_resources[i] = creator->AddData( | ||
context, | ||
native_execution_async_resources_[i].Get(context->GetIsolate())); | ||
info.native_execution_async_resources[i] = | ||
native_execution_async_resources_[i].IsEmpty() ? SIZE_MAX : | ||
creator->AddData( | ||
context, | ||
native_execution_async_resources_[i]); | ||
} | ||
CHECK_EQ(contexts_.size(), 1); | ||
CHECK_EQ(contexts_[0], env()->context()); | ||
|
@@ -1185,6 +1196,21 @@ void AsyncHooks::grow_async_ids_stack() { | |
async_ids_stack_.GetJSArray()).Check(); | ||
} | ||
|
||
void AsyncHooks::FailWithCorruptedAsyncStack(double expected_async_id) { | ||
fprintf(stderr, | ||
"Error: async hook stack has become corrupted (" | ||
"actual: %.f, expected: %.f)\n", | ||
async_id_fields_.GetValue(kExecutionAsyncId), | ||
expected_async_id); | ||
DumpBacktrace(stderr); | ||
fflush(stderr); | ||
if (!env()->abort_on_uncaught_exception()) | ||
exit(1); | ||
fprintf(stderr, "\n"); | ||
fflush(stderr); | ||
ABORT_NO_BACKTRACE(); | ||
} | ||
|
||
void Environment::Exit(int exit_code) { | ||
if (options()->trace_exit) { | ||
HandleScope handle_scope(isolate()); | ||
|
Uh oh!
There was an error while loading. Please reload this page.