[web snapshot] Perf fix: pre-reserve the space in the global object
Exports are properties in the global object. Pre-reserve the space, since we know the count upfront. Bug: v8:11525 Change-Id: Ia8ea992234ed8cf71a1060254766b0ba31562436 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3416231 Reviewed-by: Camillo Bruni <cbruni@chromium.org> Commit-Queue: Marja Hölttä <marja@chromium.org> Cr-Commit-Position: refs/heads/main@{#78767}
This commit is contained in:
parent
3f9f569cd6
commit
12c79495d7
@ -1754,6 +1754,16 @@ void WebSnapshotDeserializer::DeserializeExports() {
|
||||
Throw("Malformed export table");
|
||||
return;
|
||||
}
|
||||
// Pre-reserve the space for the properties we're going to add to the global
|
||||
// object.
|
||||
Handle<JSGlobalObject> global = isolate_->global_object();
|
||||
Handle<GlobalDictionary> dictionary(
|
||||
global->global_dictionary(isolate_, kAcquireLoad), isolate_);
|
||||
|
||||
dictionary = GlobalDictionary::EnsureCapacity(isolate_, dictionary, count,
|
||||
AllocationType::kYoung);
|
||||
global->set_global_dictionary(*dictionary, kReleaseStore);
|
||||
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
Handle<String> export_name = ReadString(true);
|
||||
Handle<Object> export_value;
|
||||
@ -1770,8 +1780,8 @@ void WebSnapshotDeserializer::DeserializeExports() {
|
||||
return;
|
||||
}
|
||||
|
||||
auto result = Object::SetProperty(isolate_, isolate_->global_object(),
|
||||
export_name, export_value);
|
||||
auto result =
|
||||
Object::SetProperty(isolate_, global, export_name, export_value);
|
||||
if (result.is_null()) {
|
||||
Throw("Setting global property failed");
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user