Introduce a new macro TO_STRING that maps to %_ToString and use that
instead of calling into any of the ToString/NonStringToString JavaScript
builtins. Also remove the TO_STRING_INLINE macro, which is basically
obsolete with %_ToString. We still have a few uses of ToString left (via
the utils export mechanism), where we need to investigate whether we
will tank badly if we replace them with TO_STRING as well.
CQ_INCLUDE_TRYBOTS=tryserver.v8:v8_linux_layout_dbg,v8_linux_nosnap_dbg
R=yangguo@chromium.org
BUG=v8:4307
LOG=n
Review URL: https://codereview.chromium.org/
1323543002
Cr-Commit-Position: refs/heads/master@{#30895}
23 files changed:
function InnerArrayJoin(separator, array, length) {
if (IS_UNDEFINED(separator)) {
separator = ',';
function InnerArrayJoin(separator, array, length) {
if (IS_UNDEFINED(separator)) {
separator = ',';
- } else if (!IS_STRING(separator)) {
- separator = $nonStringToString(separator);
+ } else {
+ separator = TO_STRING(separator);
}
var result = %_FastOneByteArrayJoin(array, separator);
}
var result = %_FastOneByteArrayJoin(array, separator);
// Fast case for one-element arrays.
if (length === 1) {
var e = array[0];
// Fast case for one-element arrays.
if (length === 1) {
var e = array[0];
- if (IS_STRING(e)) return e;
if (IS_NULL_OR_UNDEFINED(e)) return '';
if (IS_NULL_OR_UNDEFINED(e)) return '';
- return $nonStringToString(e);
}
return Join(array, length, separator, ConvertToString);
}
return Join(array, length, separator, ConvertToString);
V(MAKE_RANGE_ERROR_INDEX, JSFunction, make_range_error) \
V(MAKE_TYPE_ERROR_INDEX, JSFunction, make_type_error) \
V(NON_NUMBER_TO_NUMBER_INDEX, JSFunction, non_number_to_number) \
V(MAKE_RANGE_ERROR_INDEX, JSFunction, make_range_error) \
V(MAKE_TYPE_ERROR_INDEX, JSFunction, make_type_error) \
V(NON_NUMBER_TO_NUMBER_INDEX, JSFunction, non_number_to_number) \
- V(NON_STRING_TO_STRING_INDEX, JSFunction, non_string_to_string) \
V(REFLECT_APPLY_INDEX, JSFunction, reflect_apply) \
V(REFLECT_CONSTRUCT_INDEX, JSFunction, reflect_construct) \
V(SPREAD_ARGUMENTS_INDEX, JSFunction, spread_arguments) \
V(SPREAD_ITERABLE_INDEX, JSFunction, spread_iterable) \
V(TO_LENGTH_FUN_INDEX, JSFunction, to_length_fun) \
V(REFLECT_APPLY_INDEX, JSFunction, reflect_apply) \
V(REFLECT_CONSTRUCT_INDEX, JSFunction, reflect_construct) \
V(SPREAD_ARGUMENTS_INDEX, JSFunction, spread_arguments) \
V(SPREAD_ITERABLE_INDEX, JSFunction, spread_iterable) \
V(TO_LENGTH_FUN_INDEX, JSFunction, to_length_fun) \
- V(TO_NUMBER_FUN_INDEX, JSFunction, to_number_fun) \
- V(TO_STRING_FUN_INDEX, JSFunction, to_string_fun)
+ V(TO_NUMBER_FUN_INDEX, JSFunction, to_number_fun)
#define NATIVE_CONTEXT_JS_BUILTINS(V) \
#define NATIVE_CONTEXT_JS_BUILTINS(V) \
var MathAbs;
var MathFloor;
var ToNumber;
var MathAbs;
var MathFloor;
var ToNumber;
utils.Import(function(from) {
IsFinite = from.IsFinite;
MathAbs = from.MathAbs;
MathFloor = from.MathFloor;
ToNumber = from.ToNumber;
utils.Import(function(from) {
IsFinite = from.IsFinite;
MathAbs = from.MathAbs;
MathFloor = from.MathFloor;
ToNumber = from.ToNumber;
- ToString = from.ToString;
});
// -------------------------------------------------------------------
});
// -------------------------------------------------------------------
// ECMA 262 - 15.9.4.2
function DateParse(string) {
// ECMA 262 - 15.9.4.2
function DateParse(string) {
- var arr = %DateParseString(ToString(string), parse_buffer);
+ var arr = %DateParseString(string, parse_buffer);
if (IS_NULL(arr)) return NAN;
var day = MakeDay(arr[0], arr[1], arr[2]);
if (IS_NULL(arr)) return NAN;
var day = MakeDay(arr[0], arr[1], arr[2]);
// Imports
var GlobalRegExp = global.RegExp;
// Imports
var GlobalRegExp = global.RegExp;
-var ToString;
-
-utils.Import(function(from) {
- ToString = from.ToString;
-});
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// + https://bugs.ecmascript.org/show_bug.cgi?id=3423
function RegExpGetFlags() {
if (!IS_SPEC_OBJECT(this)) {
// + https://bugs.ecmascript.org/show_bug.cgi?id=3423
function RegExpGetFlags() {
if (!IS_SPEC_OBJECT(this)) {
- throw MakeTypeError(kFlagsGetterNonObject, ToString(this));
+ throw MakeTypeError(kFlagsGetterNonObject, TO_STRING(this));
}
var result = '';
if (this.global) result += 'g';
}
var result = '';
if (this.global) result += 'g';
}
CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
}
CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
- var s = TO_STRING_INLINE(this);
+ var s = TO_STRING(this);
var formArg = %_Arguments(0);
var formArg = %_Arguments(0);
- var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING_INLINE(formArg);
+ var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING(formArg);
var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
var MathMin;
var ObjectHasOwnProperty;
var ToNumber;
var MathMin;
var ObjectHasOwnProperty;
var ToNumber;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MathMin = from.MathMin;
ObjectHasOwnProperty = from.ObjectHasOwnProperty;
ToNumber = from.ToNumber;
MathMin = from.MathMin;
ObjectHasOwnProperty = from.ObjectHasOwnProperty;
ToNumber = from.ToNumber;
- ToString = from.ToString;
});
// -------------------------------------------------------------------
});
// -------------------------------------------------------------------
function JSONParse(text, reviver) {
function JSONParse(text, reviver) {
- var unfiltered = %ParseJson(TO_STRING_INLINE(text));
+ var unfiltered = %ParseJson(text);
if (IS_CALLABLE(reviver)) {
return Revive({'': unfiltered}, '', reviver);
} else {
if (IS_CALLABLE(reviver)) {
return Revive({'': unfiltered}, '', reviver);
} else {
return value ? "true" : "false";
} else if (IS_NULL(value)) {
return "null";
return value ? "true" : "false";
} else if (IS_NULL(value)) {
return "null";
- } else if (IS_SPEC_OBJECT(value) && !(typeof value == "function")) {
+ } else if (IS_SPEC_OBJECT(value) && !IS_CALLABLE(value)) {
// Non-callable object. If it's a primitive wrapper, it must be unwrapped.
if (IS_ARRAY(value)) {
return SerializeArray(value, replacer, stack, indent, gap);
// Non-callable object. If it's a primitive wrapper, it must be unwrapped.
if (IS_ARRAY(value)) {
return SerializeArray(value, replacer, stack, indent, gap);
value = ToNumber(value);
return JSON_NUMBER_TO_STRING(value);
} else if (IS_STRING_WRAPPER(value)) {
value = ToNumber(value);
return JSON_NUMBER_TO_STRING(value);
} else if (IS_STRING_WRAPPER(value)) {
- return %QuoteJSONString(ToString(value));
+ return %QuoteJSONString(TO_STRING(value));
} else if (IS_BOOLEAN_WRAPPER(value)) {
return %_ValueOf(value) ? "true" : "false";
} else {
} else if (IS_BOOLEAN_WRAPPER(value)) {
return %_ValueOf(value) ? "true" : "false";
} else {
} else if (IS_NUMBER(v)) {
item = %_NumberToString(v);
} else if (IS_STRING_WRAPPER(v) || IS_NUMBER_WRAPPER(v)) {
} else if (IS_NUMBER(v)) {
item = %_NumberToString(v);
} else if (IS_STRING_WRAPPER(v) || IS_NUMBER_WRAPPER(v)) {
if (IS_NUMBER_WRAPPER(space)) {
space = ToNumber(space);
} else if (IS_STRING_WRAPPER(space)) {
if (IS_NUMBER_WRAPPER(space)) {
space = ToNumber(space);
} else if (IS_STRING_WRAPPER(space)) {
- space = ToString(space);
+ space = TO_STRING(space);
macro TO_INT32(arg) = (arg | 0);
macro TO_UINT32(arg) = (arg >>> 0);
macro TO_LENGTH_OR_UINT32(arg) = (harmony_tolength ? $toLength(arg) : TO_UINT32(arg));
macro TO_INT32(arg) = (arg | 0);
macro TO_UINT32(arg) = (arg >>> 0);
macro TO_LENGTH_OR_UINT32(arg) = (harmony_tolength ? $toLength(arg) : TO_UINT32(arg));
-macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : $nonStringToString(arg));
+macro TO_STRING(arg) = (%_ToString(arg));
macro TO_NUMBER_INLINE(arg) = (IS_NUMBER(%IS_VAR(arg)) ? arg : $nonNumberToNumber(arg));
macro TO_OBJECT(arg) = (%_ToObject(arg));
macro TO_PRIMITIVE(arg) = (%_ToPrimitive(arg));
macro TO_NUMBER_INLINE(arg) = (IS_NUMBER(%IS_VAR(arg)) ? arg : $nonNumberToNumber(arg));
macro TO_OBJECT(arg) = (%_ToObject(arg));
macro TO_PRIMITIVE(arg) = (%_ToPrimitive(arg));
var StringIndexOf;
var StringSubstring;
var SymbolToString;
var StringIndexOf;
var StringSubstring;
var SymbolToString;
-var ToString = utils.ImportNow("ToString");
var Uint16x8ToString;
var Uint32x4ToString;
var Uint8x16ToString;
var Uint16x8ToString;
var Uint32x4ToString;
var Uint8x16ToString;
if (CanBeSafelyTreatedAsAnErrorObject(obj)) {
return %_CallFunction(obj, ErrorToString);
} else {
if (CanBeSafelyTreatedAsAnErrorObject(obj)) {
return %_CallFunction(obj, ErrorToString);
} else {
// object. This avoids going through getters and setters defined
// on prototype objects.
if (!IS_UNDEFINED(m)) {
// object. This avoids going through getters and setters defined
// on prototype objects.
if (!IS_UNDEFINED(m)) {
- %AddNamedProperty(this, 'message', ToString(m), DONT_ENUM);
+ %AddNamedProperty(this, 'message', TO_STRING(m), DONT_ENUM);
}
} else {
return new f(m);
}
} else {
return new f(m);
ZoneList<Expression*>* args =
new (zone()) ZoneList<Expression*>(1, zone());
args->Add(sub, zone());
ZoneList<Expression*>* args =
new (zone()) ZoneList<Expression*>(1, zone());
args->Add(sub, zone());
- Expression* middle = factory()->NewCallRuntime(
- Context::TO_STRING_FUN_INDEX, args, sub->position());
+ Expression* middle = factory()->NewCallRuntime(Runtime::kInlineToString,
+ args, sub->position());
expr = factory()->NewBinaryOperation(
Token::ADD, factory()->NewBinaryOperation(
expr = factory()->NewBinaryOperation(
Token::ADD, factory()->NewBinaryOperation(
for (var i = 0, count = 0; i < names.length; ++i) {
var name = names[i]
if (IS_SYMBOL(name)) continue
for (var i = 0, count = 0; i < names.length; ++i) {
var name = names[i]
if (IS_SYMBOL(name)) continue
- var desc = this.getOwnPropertyDescriptor(TO_STRING_INLINE(name))
+ var desc = this.getOwnPropertyDescriptor(TO_STRING(name))
if (!IS_UNDEFINED(desc) && desc.enumerable) {
enumerableNames[count++] = names[i]
}
if (!IS_UNDEFINED(desc) && desc.enumerable) {
enumerableNames[count++] = names[i]
}
for (var i = 0, count = 0; i < names.length; ++i) {
var name = names[i]
if (IS_SYMBOL(name)) continue
for (var i = 0, count = 0; i < names.length; ++i) {
var name = names[i]
if (IS_SYMBOL(name)) continue
- var desc = this.getPropertyDescriptor(TO_STRING_INLINE(name))
+ var desc = this.getPropertyDescriptor(TO_STRING(name))
if (!IS_UNDEFINED(desc)) {
if (!desc.configurable) {
throw MakeTypeError(kProxyPropNotConfigurable,
if (!IS_UNDEFINED(desc)) {
if (!desc.configurable) {
throw MakeTypeError(kProxyPropNotConfigurable,
pattern = pattern.source;
}
pattern = pattern.source;
}
- pattern = IS_UNDEFINED(pattern) ? '' : $toString(pattern);
- flags = IS_UNDEFINED(flags) ? '' : $toString(flags);
+ pattern = IS_UNDEFINED(pattern) ? '' : TO_STRING(pattern);
+ flags = IS_UNDEFINED(flags) ? '' : TO_STRING(flags);
%RegExpInitializeAndCompile(object, pattern, flags);
}
%RegExpInitializeAndCompile(object, pattern, flags);
}
'RegExp.prototype.exec', this);
}
'RegExp.prototype.exec', this);
}
- string = TO_STRING_INLINE(string);
+ string = TO_STRING(string);
var lastIndex = this.lastIndex;
// Conversion is required by the ES5 specification (RegExp.prototype.exec
var lastIndex = this.lastIndex;
// Conversion is required by the ES5 specification (RegExp.prototype.exec
throw MakeTypeError(kIncompatibleMethodReceiver,
'RegExp.prototype.test', this);
}
throw MakeTypeError(kIncompatibleMethodReceiver,
'RegExp.prototype.test', this);
}
- string = TO_STRING_INLINE(string);
+ string = TO_STRING(string);
var lastIndex = this.lastIndex;
var lastIndex = this.lastIndex;
return IS_UNDEFINED(regExpInput) ? "" : regExpInput;
};
var RegExpSetInput = function(string) {
return IS_UNDEFINED(regExpInput) ? "" : regExpInput;
};
var RegExpSetInput = function(string) {
- LAST_INPUT(RegExpLastMatchInfo) = $toString(string);
+ LAST_INPUT(RegExpLastMatchInfo) = TO_STRING(string);
};
%OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22);
};
%OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22);
var $defaultString;
var $NaN;
var $nonNumberToNumber;
var $defaultString;
var $NaN;
var $nonNumberToNumber;
var $sameValue;
var $sameValueZero;
var $toInteger;
var $toLength;
var $toNumber;
var $toPositiveInteger;
var $sameValue;
var $sameValueZero;
var $toInteger;
var $toLength;
var $toNumber;
var $toPositiveInteger;
var harmony_tolength = false;
var harmony_tolength = false;
// First check that the receiver is callable.
if (!IS_CALLABLE(this)) {
// First check that the receiver is callable.
if (!IS_CALLABLE(this)) {
- throw %make_type_error(kApplyNonFunction, %to_string_fun(this),
- typeof this);
+ throw %make_type_error(kApplyNonFunction, TO_STRING(this), typeof this);
}
// First check whether length is a positive Smi and args is an
}
// First check whether length is a positive Smi and args is an
// First check that the receiver is callable.
if (!IS_CALLABLE(this)) {
// First check that the receiver is callable.
if (!IS_CALLABLE(this)) {
- throw %make_type_error(kApplyNonFunction, %to_string_fun(this),
- typeof this);
+ throw %make_type_error(kApplyNonFunction, TO_STRING(this), typeof this);
}
// First check whether length is a positive Smi and args is an
}
// First check whether length is a positive Smi and args is an
if (!ctorOk) {
if (!IS_CALLABLE(this)) {
if (!ctorOk) {
if (!IS_CALLABLE(this)) {
- throw %make_type_error(kCalledNonCallable, %to_string_fun(this));
+ throw %make_type_error(kCalledNonCallable, TO_STRING(this));
- throw %make_type_error(kNotConstructor, %to_string_fun(this));
+ throw %make_type_error(kNotConstructor, TO_STRING(this));
}
}
if (!newTargetOk) {
if (!IS_CALLABLE(newTarget)) {
}
}
if (!newTargetOk) {
if (!IS_CALLABLE(newTarget)) {
- throw %make_type_error(kCalledNonCallable, %to_string_fun(newTarget));
+ throw %make_type_error(kCalledNonCallable, TO_STRING(newTarget));
- throw %make_type_error(kNotConstructor, %to_string_fun(newTarget));
+ throw %make_type_error(kNotConstructor, TO_STRING(newTarget));
return (IS_NULL(x)) ? 'null' : ToString(DefaultString(x));
}
return (IS_NULL(x)) ? 'null' : ToString(DefaultString(x));
}
-function NonStringToString(x) {
- if (IS_NUMBER(x)) return %_NumberToString(x);
- if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
- if (IS_UNDEFINED(x)) return 'undefined';
- // Types that can't be converted to string are caught in DefaultString.
- return (IS_NULL(x)) ? 'null' : ToString(DefaultString(x));
-}
-
// ECMA-262, section 9.4, page 34.
function ToInteger(x) {
// ECMA-262, section 9.4, page 34.
function ToInteger(x) {
$defaultString = DefaultString;
$NaN = %GetRootNaN();
$nonNumberToNumber = NonNumberToNumber;
$defaultString = DefaultString;
$NaN = %GetRootNaN();
$nonNumberToNumber = NonNumberToNumber;
-$nonStringToString = NonStringToString;
$sameValue = SameValue;
$sameValueZero = SameValueZero;
$toInteger = ToInteger;
$toLength = ToLength;
$toNumber = ToNumber;
$toPositiveInteger = ToPositiveInteger;
$sameValue = SameValue;
$sameValueZero = SameValueZero;
$toInteger = ToInteger;
$toLength = ToLength;
$toNumber = ToNumber;
$toPositiveInteger = ToPositiveInteger;
%InstallToContext([
"apply_prepare_builtin", APPLY_PREPARE,
%InstallToContext([
"apply_prepare_builtin", APPLY_PREPARE,
%InstallToContext([
"concat_iterable_to_array", ConcatIterableToArray,
"non_number_to_number", NonNumberToNumber,
%InstallToContext([
"concat_iterable_to_array", ConcatIterableToArray,
"non_number_to_number", NonNumberToNumber,
- "non_string_to_string", NonStringToString,
"to_integer_fun", ToInteger,
"to_length_fun", ToLength,
"to_number_fun", ToNumber,
"to_integer_fun", ToInteger,
"to_length_fun", ToLength,
"to_number_fun", ToNumber,
- "to_string_fun", ToString,
]);
utils.Export(function(to) {
]);
utils.Export(function(to) {
RUNTIME_FUNCTION(Runtime_DateParseString) {
HandleScope scope(isolate);
RUNTIME_FUNCTION(Runtime_DateParseString) {
HandleScope scope(isolate);
- DCHECK(args.length() == 2);
- CONVERT_ARG_HANDLE_CHECKED(String, str, 0);
+ DCHECK_EQ(2, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1);
RUNTIME_ASSERT(output->HasFastElements());
CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1);
RUNTIME_ASSERT(output->HasFastElements());
Handle<FixedArray> output_array(FixedArray::cast(output->elements()));
RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE);
Handle<FixedArray> output_array(FixedArray::cast(output->elements()));
RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE);
+ Handle<String> str;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, str,
+ Object::ToString(isolate, input));
+
str = String::Flatten(str);
DisallowHeapAllocation no_gc;
str = String::Flatten(str);
DisallowHeapAllocation no_gc;
RUNTIME_FUNCTION(Runtime_ParseJson) {
HandleScope scope(isolate);
RUNTIME_FUNCTION(Runtime_ParseJson) {
HandleScope scope(isolate);
- DCHECK(args.length() == 1);
- CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
-
+ DCHECK_EQ(1, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
+ Handle<String> source;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, source,
+ Object::ToString(isolate, object));
source = String::Flatten(source);
// Optimized fast case where we only have Latin1 characters.
Handle<Object> result;
source = String::Flatten(source);
// Optimized fast case where we only have Latin1 characters.
Handle<Object> result;
: JsonParser<false>::Parse(source));
return *result;
}
: JsonParser<false>::Parse(source));
return *result;
}
} // namespace internal
} // namespace v8
} // namespace internal
} // namespace v8
RUNTIME_FUNCTION(Runtime_URIEscape) {
HandleScope scope(isolate);
RUNTIME_FUNCTION(Runtime_URIEscape) {
HandleScope scope(isolate);
- DCHECK(args.length() == 1);
- CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
- Handle<String> string = String::Flatten(source);
- DCHECK(string->IsFlat());
+ DCHECK_EQ(1, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
+ Handle<String> source;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, source,
+ Object::ToString(isolate, input));
+ source = String::Flatten(source);
Handle<String> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
Handle<String> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, string->IsOneByteRepresentationUnderneath()
+ isolate, result, source->IsOneByteRepresentationUnderneath()
? URIEscape::Escape<uint8_t>(isolate, source)
: URIEscape::Escape<uc16>(isolate, source));
return *result;
? URIEscape::Escape<uint8_t>(isolate, source)
: URIEscape::Escape<uc16>(isolate, source));
return *result;
RUNTIME_FUNCTION(Runtime_URIUnescape) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
RUNTIME_FUNCTION(Runtime_URIUnescape) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
- CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
- Handle<String> string = String::Flatten(source);
- DCHECK(string->IsFlat());
+ CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
+ Handle<String> source;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, source,
+ Object::ToString(isolate, input));
+ source = String::Flatten(source);
Handle<String> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
Handle<String> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, string->IsOneByteRepresentationUnderneath()
+ isolate, result, source->IsOneByteRepresentationUnderneath()
? URIUnescape::Unescape<uint8_t>(isolate, source)
: URIUnescape::Unescape<uc16>(isolate, source));
return *result;
}
? URIUnescape::Unescape<uint8_t>(isolate, source)
: URIUnescape::Unescape<uc16>(isolate, source));
return *result;
}
} // namespace internal
} // namespace v8
} // namespace internal
} // namespace v8
// 21.1.5.1 CreateStringIterator Abstract Operation
function CreateStringIterator(string) {
// 21.1.5.1 CreateStringIterator Abstract Operation
function CreateStringIterator(string) {
- var s = TO_STRING_INLINE(string);
+ var s = TO_STRING(string);
var iterator = new StringIterator;
SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, s);
SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, 0);
var iterator = new StringIterator;
SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, s);
SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, 0);
var RegExpExecNoTests;
var RegExpLastMatchInfo;
var ToNumber;
var RegExpExecNoTests;
var RegExpLastMatchInfo;
var ToNumber;
utils.Import(function(from) {
ArrayIndexOf = from.ArrayIndexOf;
utils.Import(function(from) {
ArrayIndexOf = from.ArrayIndexOf;
RegExpExecNoTests = from.RegExpExecNoTests;
RegExpLastMatchInfo = from.RegExpLastMatchInfo;
ToNumber = from.ToNumber;
RegExpExecNoTests = from.RegExpExecNoTests;
RegExpLastMatchInfo = from.RegExpLastMatchInfo;
ToNumber = from.ToNumber;
- ToString = from.ToString;
});
//-------------------------------------------------------------------
});
//-------------------------------------------------------------------
var result = %_StringCharAt(this, pos);
if (%_IsSmi(result)) {
var result = %_StringCharAt(this, pos);
if (%_IsSmi(result)) {
- result = %_StringCharAt(TO_STRING_INLINE(this), TO_INTEGER(pos));
+ result = %_StringCharAt(TO_STRING(this), TO_INTEGER(pos));
var result = %_StringCharCodeAt(this, pos);
if (!%_IsSmi(result)) {
var result = %_StringCharCodeAt(this, pos);
if (!%_IsSmi(result)) {
- result = %_StringCharCodeAt(TO_STRING_INLINE(this), TO_INTEGER(pos));
+ result = %_StringCharCodeAt(TO_STRING(this), TO_INTEGER(pos));
function StringConcat(other /* and more */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.concat");
var len = %_ArgumentsLength();
function StringConcat(other /* and more */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.concat");
var len = %_ArgumentsLength();
- var this_as_string = TO_STRING_INLINE(this);
+ var this_as_string = TO_STRING(this);
- return this_as_string + TO_STRING_INLINE(other);
+ return this_as_string + TO_STRING(other);
}
var parts = new InternalArray(len + 1);
parts[0] = this_as_string;
for (var i = 0; i < len; i++) {
var part = %_Arguments(i);
}
var parts = new InternalArray(len + 1);
parts[0] = this_as_string;
for (var i = 0; i < len; i++) {
var part = %_Arguments(i);
- parts[i + 1] = TO_STRING_INLINE(part);
+ parts[i + 1] = TO_STRING(part);
}
return %StringBuilderConcat(parts, len + 1, "");
}
}
return %StringBuilderConcat(parts, len + 1, "");
}
function StringIndexOfJS(pattern /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.indexOf");
function StringIndexOfJS(pattern /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.indexOf");
- var subject = TO_STRING_INLINE(this);
- pattern = TO_STRING_INLINE(pattern);
+ var subject = TO_STRING(this);
+ pattern = TO_STRING(pattern);
var index = 0;
if (%_ArgumentsLength() > 1) {
index = %_Arguments(1); // position
var index = 0;
if (%_ArgumentsLength() > 1) {
index = %_Arguments(1); // position
function StringLastIndexOfJS(pat /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.lastIndexOf");
function StringLastIndexOfJS(pat /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.lastIndexOf");
- var sub = TO_STRING_INLINE(this);
+ var sub = TO_STRING(this);
var subLength = sub.length;
var subLength = sub.length;
- var pat = TO_STRING_INLINE(pat);
+ var pat = TO_STRING(pat);
var patLength = pat.length;
var index = subLength - patLength;
if (%_ArgumentsLength() > 1) {
var patLength = pat.length;
var index = subLength - patLength;
if (%_ArgumentsLength() > 1) {
function StringLocaleCompareJS(other) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.localeCompare");
function StringLocaleCompareJS(other) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.localeCompare");
- return %StringLocaleCompare(TO_STRING_INLINE(this),
- TO_STRING_INLINE(other));
+ return %StringLocaleCompare(TO_STRING(this), TO_STRING(other));
function StringMatchJS(regexp) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.match");
function StringMatchJS(regexp) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.match");
- var subject = TO_STRING_INLINE(this);
+ var subject = TO_STRING(this);
if (IS_REGEXP(regexp)) {
// Emulate RegExp.prototype.exec's side effect in step 5, even though
// value is discarded.
if (IS_REGEXP(regexp)) {
// Emulate RegExp.prototype.exec's side effect in step 5, even though
// value is discarded.
// proper functionality.
function StringNormalizeJS() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
// proper functionality.
function StringNormalizeJS() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
- var s = TO_STRING_INLINE(this);
+ var s = TO_STRING(this);
var formArg = %_Arguments(0);
var formArg = %_Arguments(0);
- var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING_INLINE(formArg);
+ var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING(formArg);
var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
var normalizationForm =
var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
var normalizationForm =
function StringReplace(search, replace) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.replace");
function StringReplace(search, replace) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.replace");
- var subject = TO_STRING_INLINE(this);
+ var subject = TO_STRING(this);
// Decision tree for dispatch
// .. regexp search
// Decision tree for dispatch
// .. regexp search
TO_INTEGER_FOR_SIDE_EFFECT(lastIndex);
if (!IS_CALLABLE(replace)) {
TO_INTEGER_FOR_SIDE_EFFECT(lastIndex);
if (!IS_CALLABLE(replace)) {
- replace = TO_STRING_INLINE(replace);
+ replace = TO_STRING(replace);
if (!search.global) {
// Non-global regexp search, string replace.
if (!search.global) {
// Non-global regexp search, string replace.
return StringReplaceNonGlobalRegExpWithFunction(subject, search, replace);
}
return StringReplaceNonGlobalRegExpWithFunction(subject, search, replace);
}
- search = TO_STRING_INLINE(search);
+ search = TO_STRING(search);
if (search.length == 1 &&
subject.length > 0xFF &&
if (search.length == 1 &&
subject.length > 0xFF &&
} else {
reusableMatchInfo[CAPTURE0] = start;
reusableMatchInfo[CAPTURE1] = end;
} else {
reusableMatchInfo[CAPTURE0] = start;
reusableMatchInfo[CAPTURE1] = end;
- result = ExpandReplacement(TO_STRING_INLINE(replace),
+ result = ExpandReplacement(TO_STRING(replace),
subject,
reusableMatchInfo,
result);
subject,
reusableMatchInfo,
result);
var func_result = replace(elem, match_start, subject);
// Overwrite the i'th element in the results with the string we got
// back from the callback function.
var func_result = replace(elem, match_start, subject);
// Overwrite the i'th element in the results with the string we got
// back from the callback function.
- res[i] = TO_STRING_INLINE(func_result);
+ res[i] = TO_STRING(func_result);
match_start += elem.length;
}
}
match_start += elem.length;
}
}
var func_result = %Apply(replace, UNDEFINED, elem, 0, elem.length);
// Overwrite the i'th element in the results with the string we got
// back from the callback function.
var func_result = %Apply(replace, UNDEFINED, elem, 0, elem.length);
// Overwrite the i'th element in the results with the string we got
// back from the callback function.
- res[i] = TO_STRING_INLINE(func_result);
+ res[i] = TO_STRING(func_result);
} else {
regexp = new GlobalRegExp(re);
}
} else {
regexp = new GlobalRegExp(re);
}
- var match = RegExpExec(regexp, TO_STRING_INLINE(this), 0);
+ var match = RegExpExec(regexp, TO_STRING(this), 0);
if (match) {
return match[CAPTURE0];
}
if (match) {
return match[CAPTURE0];
}
function StringSlice(start, end) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.slice");
function StringSlice(start, end) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.slice");
- var s = TO_STRING_INLINE(this);
+ var s = TO_STRING(this);
var s_len = s.length;
var start_i = TO_INTEGER(start);
var end_i = s_len;
var s_len = s.length;
var start_i = TO_INTEGER(start);
var end_i = s_len;
function StringSplitJS(separator, limit) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.split");
function StringSplitJS(separator, limit) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.split");
- var subject = TO_STRING_INLINE(this);
+ var subject = TO_STRING(this);
limit = (IS_UNDEFINED(limit)) ? 0xffffffff : TO_UINT32(limit);
var length = subject.length;
if (!IS_REGEXP(separator)) {
limit = (IS_UNDEFINED(limit)) ? 0xffffffff : TO_UINT32(limit);
var length = subject.length;
if (!IS_REGEXP(separator)) {
- var separator_string = TO_STRING_INLINE(separator);
+ var separator_string = TO_STRING(separator);
if (limit === 0) return [];
if (limit === 0) return [];
function StringSubstring(start, end) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.subString");
function StringSubstring(start, end) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.subString");
- var s = TO_STRING_INLINE(this);
+ var s = TO_STRING(this);
var s_len = s.length;
var start_i = TO_INTEGER(start);
var s_len = s.length;
var start_i = TO_INTEGER(start);
function StringSubstr(start, n) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.substr");
function StringSubstr(start, n) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.substr");
- var s = TO_STRING_INLINE(this);
+ var s = TO_STRING(this);
var len;
// Correct n: If not given, set to string length; if explicitly
var len;
// Correct n: If not given, set to string length; if explicitly
function StringToLowerCaseJS() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLowerCase");
function StringToLowerCaseJS() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLowerCase");
- return %StringToLowerCase(TO_STRING_INLINE(this));
+ return %StringToLowerCase(TO_STRING(this));
function StringToLocaleLowerCase() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleLowerCase");
function StringToLocaleLowerCase() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleLowerCase");
- return %StringToLowerCase(TO_STRING_INLINE(this));
+ return %StringToLowerCase(TO_STRING(this));
function StringToUpperCaseJS() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toUpperCase");
function StringToUpperCaseJS() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toUpperCase");
- return %StringToUpperCase(TO_STRING_INLINE(this));
+ return %StringToUpperCase(TO_STRING(this));
function StringToLocaleUpperCase() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleUpperCase");
function StringToLocaleUpperCase() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleUpperCase");
- return %StringToUpperCase(TO_STRING_INLINE(this));
+ return %StringToUpperCase(TO_STRING(this));
}
// ES5, 15.5.4.20
function StringTrimJS() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.trim");
}
// ES5, 15.5.4.20
function StringTrimJS() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.trim");
- return %StringTrim(TO_STRING_INLINE(this), true, true);
+ return %StringTrim(TO_STRING(this), true, true);
}
function StringTrimLeft() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.trimLeft");
}
function StringTrimLeft() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.trimLeft");
- return %StringTrim(TO_STRING_INLINE(this), true, false);
+ return %StringTrim(TO_STRING(this), true, false);
}
function StringTrimRight() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.trimRight");
}
function StringTrimRight() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.trimRight");
- return %StringTrim(TO_STRING_INLINE(this), false, true);
+ return %StringTrim(TO_STRING(this), false, true);
// ES6 draft, revision 26 (2014-07-18), section B.2.3.2.1
function HtmlEscape(str) {
// ES6 draft, revision 26 (2014-07-18), section B.2.3.2.1
function HtmlEscape(str) {
- return %_CallFunction(TO_STRING_INLINE(str), /"/g, """, StringReplace);
+ return %_CallFunction(TO_STRING(str), /"/g, """, StringReplace);
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.2
function StringAnchor(name) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.anchor");
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.2
function StringAnchor(name) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.anchor");
- return "<a name=\"" + HtmlEscape(name) + "\">" + TO_STRING_INLINE(this) +
+ return "<a name=\"" + HtmlEscape(name) + "\">" + TO_STRING(this) +
// ES6 draft, revision 26 (2014-07-18), section B.2.3.3
function StringBig() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.big");
// ES6 draft, revision 26 (2014-07-18), section B.2.3.3
function StringBig() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.big");
- return "<big>" + TO_STRING_INLINE(this) + "</big>";
+ return "<big>" + TO_STRING(this) + "</big>";
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.4
function StringBlink() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.blink");
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.4
function StringBlink() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.blink");
- return "<blink>" + TO_STRING_INLINE(this) + "</blink>";
+ return "<blink>" + TO_STRING(this) + "</blink>";
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.5
function StringBold() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.bold");
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.5
function StringBold() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.bold");
- return "<b>" + TO_STRING_INLINE(this) + "</b>";
+ return "<b>" + TO_STRING(this) + "</b>";
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.6
function StringFixed() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.fixed");
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.6
function StringFixed() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.fixed");
- return "<tt>" + TO_STRING_INLINE(this) + "</tt>";
+ return "<tt>" + TO_STRING(this) + "</tt>";
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.7
function StringFontcolor(color) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.fontcolor");
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.7
function StringFontcolor(color) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.fontcolor");
- return "<font color=\"" + HtmlEscape(color) + "\">" + TO_STRING_INLINE(this) +
+ return "<font color=\"" + HtmlEscape(color) + "\">" + TO_STRING(this) +
// ES6 draft, revision 26 (2014-07-18), section B.2.3.8
function StringFontsize(size) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.fontsize");
// ES6 draft, revision 26 (2014-07-18), section B.2.3.8
function StringFontsize(size) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.fontsize");
- return "<font size=\"" + HtmlEscape(size) + "\">" + TO_STRING_INLINE(this) +
+ return "<font size=\"" + HtmlEscape(size) + "\">" + TO_STRING(this) +
// ES6 draft, revision 26 (2014-07-18), section B.2.3.9
function StringItalics() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.italics");
// ES6 draft, revision 26 (2014-07-18), section B.2.3.9
function StringItalics() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.italics");
- return "<i>" + TO_STRING_INLINE(this) + "</i>";
+ return "<i>" + TO_STRING(this) + "</i>";
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.10
function StringLink(s) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.link");
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.10
function StringLink(s) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.link");
- return "<a href=\"" + HtmlEscape(s) + "\">" + TO_STRING_INLINE(this) + "</a>";
+ return "<a href=\"" + HtmlEscape(s) + "\">" + TO_STRING(this) + "</a>";
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.11
function StringSmall() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.small");
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.11
function StringSmall() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.small");
- return "<small>" + TO_STRING_INLINE(this) + "</small>";
+ return "<small>" + TO_STRING(this) + "</small>";
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.12
function StringStrike() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.strike");
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.12
function StringStrike() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.strike");
- return "<strike>" + TO_STRING_INLINE(this) + "</strike>";
+ return "<strike>" + TO_STRING(this) + "</strike>";
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.13
function StringSub() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.sub");
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.13
function StringSub() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.sub");
- return "<sub>" + TO_STRING_INLINE(this) + "</sub>";
+ return "<sub>" + TO_STRING(this) + "</sub>";
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.14
function StringSup() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.sup");
}
// ES6 draft, revision 26 (2014-07-18), section B.2.3.14
function StringSup() {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.sup");
- return "<sup>" + TO_STRING_INLINE(this) + "</sup>";
+ return "<sup>" + TO_STRING(this) + "</sup>";
}
// ES6 draft 01-20-14, section 21.1.3.13
function StringRepeat(count) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.repeat");
}
// ES6 draft 01-20-14, section 21.1.3.13
function StringRepeat(count) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.repeat");
- var s = TO_STRING_INLINE(this);
+ var s = TO_STRING(this);
var n = $toInteger(count);
// The maximum string length is stored in a smi, so a longer repeat
// must result in a range error.
var n = $toInteger(count);
// The maximum string length is stored in a smi, so a longer repeat
// must result in a range error.
function StringStartsWith(searchString /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.startsWith");
function StringStartsWith(searchString /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.startsWith");
- var s = TO_STRING_INLINE(this);
+ var s = TO_STRING(this);
if (IS_REGEXP(searchString)) {
throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.startsWith");
}
if (IS_REGEXP(searchString)) {
throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.startsWith");
}
- var ss = TO_STRING_INLINE(searchString);
+ var ss = TO_STRING(searchString);
var pos = 0;
if (%_ArgumentsLength() > 1) {
var arg = %_Arguments(1); // position
var pos = 0;
if (%_ArgumentsLength() > 1) {
var arg = %_Arguments(1); // position
function StringEndsWith(searchString /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.endsWith");
function StringEndsWith(searchString /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.endsWith");
- var s = TO_STRING_INLINE(this);
+ var s = TO_STRING(this);
if (IS_REGEXP(searchString)) {
throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.endsWith");
}
if (IS_REGEXP(searchString)) {
throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.endsWith");
}
- var ss = TO_STRING_INLINE(searchString);
+ var ss = TO_STRING(searchString);
var s_len = s.length;
var pos = s_len;
if (%_ArgumentsLength() > 1) {
var s_len = s.length;
var pos = s_len;
if (%_ArgumentsLength() > 1) {
function StringIncludes(searchString /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.includes");
function StringIncludes(searchString /* position */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.includes");
- var string = TO_STRING_INLINE(this);
+ var string = TO_STRING(this);
if (IS_REGEXP(searchString)) {
throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.includes");
}
if (IS_REGEXP(searchString)) {
throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.includes");
}
- searchString = TO_STRING_INLINE(searchString);
+ searchString = TO_STRING(searchString);
var pos = 0;
if (%_ArgumentsLength() > 1) {
pos = %_Arguments(1); // position
var pos = 0;
if (%_ArgumentsLength() > 1) {
pos = %_Arguments(1); // position
function StringCodePointAt(pos) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.codePointAt");
function StringCodePointAt(pos) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.codePointAt");
- var string = TO_STRING_INLINE(this);
+ var string = TO_STRING(this);
var size = string.length;
pos = TO_INTEGER(pos);
if (pos < 0 || pos >= size) {
var size = string.length;
pos = TO_INTEGER(pos);
if (pos < 0 || pos >= size) {
var literalSegments = $toLength(raw.length);
if (literalSegments <= 0) return "";
var literalSegments = $toLength(raw.length);
if (literalSegments <= 0) return "";
- var result = ToString(raw[0]);
+ var result = TO_STRING(raw[0]);
for (var i = 1; i < literalSegments; ++i) {
if (i < numberOfSubstitutions) {
for (var i = 1; i < literalSegments; ++i) {
if (i < numberOfSubstitutions) {
- result += ToString(%_Arguments(i));
+ result += TO_STRING(%_Arguments(i));
- result += ToString(raw[i]);
+ result += TO_STRING(raw[i]);
function SymbolFor(key) {
function SymbolFor(key) {
- key = TO_STRING_INLINE(key);
var registry = %SymbolRegistry();
if (IS_UNDEFINED(registry.for[key])) {
var symbol = %CreateSymbol(key);
var registry = %SymbolRegistry();
if (IS_UNDEFINED(registry.for[key])) {
var symbol = %CreateSymbol(key);
var GlobalObject = global.Object;
var GlobalArray = global.Array;
var InternalArray = utils.InternalArray;
var GlobalObject = global.Object;
var GlobalArray = global.Array;
var InternalArray = utils.InternalArray;
-var ToString;
-
-utils.Import(function(from) {
- ToString = from.ToString;
-});
// -------------------------------------------------------------------
// Define internal helper functions.
// -------------------------------------------------------------------
// Define internal helper functions.
// ECMA-262, section 15.1.3
function Encode(uri, unescape) {
// ECMA-262, section 15.1.3
function Encode(uri, unescape) {
- uri = TO_STRING_INLINE(uri);
var uriLength = uri.length;
var array = new InternalArray(uriLength);
var index = 0;
var uriLength = uri.length;
var array = new InternalArray(uriLength);
var index = 0;
// ECMA-262, section 15.1.3
function Decode(uri, reserved) {
// ECMA-262, section 15.1.3
function Decode(uri, reserved) {
- uri = TO_STRING_INLINE(uri);
var uriLength = uri.length;
var one_byte = %NewString(uriLength, NEW_ONE_BYTE_STRING);
var index = 0;
var uriLength = uri.length;
var one_byte = %NewString(uriLength, NEW_ONE_BYTE_STRING);
var index = 0;
// Define exported functions.
// ECMA-262 - B.2.1.
// Define exported functions.
// ECMA-262 - B.2.1.
-function URIEscapeJS(str) {
- var s = ToString(str);
+function URIEscapeJS(s) {
return %URIEscape(s);
}
// ECMA-262 - B.2.2.
return %URIEscape(s);
}
// ECMA-262 - B.2.2.
-function URIUnescapeJS(str) {
- var s = ToString(str);
+function URIUnescapeJS(s) {
return %URIUnescape(s);
}
return %URIUnescape(s);
}
- var string = ToString(uri);
- return Decode(string, reservedPredicate);
+ return Decode(uri, reservedPredicate);
}
// ECMA-262 - 15.1.3.2.
function URIDecodeComponent(component) {
var reservedPredicate = function(cc) { return false; };
}
// ECMA-262 - 15.1.3.2.
function URIDecodeComponent(component) {
var reservedPredicate = function(cc) { return false; };
- var string = ToString(component);
- return Decode(string, reservedPredicate);
+ return Decode(component, reservedPredicate);
}
// ECMA-262 - 15.1.3.3.
}
// ECMA-262 - 15.1.3.3.
- var string = ToString(uri);
- return Encode(string, unescapePredicate);
+ return Encode(uri, unescapePredicate);
- var string = ToString(component);
- return Encode(string, unescapePredicate);
+ return Encode(component, unescapePredicate);
}
// -------------------------------------------------------------------
}
// -------------------------------------------------------------------
var StringIndexOf;
var ToBoolean = utils.ImportNow("ToBoolean");
var ToNumber = utils.ImportNow("ToNumber");
var StringIndexOf;
var ToBoolean = utils.ImportNow("ToBoolean");
var ToNumber = utils.ImportNow("ToNumber");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MathAbs = from.MathAbs;
StringIndexOf = from.StringIndexOf;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MathAbs = from.MathAbs;
StringIndexOf = from.StringIndexOf;
- ToString = from.ToString;
});
utils.ImportFromExperimental(function(from) {
});
utils.ImportFromExperimental(function(from) {
// Truncate number.
return string | 0;
}
// Truncate number.
return string | 0;
}
- string = TO_STRING_INLINE(string);
+ string = TO_STRING(string);
radix = radix | 0;
} else {
// The spec says ToString should be evaluated before ToInt32.
radix = radix | 0;
} else {
// The spec says ToString should be evaluated before ToInt32.
- string = TO_STRING_INLINE(string);
+ string = TO_STRING(string);
radix = TO_INT32(radix);
if (!(radix == 0 || (2 <= radix && radix <= 36))) {
return NAN;
radix = TO_INT32(radix);
if (!(radix == 0 || (2 <= radix && radix <= 36))) {
return NAN;
// ECMA-262 - 15.1.2.3
function GlobalParseFloat(string) {
// ECMA-262 - 15.1.2.3
function GlobalParseFloat(string) {
- string = TO_STRING_INLINE(string);
+ string = TO_STRING(string);
if (%_HasCachedArrayIndex(string)) return %_GetCachedArrayIndex(string);
return %StringParseFloat(string);
}
if (%_HasCachedArrayIndex(string)) return %_GetCachedArrayIndex(string);
return %StringParseFloat(string);
}
if (!IS_SYMBOL(p)) {
var index = TO_UINT32(p);
var emit_splice = false;
if (!IS_SYMBOL(p)) {
var index = TO_UINT32(p);
var emit_splice = false;
- if (ToString(index) == p && index != 4294967295) {
+ if (TO_STRING(index) == p && index != 4294967295) {
var length = obj.length;
if (index >= length && %IsObserved(obj)) {
emit_splice = true;
var length = obj.length;
if (index >= length && %IsObserved(obj)) {
emit_splice = true;
}
} else {
if (filter & PROPERTY_ATTRIBUTES_STRING) continue;
}
} else {
if (filter & PROPERTY_ATTRIBUTES_STRING) continue;
+ name = TO_STRING(name);
}
if (seenKeys[name]) continue;
seenKeys[name] = true;
}
if (seenKeys[name]) continue;
seenKeys[name] = true;
// Get the value of this number in case it's an object.
x = %_ValueOf(this);
}
// Get the value of this number in case it's an object.
x = %_ValueOf(this);
}
- if (IS_UNDEFINED(precision)) return ToString(%_ValueOf(this));
+ if (IS_UNDEFINED(precision)) return TO_STRING(x);
var p = TO_INTEGER(precision);
if (NUMBER_IS_NAN(x)) return "NaN";
var p = TO_INTEGER(precision);
if (NUMBER_IS_NAN(x)) return "NaN";
var n = args.length;
var p = '';
if (n > 1) {
var n = args.length;
var p = '';
if (n > 1) {
+ p = TO_STRING(args[0]);
for (var i = 1; i < n - 1; i++) {
for (var i = 1; i < n - 1; i++) {
- p += ',' + ToString(args[i]);
+ p += ',' + TO_STRING(args[i]);
}
// If the formal parameters string include ) - an illegal
// character - it may make the combined function expression
}
// If the formal parameters string include ) - an illegal
// character - it may make the combined function expression
// comments we can include a trailing block comment to catch this.
p += '\n/' + '**/';
}
// comments we can include a trailing block comment to catch this.
p += '\n/' + '**/';
}
- var body = (n > 0) ? ToString(args[n - 1]) : '';
+ var body = (n > 0) ? TO_STRING(args[n - 1]) : '';
return '(' + function_token + '(' + p + ') {\n' + body + '\n})';
}
return '(' + function_token + '(' + p + ') {\n' + body + '\n})';
}
TEST(RuntimeCallJS) {
FLAG_allow_natives_syntax = true;
TEST(RuntimeCallJS) {
FLAG_allow_natives_syntax = true;
- FunctionTester T("(function(a) { return %to_string_fun(a); })");
-
- T.CheckCall(T.Val("23"), T.Val(23), T.undefined());
- T.CheckCall(T.Val("4.2"), T.Val(4.2), T.undefined());
- T.CheckCall(T.Val("str"), T.Val("str"), T.undefined());
- T.CheckCall(T.Val("true"), T.true_value(), T.undefined());
- T.CheckCall(T.Val("false"), T.false_value(), T.undefined());
- T.CheckCall(T.Val("undefined"), T.undefined(), T.undefined());
+ FunctionTester T("(function(a) { return %to_number_fun(a); })");
+
+ T.CheckCall(T.Val(23), T.Val(23), T.undefined());
+ T.CheckCall(T.Val(4.2), T.Val(4.2), T.undefined());
+ T.CheckCall(T.Val(1), T.true_value(), T.undefined());
// Test call of JS runtime functions.
// Test call of JS runtime functions.
-assertEquals("1", %to_string_fun(1));
+assertEquals(1, %to_number_fun("1"));
// kCannotConvertToPrimitive
test(function() {
// kCannotConvertToPrimitive
test(function() {
- [].join(Object(Symbol(1)));
+ var o = { toString: function() { return this } };
+ [].join(o);
}, "Cannot convert object to primitive value", TypeError);
// kCircularStructure
}, "Cannot convert object to primitive value", TypeError);
// kCircularStructure