@@ -494,27 +494,22 @@ static void LoadInlineValueOperand(MacroAssembler& masm, ValueOperand dest) {
494
494
masm.loadUnalignedValue (Address (pc, sizeof (jsbytecode)), dest);
495
495
}
496
496
497
- template <>
498
- void BaselineCompilerCodeGen ::loadScript (Register dest) {
499
- if (handler.isSelfHosted ()) {
497
+ template <typename Handler >
498
+ void BaselineCodeGen<Handler> ::loadScript(Register dest) {
499
+ if (handler.realmIndependentJitcode ()) {
500
500
masm.loadPtr (frame.addressOfInterpreterScript (), dest);
501
501
} else {
502
- masm.movePtr (ImmGCPtr (handler.scriptInternal ()), dest);
502
+ masm.movePtr (ImmGCPtr (handler.maybeScript ()), dest);
503
503
}
504
504
}
505
505
506
- template <>
507
- void BaselineInterpreterCodeGen::loadScript (Register dest) {
508
- masm.loadPtr (frame.addressOfInterpreterScript (), dest);
509
- }
510
-
511
506
template <typename Handler>
512
507
void BaselineCodeGen<Handler>::loadJitScript(Register dest) {
513
- if (handler.isSelfHosted ()) {
508
+ if (handler.realmIndependentJitcode ()) {
514
509
loadScript (dest);
515
510
masm.loadPtr (Address (dest, JSScript::offsetOfWarmUpData ()), dest);
516
511
} else {
517
- masm.movePtr (ImmPtr (handler.scriptInternal ()->jitScript ()), dest);
512
+ masm.movePtr (ImmPtr (handler.maybeScript ()->jitScript ()), dest);
518
513
}
519
514
}
520
515
@@ -1022,39 +1017,30 @@ void BaselineInterpreterCodeGen::subtractScriptSlotsSize(Register reg,
1022
1017
masm.subPtr (scratch, reg);
1023
1018
}
1024
1019
1025
- template <>
1026
- void BaselineCompilerCodeGen::loadGlobalLexicalEnvironment (Register dest) {
1027
- MOZ_ASSERT (!handler.script ()->hasNonSyntacticScope ());
1028
- masm.movePtr (ImmGCPtr (handler.globalLexicalEnvironment ()), dest);
1029
- }
1030
-
1031
- template <>
1032
- void BaselineInterpreterCodeGen::loadGlobalLexicalEnvironment (Register dest) {
1033
- masm.loadGlobalObjectData (dest);
1034
- masm.loadPtr (Address (dest, GlobalObjectData::offsetOfLexicalEnvironment ()),
1035
- dest);
1020
+ template <typename Handler>
1021
+ void BaselineCodeGen<Handler>::loadGlobalLexicalEnvironment(Register dest) {
1022
+ if (handler.realmIndependentJitcode ()) {
1023
+ masm.loadGlobalObjectData (dest);
1024
+ masm.loadPtr (Address (dest, GlobalObjectData::offsetOfLexicalEnvironment ()),
1025
+ dest);
1026
+ } else {
1027
+ MOZ_ASSERT (!handler.maybeScript ()->hasNonSyntacticScope ());
1028
+ masm.movePtr (ImmGCPtr (handler.maybeGlobalLexicalEnvironment ()), dest);
1029
+ }
1036
1030
}
1037
1031
1038
- template <>
1039
- void BaselineCompilerCodeGen ::pushGlobalLexicalEnvironmentValue (
1032
+ template <typename Handler >
1033
+ void BaselineCodeGen<Handler> ::pushGlobalLexicalEnvironmentValue(
1040
1034
ValueOperand scratch) {
1041
- if (handler.isSelfHosted ()) {
1035
+ if (handler.realmIndependentJitcode ()) {
1042
1036
loadGlobalLexicalEnvironment (scratch.scratchReg ());
1043
1037
masm.tagValue (JSVAL_TYPE_OBJECT, scratch.scratchReg (), scratch);
1044
1038
frame.push (scratch);
1045
1039
} else {
1046
- frame.push (ObjectValue (*handler.globalLexicalEnvironment ()));
1040
+ frame.push (ObjectValue (*handler.maybeGlobalLexicalEnvironment ()));
1047
1041
}
1048
1042
}
1049
1043
1050
- template <>
1051
- void BaselineInterpreterCodeGen::pushGlobalLexicalEnvironmentValue (
1052
- ValueOperand scratch) {
1053
- loadGlobalLexicalEnvironment (scratch.scratchReg ());
1054
- masm.tagValue (JSVAL_TYPE_OBJECT, scratch.scratchReg (), scratch);
1055
- frame.push (scratch);
1056
- }
1057
-
1058
1044
template <>
1059
1045
void BaselineCompilerCodeGen::loadGlobalThisValue (ValueOperand dest) {
1060
1046
JSObject* thisObj = handler.globalThis ();
@@ -1070,20 +1056,15 @@ void BaselineInterpreterCodeGen::loadGlobalThisValue(ValueOperand dest) {
1070
1056
masm.loadValue (Address (scratch, SlotOffset), dest);
1071
1057
}
1072
1058
1073
- template <>
1074
- void BaselineCompilerCodeGen ::pushScriptArg () {
1075
- if (handler.isSelfHosted ()) {
1059
+ template <typename Handler >
1060
+ void BaselineCodeGen<Handler> ::pushScriptArg() {
1061
+ if (handler.realmIndependentJitcode ()) {
1076
1062
pushArg (frame.addressOfInterpreterScript ());
1077
1063
} else {
1078
- pushArg (ImmGCPtr (handler.scriptInternal ()));
1064
+ pushArg (ImmGCPtr (handler.maybeScript ()));
1079
1065
}
1080
1066
}
1081
1067
1082
- template <>
1083
- void BaselineInterpreterCodeGen::pushScriptArg () {
1084
- pushArg (frame.addressOfInterpreterScript ());
1085
- }
1086
-
1087
1068
template <>
1088
1069
void BaselineCompilerCodeGen::pushBytecodePCArg () {
1089
1070
pushArg (ImmPtr (handler.pc ()));
@@ -1168,12 +1149,11 @@ template <>
1168
1149
void BaselineCompilerCodeGen::loadScriptGCThing (ScriptGCThingType type,
1169
1150
Register dest,
1170
1151
Register scratch) {
1171
- if (handler.isSelfHosted ()) {
1152
+ if (handler.realmIndependentJitcode ()) {
1172
1153
masm.move32 (Imm32 (GET_GCTHING_INDEX (handler.pc ())), scratch);
1173
1154
loadScriptGCThingInternal (type, dest, scratch);
1174
1155
} else {
1175
- gc::Cell* thing =
1176
- GetScriptGCThing (handler.scriptInternal (), handler.pc (), type);
1156
+ gc::Cell* thing = GetScriptGCThing (handler.script (), handler.pc (), type);
1177
1157
masm.movePtr (ImmGCPtr (thing), dest);
1178
1158
}
1179
1159
}
@@ -1198,28 +1178,20 @@ void BaselineInterpreterCodeGen::loadScriptGCThing(ScriptGCThingType type,
1198
1178
#endif
1199
1179
}
1200
1180
1201
- template <>
1202
- void BaselineCompilerCodeGen ::pushScriptGCThingArg (ScriptGCThingType type,
1203
- Register scratch1,
1204
- Register scratch2) {
1205
- if (handler.isSelfHosted ()) {
1181
+ template <typename Handler >
1182
+ void BaselineCodeGen<Handler> ::pushScriptGCThingArg(ScriptGCThingType type,
1183
+ Register scratch1,
1184
+ Register scratch2) {
1185
+ if (handler.realmIndependentJitcode ()) {
1206
1186
loadScriptGCThing (type, scratch1, scratch2);
1207
1187
pushArg (scratch1);
1208
1188
} else {
1209
1189
gc::Cell* thing =
1210
- GetScriptGCThing (handler.scriptInternal (), handler.pc (), type);
1190
+ GetScriptGCThing (handler.maybeScript (), handler.maybePC (), type);
1211
1191
pushArg (ImmGCPtr (thing));
1212
1192
}
1213
1193
}
1214
1194
1215
- template <>
1216
- void BaselineInterpreterCodeGen::pushScriptGCThingArg (ScriptGCThingType type,
1217
- Register scratch1,
1218
- Register scratch2) {
1219
- loadScriptGCThing (type, scratch1, scratch2);
1220
- pushArg (scratch1);
1221
- }
1222
-
1223
1195
template <typename Handler>
1224
1196
void BaselineCodeGen<Handler>::pushScriptNameArg(Register scratch1,
1225
1197
Register scratch2) {
@@ -1292,21 +1264,22 @@ void BaselineCompilerCodeGen::emitInitFrameFields(Register nonFunctionEnv) {
1292
1264
Register scratch2 = R2.scratchReg ();
1293
1265
MOZ_ASSERT (nonFunctionEnv != scratch && nonFunctionEnv != scratch2);
1294
1266
1295
- uint32_t flags = handler.isSelfHosted () ? BaselineFrame::SELF_HOSTED : 0 ;
1267
+ uint32_t flags =
1268
+ handler.realmIndependentJitcode () ? BaselineFrame::REALM_INDEPENDENT : 0 ;
1296
1269
masm.store32 (Imm32 (flags), frame.addressOfFlags ());
1297
1270
1298
1271
if (handler.function ()) {
1299
1272
masm.loadFunctionFromCalleeToken (frame.addressOfCalleeToken (), scratch);
1300
1273
masm.unboxObject (Address (scratch, JSFunction::offsetOfEnvironment ()),
1301
1274
scratch2);
1302
1275
masm.storePtr (scratch2, frame.addressOfEnvironmentChain ());
1303
- if (handler.isSelfHosted ()) {
1276
+ if (handler.realmIndependentJitcode ()) {
1304
1277
masm.loadPrivate (Address (scratch, JSFunction::offsetOfJitInfoOrScript ()),
1305
1278
scratch);
1306
1279
masm.storePtr (scratch, frame.addressOfInterpreterScript ());
1307
1280
}
1308
1281
} else {
1309
- if (handler.isSelfHosted ()) {
1282
+ if (handler.realmIndependentJitcode ()) {
1310
1283
masm.loadPtr (frame.addressOfCalleeToken (), scratch);
1311
1284
masm.andPtr (Imm32 (uint32_t (CalleeTokenMask)), scratch);
1312
1285
masm.storePtr (scratch, frame.addressOfInterpreterScript ());
@@ -1328,16 +1301,16 @@ void BaselineCompilerCodeGen::emitInitFrameFields(Register nonFunctionEnv) {
1328
1301
1329
1302
// Otherwise, store this script's default ICSCript in the frame.
1330
1303
masm.bind (¬Inlined);
1331
- if (handler.isSelfHosted ()) {
1332
- // When self-hosted JitCode is reused in a new realm, the frames baked into
1304
+ if (handler.realmIndependentJitcode ()) {
1305
+ // When JitCode is reused in a new realm, the frames baked into
1333
1306
// the native bytecode need to refer to the IC list for the new JitScript or
1334
1307
// they will execute the IC scripts using the IC stub fields from the wrong
1335
1308
// script.
1336
1309
loadJitScript (scratch);
1337
1310
masm.addPtr (Imm32 (JitScript::offsetOfICScript ()), scratch);
1338
1311
masm.storePtr (scratch, frame.addressOfICScript ());
1339
1312
} else {
1340
- masm.storePtr (ImmPtr (handler.scriptInternal ()->jitScript ()->icScript ()),
1313
+ masm.storePtr (ImmPtr (handler.script ()->jitScript ()->icScript ()),
1341
1314
frame.addressOfICScript ());
1342
1315
}
1343
1316
masm.bind (&done);
@@ -1430,7 +1403,7 @@ bool BaselineCompilerCodeGen::initEnvironmentChain() {
1430
1403
AllocatableGeneralRegisterSet regs (GeneralRegisterSet::All ());
1431
1404
Register temp = regs.takeAny ();
1432
1405
Label done;
1433
- if (!handler.isSelfHosted ()) {
1406
+ if (!handler.realmIndependentJitcode ()) {
1434
1407
// Allocate a NamedLambdaObject and/or a CallObject. If the function needs
1435
1408
// both, the NamedLambdaObject must enclose the CallObject. If one of the
1436
1409
// allocations fails, we perform the whole operation in C++.
@@ -2728,57 +2701,38 @@ bool BaselineInterpreterCodeGen::emit_Double() {
2728
2701
return true ;
2729
2702
}
2730
2703
2731
- template <>
2732
- bool BaselineCompilerCodeGen ::emit_BigInt () {
2733
- if (handler.isSelfHosted ()) {
2704
+ template <typename Handler >
2705
+ bool BaselineCodeGen<Handler> ::emit_BigInt() {
2706
+ if (handler.realmIndependentJitcode ()) {
2734
2707
frame.syncStack (0 );
2735
2708
Register scratch1 = R0.scratchReg ();
2736
2709
Register scratch2 = R1.scratchReg ();
2737
2710
loadScriptGCThing (ScriptGCThingType::BigInt, scratch1, scratch2);
2738
2711
masm.tagValue (JSVAL_TYPE_BIGINT, scratch1, R0);
2739
2712
frame.push (R0);
2740
2713
} else {
2741
- BigInt* bi = handler.scriptInternal ()->getBigInt (handler.pc ());
2714
+ BigInt* bi = handler.maybeScript ()->getBigInt (handler.maybePC ());
2742
2715
frame.push (BigIntValue (bi));
2743
2716
}
2744
2717
return true ;
2745
2718
}
2746
2719
2747
- template <>
2748
- bool BaselineInterpreterCodeGen::emit_BigInt () {
2749
- Register scratch1 = R0.scratchReg ();
2750
- Register scratch2 = R1.scratchReg ();
2751
- loadScriptGCThing (ScriptGCThingType::BigInt, scratch1, scratch2);
2752
- masm.tagValue (JSVAL_TYPE_BIGINT, scratch1, R0);
2753
- frame.push (R0);
2754
- return true ;
2755
- }
2756
-
2757
- template <>
2758
- bool BaselineCompilerCodeGen::emit_String () {
2759
- if (handler.isSelfHosted ()) {
2720
+ template <typename Handler>
2721
+ bool BaselineCodeGen<Handler>::emit_String() {
2722
+ if (handler.realmIndependentJitcode ()) {
2760
2723
frame.syncStack (0 );
2761
2724
Register scratch1 = R0.scratchReg ();
2762
2725
Register scratch2 = R1.scratchReg ();
2763
2726
loadScriptGCThing (ScriptGCThingType::String, scratch1, scratch2);
2764
2727
masm.tagValue (JSVAL_TYPE_STRING, scratch1, R0);
2765
2728
frame.push (R0);
2766
2729
} else {
2767
- frame.push (StringValue (handler.scriptInternal ()->getString (handler.pc ())));
2730
+ frame.push (
2731
+ StringValue (handler.maybeScript ()->getString (handler.maybePC ())));
2768
2732
}
2769
2733
return true ;
2770
2734
}
2771
2735
2772
- template <>
2773
- bool BaselineInterpreterCodeGen::emit_String () {
2774
- Register scratch1 = R0.scratchReg ();
2775
- Register scratch2 = R1.scratchReg ();
2776
- loadScriptGCThing (ScriptGCThingType::String, scratch1, scratch2);
2777
- masm.tagValue (JSVAL_TYPE_STRING, scratch1, R0);
2778
- frame.push (R0);
2779
- return true ;
2780
- }
2781
-
2782
2736
template <>
2783
2737
bool BaselineCompilerCodeGen::emit_Symbol () {
2784
2738
unsigned which = GET_UINT8 (handler.pc ());
@@ -2801,30 +2755,21 @@ bool BaselineInterpreterCodeGen::emit_Symbol() {
2801
2755
return true ;
2802
2756
}
2803
2757
2804
- template <>
2805
- bool BaselineCompilerCodeGen ::emit_Object () {
2806
- if (handler.isSelfHosted ()) {
2758
+ template <typename Handler >
2759
+ bool BaselineCodeGen<Handler> ::emit_Object() {
2760
+ if (handler.realmIndependentJitcode ()) {
2807
2761
Register scratch1 = R0.scratchReg ();
2808
2762
Register scratch2 = R1.scratchReg ();
2809
2763
loadScriptGCThing (ScriptGCThingType::Object, scratch1, scratch2);
2810
2764
masm.tagValue (JSVAL_TYPE_OBJECT, scratch1, R0);
2811
2765
frame.push (R0);
2812
2766
} else {
2813
- frame.push (ObjectValue (*handler.scriptInternal ()->getObject (handler.pc ())));
2767
+ frame.push (
2768
+ ObjectValue (*handler.maybeScript ()->getObject (handler.maybePC ())));
2814
2769
}
2815
2770
return true ;
2816
2771
}
2817
2772
2818
- template <>
2819
- bool BaselineInterpreterCodeGen::emit_Object () {
2820
- Register scratch1 = R0.scratchReg ();
2821
- Register scratch2 = R1.scratchReg ();
2822
- loadScriptGCThing (ScriptGCThingType::Object, scratch1, scratch2);
2823
- masm.tagValue (JSVAL_TYPE_OBJECT, scratch1, R0);
2824
- frame.push (R0);
2825
- return true ;
2826
- }
2827
-
2828
2773
template <typename Handler>
2829
2774
bool BaselineCodeGen<Handler>::emit_CallSiteObj() {
2830
2775
return emit_Object ();
@@ -3702,10 +3647,10 @@ bool BaselineCodeGen<Handler>::emit_GetGName() {
3702
3647
3703
3648
template <>
3704
3649
bool BaselineCompilerCodeGen::tryOptimizeBindUnqualifiedGlobalName () {
3705
- if (handler.isSelfHosted ()) {
3650
+ if (handler.realmIndependentJitcode ()) {
3706
3651
return false ;
3707
3652
}
3708
- JSScript* script = handler.scriptInternal ();
3653
+ JSScript* script = handler.script ();
3709
3654
MOZ_ASSERT (!script->hasNonSyntacticScope ());
3710
3655
3711
3656
if (handler.compilingOffThread ()) {
@@ -6361,8 +6306,8 @@ bool BaselineCodeGen<Handler>::emitEnterGeneratorCode(Register script,
6361
6306
masm.storePtr (scratch, icScriptAddr);
6362
6307
6363
6308
Label noBaselineScript;
6364
- // Self-hosted frames need the interpreterScript pointer
6365
- if (handler.isSelfHosted ()) {
6309
+ // Frames with shared bytecode need the interpreterScript pointer
6310
+ if (handler.realmIndependentJitcode ()) {
6366
6311
masm.storePtr (script, frame.addressOfInterpreterScript ());
6367
6312
}
6368
6313
masm.loadJitScript (script, scratch);
@@ -6628,7 +6573,7 @@ bool BaselineCodeGen<Handler>::emit_Resume() {
6628
6573
6629
6574
// After the generator returns, we restore the stack pointer, switch back to
6630
6575
// the current realm, push the return value, and we're done.
6631
- if (handler. maybeScript () && !handler.isSelfHosted ()) {
6576
+ if (!handler.realmIndependentJitcode ()) {
6632
6577
masm.switchToRealm (handler.maybeScript ()->realm (), R2.scratchReg ());
6633
6578
} else {
6634
6579
masm.switchToBaselineFrameRealm (R2.scratchReg ());
@@ -6943,7 +6888,7 @@ bool BaselineCodeGen<Handler>::emitPrologue() {
6943
6888
6944
6889
frame.assertSyncedStack ();
6945
6890
6946
- if (handler. maybeScript () && !handler.isSelfHosted ()) {
6891
+ if (!handler.realmIndependentJitcode ()) {
6947
6892
masm.debugAssertContextRealm (handler.maybeScript ()->realm (),
6948
6893
R1.scratchReg ());
6949
6894
}
0 commit comments