Commit b4bfbce6 authored by Mike Stanton's avatar Mike Stanton Committed by Commit Bot

[Builtins] Math.abs and Math.imul ported to Torque

This is part of a general move of math builtins away from
builtins-math-gen.cc.

Change-Id: Ifb6e5d4779bb9e6f69ff7c58d09ca8fc94f4cc66
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1914210
Commit-Queue: Michael Stanton <mvstanton@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64943}
parent a5376b7e
......@@ -17,14 +17,14 @@ namespace array {
const length: Number = GetLengthProperty(object);
// 3. Let relativeTarget be ? ToInteger(target).
const relativeTarget: Number = ToInteger_Inline(context, arguments[0]);
const relativeTarget: Number = ToInteger_Inline(arguments[0]);
// 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0);
// else let to be min(relativeTarget, len).
let to: Number = ConvertToRelativeIndex(relativeTarget, length);
// 5. Let relativeStart be ? ToInteger(start).
const relativeStart: Number = ToInteger_Inline(context, arguments[1]);
const relativeStart: Number = ToInteger_Inline(arguments[1]);
// 6. If relativeStart < 0, let from be max((len + relativeStart), 0);
// else let from be min(relativeStart, len).
......@@ -34,7 +34,7 @@ namespace array {
// else let relativeEnd be ? ToInteger(end).
let relativeEnd: Number = length;
if (arguments[2] != Undefined) {
relativeEnd = ToInteger_Inline(context, arguments[2]);
relativeEnd = ToInteger_Inline(arguments[2]);
}
// 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0);
......
......@@ -74,7 +74,7 @@ namespace array {
} else {
result = Call(context, callable, element, locales, options);
}
return ToString_Inline(context, result);
return ToString_Inline(result);
}
label TypeError {
ThrowTypeError(kCalledNonCallable, prop);
......@@ -528,8 +528,7 @@ namespace array {
sepObj: JSAny, locales: JSAny, options: JSAny): JSAny {
// 3. If separator is undefined, let sep be the single-element String ",".
// 4. Else, let sep be ? ToString(separator).
const sep: String =
sepObj == Undefined ? ',' : ToString_Inline(context, sepObj);
const sep: String = sepObj == Undefined ? ',' : ToString_Inline(sepObj);
// If the receiver is not empty and not already being joined, continue with
// the normal join algorithm.
......
......@@ -64,7 +64,7 @@ namespace array {
// else let n be len - 1.
const n: Number = arguments.length < 2 ?
length - 1 :
ToInteger_Inline(context, arguments[1], kTruncateMinusZero);
ToInteger_Inline(arguments[1], kTruncateMinusZero);
// 5. If n >= 0, then.
let k: Number = SmiConstant(0);
......
......@@ -143,7 +143,7 @@ namespace array {
// 3. Let relativeStart be ? ToInteger(start).
const start: JSAny = arguments[0];
const relativeStart: Number = ToInteger_Inline(context, start);
const relativeStart: Number = ToInteger_Inline(start);
// 4. If relativeStart < 0, let k be max((len + relativeStart), 0);
// else let k be min(relativeStart, len).
......@@ -153,8 +153,7 @@ namespace array {
// 5. If end is undefined, let relativeEnd be len;
// else let relativeEnd be ? ToInteger(end).
const end: JSAny = arguments[1];
const relativeEnd: Number =
end == Undefined ? len : ToInteger_Inline(context, end);
const relativeEnd: Number = end == Undefined ? len : ToInteger_Inline(end);
// 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0);
// else let final be min(relativeEnd, len).
......
......@@ -360,7 +360,7 @@ namespace array {
// 3. Let relativeStart be ? ToInteger(start).
const start: JSAny = arguments[0];
const relativeStart: Number = ToInteger_Inline(context, start);
const relativeStart: Number = ToInteger_Inline(start);
// 4. If relativeStart < 0, let actualStart be max((len + relativeStart),
// 0);
......@@ -389,7 +389,7 @@ namespace array {
insertCount = Convert<Smi>(arguments.length) - 2;
// b. Let dc be ? ToInteger(deleteCount).
const deleteCount: JSAny = arguments[1];
const dc: Number = ToInteger_Inline(context, deleteCount);
const dc: Number = ToInteger_Inline(deleteCount);
// c. Let actualDeleteCount be min(max(dc, 0), len - actualStart).
actualDeleteCount = Min(Max(dc, 0), len - actualStart);
}
......
......@@ -460,12 +460,16 @@ extern macro Comment(constexpr string);
extern macro StaticAssert(bool);
extern macro Print(Object);
extern macro DebugBreak();
extern transitioning macro ToInteger_Inline(Context, JSAny): Number;
extern transitioning macro ToInteger_Inline(
Context, JSAny, constexpr ToIntegerTruncationMode): Number;
extern transitioning macro ToLength_Inline(Context, JSAny): Number;
extern transitioning macro ToNumber_Inline(Context, JSAny): Number;
extern transitioning macro ToString_Inline(Context, JSAny): String;
extern transitioning macro ToInteger_Inline(implicit context: Context)(JSAny):
Number;
extern transitioning macro ToInteger_Inline(implicit context: Context)(
JSAny, constexpr ToIntegerTruncationMode): Number;
extern transitioning macro ToLength_Inline(implicit context: Context)(JSAny):
Number;
extern transitioning macro ToNumber_Inline(implicit context: Context)(JSAny):
Number;
extern transitioning macro ToString_Inline(implicit context: Context)(JSAny):
String;
extern transitioning macro ToThisString(implicit context: Context)(
JSAny, String): String;
extern transitioning macro ToThisValue(implicit context: Context)(
......@@ -1197,7 +1201,7 @@ macro ChangeSafeIntegerNumberToUintPtr(value: Number):
transitioning macro ToUintPtr(implicit context: Context)(value: JSAny):
uintptr labels IfLessThanZero, IfUIntPtrOverflow, IfSafeIntegerOverflow {
if (value == Undefined) return 0;
const indexNumber = ToInteger_Inline(context, value, kTruncateMinusZero);
const indexNumber = ToInteger_Inline(value, kTruncateMinusZero);
return TryNumberToUintPtr(indexNumber, kModeValueIsAnyNumber)
otherwise IfLessThanZero, IfUIntPtrOverflow, IfSafeIntegerOverflow;
}
......@@ -1211,7 +1215,7 @@ transitioning macro ToUintPtr(implicit context: Context)(value: JSAny):
transitioning macro ToIndex(implicit context: Context)(value: JSAny):
uintptr labels IfRangeError {
if (value == Undefined) return 0;
const indexNumber = ToInteger_Inline(context, value, kTruncateMinusZero);
const indexNumber = ToInteger_Inline(value, kTruncateMinusZero);
// Less than 0 case, uintptr range overflow and safe integer range overflow
// imply IfRangeError.
return TryNumberToUintPtr(indexNumber, kModeValueIsAnyNumber)
......@@ -1234,7 +1238,7 @@ transitioning macro GetLengthProperty(implicit context: Context)(o: JSAny):
}
}
label ToLength(length: JSAny) deferred {
return ToLength_Inline(context, length);
return ToLength_Inline(length);
}
}
......@@ -1282,8 +1286,7 @@ extern macro AllocateSeqTwoByteString(uint32): String;
@export
transitioning macro ConvertToRelativeIndex(implicit context: Context)(
index: JSAny, length: uintptr): uintptr {
const indexNumber: Number =
ToInteger_Inline(context, index, kTruncateMinusZero);
const indexNumber: Number = ToInteger_Inline(index, kTruncateMinusZero);
return ConvertToRelativeIndex(indexNumber, length);
}
......@@ -1330,8 +1333,7 @@ macro ConvertToRelativeIndex(indexNumber: Number, length: uintptr): uintptr {
@export
transitioning macro ClampToIndexRange(implicit context: Context)(
index: JSAny, limit: uintptr): uintptr {
const indexNumber: Number =
ToInteger_Inline(context, index, kTruncateMinusZero);
const indexNumber: Number = ToInteger_Inline(index, kTruncateMinusZero);
return ClampToIndexRange(indexNumber, limit);
}
......
......@@ -628,14 +628,10 @@ namespace internal {
TFS(MapIteratorToList, kSource) \
\
/* Math */ \
/* ES6 #sec-math.abs */ \
TFJ(MathAbs, 1, kReceiver, kX) \
/* ES6 #sec-math.ceil */ \
TFJ(MathCeil, 1, kReceiver, kX) \
/* ES6 #sec-math.floor */ \
TFJ(MathFloor, 1, kReceiver, kX) \
/* ES6 #sec-math.imul */ \
TFJ(MathImul, 2, kReceiver, kX, kY) \
/* ES6 #sec-math.max */ \
TFJ(MathMax, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
/* ES6 #sec-math.min */ \
......
......@@ -16,90 +16,6 @@ namespace internal {
// -----------------------------------------------------------------------------
// ES6 section 20.2.2 Function Properties of the Math Object
// ES6 #sec-math.abs
TF_BUILTIN(MathAbs, CodeStubAssembler) {
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
// We might need to loop once for ToNumber conversion.
TVARIABLE(Object, var_x);
Label loop(this, &var_x);
var_x = CAST(Parameter(Descriptor::kX));
Goto(&loop);
BIND(&loop);
{
// Load the current {x} value.
TNode<Object> x = var_x.value();
// Check if {x} is a Smi or a HeapObject.
Label if_xissmi(this), if_xisnotsmi(this);
Branch(TaggedIsSmi(x), &if_xissmi, &if_xisnotsmi);
BIND(&if_xissmi);
{
TNode<Smi> x_smi = CAST(x);
Label if_overflow(this, Label::kDeferred);
// check if support abs function
if (IsIntPtrAbsWithOverflowSupported()) {
TNode<PairT<IntPtrT, BoolT>> pair =
IntPtrAbsWithOverflow(BitcastTaggedToWordForTagAndSmiBits(x_smi));
TNode<BoolT> overflow = Projection<1>(pair);
GotoIf(overflow, &if_overflow);
// There is a Smi representation for negated {x}.
TNode<IntPtrT> result = Projection<0>(pair);
Return(BitcastWordToTagged(result));
} else {
// Check if {x} is already positive.
Label if_xispositive(this), if_xisnotpositive(this);
BranchIfSmiLessThanOrEqual(SmiConstant(0), x_smi, &if_xispositive,
&if_xisnotpositive);
BIND(&if_xispositive);
{
// Just return the input {x}.
Return(x_smi);
}
BIND(&if_xisnotpositive);
{
// Try to negate the {x} value.
TNode<Smi> result = TrySmiSub(SmiConstant(0), x_smi, &if_overflow);
Return(result);
}
}
BIND(&if_overflow);
{ Return(NumberConstant(0.0 - Smi::kMinValue)); }
}
BIND(&if_xisnotsmi);
{
// Check if {x} is a HeapNumber.
Label if_xisheapnumber(this), if_xisnotheapnumber(this, Label::kDeferred);
TNode<HeapObject> x_heap_object = CAST(x);
Branch(IsHeapNumber(x_heap_object), &if_xisheapnumber,
&if_xisnotheapnumber);
BIND(&if_xisheapnumber);
{
TNode<Float64T> x_value = LoadHeapNumberValue(x_heap_object);
TNode<Float64T> value = Float64Abs(x_value);
TNode<HeapNumber> result = AllocateHeapNumberWithValue(value);
Return(result);
}
BIND(&if_xisnotheapnumber);
{
// Need to convert {x} to a Number first.
var_x = CallBuiltin(Builtins::kNonNumberToNumber, context, x);
Goto(&loop);
}
}
}
}
void MathBuiltinsAssembler::MathRoundingOperation(
TNode<Context> context, TNode<Object> x,
TNode<Float64T> (CodeStubAssembler::*float64op)(SloppyTNode<Float64T>)) {
......@@ -180,18 +96,6 @@ TF_BUILTIN(MathFloor, MathBuiltinsAssembler) {
MathRoundingOperation(context, x, &CodeStubAssembler::Float64Floor);
}
// ES6 #sec-math.imul
TF_BUILTIN(MathImul, CodeStubAssembler) {
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<Object> x = CAST(Parameter(Descriptor::kX));
TNode<Object> y = CAST(Parameter(Descriptor::kY));
TNode<Word32T> x_value = TruncateTaggedToWord32(context, x);
TNode<Word32T> y_value = TruncateTaggedToWord32(context, y);
TNode<Int32T> value = Signed(Int32Mul(x_value, y_value));
TNode<Number> result = ChangeInt32ToTagged(value);
Return(result);
}
TNode<Number> MathBuiltinsAssembler::MathPow(TNode<Context> context,
TNode<Object> base,
TNode<Object> exponent) {
......
......@@ -66,8 +66,7 @@ namespace string {
const string: String = ToThisString(receiver, methodName);
// 3. Let position be ? ToInteger(pos).
const indexNumber: Number =
ToInteger_Inline(context, position, kTruncateMinusZero);
const indexNumber: Number = ToInteger_Inline(position, kTruncateMinusZero);
// Convert the {position} to a uintptr and check that it's in bounds of
// the {string}.
......@@ -153,7 +152,7 @@ namespace string {
// Concatenate all the arguments passed to this builtin.
const length: intptr = Convert<intptr>(arguments.length);
for (let i: intptr = 0; i < length; i++) {
const temp: String = ToString_Inline(context, arguments[i]);
const temp: String = ToString_Inline(arguments[i]);
string = string + temp;
}
return string;
......@@ -186,7 +185,7 @@ namespace string {
}
}
// 2. b. Let s be ? ToString(value).
s = ToString_Inline(context, arguments[0]);
s = ToString_Inline(arguments[0]);
}
// 3. If NewTarget is undefined, return s.
if (newTarget == Undefined) {
......
......@@ -140,6 +140,17 @@ Convert<int32, uint31>(i: uint31): int32 {
Convert<int32, intptr>(i: intptr): int32 {
return TruncateIntPtrToInt32(i);
}
Convert<int32, Number>(n: Number): int32 {
typeswitch (n) {
case (s: Smi): {
return Convert<int32>(s);
}
case (h: HeapNumber): {
return TruncateHeapNumberValueToWord32(h);
}
}
}
Convert<Smi, intptr>(i: intptr): Smi {
return SmiTag(i);
}
......
This diff is collapsed.
......@@ -36,9 +36,8 @@ namespace number {
// 3. Else if radix is undefined, let radixNumber be 10.
// 4. Else, let radixNumber be ? ToInteger(radix).
const radix: JSAny = arguments[0];
const radixNumber: Number = radix == Undefined ?
10 :
ToInteger_Inline(context, radix, kTruncateMinusZero);
const radixNumber: Number =
radix == Undefined ? 10 : ToInteger_Inline(radix, kTruncateMinusZero);
// 5. If radixNumber < 2 or radixNumber > 36, throw a RangeError exception.
if (radixNumber < 2 || radixNumber > 36) {
......
......@@ -34,7 +34,7 @@ namespace regexp {
// Ensure {receiver} is a JSRegExp.
const receiver = Cast<JSRegExp>(receiver) otherwise ThrowTypeError(
kIncompatibleMethodReceiver, 'RegExp.prototype.exec', receiver);
const string = ToString_Inline(context, string);
const string = ToString_Inline(string);
return IsFastRegExpNoPrototype(receiver) ?
RegExpPrototypeExecBodyFast(receiver, string) :
......
......@@ -20,7 +20,7 @@ namespace regexp {
const receiver = UnsafeCast<JSReceiver>(receiver);
// 3. Let S be ? ToString(O).
const string: String = ToString_Inline(context, string);
const string: String = ToString_Inline(string);
let matcher: Object;
let global: bool;
......@@ -64,14 +64,13 @@ namespace regexp {
// 5. Let flags be ? ToString(? Get(R, "flags")).
const flags = GetProperty(receiver, 'flags');
const flagsString = ToString_Inline(context, flags);
const flagsString = ToString_Inline(flags);
// 6. Let matcher be ? Construct(C, « R, flags »).
matcher = Construct(speciesConstructor, receiver, flagsString);
// 7. Let lastIndex be ? ToLength(? Get(R, "lastIndex")).
const lastIndex: Number =
ToLength_Inline(context, SlowLoadLastIndex(receiver));
const lastIndex: Number = ToLength_Inline(SlowLoadLastIndex(receiver));
// 8. Perform ? Set(matcher, "lastIndex", lastIndex, true).
SlowStoreLastIndex(UnsafeCast<JSReceiver>(matcher), lastIndex);
......@@ -216,13 +215,12 @@ namespace regexp {
assert(!isFastRegExp);
// i. Let matchStr be ? ToString(? Get(match, "0")).
const match = UnsafeCast<JSAny>(match);
const matchStr =
ToString_Inline(context, GetProperty(match, SmiConstant(0)));
const matchStr = ToString_Inline(GetProperty(match, SmiConstant(0)));
if (matchStr == kEmptyString) {
// 1. Let thisIndex be ? ToLength(? Get(R, "lastIndex")).
const lastIndex: JSAny = SlowLoadLastIndex(iteratingRegExp);
const thisIndex: Number = ToLength_Inline(context, lastIndex);
const thisIndex: Number = ToLength_Inline(lastIndex);
// 2. Let nextIndex be ! AdvanceStringIndex(S, thisIndex,
// fullUnicode).
......
......@@ -34,7 +34,7 @@ namespace regexp {
ThrowIfNotJSReceiver(
receiver, kIncompatibleMethodReceiver, 'RegExp.prototype.@@match');
const receiver = UnsafeCast<JSReceiver>(receiver);
const string: String = ToString_Inline(context, string);
const string: String = ToString_Inline(string);
// Strict: Reads global and unicode properties.
// TODO(jgruber): Handle slow flag accesses on the fast path and make this
......
......@@ -50,7 +50,7 @@ namespace regexp {
case (elString: String): {
const replacementObj: JSAny =
Call(context, replaceFn, Undefined, elString, matchStart, string);
const replacement: String = ToString_Inline(context, replacementObj);
const replacement: String = ToString_Inline(replacementObj);
matchesElements.objects[i] = replacement;
matchStart += elString.length_smi;
}
......@@ -75,7 +75,7 @@ namespace regexp {
// Overwrite the i'th element in the results with the string
// we got back from the callback function.
matchesElements.objects[i] = ToString_Inline(context, replacementObj);
matchesElements.objects[i] = ToString_Inline(replacementObj);
}
}
......@@ -163,7 +163,7 @@ namespace regexp {
}
case (Object): {
const lastIndex: JSAny = SlowLoadLastIndex(regexp);
const thisIndex: Number = ToLength_Inline(context, lastIndex);
const thisIndex: Number = ToLength_Inline(lastIndex);
const nextIndex: Number =
AdvanceStringIndexSlow(string, thisIndex, unicode);
SlowStoreLastIndex(regexp, nextIndex);
......@@ -190,7 +190,7 @@ namespace regexp {
}
case (JSAny): {
const stableRegexp: JSRegExp = regexp;
const replaceString: String = ToString_Inline(context, replaceValue);
const replaceString: String = ToString_Inline(replaceValue);
try {
// ToString(replaceValue) could potentially change the shape of the
......@@ -245,7 +245,7 @@ namespace regexp {
otherwise ThrowTypeError(kIncompatibleMethodReceiver, methodName);
// Let S be ? ToString(string).
const s = ToString_Inline(context, string);
const s = ToString_Inline(string);
// Fast-path checks: 1. Is the {receiver} an unmodified JSRegExp instance?
try {
......
......@@ -93,7 +93,7 @@ namespace regexp {
ThrowIfNotJSReceiver(
receiver, kIncompatibleMethodReceiver, 'RegExp.prototype.@@search');
const receiver = UnsafeCast<JSReceiver>(receiver);
const string: String = ToString_Inline(context, string);
const string: String = ToString_Inline(string);
if (IsFastRegExpPermissive(receiver)) {
// TODO(pwong): Could be optimized to remove the overhead of calling the
......
......@@ -58,7 +58,7 @@ namespace regexp {
ThrowIfNotJSReceiver(
receiver, kIncompatibleMethodReceiver, 'RegExp.prototype.@@split');
const receiver = UnsafeCast<JSReceiver>(receiver);
const string: String = ToString_Inline(context, arguments[0]);
const string: String = ToString_Inline(arguments[0]);
const limit = arguments[1];
// Strict: Reads the flags property.
......
......@@ -13,7 +13,7 @@ namespace regexp {
const methodName: constexpr string = 'RegExp.prototype.test';
const receiver = Cast<JSReceiver>(receiver)
otherwise ThrowTypeError(kIncompatibleMethodReceiver, methodName);
const str: String = ToString_Inline(context, string);
const str: String = ToString_Inline(string);
if (IsFastRegExpPermissive(receiver)) {
RegExpPrototypeExecBodyWithoutResultFast(
UnsafeCast<JSRegExp>(receiver), str)
......
......@@ -286,9 +286,8 @@ namespace regexp {
@export
transitioning macro RegExpCreate(implicit context: Context)(
initialMap: Map, maybeString: JSAny, flags: String): JSAny {
const pattern: String = maybeString == Undefined ?
kEmptyString :
ToString_Inline(context, maybeString);
const pattern: String =
maybeString == Undefined ? kEmptyString : ToString_Inline(maybeString);
const regexp =
UnsafeCast<JSRegExp>(AllocateFastOrSlowJSObjectFromMap(initialMap));
return RegExpInitializeAndCompile(context, regexp, pattern, flags);
......
......@@ -42,7 +42,7 @@ namespace string {
}
// 5. Let searchStr be ? ToString(searchString).
const searchStr: String = ToString_Inline(context, searchString);
const searchStr: String = ToString_Inline(searchString);
// 6. Let len be the length of S.
const len: uintptr = string.length_uintptr;
......
......@@ -13,7 +13,7 @@ namespace string {
let result = '<' + tagName;
if (attr != kEmptyString) {
const attrStringValue: String =
StringEscapeQuotes(context, ToString_Inline(context, attrValue));
StringEscapeQuotes(context, ToString_Inline(attrValue));
result = result + ' ' + attr + '=\"' + attrStringValue + '\"';
}
......
......@@ -21,7 +21,7 @@ namespace string {
if (arguments.length == 0) {
return receiverString;
}
const maxLength: Number = ToLength_Inline(context, arguments[0]);
const maxLength: Number = ToLength_Inline(arguments[0]);
assert(IsNumberNormalized(maxLength));
typeswitch (maxLength) {
......@@ -40,7 +40,7 @@ namespace string {
if (arguments.length != 1) {
const fill = arguments[1];
if (fill != Undefined) {
fillString = ToString_Inline(context, fill);
fillString = ToString_Inline(fill);
fillLength = fillString.length_intptr;
if (fillLength == 0) {
return receiverString;
......
......@@ -35,7 +35,7 @@ namespace string {
try {
// 3. Let n be ? ToInteger(count).
typeswitch (ToInteger_Inline(context, count, kTruncateMinusZero)) {
typeswitch (ToInteger_Inline(count, kTruncateMinusZero)) {
case (n: Smi): {
// 4. If n < 0, throw a RangeError exception.
if (n < 0) goto InvalidCount;
......
......@@ -76,8 +76,7 @@ namespace string {
const flags = GetProperty(searchValue, 'flags');
RequireObjectCoercible(flags, 'String.prototype.replaceAll');
shouldThrow =
StringIndexOf(
ToString_Inline(context, flags), StringConstant('g'), 0) == -1;
StringIndexOf(ToString_Inline(flags), StringConstant('g'), 0) == -1;
}
}
if (shouldThrow) {
......@@ -119,10 +118,10 @@ namespace string {
}
// 3. Let string be ? ToString(O).
const string = ToString_Inline(context, receiver);
const string = ToString_Inline(receiver);
// 4. Let searchString be ? ToString(searchValue).
const searchString = ToString_Inline(context, searchValue);
const searchString = ToString_Inline(searchValue);
// 5. Let functionalReplace be IsCallable(replaceValue).
let replaceValueArg = replaceValue;
......@@ -131,7 +130,7 @@ namespace string {
// 6. If functionalReplace is false, then
if (!functionalReplace) {
// a. Let replaceValue be ? ToString(replaceValue).
replaceValueArg = ToString_Inline(context, replaceValue);
replaceValueArg = ToString_Inline(replaceValue);
}
// 7. Let searchLength be the length of searchString.
......@@ -163,11 +162,9 @@ namespace string {
// i. Let replacement be ? ToString(? Call(replaceValue, undefined,
// « searchString, position,
// string »).
replacement = ToString_Inline(
context,
Call(
context, UnsafeCast<Callable>(replaceValueArg), Undefined,
searchString, position, string));
replacement = ToString_Inline(Call(
context, UnsafeCast<Callable>(replaceValueArg), Undefined,
searchString, position, string));
} else {
// i. Assert: Type(replaceValue) is String.
const replaceValueString = UnsafeCast<String>(replaceValueArg);
......
......@@ -23,7 +23,7 @@ namespace string {
}
// 5. Let searchStr be ? ToString(searchString).
const searchStr: String = ToString_Inline(context, searchString);
const searchStr: String = ToString_Inline(searchString);
// 8. Let len be the length of S.
const len: uintptr = string.length_uintptr;
......
......@@ -327,7 +327,7 @@ namespace typed_array {
}
label IfIteratorUndefined {
const lengthObj: JSAny = GetProperty(obj, kLengthString);
const lengthNumber: Number = ToLength_Inline(context, lengthObj);
const lengthNumber: Number = ToLength_Inline(lengthObj);
// Throw RangeError here if the length does not fit in uintptr because
// such a length will not pass bounds checks in ConstructByArrayLike()
// anyway.
......
......@@ -278,7 +278,7 @@ namespace typed_array {
comparefn: Callable)(a: JSAny, b: JSAny): Number {
// a. Let v be ? ToNumber(? Call(comparefn, undefined, x, y)).
const v: Number =
ToNumber_Inline(context, Call(context, comparefn, Undefined, a, b));
ToNumber_Inline(Call(context, comparefn, Undefined, a, b));
// b. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
if (IsDetachedBuffer(array.buffer)) {
......
......@@ -654,6 +654,14 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
WordShl(BitcastTaggedToWordForTagAndSmiBits(a), shift));
}
TNode<IntPtrT> EasyIntPtrAbsWithOverflow(TNode<IntPtrT> a,
Label* if_overflow) {
TNode<PairT<IntPtrT, BoolT>> pair = IntPtrAbsWithOverflow(a);
Node* overflow = Projection(1, pair);
GotoIf(overflow, if_overflow);
return UncheckedCast<IntPtrT>(Projection(0, pair));
}
TNode<Smi> SmiShr(TNode<Smi> a, int shift) {
if (kTaggedSize == kInt64Size) {
return BitcastWordToTaggedSigned(
......
......@@ -346,10 +346,10 @@ namespace array {
}
// 5. Let xString be ? ToString(x).
const xString = ToString_Inline(context, x);
const xString = ToString_Inline(x);
// 6. Let yString be ? ToString(y).
const yString = ToString_Inline(context, y);
const yString = ToString_Inline(y);
// 7. Let xSmaller be the result of performing
// Abstract Relational Comparison xString < yString.
......@@ -371,7 +371,7 @@ namespace array {
const cmpfn = UnsafeCast<Callable>(comparefn);
// a. Let v be ? ToNumber(? Call(comparefn, undefined, x, y)).
const v = ToNumber_Inline(context, Call(context, cmpfn, Undefined, x, y));
const v = ToNumber_Inline(Call(context, cmpfn, Undefined, x, y));
// b. If v is NaN, return +0.
if (NumberIsNaN(v)) return 0;
......
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