@@ -180,6 +180,19 @@ static Definition* PrepareIndexedOp(FlowGraph* flow_graph,
180180 return safe_index;
181181}
182182
183+ static Definition* CreateBoxedParameterIfNeeded (BlockBuilder* builder,
184+ Definition* value,
185+ Representation representation,
186+ intptr_t arg_index) {
187+ const auto & function = builder->function ();
188+ if (function.is_unboxed_parameter_at (arg_index)) {
189+ return builder->AddDefinition (
190+ BoxInstr::Create (representation, new Value (value)));
191+ } else {
192+ return value;
193+ }
194+ }
195+
183196static Definition* CreateBoxedResultIfNeeded (BlockBuilder* builder,
184197 Definition* value,
185198 Representation representation) {
@@ -212,6 +225,7 @@ static bool IntrinsifyArrayGetIndexed(FlowGraph* flow_graph,
212225 Definition* array = builder.AddParameter (0 , /* with_frame=*/ false );
213226 Definition* index = builder.AddParameter (1 , /* with_frame=*/ false );
214227
228+ index = CreateBoxedParameterIfNeeded (&builder, index, kUnboxedInt64 , 1 );
215229 index = PrepareIndexedOp (flow_graph, &builder, array, index,
216230 Slot::GetLengthFieldForArrayCid (array_cid));
217231
@@ -314,6 +328,7 @@ static bool IntrinsifyArraySetIndexed(FlowGraph* flow_graph,
314328 Definition* index = builder.AddParameter (1 , /* with_frame=*/ false );
315329 Definition* value = builder.AddParameter (2 , /* with_frame=*/ false );
316330
331+ index = CreateBoxedParameterIfNeeded (&builder, index, kUnboxedInt64 , 1 );
317332 index = PrepareIndexedOp (flow_graph, &builder, array, index,
318333 Slot::GetLengthFieldForArrayCid (array_cid));
319334
0 commit comments