From de9a101d20ba5e59f873dd8cce0f3fe1d1a39977 Mon Sep 17 00:00:00 2001 From: jgruber Date: Fri, 23 Feb 2018 10:06:49 +0100 Subject: [PATCH] [builtins] Replace placeholders in constants table During builtins generation, parts of the builtins table may be filled with placeholder code objects. This CL ensures that such placeholders are replaced by the real builtin object during finalization of the builtins constants table. Bug: v8:6666 Change-Id: I3a2635b29b37690fd7e950b9f38d500704671afb Reviewed-on: https://chromium-review.googlesource.com/934241 Reviewed-by: Yang Guo Commit-Queue: Jakob Gruber Cr-Commit-Position: refs/heads/master@{#51498} --- src/builtins/constants-table-builder.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/builtins/constants-table-builder.cc b/src/builtins/constants-table-builder.cc index 6c6d8a9c0b..a4117bd5a2 100644 --- a/src/builtins/constants-table-builder.cc +++ b/src/builtins/constants-table-builder.cc @@ -54,10 +54,19 @@ void BuiltinsConstantsTableBuilder::Finalize() { Handle table = isolate_->factory()->NewFixedArray(map_.size(), TENURED); + Builtins* builtins = isolate_->builtins(); ConstantsMap::IteratableScope it_scope(&map_); for (auto it = it_scope.begin(); it != it_scope.end(); ++it) { uint32_t index = *it.entry(); - table->set(index, it.key()); + Object* value = it.key(); + if (value->IsCode() && Code::cast(value)->kind() == Code::BUILTIN) { + // Replace placeholder code objects with the real builtin. + // See also: SetupIsolateDelegate::PopulateWithPlaceholders. + // TODO(jgruber): Deduplicate placeholders and their corresponding + // builtin. + value = builtins->builtin(Code::cast(value)->builtin_index()); + } + table->set(index, value); } #ifdef DEBUG