[builtins] Change A.p.join invalid string length errors to use ThrowInvalidStringLength runtime.

This is to enable switching from throwing a JS exception (RangeError)
to an abort when the --abort_on_stack_or_string_length_overflow flag
is set.

Bug: chromium:901652
Change-Id: Ia3ff2ec55e77a4f60d715f0bc767e6180a5e001a
Reviewed-on: https://chromium-review.googlesource.com/c/1322312
Commit-Queue: Peter Wong <peter.wm.wong@gmail.com>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57307}
This commit is contained in:
peterwmwong 2018-11-07 15:28:15 +08:00 committed by Commit Bot
parent d1cb4ef48a
commit c80d049a75
2 changed files with 4 additions and 5 deletions

View File

@ -106,7 +106,7 @@ module array {
return length; return length;
} }
label IfOverflow deferred { label IfOverflow deferred {
ThrowRangeError(context, kInvalidStringLength); ThrowInvalidStringLength(context);
} }
} }
@ -203,7 +203,7 @@ module array {
// Detect integer overflow // Detect integer overflow
// TODO(tebbi): Replace with overflow-checked multiplication. // TODO(tebbi): Replace with overflow-checked multiplication.
if (sepsLen / separatorLength != nofSeparatorsInt) deferred { if (sepsLen / separatorLength != nofSeparatorsInt) deferred {
ThrowRangeError(context, kInvalidStringLength); ThrowInvalidStringLength(context);
} }
const totalStringLength: intptr = const totalStringLength: intptr =
@ -348,7 +348,7 @@ module array {
return StringRepeat(context, sep, nofSeparators); return StringRepeat(context, sep, nofSeparators);
} }
label IfNotSmi { label IfNotSmi {
ThrowRangeError(context, kInvalidStringLength); ThrowInvalidStringLength(context);
} }
} else { } else {
loadJoinElements = LoadJoinElement<DictionaryElements>; loadJoinElements = LoadJoinElement<DictionaryElements>;

View File

@ -168,8 +168,6 @@ const kCalledNonCallable: constexpr MessageTemplate
generates 'MessageTemplate::kCalledNonCallable'; generates 'MessageTemplate::kCalledNonCallable';
const kCalledOnNullOrUndefined: constexpr MessageTemplate const kCalledOnNullOrUndefined: constexpr MessageTemplate
generates 'MessageTemplate::kCalledOnNullOrUndefined'; generates 'MessageTemplate::kCalledOnNullOrUndefined';
const kInvalidStringLength: constexpr MessageTemplate
generates 'MessageTemplate::kInvalidStringLength';
const kMaxSafeInteger: constexpr float64 generates 'kMaxSafeInteger'; const kMaxSafeInteger: constexpr float64 generates 'kMaxSafeInteger';
const kStringMaxLength: constexpr int31 generates 'String::kMaxLength'; const kStringMaxLength: constexpr int31 generates 'String::kMaxLength';
@ -303,6 +301,7 @@ extern builtin StringLessThan(Context, String, String): Boolean;
extern macro StrictEqual(Object, Object): Boolean; extern macro StrictEqual(Object, Object): Boolean;
extern macro SmiLexicographicCompare(Smi, Smi): Smi; extern macro SmiLexicographicCompare(Smi, Smi): Smi;
extern runtime ReThrow(Context, Object): never; extern runtime ReThrow(Context, Object): never;
extern runtime ThrowInvalidStringLength(Context): never;
extern operator '<' macro Int32LessThan(int32, int32): bool; extern operator '<' macro Int32LessThan(int32, int32): bool;
extern operator '>' macro Int32GreaterThan(int32, int32): bool; extern operator '>' macro Int32GreaterThan(int32, int32): bool;