@@ -5380,24 +5380,31 @@ Reduction JSCallReducer::ReduceArrayPrototypePop(Node* node){
53805380 }
53815381
53825382// Compute the new{length}.
5383- length = graph ()->NewNode (simplified ()->NumberSubtract (), length,
5384- jsgraph ()->OneConstant ());
5383+ Node* new_length = graph ()->NewNode (simplified ()->NumberSubtract (),
5384+ length, jsgraph ()->OneConstant ());
5385+
5386+ // This extra check exists solely to break an exploitation technique
5387+ // that abuses typer mismatches.
5388+ new_length = efalse = graph ()->NewNode (
5389+ simplified ()->CheckBounds (p.feedback (),
5390+ CheckBoundsFlag::kAbortOnOutOfBounds ),
5391+ new_length, length, efalse, if_false);
53855392
53865393// Store the new{length} to the{receiver}.
53875394 efalse = graph ()->NewNode (
53885395simplified ()->StoreField (AccessBuilder::ForJSArrayLength (kind)),
5389- receiver, length , efalse, if_false);
5396+ receiver, new_length , efalse, if_false);
53905397
53915398// Load the last entry from the{elements}.
53925399 vfalse = efalse = graph ()->NewNode (
53935400simplified ()->LoadElement (AccessBuilder::ForFixedArrayElement (kind)),
5394- elements, length , efalse, if_false);
5401+ elements, new_length , efalse, if_false);
53955402
53965403// Store a hole to the element we just removed from the{receiver}.
53975404 efalse = graph ()->NewNode (
53985405simplified ()->StoreElement (
53995406AccessBuilder::ForFixedArrayElement (GetHoleyElementsKind (kind))),
5400- elements, length , jsgraph ()->TheHoleConstant (), efalse, if_false);
5407+ elements, new_length , jsgraph ()->TheHoleConstant (), efalse, if_false);
54015408 }
54025409
54035410 control = graph ()->NewNode (common ()->Merge (2 ), if_true, if_false);
@@ -5573,19 +5580,27 @@ Reduction JSCallReducer::ReduceArrayPrototypeShift(Node* node){
55735580 }
55745581
55755582// Compute the new{length}.
5576- length = graph ()->NewNode (simplified ()->NumberSubtract (), length,
5577- jsgraph ()->OneConstant ());
5583+ Node* new_length = graph ()->NewNode (simplified ()->NumberSubtract (),
5584+ length, jsgraph ()->OneConstant ());
5585+
5586+ // This extra check exists solely to break an exploitation technique
5587+ // that abuses typer mismatches.
5588+ new_length = etrue1 = graph ()->NewNode (
5589+ simplified ()->CheckBounds (p.feedback (),
5590+ CheckBoundsFlag::kAbortOnOutOfBounds ),
5591+ new_length, length, etrue1, if_true1);
55785592
55795593// Store the new{length} to the{receiver}.
55805594 etrue1 = graph ()->NewNode (
55815595simplified ()->StoreField (AccessBuilder::ForJSArrayLength (kind)),
5582- receiver, length , etrue1, if_true1);
5596+ receiver, new_length , etrue1, if_true1);
55835597
55845598// Store a hole to the element we just removed from the{receiver}.
55855599 etrue1 = graph ()->NewNode (
55865600simplified ()->StoreElement (AccessBuilder::ForFixedArrayElement (
55875601GetHoleyElementsKind (kind))),
5588- elements, length, jsgraph ()->TheHoleConstant (), etrue1, if_true1);
5602+ elements, new_length, jsgraph ()->TheHoleConstant (), etrue1,
5603+ if_true1);
55895604 }
55905605
55915606 Node* if_false1 = graph ()->NewNode (common ()->IfFalse (), branch1);
0 commit comments