Skip to content

Commit 7b677a5

Browse files
PanTao2V8 LUCI CQ
authored andcommitted
Reland "[cache] Don't compare host defined options if the script was deserialized"
This is a reland of commit b9cfb8b Original change's description: > [cache] Don't compare host defined options if the script was deserialized > > We don't serialize host defined options (see > CodeSerializer::SerializeObjectImpl()). > > Change-Id: Icab9fe910a5ec93b5eacc4869aba75034ad8b447 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4805329 > Reviewed-by: Camillo Bruni <[email protected]> > Reviewed-by: Toon Verwaest <[email protected]> > Commit-Queue: Tao Pan <[email protected]> > Cr-Commit-Position: refs/heads/main@{#90698} Change-Id: I7ea5e9355056104ebd25b385aba63c1233d42260 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4998581 Reviewed-by: Camillo Bruni <[email protected]> Reviewed-by: Toon Verwaest <[email protected]> Commit-Queue: Tao Pan <[email protected]> Cr-Commit-Position: refs/heads/main@{#90711}
1 parent ef62aa3 commit 7b677a5

5 files changed

Lines changed: 21 additions & 2 deletions

File tree

src/objects/compilation-cache-table.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,13 @@ bool ScriptCacheKey::MatchesOrigin(Tagged<Script> script) {
270270
return false;
271271
}
272272

273+
// Don't compare host options if the script was deserialized because we didn't
274+
// serialize host options (see CodeSerializer::SerializeObjectImpl())
275+
if (script->deserialized() &&
276+
script->host_defined_options() ==
277+
ReadOnlyRoots(isolate_).empty_fixed_array()) {
278+
return true;
279+
}
273280
// TODO(cbruni, chromium:1244145): Remove once migrated to the context
274281
Handle<Object> maybe_host_defined_options;
275282
if (!host_defined_options_.ToHandle(&maybe_host_defined_options)) {

src/objects/script-inl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ void Script::set_produce_compile_hints(bool produce_compile_hints) {
146146
set_flags(ProduceCompileHintsBit::update(flags(), produce_compile_hints));
147147
}
148148

149+
bool Script::deserialized() const { return DeserializedBit::decode(flags()); }
150+
151+
void Script::set_deserialized(bool value) {
152+
set_flags(DeserializedBit::update(flags(), value));
153+
}
154+
149155
bool Script::is_repl_mode() const { return IsReplModeBit::decode(flags()); }
150156

151157
void Script::set_is_repl_mode(bool value) {

src/objects/script.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ class Script : public TorqueGeneratedScript<Script, Struct> {
124124
inline bool produce_compile_hints() const;
125125
inline void set_produce_compile_hints(bool produce_compile_hints);
126126

127+
inline bool deserialized() const;
128+
inline void set_deserialized(bool value);
129+
127130
// [compilation_state]: determines whether the script has already been
128131
// compiled. Encoded in the 'flags' field.
129132
inline CompilationState compilation_state();

src/objects/script.tq

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ bitfield struct ScriptFlags extends uint31 {
1313
// Whether an instrumentation breakpoint is set for this script (wasm only).
1414
break_on_entry: bool: 1 bit;
1515
produce_compile_hints: bool: 1 bit;
16+
deserialized: bool: 1 bit;
1617
}
1718

1819
extern class Script extends Struct {

src/snapshot/code-serializer.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,9 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
483483
result = merge.CompleteMergeInForeground(isolate, new_script);
484484
}
485485

486-
BaselineBatchCompileIfSparkplugCompiled(isolate,
487-
Script::cast(result->script()));
486+
Tagged<Script> script = Script::cast(result->script());
487+
script->set_deserialized(true);
488+
BaselineBatchCompileIfSparkplugCompiled(isolate, script);
488489
if (v8_flags.profile_deserialization) {
489490
double ms = timer.Elapsed().InMillisecondsF();
490491
int length = cached_data->length();
@@ -619,6 +620,7 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::FinishOffThreadDeserialize(
619620
// Fix up the script list to include the newly deserialized script.
620621
Handle<WeakArrayList> list = isolate->factory()->script_list();
621622
for (Handle<Script> script : data.scripts) {
623+
script->set_deserialized(true);
622624
BaselineBatchCompileIfSparkplugCompiled(isolate, *script);
623625
DCHECK(data.persistent_handles->Contains(script.location()));
624626
list = WeakArrayList::AddToEnd(isolate, list,

0 commit comments

Comments
 (0)