[errors] Add the requested length to the TypedArray length error.

Why not?

Bug: v8:6215
Change-Id: I29f3731cbd0d03af6858eb475a1df8b8988cb89f
Reviewed-on: https://chromium-review.googlesource.com/469848
Reviewed-by: Franziska Hinkelmann <franzih@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44452}
This commit is contained in:
Peter Marshall 2017-04-06 16:27:23 +02:00 committed by Commit Bot
parent 1ccf6c0943
commit 4f03ccdfcf
3 changed files with 8 additions and 7 deletions

View File

@ -354,7 +354,7 @@ TF_BUILTIN(TypedArrayConstructByLength, TypedArrayBuiltinsAssembler) {
BIND(&invalid_length);
{
CallRuntime(Runtime::kThrowRangeError, context,
SmiConstant(MessageTemplate::kInvalidTypedArrayLength));
SmiConstant(MessageTemplate::kInvalidTypedArrayLength), length);
Unreachable();
}
}
@ -495,7 +495,7 @@ TF_BUILTIN(TypedArrayConstructByArrayBuffer, TypedArrayBuiltinsAssembler) {
BIND(&invalid_length);
{
CallRuntime(Runtime::kThrowRangeError, context,
SmiConstant(MessageTemplate::kInvalidTypedArrayLength));
SmiConstant(MessageTemplate::kInvalidTypedArrayLength), length);
Unreachable();
}
}
@ -536,7 +536,7 @@ compiler::Node* TypedArrayBuiltinsAssembler::ByteLengthIsValid(
TF_BUILTIN(TypedArrayConstructByArrayLike, TypedArrayBuiltinsAssembler) {
Node* const holder = Parameter(Descriptor::kHolder);
Node* const array_like = Parameter(Descriptor::kArrayLike);
Node* length = Parameter(Descriptor::kLength);
Node* initial_length = Parameter(Descriptor::kLength);
Node* const element_size = Parameter(Descriptor::kElementSize);
CSA_ASSERT(this, TaggedIsSmi(element_size));
Node* const context = Parameter(Descriptor::kContext);
@ -547,7 +547,7 @@ TF_BUILTIN(TypedArrayConstructByArrayLike, TypedArrayBuiltinsAssembler) {
Label invalid_length(this), fill(this), fast_copy(this);
// The caller has looked up length on array_like, which is observable.
length = ToSmiLength(length, context, &invalid_length);
Node* length = ToSmiLength(initial_length, context, &invalid_length);
InitializeBasedOnLength(holder, length, element_size, byte_offset, initialize,
context);
@ -597,7 +597,8 @@ TF_BUILTIN(TypedArrayConstructByArrayLike, TypedArrayBuiltinsAssembler) {
BIND(&invalid_length);
{
CallRuntime(Runtime::kThrowRangeError, context,
SmiConstant(MessageTemplate::kInvalidTypedArrayLength));
SmiConstant(MessageTemplate::kInvalidTypedArrayLength),
initial_length);
Unreachable();
}
}

View File

@ -525,7 +525,7 @@ class ErrorUtils : public AllStatic {
T(InvalidTimeValue, "Invalid time value") \
T(InvalidTypedArrayAlignment, "% of % should be a multiple of %") \
T(InvalidTypedArrayIndex, "Invalid typed array index") \
T(InvalidTypedArrayLength, "Invalid typed array length") \
T(InvalidTypedArrayLength, "Invalid typed array length: %") \
T(LetInLexicalBinding, "let is disallowed as a lexically bound name") \
T(LocaleMatcher, "Illegal value for localeMatcher:%") \
T(NormalizationForm, "The normalization form should be one of %.") \

View File

@ -417,7 +417,7 @@ test(function() {
// kInvalidArrayBufferLength
test(function() {
new Uint16Array(-1);
}, "Invalid typed array length", RangeError);
}, "Invalid typed array length: -1", RangeError);
// kNormalizationForm
test(function() {