@@ -2911,7 +2911,6 @@ static bool InlineSetIndexed(FlowGraph* flow_graph,
2911
2911
Instruction* call,
2912
2912
Definition* receiver,
2913
2913
const InstructionSource& source,
2914
- const Cids* value_check,
2915
2914
FlowGraphInliner::ExactnessInfo* exactness,
2916
2915
GraphEntryInstr* graph_entry,
2917
2916
FunctionEntryInstr** entry,
@@ -3050,16 +3049,6 @@ static bool InlineSetIndexed(FlowGraph* flow_graph,
3050
3049
array_cid == kExternalTypedDataUint8ArrayCid ||
3051
3050
array_cid == kExternalTypedDataUint8ClampedArrayCid ;
3052
3051
3053
- if (value_check != nullptr ) {
3054
- // No store barrier needed because checked value is a smi, an unboxed mint,
3055
- // an unboxed double, an unboxed Float32x4, or unboxed Int32x4.
3056
- needs_store_barrier = kNoStoreBarrier ;
3057
- Instruction* check = flow_graph->CreateCheckClass (
3058
- stored_value, *value_check, call->deopt_id (), call->source ());
3059
- cursor =
3060
- flow_graph->AppendTo (cursor, check, call->env (), FlowGraph::kEffect );
3061
- }
3062
-
3063
3052
if (array_cid == kTypedDataFloat32ArrayCid ) {
3064
3053
stored_value = new (Z)
3065
3054
DoubleToFloatInstr (new (Z) Value (stored_value), call->deopt_id ());
@@ -3339,110 +3328,16 @@ static bool InlineByteArrayBaseStore(FlowGraph* flow_graph,
3339
3328
(*entry)->InheritDeoptTarget (Z, call);
3340
3329
Instruction* cursor = *entry;
3341
3330
3342
- // Prepare additional checks. In AOT Dart2, we use an explicit null check and
3343
- // non-speculative unboxing for most value types.
3344
- Cids* value_check = nullptr ;
3345
- bool needs_null_check = false ;
3346
- switch (view_cid) {
3347
- case kTypedDataInt8ArrayCid :
3348
- case kTypedDataUint8ArrayCid :
3349
- case kTypedDataUint8ClampedArrayCid :
3350
- case kExternalTypedDataUint8ArrayCid :
3351
- case kExternalTypedDataUint8ClampedArrayCid :
3352
- case kTypedDataInt16ArrayCid :
3353
- case kTypedDataUint16ArrayCid : {
3354
- if (CompilerState::Current ().is_aot ()) {
3355
- needs_null_check = true ;
3356
- } else {
3357
- // Check that value is always smi.
3358
- value_check = Cids::CreateMonomorphic (Z, kSmiCid );
3359
- }
3360
- break ;
3361
- }
3362
- case kTypedDataInt32ArrayCid :
3363
- case kTypedDataUint32ArrayCid :
3364
- if (CompilerState::Current ().is_aot ()) {
3365
- needs_null_check = true ;
3366
- } else {
3367
- // On 64-bit platforms assume that stored value is always a smi.
3368
- if (compiler::target::kSmiBits >= 32 ) {
3369
- value_check = Cids::CreateMonomorphic (Z, kSmiCid );
3370
- }
3371
- }
3372
- break ;
3373
- case kTypedDataFloat32ArrayCid :
3374
- case kTypedDataFloat64ArrayCid : {
3375
- // Check that value is always double.
3376
- if (CompilerState::Current ().is_aot ()) {
3377
- needs_null_check = true ;
3378
- } else {
3379
- value_check = Cids::CreateMonomorphic (Z, kDoubleCid );
3380
- }
3381
- break ;
3382
- }
3383
- case kTypedDataInt32x4ArrayCid : {
3384
- // Check that value is always Int32x4.
3385
- value_check = Cids::CreateMonomorphic (Z, kInt32x4Cid );
3386
- break ;
3387
- }
3388
- case kTypedDataFloat32x4ArrayCid : {
3389
- // Check that value is always Float32x4.
3390
- value_check = Cids::CreateMonomorphic (Z, kFloat32x4Cid );
3391
- break ;
3392
- }
3393
- case kTypedDataFloat64x2ArrayCid : {
3394
- // Check that value is always Float64x2.
3395
- value_check = Cids::CreateMonomorphic (Z, kFloat64x2Cid );
3396
- break ;
3397
- }
3398
- case kTypedDataInt64ArrayCid :
3399
- case kTypedDataUint64ArrayCid :
3400
- // StoreIndexedInstr takes unboxed int64, so value is
3401
- // checked when unboxing. In AOT, we use an
3402
- // explicit null check and non-speculative unboxing.
3403
- needs_null_check = CompilerState::Current ().is_aot ();
3404
- break ;
3405
- default :
3406
- // Array cids are already checked in the caller.
3407
- UNREACHABLE ();
3408
- }
3409
-
3410
3331
Definition* stored_value = call->ArgumentAt (2 );
3411
3332
3412
- // Handle value check.
3413
- if (value_check != nullptr ) {
3414
- Instruction* check = flow_graph->CreateCheckClass (
3415
- stored_value, *value_check, call->deopt_id (), call->source ());
3416
- cursor =
3417
- flow_graph->AppendTo (cursor, check, call->env (), FlowGraph::kEffect );
3418
- }
3419
-
3420
- // Handle null check.
3421
- if (needs_null_check) {
3333
+ // We know that the incomming type matches, but we still need to handle the
3334
+ // null check.
3335
+ if (!dart::Thread::Current ()->isolate_group ()->null_safety ()) {
3422
3336
String& name = String::ZoneHandle (Z, target.name ());
3423
3337
Instruction* check = new (Z) CheckNullInstr (
3424
3338
new (Z) Value (stored_value), name, call->deopt_id (), call->source ());
3425
3339
cursor =
3426
3340
flow_graph->AppendTo (cursor, check, call->env (), FlowGraph::kEffect );
3427
- // With an explicit null check, a non-speculative unbox suffices.
3428
- switch (view_cid) {
3429
- case kTypedDataFloat32ArrayCid :
3430
- case kTypedDataFloat64ArrayCid :
3431
- stored_value =
3432
- UnboxInstr::Create (kUnboxedDouble , new (Z) Value (stored_value),
3433
- call->deopt_id (), Instruction::kNotSpeculative );
3434
- cursor = flow_graph->AppendTo (cursor, stored_value, call->env (),
3435
- FlowGraph::kValue );
3436
- break ;
3437
- case kTypedDataInt64ArrayCid :
3438
- case kTypedDataUint64ArrayCid :
3439
- stored_value = new (Z)
3440
- UnboxInt64Instr (new (Z) Value (stored_value), call->deopt_id (),
3441
- Instruction::kNotSpeculative );
3442
- cursor = flow_graph->AppendTo (cursor, stored_value, call->env (),
3443
- FlowGraph::kValue );
3444
- break ;
3445
- }
3446
3341
}
3447
3342
3448
3343
// Handle conversions and special unboxing (to ensure unboxing instructions
@@ -3464,13 +3359,33 @@ static bool InlineByteArrayBaseStore(FlowGraph* flow_graph,
3464
3359
FlowGraph::kValue );
3465
3360
break ;
3466
3361
}
3467
- case kTypedDataFloat32ArrayCid : {
3468
- stored_value = new (Z)
3469
- DoubleToFloatInstr (new (Z) Value (stored_value), call->deopt_id ());
3470
- cursor = flow_graph->AppendTo (cursor, stored_value, nullptr ,
3362
+
3363
+ case kTypedDataInt64ArrayCid :
3364
+ case kTypedDataUint64ArrayCid : {
3365
+ stored_value =
3366
+ new (Z) UnboxInt64Instr (new (Z) Value (stored_value), call->deopt_id (),
3367
+ Instruction::kNotSpeculative );
3368
+ cursor = flow_graph->AppendTo (cursor, stored_value, call->env (),
3471
3369
FlowGraph::kValue );
3472
3370
break ;
3473
3371
}
3372
+
3373
+ case kTypedDataFloat32ArrayCid :
3374
+ case kTypedDataFloat64ArrayCid : {
3375
+ stored_value =
3376
+ UnboxInstr::Create (kUnboxedDouble , new (Z) Value (stored_value),
3377
+ call->deopt_id (), Instruction::kNotSpeculative );
3378
+ cursor = flow_graph->AppendTo (cursor, stored_value, call->env (),
3379
+ FlowGraph::kValue );
3380
+ if (view_cid == kTypedDataFloat32ArrayCid ) {
3381
+ stored_value = new (Z)
3382
+ DoubleToFloatInstr (new (Z) Value (stored_value), call->deopt_id ());
3383
+ cursor = flow_graph->AppendTo (cursor, stored_value, call->env (),
3384
+ FlowGraph::kValue );
3385
+ }
3386
+ break ;
3387
+ }
3388
+
3474
3389
case kTypedDataInt32ArrayCid : {
3475
3390
stored_value = new (Z)
3476
3391
UnboxInt32Instr (UnboxInt32Instr::kTruncate ,
@@ -4729,72 +4644,50 @@ bool FlowGraphInliner::TryInlineRecognizedMethod(
4729
4644
}
4730
4645
4731
4646
switch (kind) {
4647
+ case MethodRecognizer::kUint8ClampedArraySetIndexed :
4648
+ case MethodRecognizer::kExternalUint8ClampedArraySetIndexed :
4649
+ // These require clamping. Just inline normal body instead which
4650
+ // contains necessary clamping code.
4651
+ return false ;
4652
+
4732
4653
// Recognized []= operators.
4733
4654
case MethodRecognizer::kObjectArraySetIndexed :
4734
4655
case MethodRecognizer::kGrowableArraySetIndexed :
4735
4656
case MethodRecognizer::kObjectArraySetIndexedUnchecked :
4736
4657
case MethodRecognizer::kGrowableArraySetIndexedUnchecked :
4737
- return InlineSetIndexed (flow_graph, kind, target, call, receiver, source,
4738
- /* value_check = */ nullptr , exactness,
4739
- graph_entry, entry, last, result);
4740
4658
case MethodRecognizer::kInt8ArraySetIndexed :
4741
4659
case MethodRecognizer::kUint8ArraySetIndexed :
4742
- case MethodRecognizer::kUint8ClampedArraySetIndexed :
4743
4660
case MethodRecognizer::kExternalUint8ArraySetIndexed :
4744
- case MethodRecognizer::kExternalUint8ClampedArraySetIndexed :
4745
4661
case MethodRecognizer::kInt16ArraySetIndexed :
4746
- case MethodRecognizer::kUint16ArraySetIndexed : {
4747
- // Optimistically assume Smi.
4748
- if (ic_data != nullptr &&
4749
- ic_data->HasDeoptReason (ICData::kDeoptCheckSmi )) {
4750
- // Optimistic assumption failed at least once.
4751
- return false ;
4752
- }
4753
- Cids* value_check = Cids::CreateMonomorphic (Z, kSmiCid );
4754
- return InlineSetIndexed (flow_graph, kind, target, call, receiver, source,
4755
- value_check, exactness, graph_entry, entry, last,
4756
- result);
4757
- }
4662
+ case MethodRecognizer::kUint16ArraySetIndexed :
4758
4663
case MethodRecognizer::kInt32ArraySetIndexed :
4759
- case MethodRecognizer::kUint32ArraySetIndexed : {
4760
- // Value check not needed for Int32 and Uint32 arrays because they
4761
- // implicitly contain unboxing instructions which check for right type.
4762
- return InlineSetIndexed (flow_graph, kind, target, call, receiver, source,
4763
- /* value_check = */ nullptr , exactness,
4764
- graph_entry, entry, last, result);
4765
- }
4664
+ case MethodRecognizer::kUint32ArraySetIndexed :
4766
4665
case MethodRecognizer::kInt64ArraySetIndexed :
4767
4666
case MethodRecognizer::kUint64ArraySetIndexed :
4768
4667
return InlineSetIndexed (flow_graph, kind, target, call, receiver, source,
4769
- /* value_check = */ nullptr , exactness,
4770
- graph_entry, entry, last, result);
4668
+ exactness, graph_entry, entry, last, result);
4669
+
4771
4670
case MethodRecognizer::kFloat32ArraySetIndexed :
4772
4671
case MethodRecognizer::kFloat64ArraySetIndexed : {
4773
4672
if (!CanUnboxDouble ()) {
4774
4673
return false ;
4775
4674
}
4776
- Cids* value_check = Cids::CreateMonomorphic (Z, kDoubleCid );
4777
4675
return InlineSetIndexed (flow_graph, kind, target, call, receiver, source,
4778
- value_check, exactness, graph_entry, entry, last,
4779
- result);
4676
+ exactness, graph_entry, entry, last, result);
4780
4677
}
4781
4678
case MethodRecognizer::kFloat32x4ArraySetIndexed : {
4782
4679
if (!ShouldInlineSimd ()) {
4783
4680
return false ;
4784
4681
}
4785
- Cids* value_check = Cids::CreateMonomorphic (Z, kFloat32x4Cid );
4786
4682
return InlineSetIndexed (flow_graph, kind, target, call, receiver, source,
4787
- value_check, exactness, graph_entry, entry, last,
4788
- result);
4683
+ exactness, graph_entry, entry, last, result);
4789
4684
}
4790
4685
case MethodRecognizer::kFloat64x2ArraySetIndexed : {
4791
4686
if (!ShouldInlineSimd ()) {
4792
4687
return false ;
4793
4688
}
4794
- Cids* value_check = Cids::CreateMonomorphic (Z, kFloat64x2Cid );
4795
4689
return InlineSetIndexed (flow_graph, kind, target, call, receiver, source,
4796
- value_check, exactness, graph_entry, entry, last,
4797
- result);
4690
+ exactness, graph_entry, entry, last, result);
4798
4691
}
4799
4692
case MethodRecognizer::kByteArrayBaseSetInt8 :
4800
4693
return InlineByteArrayBaseStore (flow_graph, target, call, receiver,
0 commit comments