Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1de5512

Browse filesBrowse files
committed
deps: V8: cherry-pick 217457d0a560
Original commit message: [set-methods] Handle SetLike with infinite size This CL adds a check for identifying SetLikes with infinite sizes in methods dependent on the size of `other`s. Bug: 351332634 Change-Id: I5c6d9c0cc7f3f5fae5cedc72a44bc21c917c84b8 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5684652 Reviewed-by: Shu-yu Guo <syg@chromium.org> Commit-Queue: Rezvan Mahdavi Hezaveh <rezvan@chromium.org> Cr-Commit-Position: refs/heads/main@{#94897} Refs: v8/v8@217457d PR-URL: #54883 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
1 parent 67ecb10 commit 1de5512
Copy full SHA for 1de5512

File tree

Expand file treeCollapse file tree

11 files changed

+190
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

11 files changed

+190
-7
lines changed
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.19',
39+
'v8_embedder_string': '-node.20',
4040

4141
##### V8 defaults for Node.js #####
4242

Collapse file

‎deps/v8/src/builtins/set-difference.tq‎

Copy file name to clipboardExpand all lines: deps/v8/src/builtins/set-difference.tq
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ transitioning javascript builtin SetPrototypeDifference(
8585
}
8686
} label SlowPath {
8787
// 6. If thisSize ≤ otherRec.[[Size]], then
88-
if (thisSize <= Convert<int32>(otherRec.size)) {
88+
if (otherRec.size == V8_INFINITY ||
89+
thisSize <= Convert<int32>(otherRec.size)) {
8990
// a. Let index be 0.
9091
let thisIter = collections::NewOrderedHashSetIterator(table.GetTable());
9192

Collapse file

‎deps/v8/src/builtins/set-intersection.tq‎

Copy file name to clipboardExpand all lines: deps/v8/src/builtins/set-intersection.tq
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ transitioning javascript builtin SetPrototypeIntersection(
8181
}
8282
} label SlowPath {
8383
// 6. If thisSize ≤ otherRec.[[Size]], then
84-
if (thisSize <= Convert<int32>(otherRec.size)) {
84+
if (otherRec.size == V8_INFINITY ||
85+
thisSize <= Convert<int32>(otherRec.size)) {
8586
// a. Let index be 0.
8687
let thisIter = collections::NewOrderedHashSetIterator(table.GetTable());
8788

Collapse file

‎deps/v8/src/builtins/set-is-disjoint-from.tq‎

Copy file name to clipboardExpand all lines: deps/v8/src/builtins/set-is-disjoint-from.tq
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ transitioning javascript builtin SetPrototypeIsDisjointFrom(
7373
}
7474
} label SlowPath {
7575
// 5. If thisSize ≤ otherRec.[[Size]], then
76-
if (thisSize <= Convert<int32>(otherRec.size)) {
76+
if (otherRec.size == V8_INFINITY ||
77+
thisSize <= Convert<int32>(otherRec.size)) {
7778
// a. Let index be 0.
7879
let thisIter = collections::NewOrderedHashSetIterator(table.GetTable());
7980

Collapse file

‎deps/v8/src/builtins/set-is-subset-of.tq‎

Copy file name to clipboardExpand all lines: deps/v8/src/builtins/set-is-subset-of.tq
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ transitioning javascript builtin SetPrototypeIsSubsetOf(
2525
const thisSize = table.LoadSize();
2626

2727
// 5. If thisSize > otherRec.[[Size]], return false.
28-
if (thisSize > Convert<int32>(otherRec.size)) {
28+
if (!(otherRec.size == V8_INFINITY) &&
29+
thisSize > Convert<int32>(otherRec.size)) {
2930
return False;
3031
}
3132

Collapse file

‎deps/v8/src/builtins/set-is-superset-of.tq‎

Copy file name to clipboardExpand all lines: deps/v8/src/builtins/set-is-superset-of.tq
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ transitioning javascript builtin SetPrototypeIsSupersetOf(
2626
const thisSize = table.LoadSize();
2727

2828
// 5. If thisSize < otherRec.[[Size]], return false.
29-
if (thisSize < Convert<int32>(otherRec.size)) {
29+
if (otherRec.size == V8_INFINITY ||
30+
thisSize < Convert<int32>(otherRec.size)) {
3031
return False;
3132
}
3233

Collapse file

‎deps/v8/test/mjsunit/harmony/set-difference.js‎

Copy file name to clipboardExpand all lines: deps/v8/test/mjsunit/harmony/set-difference.js
+40-1Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,43 @@
305305
assertThrows(() => {
306306
new Set().difference(setLike);
307307
}, RangeError, "'-1' is an invalid size");
308-
})()
308+
})();
309+
310+
(function TestDifferenceSetLikeWithInfiniteSize() {
311+
let setLike = {
312+
size: Infinity,
313+
has(v) {
314+
return true;
315+
},
316+
keys() {
317+
throw new Error('Unexpected call to |keys| method');
318+
},
319+
};
320+
321+
const firstSet = new Set();
322+
firstSet.add(42);
323+
firstSet.add(43);
324+
325+
const resultSet = new Set();
326+
327+
const resultArray = Array.from(resultSet);
328+
const differenceArray = Array.from(firstSet.difference(setLike));
329+
330+
assertEquals(resultArray, differenceArray);
331+
})();
332+
333+
(function TestDifferenceSetLikeWithNegativeInfiniteSize() {
334+
let setLike = {
335+
size: -Infinity,
336+
has(v) {
337+
return true;
338+
},
339+
keys() {
340+
throw new Error('Unexpected call to |keys| method');
341+
},
342+
};
343+
344+
assertThrows(() => {
345+
new Set().difference(setLike);
346+
}, RangeError, '\'-Infinity\' is an invalid size');
347+
})();
Collapse file

‎deps/v8/test/mjsunit/harmony/set-intersection.js‎

Copy file name to clipboardExpand all lines: deps/v8/test/mjsunit/harmony/set-intersection.js
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,40 @@
281281

282282
assertEquals([43], Array.from(firstSet.intersection(evil)));
283283
})();
284+
285+
(function TestIntersectionSetLikeWithInfiniteSize() {
286+
let setLike = {
287+
size: Infinity,
288+
has(v) {
289+
return true;
290+
},
291+
keys() {
292+
throw new Error('Unexpected call to |keys| method');
293+
},
294+
};
295+
296+
const firstSet = new Set();
297+
firstSet.add(42);
298+
firstSet.add(43);
299+
300+
const resultArray = [42, 43];
301+
const intersectionArray = Array.from(firstSet.intersection(setLike));
302+
303+
assertEquals(resultArray, intersectionArray);
304+
})();
305+
306+
(function TestIntersectionSetLikeWithNegativeInfiniteSize() {
307+
let setLike = {
308+
size: -Infinity,
309+
has(v) {
310+
return true;
311+
},
312+
keys() {
313+
throw new Error('Unexpected call to |keys| method');
314+
},
315+
};
316+
317+
assertThrows(() => {
318+
new Set().intersection(setLike);
319+
}, RangeError, '\'-Infinity\' is an invalid size');
320+
})();
Collapse file

‎deps/v8/test/mjsunit/harmony/set-is-disjoint-from.js‎

Copy file name to clipboardExpand all lines: deps/v8/test/mjsunit/harmony/set-is-disjoint-from.js
+34Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,37 @@
216216

217217
assertFalse(firstSet.isDisjointFrom(evil));
218218
})();
219+
220+
(function TestIsDisjointFromSetLikeWithInfiniteSize() {
221+
let setLike = {
222+
size: Infinity,
223+
has(v) {
224+
return true;
225+
},
226+
keys() {
227+
throw new Error('Unexpected call to |keys| method');
228+
},
229+
};
230+
231+
const firstSet = new Set();
232+
firstSet.add(42);
233+
firstSet.add(43);
234+
235+
assertEquals(firstSet.isDisjointFrom(setLike), false);
236+
})();
237+
238+
(function TestIsDisjointFromSetLikeWithNegativeInfiniteSize() {
239+
let setLike = {
240+
size: -Infinity,
241+
has(v) {
242+
return true;
243+
},
244+
keys() {
245+
throw new Error('Unexpected call to |keys| method');
246+
},
247+
};
248+
249+
assertThrows(() => {
250+
new Set().isDisjointFrom(setLike);
251+
}, RangeError, '\'-Infinity\' is an invalid size');
252+
})();
Collapse file

‎deps/v8/test/mjsunit/harmony/set-is-subset-of.js‎

Copy file name to clipboardExpand all lines: deps/v8/test/mjsunit/harmony/set-is-subset-of.js
+34Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,37 @@
266266

267267
assertEquals(firstSet.isSubsetOf(setLike), true);
268268
})();
269+
270+
(function TestIsSubsetOfSetLikeWithInfiniteSize() {
271+
let setLike = {
272+
size: Infinity,
273+
has(v) {
274+
return true;
275+
},
276+
keys() {
277+
throw new Error('Unexpected call to |keys| method');
278+
},
279+
};
280+
281+
const firstSet = new Set();
282+
firstSet.add(42);
283+
firstSet.add(43);
284+
285+
assertEquals(firstSet.isSubsetOf(setLike), true);
286+
})();
287+
288+
(function TestIsSubsetOfSetLikeWithNegativeInfiniteSize() {
289+
let setLike = {
290+
size: -Infinity,
291+
has(v) {
292+
return true;
293+
},
294+
keys() {
295+
throw new Error('Unexpected call to |keys| method');
296+
},
297+
};
298+
299+
assertThrows(() => {
300+
new Set().isSubsetOf(setLike);
301+
}, RangeError, '\'-Infinity\' is an invalid size');
302+
})();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.