@@ -979,8 +979,19 @@ class Instruction : public ZoneAllocated {
979
979
return kTagged ;
980
980
}
981
981
982
- // By default, instructions should check types of inputs when unboxing.
983
- virtual SpeculativeMode speculative_mode () const { return kGuardInputs ; }
982
+ SpeculativeMode SpeculativeModeOfInputs () const {
983
+ for (intptr_t i = 0 ; i < InputCount (); i++) {
984
+ if (SpeculativeModeOfInput (i) == kGuardInputs ) {
985
+ return kGuardInputs ;
986
+ }
987
+ }
988
+ return kNotSpeculative ;
989
+ }
990
+
991
+ // By default, instructions should check types of inputs when unboxing
992
+ virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const {
993
+ return kGuardInputs ;
994
+ }
984
995
985
996
// Representation of the value produced by this computation.
986
997
virtual Representation representation () const { return kTagged ; }
@@ -2378,7 +2389,7 @@ class PhiInstr : public Definition {
2378
2389
virtual void set_representation (Representation r) { representation_ = r; }
2379
2390
2380
2391
// In AOT mode Phi instructions do not check types of inputs when unboxing.
2381
- virtual SpeculativeMode speculative_mode ( ) const {
2392
+ virtual SpeculativeMode SpeculativeModeOfInput ( intptr_t index ) const {
2382
2393
return FLAG_precompiled_mode ? kNotSpeculative : kGuardInputs ;
2383
2394
}
2384
2395
@@ -4203,12 +4214,13 @@ class EqualityCompareInstr : public TemplateComparison<2, NoThrow, Pure> {
4203
4214
return kTagged ;
4204
4215
}
4205
4216
4206
- virtual SpeculativeMode speculative_mode () const { return speculative_mode_; }
4217
+ virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const {
4218
+ return speculative_mode_;
4219
+ }
4207
4220
4208
4221
virtual bool AttributesEqual (Instruction* other) const {
4209
4222
return ComparisonInstr::AttributesEqual (other) &&
4210
- (speculative_mode () ==
4211
- other->AsEqualityCompare ()->speculative_mode ());
4223
+ (speculative_mode_ == other->AsEqualityCompare ()->speculative_mode_ );
4212
4224
}
4213
4225
4214
4226
PRINT_OPERANDS_TO_SUPPORT
@@ -4250,11 +4262,13 @@ class RelationalOpInstr : public TemplateComparison<2, NoThrow, Pure> {
4250
4262
return kTagged ;
4251
4263
}
4252
4264
4253
- virtual SpeculativeMode speculative_mode () const { return speculative_mode_; }
4265
+ virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const {
4266
+ return speculative_mode_;
4267
+ }
4254
4268
4255
4269
virtual bool AttributesEqual (Instruction* other) const {
4256
4270
return ComparisonInstr::AttributesEqual (other) &&
4257
- (speculative_mode () == other->AsRelationalOp ()->speculative_mode () );
4271
+ (speculative_mode_ == other->AsRelationalOp ()->speculative_mode_ );
4258
4272
}
4259
4273
4260
4274
PRINT_OPERANDS_TO_SUPPORT
@@ -4881,7 +4895,7 @@ class StoreInstanceFieldInstr : public TemplateInstruction<2, NoThrow> {
4881
4895
token_pos,
4882
4896
kind) {}
4883
4897
4884
- virtual SpeculativeMode speculative_mode ( ) const {
4898
+ virtual SpeculativeMode SpeculativeModeOfInput ( intptr_t index ) const {
4885
4899
// In AOT unbox is done based on TFA, therefore it was proven to be correct
4886
4900
// and it can never deoptmize.
4887
4901
return (IsUnboxedStore () && FLAG_precompiled_mode) ? kNotSpeculative
@@ -5362,7 +5376,9 @@ class StoreIndexedInstr : public TemplateInstruction<3, NoThrow> {
5362
5376
(emit_store_barrier_ == kEmitStoreBarrier );
5363
5377
}
5364
5378
5365
- virtual SpeculativeMode speculative_mode () const { return speculative_mode_; }
5379
+ virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const {
5380
+ return speculative_mode_;
5381
+ }
5366
5382
5367
5383
virtual bool ComputeCanDeoptimize () const { return false ; }
5368
5384
@@ -6306,7 +6322,9 @@ class BoxIntegerInstr : public BoxInstr {
6306
6322
6307
6323
virtual void InferRange (RangeAnalysis* analysis, Range* range);
6308
6324
6309
- virtual SpeculativeMode speculative_mode () const { return kNotSpeculative ; }
6325
+ virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const {
6326
+ return kNotSpeculative ;
6327
+ }
6310
6328
6311
6329
virtual CompileType ComputeType () const ;
6312
6330
virtual bool RecomputeType ();
@@ -6375,7 +6393,7 @@ class UnboxInstr : public TemplateDefinition<1, NoThrow, Pure> {
6375
6393
Value* value () const { return inputs_[0 ]; }
6376
6394
6377
6395
virtual bool ComputeCanDeoptimize () const {
6378
- if (speculative_mode () == kNotSpeculative ) {
6396
+ if (SpeculativeModeOfInputs () == kNotSpeculative ) {
6379
6397
return false ;
6380
6398
}
6381
6399
@@ -6393,7 +6411,9 @@ class UnboxInstr : public TemplateDefinition<1, NoThrow, Pure> {
6393
6411
return true ;
6394
6412
}
6395
6413
6396
- virtual SpeculativeMode speculative_mode () const { return speculative_mode_; }
6414
+ virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const {
6415
+ return speculative_mode_;
6416
+ }
6397
6417
6398
6418
virtual Representation representation () const { return representation_; }
6399
6419
@@ -6403,7 +6423,7 @@ class UnboxInstr : public TemplateDefinition<1, NoThrow, Pure> {
6403
6423
virtual bool AttributesEqual (Instruction* other) const {
6404
6424
UnboxInstr* other_unbox = other->AsUnbox ();
6405
6425
return (representation () == other_unbox->representation ()) &&
6406
- (speculative_mode () == other_unbox->speculative_mode () );
6426
+ (speculative_mode_ == other_unbox->speculative_mode_ );
6407
6427
}
6408
6428
6409
6429
Definition* Canonicalize (FlowGraph* flow_graph);
@@ -6763,7 +6783,9 @@ class BinaryDoubleOpInstr : public TemplateDefinition<2, NoThrow, Pure> {
6763
6783
return kUnboxedDouble ;
6764
6784
}
6765
6785
6766
- virtual SpeculativeMode speculative_mode () const { return speculative_mode_; }
6786
+ virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const {
6787
+ return speculative_mode_;
6788
+ }
6767
6789
6768
6790
virtual intptr_t DeoptimizationTarget () const {
6769
6791
// Direct access since this instruction cannot deoptimize, and the deopt-id
@@ -6781,7 +6803,7 @@ class BinaryDoubleOpInstr : public TemplateDefinition<2, NoThrow, Pure> {
6781
6803
virtual bool AttributesEqual (Instruction* other) const {
6782
6804
const BinaryDoubleOpInstr* other_bin_op = other->AsBinaryDoubleOp ();
6783
6805
return (op_kind () == other_bin_op->op_kind ()) &&
6784
- (speculative_mode () == other_bin_op->speculative_mode () );
6806
+ (speculative_mode_ == other_bin_op->speculative_mode_ );
6785
6807
}
6786
6808
6787
6809
private:
@@ -6939,11 +6961,14 @@ class UnaryInt64OpInstr : public UnaryIntegerOpInstr {
6939
6961
}
6940
6962
6941
6963
virtual bool AttributesEqual (Instruction* other) const {
6964
+ UnaryInt64OpInstr* unary_op_other = other->AsUnaryInt64Op ();
6942
6965
return UnaryIntegerOpInstr::AttributesEqual (other) &&
6943
- (speculative_mode () == other-> speculative_mode () );
6966
+ (speculative_mode_ == unary_op_other-> speculative_mode_ );
6944
6967
}
6945
6968
6946
- virtual SpeculativeMode speculative_mode () const { return speculative_mode_; }
6969
+ virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const {
6970
+ return speculative_mode_;
6971
+ }
6947
6972
6948
6973
DECLARE_INSTRUCTION (UnaryInt64Op)
6949
6974
@@ -7259,11 +7284,13 @@ class BinaryInt64OpInstr : public BinaryIntegerOpInstr {
7259
7284
return kUnboxedInt64 ;
7260
7285
}
7261
7286
7262
- virtual SpeculativeMode speculative_mode () const { return speculative_mode_; }
7287
+ virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const {
7288
+ return speculative_mode_;
7289
+ }
7263
7290
7264
7291
virtual bool AttributesEqual (Instruction* other) const {
7265
7292
return BinaryIntegerOpInstr::AttributesEqual (other) &&
7266
- (speculative_mode () == other->AsBinaryInt64Op ()->speculative_mode () );
7293
+ (speculative_mode_ == other->AsBinaryInt64Op ()->speculative_mode_ );
7267
7294
}
7268
7295
7269
7296
virtual void InferRange (RangeAnalysis* analysis, Range* range);
@@ -7321,7 +7348,9 @@ class ShiftInt64OpInstr : public ShiftIntegerOpInstr {
7321
7348
intptr_t deopt_id)
7322
7349
: ShiftIntegerOpInstr(op_kind, left, right, deopt_id) {}
7323
7350
7324
- virtual SpeculativeMode speculative_mode () const { return kNotSpeculative ; }
7351
+ virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const {
7352
+ return kNotSpeculative ;
7353
+ }
7325
7354
virtual bool ComputeCanDeoptimize () const { return false ; }
7326
7355
virtual bool MayThrow () const { return true ; }
7327
7356
@@ -7380,7 +7409,9 @@ class ShiftUint32OpInstr : public ShiftIntegerOpInstr {
7380
7409
intptr_t deopt_id)
7381
7410
: ShiftIntegerOpInstr(op_kind, left, right, deopt_id) {}
7382
7411
7383
- virtual SpeculativeMode speculative_mode () const { return kNotSpeculative ; }
7412
+ virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const {
7413
+ return kNotSpeculative ;
7414
+ }
7384
7415
virtual bool ComputeCanDeoptimize () const { return false ; }
7385
7416
virtual bool MayThrow () const { return true ; }
7386
7417
@@ -7465,10 +7496,12 @@ class UnaryDoubleOpInstr : public TemplateDefinition<1, NoThrow, Pure> {
7465
7496
return kUnboxedDouble ;
7466
7497
}
7467
7498
7468
- virtual SpeculativeMode speculative_mode () const { return speculative_mode_; }
7499
+ virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const {
7500
+ return speculative_mode_;
7501
+ }
7469
7502
7470
7503
virtual bool AttributesEqual (Instruction* other) const {
7471
- return speculative_mode () == other->AsUnaryDoubleOp ()->speculative_mode () ;
7504
+ return speculative_mode_ == other->AsUnaryDoubleOp ()->speculative_mode_ ;
7472
7505
}
7473
7506
7474
7507
PRINT_OPERANDS_TO_SUPPORT
@@ -7614,10 +7647,12 @@ class Int64ToDoubleInstr : public TemplateDefinition<1, NoThrow, Pure> {
7614
7647
7615
7648
virtual bool ComputeCanDeoptimize () const { return false ; }
7616
7649
7617
- virtual SpeculativeMode speculative_mode () const { return speculative_mode_; }
7650
+ virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const {
7651
+ return speculative_mode_;
7652
+ }
7618
7653
7619
7654
virtual bool AttributesEqual (Instruction* other) const {
7620
- return speculative_mode () == other->AsInt64ToDouble ()->speculative_mode () ;
7655
+ return speculative_mode_ == other->AsInt64ToDouble ()->speculative_mode_ ;
7621
7656
}
7622
7657
7623
7658
private:
@@ -7746,7 +7781,9 @@ class DoubleToFloatInstr : public TemplateDefinition<1, NoThrow, Pure> {
7746
7781
return kUnboxedDouble ;
7747
7782
}
7748
7783
7749
- virtual SpeculativeMode speculative_mode () const { return speculative_mode_; }
7784
+ virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const {
7785
+ return speculative_mode_;
7786
+ }
7750
7787
7751
7788
virtual intptr_t DeoptimizationTarget () const { return GetDeoptId (); }
7752
7789
0 commit comments