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