@@ -259,7 +259,11 @@ bool Range::AddAndCheckOverflow(const Representation& r, Range* other) {
259
259
bool may_overflow = false ;
260
260
lower_ = AddWithoutOverflow (r, lower_, other->lower (), &may_overflow);
261
261
upper_ = AddWithoutOverflow (r, upper_, other->upper (), &may_overflow);
262
- KeepOrder ();
262
+ if (may_overflow) {
263
+ Clear ();
264
+ } else {
265
+ KeepOrder ();
266
+ }
263
267
#ifdef DEBUG
264
268
Verify ();
265
269
#endif
@@ -271,13 +275,21 @@ bool Range::SubAndCheckOverflow(const Representation& r, Range* other) {
271
275
bool may_overflow = false ;
272
276
lower_ = SubWithoutOverflow (r, lower_, other->upper (), &may_overflow);
273
277
upper_ = SubWithoutOverflow (r, upper_, other->lower (), &may_overflow);
274
- KeepOrder ();
278
+ if (may_overflow) {
279
+ Clear ();
280
+ } else {
281
+ KeepOrder ();
282
+ }
275
283
#ifdef DEBUG
276
284
Verify ();
277
285
#endif
278
286
return may_overflow;
279
287
}
280
288
289
+ void Range::Clear () {
290
+ lower_ = kMinInt ;
291
+ upper_ = kMaxInt ;
292
+ }
281
293
282
294
void Range::KeepOrder () {
283
295
if (lower_ > upper_) {
@@ -301,8 +313,12 @@ bool Range::MulAndCheckOverflow(const Representation& r, Range* other) {
301
313
int v2 = MulWithoutOverflow (r, lower_, other->upper (), &may_overflow);
302
314
int v3 = MulWithoutOverflow (r, upper_, other->lower (), &may_overflow);
303
315
int v4 = MulWithoutOverflow (r, upper_, other->upper (), &may_overflow);
304
- lower_ = Min (Min (v1, v2), Min (v3, v4));
305
- upper_ = Max (Max (v1, v2), Max (v3, v4));
316
+ if (may_overflow) {
317
+ Clear ();
318
+ } else {
319
+ lower_ = Min (Min (v1, v2), Min (v3, v4));
320
+ upper_ = Max (Max (v1, v2), Max (v3, v4));
321
+ }
306
322
#ifdef DEBUG
307
323
Verify ();
308
324
#endif
@@ -3184,6 +3200,13 @@ bool HAllocate::HandleSideEffectDominator(GVNFlag side_effect,
3184
3200
return false ;
3185
3201
}
3186
3202
3203
+ if (IsAllocationFoldingDominator ()) {
3204
+ if (FLAG_trace_allocation_folding) {
3205
+ PrintF (" #%d (%s) cannot fold into #%d (%s), already dominator\n " , id (),
3206
+ Mnemonic (), dominator->id (), dominator->Mnemonic ());
3207
+ }
3208
+ return false ;
3209
+ }
3187
3210
3188
3211
if (!IsFoldable (dominator_allocate)) {
3189
3212
if (FLAG_trace_allocation_folding) {
@@ -3235,17 +3258,6 @@ bool HAllocate::HandleSideEffectDominator(GVNFlag side_effect,
3235
3258
}
3236
3259
}
3237
3260
3238
- if (IsAllocationFoldingDominator ()) {
3239
- DeleteAndReplaceWith (dominator_allocate);
3240
- if (FLAG_trace_allocation_folding) {
3241
- PrintF (
3242
- " #%d (%s) folded dominator into #%d (%s), new dominator size: %d\n " ,
3243
- id (), Mnemonic (), dominator_allocate->id (),
3244
- dominator_allocate->Mnemonic (), new_dominator_size);
3245
- }
3246
- return true ;
3247
- }
3248
-
3249
3261
if (!dominator_allocate->IsAllocationFoldingDominator ()) {
3250
3262
HAllocate* first_alloc =
3251
3263
HAllocate::New (isolate, zone, dominator_allocate->context (),
@@ -3280,6 +3292,8 @@ std::ostream& HAllocate::PrintDataTo(std::ostream& os) const { // NOLINT
3280
3292
if (IsOldSpaceAllocation ()) os << " P" ;
3281
3293
if (MustAllocateDoubleAligned ()) os << " A" ;
3282
3294
if (MustPrefillWithFiller ()) os << " F" ;
3295
+ if (IsAllocationFoldingDominator ()) os << " d" ;
3296
+ if (IsAllocationFolded ()) os << " f" ;
3283
3297
return os << " )" ;
3284
3298
}
3285
3299
0 commit comments