@@ -3525,45 +3525,30 @@ static bool NeedsFunctionEnvironmentObjects(frontend::BytecodeEmitter* bce) {
3525
3525
return false ;
3526
3526
}
3527
3527
3528
- /* static */
3529
- void JSScript::initFromFunctionBox (HandleScript script,
3530
- frontend::FunctionBox* funbox) {
3531
- JSFunction* fun = funbox->function ( );
3532
- if (fun-> isInterpretedLazy ()) {
3533
- fun-> setUnlazifiedScript (script);
3534
- } else {
3535
- fun-> setScript (script );
3536
- }
3537
-
3538
- script-> setFlag (ImmutableFlags::FunHasExtensibleScope,
3539
- funbox->hasExtensibleScope ());
3540
- script-> setFlag (ImmutableFlags::NeedsHomeObject , funbox->needsHomeObject ());
3541
- script-> setFlag (ImmutableFlags::IsDerivedClassConstructor,
3542
- funbox->isDerivedClassConstructor ());
3528
+ void JSScript::initFromFunctionBox (frontend::FunctionBox* funbox) {
3529
+ funLength_ = funbox-> length ;
3530
+
3531
+ setFlag (ImmutableFlags::FunHasExtensibleScope, funbox->hasExtensibleScope () );
3532
+ setFlag (ImmutableFlags::NeedsHomeObject, funbox-> needsHomeObject ());
3533
+ setFlag (ImmutableFlags::IsDerivedClassConstructor,
3534
+ funbox-> isDerivedClassConstructor ());
3535
+ setFlag (ImmutableFlags::HasMappedArgsObj, funbox-> hasMappedArgsObj () );
3536
+ setFlag (ImmutableFlags::FunctionHasThisBinding, funbox-> hasThisBinding ());
3537
+ setFlag (ImmutableFlags::FunctionHasExtraBodyVarScope,
3538
+ funbox-> hasExtraBodyVarScope ());
3539
+ setFlag (ImmutableFlags::IsGenerator, funbox->isGenerator ());
3540
+ setFlag (ImmutableFlags::IsAsync , funbox->isAsync ());
3541
+ setFlag (ImmutableFlags::HasRest, funbox-> hasRest ());
3542
+ setFlag (ImmutableFlags::HasInnerFunctions, funbox->hasInnerFunctions ());
3543
3543
3544
3544
if (funbox->argumentsHasLocalBinding ()) {
3545
- script-> setArgumentsHasVarBinding ();
3545
+ setArgumentsHasVarBinding ();
3546
3546
if (funbox->definitelyNeedsArgsObj ()) {
3547
- script-> setNeedsArgsObj (true );
3547
+ setNeedsArgsObj (true );
3548
3548
}
3549
3549
} else {
3550
3550
MOZ_ASSERT (!funbox->definitelyNeedsArgsObj ());
3551
3551
}
3552
- script->setFlag (ImmutableFlags::HasMappedArgsObj, funbox->hasMappedArgsObj ());
3553
-
3554
- script->setFlag (ImmutableFlags::FunctionHasThisBinding,
3555
- funbox->hasThisBinding ());
3556
- script->setFlag (ImmutableFlags::FunctionHasExtraBodyVarScope,
3557
- funbox->hasExtraBodyVarScope ());
3558
-
3559
- script->funLength_ = funbox->length ;
3560
-
3561
- script->setFlag (ImmutableFlags::IsGenerator, funbox->isGenerator ());
3562
- script->setFlag (ImmutableFlags::IsAsync, funbox->isAsync ());
3563
- script->setFlag (ImmutableFlags::HasRest, funbox->hasRest ());
3564
-
3565
- script->setFlag (ImmutableFlags::HasInnerFunctions,
3566
- funbox->hasInnerFunctions ());
3567
3552
}
3568
3553
3569
3554
/* static */
@@ -3612,6 +3597,11 @@ bool JSScript::fullyInitFromEmitter(JSContext* cx, HandleScript script,
3612
3597
script->setFlag (ImmutableFlags::NeedsFunctionEnvironmentObjects,
3613
3598
NeedsFunctionEnvironmentObjects (bce));
3614
3599
3600
+ // Initialize script flags from FunctionBox
3601
+ if (bce->sc ->isFunctionBox ()) {
3602
+ script->initFromFunctionBox (bce->sc ->asFunctionBox ());
3603
+ }
3604
+
3615
3605
// Create and initialize PrivateScriptData
3616
3606
if (!PrivateScriptData::InitFromEmitter (cx, script, bce)) {
3617
3607
return false ;
@@ -3625,11 +3615,16 @@ bool JSScript::fullyInitFromEmitter(JSContext* cx, HandleScript script,
3625
3615
return false ;
3626
3616
}
3627
3617
3628
- // There shouldn't be any fallible operation after initFromFunctionBox,
3629
- // JSFunction::hasUncompletedScript relies on the fact that the existence
3630
- // of the pointer to JSScript means the pointed JSScript is complete .
3618
+ // NOTE: JSScript is now constructed and should be linked in.
3619
+
3620
+ // Link JSFunction to this JSScript.
3631
3621
if (bce->sc ->isFunctionBox ()) {
3632
- initFromFunctionBox (script, bce->sc ->asFunctionBox ());
3622
+ JSFunction* fun = bce->sc ->asFunctionBox ()->function ();
3623
+ if (fun->isInterpretedLazy ()) {
3624
+ fun->setUnlazifiedScript (script);
3625
+ } else {
3626
+ fun->setScript (script);
3627
+ }
3633
3628
}
3634
3629
3635
3630
// Part of the parse result – the scope containing each inner function – must
0 commit comments