Commit ed1473bd authored by Shu-yu Guo's avatar Shu-yu Guo Committed by V8 LUCI CQ

Improve error message for Set/Map grow failures

Bug: v8:11852
Change-Id: I1d3c01b827e847bb7edcd2ebe7d3b340f7d53069
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3097473
Auto-Submit: Shu-yu Guo <syg@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76355}
parent bdb22362
...@@ -380,6 +380,7 @@ namespace internal { ...@@ -380,6 +380,7 @@ namespace internal {
T(TypedArrayTooLargeToSort, \ T(TypedArrayTooLargeToSort, \
"Custom comparefn not supported for huge TypedArrays") \ "Custom comparefn not supported for huge TypedArrays") \
T(ValueOutOfRange, "Value % out of range for % options property %") \ T(ValueOutOfRange, "Value % out of range for % options property %") \
T(CollectionGrowFailed, "% maximum size exceeded") \
/* SyntaxError */ \ /* SyntaxError */ \
T(AmbiguousExport, \ T(AmbiguousExport, \
"The requested module '%' contains conflicting star exports for name '%'") \ "The requested module '%' contains conflicting star exports for name '%'") \
......
...@@ -29,7 +29,9 @@ RUNTIME_FUNCTION(Runtime_SetGrow) { ...@@ -29,7 +29,9 @@ RUNTIME_FUNCTION(Runtime_SetGrow) {
OrderedHashSet::EnsureGrowable(isolate, table); OrderedHashSet::EnsureGrowable(isolate, table);
if (!table_candidate.ToHandle(&table)) { if (!table_candidate.ToHandle(&table)) {
THROW_NEW_ERROR_RETURN_FAILURE( THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewRangeError(MessageTemplate::kValueOutOfRange)); isolate,
NewRangeError(MessageTemplate::kCollectionGrowFailed,
isolate->factory()->NewStringFromAsciiChecked("Set")));
} }
holder->set_table(*table); holder->set_table(*table);
return ReadOnlyRoots(isolate).undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
...@@ -64,7 +66,9 @@ RUNTIME_FUNCTION(Runtime_MapGrow) { ...@@ -64,7 +66,9 @@ RUNTIME_FUNCTION(Runtime_MapGrow) {
OrderedHashMap::EnsureGrowable(isolate, table); OrderedHashMap::EnsureGrowable(isolate, table);
if (!table_candidate.ToHandle(&table)) { if (!table_candidate.ToHandle(&table)) {
THROW_NEW_ERROR_RETURN_FAILURE( THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewRangeError(MessageTemplate::kValueOutOfRange)); isolate,
NewRangeError(MessageTemplate::kCollectionGrowFailed,
isolate->factory()->NewStringFromAsciiChecked("Map")));
} }
holder->set_table(*table); holder->set_table(*table);
return ReadOnlyRoots(isolate).undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
......
...@@ -83,7 +83,7 @@ bytecodes: [ ...@@ -83,7 +83,7 @@ bytecodes: [
B(Mov), R(this), R(0), B(Mov), R(this), R(0),
B(Mov), R(context), R(2), B(Mov), R(context), R(2),
/* 48 E> */ B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(3), /* 48 E> */ B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(3),
/* 53 S> */ B(Wide), B(LdaSmi), I16(283), /* 53 S> */ B(Wide), B(LdaSmi), I16(284),
B(Star3), B(Star3),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star4), B(Star4),
...@@ -114,7 +114,7 @@ bytecodes: [ ...@@ -114,7 +114,7 @@ bytecodes: [
B(Mov), R(this), R(0), B(Mov), R(this), R(0),
B(Mov), R(context), R(2), B(Mov), R(context), R(2),
/* 41 E> */ B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(3), /* 41 E> */ B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(3),
/* 46 S> */ B(Wide), B(LdaSmi), I16(282), /* 46 S> */ B(Wide), B(LdaSmi), I16(283),
B(Star3), B(Star3),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star4), B(Star4),
...@@ -145,7 +145,7 @@ bytecodes: [ ...@@ -145,7 +145,7 @@ bytecodes: [
B(Mov), R(this), R(0), B(Mov), R(this), R(0),
B(Mov), R(context), R(2), B(Mov), R(context), R(2),
/* 48 E> */ B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(3), /* 48 E> */ B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(3),
/* 53 S> */ B(Wide), B(LdaSmi), I16(283), /* 53 S> */ B(Wide), B(LdaSmi), I16(284),
B(Star3), B(Star3),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star4), B(Star4),
...@@ -176,7 +176,7 @@ bytecodes: [ ...@@ -176,7 +176,7 @@ bytecodes: [
B(Mov), R(this), R(0), B(Mov), R(this), R(0),
B(Mov), R(context), R(2), B(Mov), R(context), R(2),
/* 41 E> */ B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(3), /* 41 E> */ B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(3),
/* 46 S> */ B(Wide), B(LdaSmi), I16(282), /* 46 S> */ B(Wide), B(LdaSmi), I16(283),
B(Star4), B(Star4),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star5), B(Star5),
......
...@@ -56,7 +56,7 @@ bytecodes: [ ...@@ -56,7 +56,7 @@ bytecodes: [
B(Mov), R(this), R(0), B(Mov), R(this), R(0),
B(Mov), R(context), R(2), B(Mov), R(context), R(2),
/* 44 E> */ B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(3), /* 44 E> */ B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(3),
/* 49 S> */ B(Wide), B(LdaSmi), I16(281), /* 49 S> */ B(Wide), B(LdaSmi), I16(282),
B(Star3), B(Star3),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star4), B(Star4),
...@@ -88,7 +88,7 @@ bytecodes: [ ...@@ -88,7 +88,7 @@ bytecodes: [
B(Mov), R(this), R(0), B(Mov), R(this), R(0),
B(Mov), R(context), R(2), B(Mov), R(context), R(2),
/* 44 E> */ B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(3), /* 44 E> */ B(CallRuntime), U16(Runtime::kAddPrivateBrand), R(0), U8(3),
/* 49 S> */ B(Wide), B(LdaSmi), I16(281), /* 49 S> */ B(Wide), B(LdaSmi), I16(282),
B(Star3), B(Star3),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star4), B(Star4),
......
...@@ -24,7 +24,7 @@ bytecodes: [ ...@@ -24,7 +24,7 @@ bytecodes: [
B(TestReferenceEqual), R(this), B(TestReferenceEqual), R(this),
B(Mov), R(this), R(1), B(Mov), R(this), R(1),
B(JumpIfTrue), U8(16), B(JumpIfTrue), U8(16),
B(Wide), B(LdaSmi), I16(279), B(Wide), B(LdaSmi), I16(280),
B(Star2), B(Star2),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star3), B(Star3),
...@@ -55,7 +55,7 @@ frame size: 2 ...@@ -55,7 +55,7 @@ frame size: 2
parameter count: 1 parameter count: 1
bytecode array length: 14 bytecode array length: 14
bytecodes: [ bytecodes: [
/* 56 S> */ B(Wide), B(LdaSmi), I16(281), /* 56 S> */ B(Wide), B(LdaSmi), I16(282),
B(Star0), B(Star0),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star1), B(Star1),
...@@ -82,7 +82,7 @@ frame size: 2 ...@@ -82,7 +82,7 @@ frame size: 2
parameter count: 1 parameter count: 1
bytecode array length: 14 bytecode array length: 14
bytecodes: [ bytecodes: [
/* 56 S> */ B(Wide), B(LdaSmi), I16(281), /* 56 S> */ B(Wide), B(LdaSmi), I16(282),
B(Star0), B(Star0),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star1), B(Star1),
...@@ -121,7 +121,7 @@ bytecodes: [ ...@@ -121,7 +121,7 @@ bytecodes: [
B(TestReferenceEqual), R(this), B(TestReferenceEqual), R(this),
B(Mov), R(this), R(0), B(Mov), R(this), R(0),
B(JumpIfTrue), U8(16), B(JumpIfTrue), U8(16),
B(Wide), B(LdaSmi), I16(279), B(Wide), B(LdaSmi), I16(280),
B(Star2), B(Star2),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star3), B(Star3),
...@@ -143,7 +143,7 @@ bytecodes: [ ...@@ -143,7 +143,7 @@ bytecodes: [
B(TestReferenceEqual), R(this), B(TestReferenceEqual), R(this),
B(Mov), R(this), R(1), B(Mov), R(this), R(1),
B(JumpIfTrue), U8(16), B(JumpIfTrue), U8(16),
B(Wide), B(LdaSmi), I16(280), B(Wide), B(LdaSmi), I16(281),
B(Star3), B(Star3),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star4), B(Star4),
...@@ -158,7 +158,7 @@ bytecodes: [ ...@@ -158,7 +158,7 @@ bytecodes: [
B(TestReferenceEqual), R(this), B(TestReferenceEqual), R(this),
B(Mov), R(this), R(0), B(Mov), R(this), R(0),
B(JumpIfTrue), U8(16), B(JumpIfTrue), U8(16),
B(Wide), B(LdaSmi), I16(279), B(Wide), B(LdaSmi), I16(280),
B(Star2), B(Star2),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star3), B(Star3),
...@@ -188,7 +188,7 @@ frame size: 2 ...@@ -188,7 +188,7 @@ frame size: 2
parameter count: 1 parameter count: 1
bytecode array length: 14 bytecode array length: 14
bytecodes: [ bytecodes: [
/* 60 S> */ B(Wide), B(LdaSmi), I16(283), /* 60 S> */ B(Wide), B(LdaSmi), I16(284),
B(Star0), B(Star0),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star1), B(Star1),
...@@ -214,7 +214,7 @@ frame size: 2 ...@@ -214,7 +214,7 @@ frame size: 2
parameter count: 1 parameter count: 1
bytecode array length: 14 bytecode array length: 14
bytecodes: [ bytecodes: [
/* 53 S> */ B(Wide), B(LdaSmi), I16(282), /* 53 S> */ B(Wide), B(LdaSmi), I16(283),
B(Star0), B(Star0),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star1), B(Star1),
...@@ -240,7 +240,7 @@ frame size: 2 ...@@ -240,7 +240,7 @@ frame size: 2
parameter count: 1 parameter count: 1
bytecode array length: 14 bytecode array length: 14
bytecodes: [ bytecodes: [
/* 60 S> */ B(Wide), B(LdaSmi), I16(283), /* 60 S> */ B(Wide), B(LdaSmi), I16(284),
B(Star0), B(Star0),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star1), B(Star1),
...@@ -266,7 +266,7 @@ frame size: 3 ...@@ -266,7 +266,7 @@ frame size: 3
parameter count: 1 parameter count: 1
bytecode array length: 14 bytecode array length: 14
bytecodes: [ bytecodes: [
/* 46 S> */ B(Wide), B(LdaSmi), I16(282), /* 46 S> */ B(Wide), B(LdaSmi), I16(283),
B(Star1), B(Star1),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star2), B(Star2),
......
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
const kMapSizeLimit = 1 << 24;
let m = new Map();
for (let i = 0; i < kMapSizeLimit + 1; i++) {
m.set(i, 0);
}
*%(basename)s:{NUMBER}: RangeError: Map maximum size exceeded
m.set(i, 0);
^
RangeError: Map maximum size exceeded
at Map.set (<anonymous>)
at *%(basename)s:{NUMBER}:{NUMBER}
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
const kSetSizeLimit = 1 << 24;
let s = new Set();
for (let i = 0; i < kSetSizeLimit + 1; i++) {
s.add(i);
}
*%(basename)s:{NUMBER}: RangeError: Set maximum size exceeded
s.add(i);
^
RangeError: Set maximum size exceeded
at Set.add (<anonymous>)
at *%(basename)s:{NUMBER}:{NUMBER}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment