@@ -72,6 +72,46 @@ void FlowGraph::EnsureSSATempIndex(Definition* defn, Definition* replacement) {
72
72
}
73
73
}
74
74
75
+ // When updating this check also [ParameterOffsetAt] and
76
+ // [PopulateEnvironmentFromFunctionEntry]
77
+ Location FlowGraph::ParameterLocationAt (const Function& function,
78
+ intptr_t index) {
79
+ ASSERT (index <= function.NumParameters ());
80
+ intptr_t offset_in_words_from_caller_sp = 0 ;
81
+ for (intptr_t i = function.NumParameters () - 1 ; i > index ; i--) {
82
+ if (function.is_unboxed_integer_parameter_at (i)) {
83
+ offset_in_words_from_caller_sp += compiler::target::kIntSpillFactor ;
84
+ } else if (function.is_unboxed_double_parameter_at (i)) {
85
+ offset_in_words_from_caller_sp += compiler::target::kDoubleSpillFactor ;
86
+ } else {
87
+ ASSERT (!function.is_unboxed_parameter_at (i));
88
+ // Boxed parameters occupy one word.
89
+ offset_in_words_from_caller_sp++;
90
+ }
91
+ }
92
+
93
+ const auto offset_in_words_from_fp =
94
+ offset_in_words_from_caller_sp +
95
+ compiler::target::frame_layout.param_end_from_fp + 1 ;
96
+
97
+ if (function.is_unboxed_double_parameter_at (index )) {
98
+ return Location::DoubleStackSlot (offset_in_words_from_fp, FPREG);
99
+ } else if (function.is_unboxed_integer_parameter_at (index )) {
100
+ if (compiler::target::kIntSpillFactor == 1 ) {
101
+ return Location::StackSlot (offset_in_words_from_fp, FPREG);
102
+ } else {
103
+ ASSERT (compiler::target::kIntSpillFactor == 2 );
104
+ return Location::Pair (
105
+ Location::StackSlot (offset_in_words_from_fp, FPREG),
106
+ Location::StackSlot (offset_in_words_from_fp + 1 , FPREG));
107
+ }
108
+ } else {
109
+ return Location::StackSlot (offset_in_words_from_fp, FPREG);
110
+ }
111
+ }
112
+
113
+ // When updating this check also [ParameterLocationAt] and
114
+ // [PopulateEnvironmentFromFunctionEntry]
75
115
intptr_t FlowGraph::ParameterOffsetAt (const Function& function,
76
116
intptr_t index,
77
117
bool last_slot /* =true*/ ) {
@@ -84,7 +124,7 @@ intptr_t FlowGraph::ParameterOffsetAt(const Function& function,
84
124
param_offset += compiler::target::kDoubleSpillFactor ;
85
125
} else {
86
126
ASSERT (!function.is_unboxed_parameter_at (i));
87
- // Unboxed parameters always occupy one word
127
+ // Boxed parameters occupy one word.
88
128
param_offset++;
89
129
}
90
130
}
@@ -1203,6 +1243,8 @@ void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis,
1203
1243
#endif // defined(DEBUG)
1204
1244
}
1205
1245
1246
+ // When updating this check also [ParameterLocationAt] and
1247
+ // [ParameterOffsetAt].
1206
1248
void FlowGraph::PopulateEnvironmentFromFunctionEntry (
1207
1249
FunctionEntryInstr* function_entry,
1208
1250
GrowableArray<Definition*>* env,
@@ -1218,32 +1260,44 @@ void FlowGraph::PopulateEnvironmentFromFunctionEntry(
1218
1260
1219
1261
ASSERT (variable_count () == env->length ());
1220
1262
ASSERT (direct_parameter_count <= env->length ());
1221
- intptr_t param_offset = 0 ;
1263
+
1264
+ intptr_t offset_in_words_from_fp =
1265
+ (compiler::target::frame_layout.param_end_from_fp + 1 ) +
1266
+ direct_parameters_size_;
1222
1267
for (intptr_t i = 0 ; i < direct_parameter_count; i++) {
1223
1268
ASSERT (FLAG_precompiled_mode || !function ().is_unboxed_parameter_at (i));
1224
- ParameterInstr* param;
1225
1269
1226
1270
const intptr_t index = (function ().IsFactory () ? (i - 1 ) : i);
1227
1271
1272
+ Representation rep;
1273
+ Location location;
1274
+
1228
1275
if (index >= 0 && function ().is_unboxed_integer_parameter_at (index )) {
1229
- constexpr intptr_t kCorrection = compiler::target::kIntSpillFactor - 1 ;
1230
- param = new (zone ()) ParameterInstr (/* env_index=*/ i, /* param_index=*/ i,
1231
- param_offset + kCorrection ,
1232
- function_entry, kUnboxedInt64 );
1233
- param_offset += compiler::target::kIntSpillFactor ;
1276
+ rep = kUnboxedInt64 ;
1277
+ offset_in_words_from_fp -= compiler::target::kIntSpillFactor ;
1278
+ if (compiler::target::kIntSpillFactor == 1 ) {
1279
+ location = Location::StackSlot (offset_in_words_from_fp, FPREG);
1280
+ } else {
1281
+ ASSERT (compiler::target::kIntSpillFactor == 2 );
1282
+ location = Location::Pair (
1283
+ Location::StackSlot (offset_in_words_from_fp, FPREG),
1284
+ Location::StackSlot (offset_in_words_from_fp + 1 , FPREG));
1285
+ }
1234
1286
} else if (index >= 0 && function ().is_unboxed_double_parameter_at (index )) {
1235
- constexpr intptr_t kCorrection = compiler::target::kDoubleSpillFactor - 1 ;
1236
- param = new (zone ()) ParameterInstr (/* env_index=*/ i, /* param_index=*/ i,
1237
- param_offset + kCorrection ,
1238
- function_entry, kUnboxedDouble );
1239
- param_offset += compiler::target::kDoubleSpillFactor ;
1287
+ rep = kUnboxedDouble ;
1288
+ offset_in_words_from_fp -= compiler::target::kDoubleSpillFactor ;
1289
+ location = Location::DoubleStackSlot (offset_in_words_from_fp, FPREG);
1240
1290
} else {
1241
1291
ASSERT (index < 0 || !function ().is_unboxed_parameter_at (index ));
1242
- param =
1243
- new (zone ()) ParameterInstr (/* env_index=*/ i, /* param_index=*/ i,
1244
- param_offset, function_entry, kTagged );
1245
- param_offset++;
1292
+ rep = kTagged ;
1293
+ offset_in_words_from_fp -= 1 ;
1294
+ location = Location::StackSlot (offset_in_words_from_fp, FPREG);
1246
1295
}
1296
+
1297
+ auto param = new (zone ()) ParameterInstr (function_entry,
1298
+ /* env_index=*/ i,
1299
+ /* param_index=*/ i, location, rep);
1300
+
1247
1301
AllocateSSAIndex (param);
1248
1302
AddToInitialDefinitions (function_entry, param);
1249
1303
(*env)[i] = param;
@@ -1296,16 +1350,25 @@ void FlowGraph::PopulateEnvironmentFromFunctionEntry(
1296
1350
1297
1351
// Replace the argument descriptor slot with a special parameter.
1298
1352
if (parsed_function ().has_arg_desc_var ()) {
1299
- Definition* defn =
1300
- new (Z) SpecialParameterInstr (SpecialParameterInstr::kArgDescriptor ,
1301
- DeoptId::kNone , function_entry);
1353
+ auto defn = new (Z)
1354
+ ParameterInstr (function_entry, ArgumentDescriptorEnvIndex (),
1355
+ ParameterInstr::kNotFunctionParameter ,
1356
+ Location::RegisterLocation (ARGS_DESC_REG), kTagged );
1302
1357
AllocateSSAIndex (defn);
1303
1358
AddToInitialDefinitions (function_entry, defn);
1304
1359
(*env)[ArgumentDescriptorEnvIndex ()] = defn;
1305
1360
}
1306
1361
}
1307
1362
}
1308
1363
1364
+ static Location EnvIndexToStackLocation (intptr_t num_direct_parameters,
1365
+ intptr_t env_index) {
1366
+ return Location::StackSlot (
1367
+ compiler::target::frame_layout.FrameSlotForVariableIndex (
1368
+ num_direct_parameters - env_index),
1369
+ FPREG);
1370
+ }
1371
+
1309
1372
void FlowGraph::PopulateEnvironmentFromOsrEntry (
1310
1373
OsrEntryInstr* osr_entry,
1311
1374
GrowableArray<Definition*>* env) {
@@ -1319,8 +1382,9 @@ void FlowGraph::PopulateEnvironmentFromOsrEntry(
1319
1382
const intptr_t param_index = (i < num_direct_parameters ())
1320
1383
? i
1321
1384
: ParameterInstr::kNotFunctionParameter ;
1322
- ParameterInstr* param = new (zone ())
1323
- ParameterInstr (/* env_index=*/ i, param_index, i, osr_entry, kTagged );
1385
+ ParameterInstr* param = new (zone ()) ParameterInstr (
1386
+ osr_entry, /* env_index=*/ i, param_index,
1387
+ EnvIndexToStackLocation (num_direct_parameters (), i), kTagged );
1324
1388
AllocateSSAIndex (param);
1325
1389
AddToInitialDefinitions (osr_entry, param);
1326
1390
(*env)[i] = param;
@@ -1342,21 +1406,19 @@ void FlowGraph::PopulateEnvironmentFromCatchEntry(
1342
1406
// Add real definitions for all locals and parameters.
1343
1407
ASSERT (variable_count () == env->length ());
1344
1408
for (intptr_t i = 0 , n = variable_count (); i < n; ++i) {
1345
- // Replace usages of the raw exception/stacktrace variables with
1346
- // [SpecialParameterInstr]s .
1347
- Definition* param = nullptr ;
1409
+ // Local variables will arive on the stack while exception and
1410
+ // stack trace will be passed in fixed registers .
1411
+ Location loc ;
1348
1412
if (raw_exception_var_envindex == i) {
1349
- param = new (Z) SpecialParameterInstr (SpecialParameterInstr::kException ,
1350
- DeoptId::kNone , catch_entry);
1413
+ loc = LocationExceptionLocation ();
1351
1414
} else if (raw_stacktrace_var_envindex == i) {
1352
- param = new (Z) SpecialParameterInstr (SpecialParameterInstr::kStackTrace ,
1353
- DeoptId::kNone , catch_entry);
1415
+ loc = LocationStackTraceLocation ();
1354
1416
} else {
1355
- param = new (Z)
1356
- ParameterInstr (/* env_index=*/ i,
1357
- /* param_index=*/ ParameterInstr::kNotFunctionParameter ,
1358
- i, catch_entry, kTagged );
1417
+ loc = EnvIndexToStackLocation (num_direct_parameters (), i);
1359
1418
}
1419
+ auto param = new (Z) ParameterInstr (
1420
+ catch_entry, /* env_index=*/ i,
1421
+ /* param_index=*/ ParameterInstr::kNotFunctionParameter , loc, kTagged );
1360
1422
1361
1423
AllocateSSAIndex (param); // New SSA temp.
1362
1424
(*env)[i] = param;
0 commit comments