[builtins] Only create constants table if serializing

Since we currently only fill the constants table if we're serializing,
we should only create & finalize the table in that case. Otherwise,
leave it initialized to empty_fixed_array.

Cq-Include-Trybots: luci.v8.try:v8_linux64_fyi_rel_ng
Bug: v8:6666
Change-Id: I6ecbfac9dc9a9dac7ff0f11331be09b1cbfb4c18
Reviewed-on: https://chromium-review.googlesource.com/948490
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51727}
This commit is contained in:
jgruber 2018-03-05 13:10:59 +01:00 committed by Commit Bot
parent a74b24913b
commit 8020b0dda5
2 changed files with 8 additions and 2 deletions

View File

@ -32,6 +32,8 @@ uint32_t BuiltinsConstantsTableBuilder::AddObject(Handle<Object> object) {
// Not yet finalized.
DCHECK_EQ(isolate_->heap()->empty_fixed_array(),
isolate_->heap()->builtins_constants_table());
DCHECK(isolate_->serializer_enabled());
#endif
uint32_t* maybe_key = map_.Find(object);
@ -68,6 +70,7 @@ void BuiltinsConstantsTableBuilder::Finalize() {
DCHECK_EQ(isolate_->heap()->empty_fixed_array(),
isolate_->heap()->builtins_constants_table());
DCHECK(isolate_->serializer_enabled());
DCHECK_LT(0, map_.size());
Handle<FixedArray> table =

View File

@ -3050,7 +3050,10 @@ bool Isolate::Init(StartupDeserializer* des) {
// Terminate the partial snapshot cache so we can iterate.
partial_snapshot_cache_.push_back(heap_.undefined_value());
#ifdef V8_EMBEDDED_BUILTINS
builtins_constants_table_builder_ = new BuiltinsConstantsTableBuilder(this);
if (serializer_enabled()) {
builtins_constants_table_builder_ =
new BuiltinsConstantsTableBuilder(this);
}
#endif
}
@ -3085,7 +3088,7 @@ bool Isolate::Init(StartupDeserializer* des) {
setup_delegate_->SetupInterpreter(interpreter_);
#ifdef V8_EMBEDDED_BUILTINS
if (create_heap_objects) {
if (create_heap_objects && serializer_enabled()) {
builtins_constants_table_builder_->Finalize();
delete builtins_constants_table_builder_;
builtins_constants_table_builder_ = nullptr;