Skip to content

Commit 0ec3f4c

Browse files
committed
Bug 1965844 - Part 4: Correctly update search index for resized typed array in lastIndexOf. r=jandem
Test case in <tc39/test262#4477>. Differential Revision: https://phabricator.services.mozilla.com/D248929 UltraBlame original commit: a7c3286c781fa3d67f2b75540b9be2c476e523a0
1 parent 1ab214d commit 0ec3f4c

File tree

1 file changed

+127
-69
lines changed

1 file changed

+127
-69
lines changed

js/src/vm/TypedArrayObject.cpp

Lines changed: 127 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -16113,6 +16113,91 @@ false
1611316113
}
1611416114
/
1611516115
/
16116+
Steps
16117+
6
16118+
-
16119+
8
16120+
.
16121+
if
16122+
(
16123+
fromIndex
16124+
>
16125+
=
16126+
0
16127+
)
16128+
{
16129+
k
16130+
=
16131+
size_t
16132+
(
16133+
std
16134+
:
16135+
:
16136+
min
16137+
(
16138+
fromIndex
16139+
double
16140+
(
16141+
len
16142+
-
16143+
1
16144+
)
16145+
)
16146+
)
16147+
;
16148+
}
16149+
else
16150+
{
16151+
double
16152+
d
16153+
=
16154+
double
16155+
(
16156+
len
16157+
)
16158+
+
16159+
fromIndex
16160+
;
16161+
if
16162+
(
16163+
d
16164+
<
16165+
0
16166+
)
16167+
{
16168+
args
16169+
.
16170+
rval
16171+
(
16172+
)
16173+
.
16174+
setInt32
16175+
(
16176+
-
16177+
1
16178+
)
16179+
;
16180+
return
16181+
true
16182+
;
16183+
}
16184+
k
16185+
=
16186+
size_t
16187+
(
16188+
d
16189+
)
16190+
;
16191+
}
16192+
MOZ_ASSERT
16193+
(
16194+
k
16195+
<
16196+
len
16197+
)
16198+
;
16199+
/
16200+
/
1611616201
Reacquire
1611716202
the
1611816203
length
@@ -16131,14 +16216,9 @@ the
1613116216
array
1613216217
buffer
1613316218
.
16134-
len
16219+
size_t
16220+
currentLength
1613516221
=
16136-
std
16137-
:
16138-
:
16139-
min
16140-
(
16141-
len
1614216222
tarray
1614316223
-
1614416224
>
@@ -16150,10 +16230,31 @@ valueOr
1615016230
(
1615116231
0
1615216232
)
16153-
)
1615416233
;
1615516234
/
1615616235
/
16236+
Restrict
16237+
the
16238+
search
16239+
index
16240+
and
16241+
length
16242+
if
16243+
the
16244+
new
16245+
length
16246+
is
16247+
smaller
16248+
.
16249+
if
16250+
(
16251+
currentLength
16252+
<
16253+
len
16254+
)
16255+
{
16256+
/
16257+
/
1615716258
Return
1615816259
early
1615916260
if
@@ -16165,7 +16266,7 @@ zero
1616516266
.
1616616267
if
1616716268
(
16168-
len
16269+
currentLength
1616916270
=
1617016271
=
1617116272
0
@@ -16189,80 +16290,37 @@ true
1618916290
}
1619016291
/
1619116292
/
16192-
Steps
16193-
6
16194-
-
16195-
8
16293+
Otherwise
16294+
just
16295+
restrict
16296+
|
16297+
k
16298+
|
16299+
and
16300+
|
16301+
len
16302+
|
16303+
to
16304+
the
16305+
current
16306+
length
1619616307
.
16197-
if
16198-
(
16199-
fromIndex
16200-
>
16201-
=
16202-
0
16203-
)
16204-
{
1620516308
k
1620616309
=
16207-
size_t
16208-
(
1620916310
std
1621016311
:
1621116312
:
1621216313
min
1621316314
(
16214-
fromIndex
16215-
double
16216-
(
16217-
len
16315+
k
16316+
currentLength
1621816317
-
1621916318
1
1622016319
)
16221-
)
16222-
)
1622316320
;
16224-
}
16225-
else
16226-
{
16227-
double
16228-
d
16229-
=
16230-
double
16231-
(
1623216321
len
16233-
)
16234-
+
16235-
fromIndex
16236-
;
16237-
if
16238-
(
16239-
d
16240-
<
16241-
0
16242-
)
16243-
{
16244-
args
16245-
.
16246-
rval
16247-
(
16248-
)
16249-
.
16250-
setInt32
16251-
(
16252-
-
16253-
1
16254-
)
16255-
;
16256-
return
16257-
true
16258-
;
16259-
}
16260-
k
1626116322
=
16262-
size_t
16263-
(
16264-
d
16265-
)
16323+
currentLength
1626616324
;
1626716325
}
1626816326
}

0 commit comments

Comments
 (0)