@@ -314,12 +314,12 @@ class StressOffThreadDeserializeThread final : public base::Thread {
314
314
CodeSerializer::StartDeserializeOffThread (&local_isolate, cached_data_);
315
315
}
316
316
317
- MaybeHandle<SharedFunctionInfo> Finalize (Isolate* isolate,
318
- Handle <String> source,
319
- ScriptOriginOptions origin_options ) {
317
+ MaybeHandle<SharedFunctionInfo> Finalize (
318
+ Isolate* isolate, Handle <String> source,
319
+ const ScriptDetails& script_details ) {
320
320
return CodeSerializer::FinishOffThreadDeserialize (
321
321
isolate, std::move (off_thread_data_), cached_data_, source,
322
- origin_options );
322
+ script_details );
323
323
}
324
324
325
325
private:
@@ -330,7 +330,8 @@ class StressOffThreadDeserializeThread final : public base::Thread {
330
330
331
331
void FinalizeDeserialization (Isolate* isolate,
332
332
Handle <SharedFunctionInfo> result,
333
- const base::ElapsedTimer& timer) {
333
+ const base::ElapsedTimer& timer,
334
+ const ScriptDetails& script_details) {
334
335
// Devtools can report time in this function as profiler overhead, since none
335
336
// of the following tasks would need to happen normally.
336
337
TRACE_EVENT0 (TRACE_DISABLED_BY_DEFAULT (" v8.compile" ),
@@ -343,10 +344,16 @@ void FinalizeDeserialization(Isolate* isolate,
343
344
log_code_creation);
344
345
}
345
346
347
+ Handle <Script> script (Script::cast (result->script ()), isolate);
348
+ // Reset the script details, including host-defined options.
349
+ {
350
+ DisallowGarbageCollection no_gc;
351
+ SetScriptFieldsFromDetails (isolate, *script, script_details, &no_gc);
352
+ }
353
+
346
354
bool needs_source_positions = isolate->NeedsSourcePositions ();
347
355
if (!log_code_creation && !needs_source_positions) return ;
348
356
349
- Handle <Script> script (Script::cast (result->script ()), isolate);
350
357
if (needs_source_positions) {
351
358
Script::InitLineEnds (isolate, script);
352
359
}
@@ -430,13 +437,13 @@ const char* ToString(SerializedCodeSanityCheckResult result) {
430
437
431
438
MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize (
432
439
Isolate* isolate, AlignedCachedData* cached_data, Handle <String> source,
433
- ScriptOriginOptions origin_options ,
440
+ const ScriptDetails& script_details ,
434
441
MaybeHandle<Script> maybe_cached_script) {
435
442
if (v8_flags.stress_background_compile ) {
436
443
StressOffThreadDeserializeThread thread (isolate, cached_data);
437
444
CHECK (thread.Start ());
438
445
thread.Join ();
439
- return thread.Finalize (isolate, source, origin_options );
446
+ return thread.Finalize (isolate, source, script_details );
440
447
// TODO(leszeks): Compare off-thread deserialized data to on-thread.
441
448
}
442
449
@@ -451,7 +458,7 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
451
458
SerializedCodeSanityCheckResult::kSuccess ;
452
459
const SerializedCodeData scd = SerializedCodeData::FromCachedData (
453
460
isolate, cached_data,
454
- SerializedCodeData::SourceHash (source, origin_options),
461
+ SerializedCodeData::SourceHash (source, script_details. origin_options ),
455
462
&sanity_check_result);
456
463
if (sanity_check_result != SerializedCodeSanityCheckResult::kSuccess ) {
457
464
if (v8_flags.profile_deserialization ) {
@@ -498,7 +505,7 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
498
505
PrintF (" [Deserializing from %d bytes took %0.3f ms]\n " , length, ms);
499
506
}
500
507
501
- FinalizeDeserialization (isolate, result, timer);
508
+ FinalizeDeserialization (isolate, result, timer, script_details );
502
509
503
510
return scope.CloseAndEscape (result);
504
511
}
@@ -553,7 +560,7 @@ CodeSerializer::StartDeserializeOffThread(LocalIsolate* local_isolate,
553
560
MaybeHandle<SharedFunctionInfo> CodeSerializer::FinishOffThreadDeserialize (
554
561
Isolate* isolate, OffThreadDeserializeData&& data,
555
562
AlignedCachedData* cached_data, Handle <String> source,
556
- ScriptOriginOptions origin_options ,
563
+ const ScriptDetails& script_details ,
557
564
BackgroundMergeTask* background_merge_task) {
558
565
base::ElapsedTimer timer;
559
566
if (v8_flags.profile_deserialization || v8_flags.log_function_events ) {
@@ -569,7 +576,8 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::FinishOffThreadDeserialize(
569
576
data.sanity_check_result ;
570
577
const SerializedCodeData scd =
571
578
SerializedCodeData::FromPartiallySanityCheckedCachedData (
572
- cached_data, SerializedCodeData::SourceHash (source, origin_options),
579
+ cached_data,
580
+ SerializedCodeData::SourceHash (source, script_details.origin_options ),
573
581
&sanity_check_result);
574
582
if (sanity_check_result != SerializedCodeSanityCheckResult::kSuccess ) {
575
583
// The only case where the deserialization result could exist despite a
@@ -642,7 +650,7 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::FinishOffThreadDeserialize(
642
650
length, ms);
643
651
}
644
652
645
- FinalizeDeserialization (isolate, result, timer);
653
+ FinalizeDeserialization (isolate, result, timer, script_details );
646
654
647
655
DCHECK (!background_merge_task ||
648
656
!background_merge_task->HasPendingForegroundWork ());
0 commit comments