[runtime] Replace %to_string_fun with %_ToString.
authorbmeurer <bmeurer@chromium.org>
Wed, 23 Sep 2015 21:46:37 +0000 (14:46 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 23 Sep 2015 21:46:49 +0000 (21:46 +0000)
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:
src/array.js
src/contexts.h
src/date.js
src/harmony-regexp.js
src/i18n.js
src/json.js
src/macros.py
src/messages.js
src/parser.cc
src/proxy.js
src/regexp.js
src/runtime.js
src/runtime/runtime-date.cc
src/runtime/runtime-json.cc
src/runtime/runtime-uri.cc
src/string-iterator.js
src/string.js
src/symbol.js
src/uri.js
src/v8natives.js
test/cctest/compiler/test-run-jscalls.cc
test/mjsunit/compiler/jsnatives.js
test/mjsunit/messages.js

index 94775cd..721121e 100644 (file)
@@ -411,8 +411,8 @@ function ArrayToLocaleString() {
 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);
@@ -421,9 +421,8 @@ function InnerArrayJoin(separator, array, length) {
   // 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 '';
-    return $nonStringToString(e);
+    return TO_STRING(e);
   }
 
   return Join(array, length, separator, ConvertToString);
index 62c1880..267fdea 100644 (file)
@@ -79,14 +79,12 @@ enum BindingFlags {
   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(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)                                 \
index f7a6a08..d2d5915 100644 (file)
@@ -22,14 +22,12 @@ var IsFinite;
 var MathAbs;
 var MathFloor;
 var ToNumber;
-var ToString;
 
 utils.Import(function(from) {
   IsFinite = from.IsFinite;
   MathAbs = from.MathAbs;
   MathFloor = from.MathFloor;
   ToNumber = from.ToNumber;
-  ToString = from.ToString;
 });
 
 // -------------------------------------------------------------------
@@ -268,7 +266,7 @@ var parse_buffer = new InternalArray(8);
 
 // 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]);
index 1507167..1ab76fa 100644 (file)
 // Imports
 
 var GlobalRegExp = global.RegExp;
-var ToString;
-
-utils.Import(function(from) {
-  ToString = from.ToString;
-});
 
 // -------------------------------------------------------------------
 
@@ -24,7 +19,7 @@ utils.Import(function(from) {
 // + 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';
index c50f1f9..a3e2e34 100644 (file)
@@ -2004,10 +2004,10 @@ OverrideFunction(GlobalString.prototype, 'normalize', function() {
     }
 
     CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
-    var s = TO_STRING_INLINE(this);
+    var s = TO_STRING(this);
 
     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'];
 
index a0a88a0..8fe30ef 100644 (file)
@@ -17,7 +17,6 @@ var MathMax;
 var MathMin;
 var ObjectHasOwnProperty;
 var ToNumber;
-var ToString;
 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
 
 utils.Import(function(from) {
@@ -25,7 +24,6 @@ utils.Import(function(from) {
   MathMin = from.MathMin;
   ObjectHasOwnProperty = from.ObjectHasOwnProperty;
   ToNumber = from.ToNumber;
-  ToString = from.ToString;
 });
 
 // -------------------------------------------------------------------
@@ -57,7 +55,7 @@ function Revive(holder, name, 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 {
@@ -161,7 +159,7 @@ function JSONSerialize(key, holder, replacer, stack, indent, gap) {
     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);
@@ -169,7 +167,7 @@ function JSONSerialize(key, holder, replacer, stack, indent, gap) {
       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 {
@@ -198,7 +196,7 @@ function JSONStringify(value, replacer, space) {
       } else if (IS_NUMBER(v)) {
         item = %_NumberToString(v);
       } else if (IS_STRING_WRAPPER(v) || IS_NUMBER_WRAPPER(v)) {
-        item = ToString(v);
+        item = TO_STRING(v);
       } else {
         continue;
       }
@@ -214,7 +212,7 @@ function JSONStringify(value, replacer, space) {
     if (IS_NUMBER_WRAPPER(space)) {
       space = ToNumber(space);
     } else if (IS_STRING_WRAPPER(space)) {
-      space = ToString(space);
+      space = TO_STRING(space);
     }
   }
   var gap;
index aa994fc..f3b646b 100644 (file)
@@ -147,7 +147,7 @@ macro TO_INTEGER_MAP_MINUS_ZERO(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : %NumberToI
 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));
index 2e73d6e..5441cfe 100644 (file)
@@ -49,7 +49,6 @@ var StringCharAt;
 var StringIndexOf;
 var StringSubstring;
 var SymbolToString;
-var ToString = utils.ImportNow("ToString");
 var Uint16x8ToString;
 var Uint32x4ToString;
 var Uint8x16ToString;
@@ -169,7 +168,7 @@ function ToStringCheckErrorObject(obj) {
   if (CanBeSafelyTreatedAsAnErrorObject(obj)) {
     return %_CallFunction(obj, ErrorToString);
   } else {
-    return ToString(obj);
+    return TO_STRING(obj);
   }
 }
 
@@ -953,7 +952,7 @@ function DefineError(global, f) {
       // 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);
index 3edde7d..123a7bd 100644 (file)
@@ -6102,8 +6102,8 @@ Expression* Parser::CloseTemplateLiteral(TemplateLiteralState* state, int start,
       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(
index fbca982..cc45b32 100644 (file)
@@ -145,7 +145,7 @@ function DerivedKeysTrap() {
   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]
     }
@@ -159,7 +159,7 @@ function DerivedEnumerateTrap() {
   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,
index 3e5c0b6..e19a813 100644 (file)
@@ -66,8 +66,8 @@ function DoConstructRegExp(object, pattern, flags) {
     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);
 }
@@ -161,7 +161,7 @@ function RegExpExecJS(string) {
                         '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
@@ -208,7 +208,7 @@ function RegExpTest(string) {
     throw MakeTypeError(kIncompatibleMethodReceiver,
                         'RegExp.prototype.test', this);
   }
-  string = TO_STRING_INLINE(string);
+  string = TO_STRING(string);
 
   var lastIndex = this.lastIndex;
 
@@ -392,7 +392,7 @@ var RegExpGetInput = function() {
   return IS_UNDEFINED(regExpInput) ? "" : regExpInput;
 };
 var RegExpSetInput = function(string) {
-  LAST_INPUT(RegExpLastMatchInfo) = $toString(string);
+  LAST_INPUT(RegExpLastMatchInfo) = TO_STRING(string);
 };
 
 %OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22);
index e2eec4f..f0bc133 100644 (file)
 var $defaultString;
 var $NaN;
 var $nonNumberToNumber;
-var $nonStringToString;
 var $sameValue;
 var $sameValueZero;
 var $toInteger;
 var $toLength;
 var $toNumber;
 var $toPositiveInteger;
-var $toString;
 
 var harmony_tolength = false;
 
@@ -47,8 +45,7 @@ function APPLY_PREPARE(args) {
 
   // 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
@@ -84,8 +81,7 @@ function REFLECT_APPLY_PREPARE(args) {
 
   // 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
@@ -134,17 +130,17 @@ function REFLECT_CONSTRUCT_PREPARE(
 
   if (!ctorOk) {
     if (!IS_CALLABLE(this)) {
-      throw %make_type_error(kCalledNonCallable, %to_string_fun(this));
+      throw %make_type_error(kCalledNonCallable, TO_STRING(this));
     } else {
-      throw %make_type_error(kNotConstructor, %to_string_fun(this));
+      throw %make_type_error(kNotConstructor, TO_STRING(this));
     }
   }
 
   if (!newTargetOk) {
     if (!IS_CALLABLE(newTarget)) {
-      throw %make_type_error(kCalledNonCallable, %to_string_fun(newTarget));
+      throw %make_type_error(kCalledNonCallable, TO_STRING(newTarget));
     } else {
-      throw %make_type_error(kNotConstructor, %to_string_fun(newTarget));
+      throw %make_type_error(kNotConstructor, TO_STRING(newTarget));
     }
   }
 
@@ -220,14 +216,6 @@ function ToString(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) {
@@ -360,14 +348,12 @@ function ToPositiveInteger(x, rangeErrorIndex) {
 $defaultString = DefaultString;
 $NaN = %GetRootNaN();
 $nonNumberToNumber = NonNumberToNumber;
-$nonStringToString = NonStringToString;
 $sameValue = SameValue;
 $sameValueZero = SameValueZero;
 $toInteger = ToInteger;
 $toLength = ToLength;
 $toNumber = ToNumber;
 $toPositiveInteger = ToPositiveInteger;
-$toString = ToString;
 
 %InstallToContext([
   "apply_prepare_builtin", APPLY_PREPARE,
@@ -379,11 +365,9 @@ $toString = ToString;
 %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_string_fun", ToString,
 ]);
 
 utils.Export(function(to) {
index 4d238b4..b4ed6bd 100644 (file)
@@ -100,8 +100,8 @@ RUNTIME_FUNCTION(Runtime_DateCurrentTime) {
 
 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());
@@ -110,6 +110,10 @@ RUNTIME_FUNCTION(Runtime_DateParseString) {
   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;
 
index 07ccb99..07232d5 100644 (file)
@@ -39,9 +39,11 @@ RUNTIME_FUNCTION(Runtime_BasicJSONStringify) {
 
 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;
@@ -51,5 +53,6 @@ RUNTIME_FUNCTION(Runtime_ParseJson) {
                                          : JsonParser<false>::Parse(source));
   return *result;
 }
+
 }  // namespace internal
 }  // namespace v8
index d4e62ce..e64e9dc 100644 (file)
@@ -258,13 +258,15 @@ MaybeHandle<String> URIEscape::Escape(Isolate* isolate, Handle<String> string) {
 
 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(
-      isolate, result, string->IsOneByteRepresentationUnderneath()
+      isolate, result, source->IsOneByteRepresentationUnderneath()
                            ? URIEscape::Escape<uint8_t>(isolate, source)
                            : URIEscape::Escape<uc16>(isolate, source));
   return *result;
@@ -274,15 +276,18 @@ RUNTIME_FUNCTION(Runtime_URIEscape) {
 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(
-      isolate, result, string->IsOneByteRepresentationUnderneath()
+      isolate, result, source->IsOneByteRepresentationUnderneath()
                            ? URIUnescape::Unescape<uint8_t>(isolate, source)
                            : URIUnescape::Unescape<uc16>(isolate, source));
   return *result;
 }
+
 }  // namespace internal
 }  // namespace v8
index d637757..660dc7c 100644 (file)
@@ -26,7 +26,7 @@ function StringIterator() {}
 
 // 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);
index 039a2b8..2ee8a22 100644 (file)
@@ -19,7 +19,6 @@ var RegExpExec;
 var RegExpExecNoTests;
 var RegExpLastMatchInfo;
 var ToNumber;
-var ToString;
 
 utils.Import(function(from) {
   ArrayIndexOf = from.ArrayIndexOf;
@@ -28,7 +27,6 @@ utils.Import(function(from) {
   RegExpExecNoTests = from.RegExpExecNoTests;
   RegExpLastMatchInfo = from.RegExpLastMatchInfo;
   ToNumber = from.ToNumber;
-  ToString = from.ToString;
 });
 
 //-------------------------------------------------------------------
@@ -57,7 +55,7 @@ function StringCharAtJS(pos) {
 
   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));
   }
   return result;
 }
@@ -69,7 +67,7 @@ function StringCharCodeAtJS(pos) {
 
   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));
   }
   return result;
 }
@@ -79,15 +77,15 @@ function StringCharCodeAtJS(pos) {
 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);
   if (len === 1) {
-    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);
-    parts[i + 1] = TO_STRING_INLINE(part);
+    parts[i + 1] = TO_STRING(part);
   }
   return %StringBuilderConcat(parts, len + 1, "");
 }
@@ -97,8 +95,8 @@ function StringConcat(other /* and more */) {  // length == 1
 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
@@ -114,9 +112,9 @@ function StringIndexOfJS(pattern /* position */) {  // length == 1
 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 pat = TO_STRING_INLINE(pat);
+  var pat = TO_STRING(pat);
   var patLength = pat.length;
   var index = subLength - patLength;
   if (%_ArgumentsLength() > 1) {
@@ -145,8 +143,7 @@ function StringLastIndexOfJS(pat /* position */) {  // length == 1
 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));
 }
 
 
@@ -154,7 +151,7 @@ function StringLocaleCompareJS(other) {
 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.
@@ -179,10 +176,10 @@ function StringMatchJS(regexp) {
 // 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 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 =
@@ -208,7 +205,7 @@ var reusableMatchInfo = [2, "", "", -1, -1];
 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
@@ -234,7 +231,7 @@ function StringReplace(search, 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.
@@ -282,7 +279,7 @@ function StringReplace(search, replace) {
     return StringReplaceNonGlobalRegExpWithFunction(subject, search, replace);
   }
 
-  search = TO_STRING_INLINE(search);
+  search = TO_STRING(search);
 
   if (search.length == 1 &&
       subject.length > 0xFF &&
@@ -305,7 +302,7 @@ function StringReplace(search, replace) {
   } else {
     reusableMatchInfo[CAPTURE0] = start;
     reusableMatchInfo[CAPTURE1] = end;
-    result = ExpandReplacement(TO_STRING_INLINE(replace),
+    result = ExpandReplacement(TO_STRING(replace),
                                subject,
                                reusableMatchInfo,
                                result);
@@ -467,7 +464,7 @@ function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
         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;
       }
     }
@@ -481,7 +478,7 @@ function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
         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);
       }
     }
   }
@@ -539,7 +536,7 @@ function StringSearch(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];
   }
@@ -551,7 +548,7 @@ function StringSearch(re) {
 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;
@@ -593,12 +590,12 @@ function StringSlice(start, end) {
 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)) {
-    var separator_string = TO_STRING_INLINE(separator);
+    var separator_string = TO_STRING(separator);
 
     if (limit === 0) return [];
 
@@ -685,7 +682,7 @@ function StringSplitOnRegExp(subject, separator, limit, length) {
 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);
@@ -718,7 +715,7 @@ function StringSubstring(start, end) {
 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
@@ -758,7 +755,7 @@ function StringSubstr(start, n) {
 function StringToLowerCaseJS() {
   CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLowerCase");
 
-  return %StringToLowerCase(TO_STRING_INLINE(this));
+  return %StringToLowerCase(TO_STRING(this));
 }
 
 
@@ -766,7 +763,7 @@ function StringToLowerCaseJS() {
 function StringToLocaleLowerCase() {
   CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleLowerCase");
 
-  return %StringToLowerCase(TO_STRING_INLINE(this));
+  return %StringToLowerCase(TO_STRING(this));
 }
 
 
@@ -774,7 +771,7 @@ function StringToLocaleLowerCase() {
 function StringToUpperCaseJS() {
   CHECK_OBJECT_COERCIBLE(this, "String.prototype.toUpperCase");
 
-  return %StringToUpperCase(TO_STRING_INLINE(this));
+  return %StringToUpperCase(TO_STRING(this));
 }
 
 
@@ -782,26 +779,26 @@ function StringToUpperCaseJS() {
 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");
 
-  return %StringTrim(TO_STRING_INLINE(this), true, true);
+  return %StringTrim(TO_STRING(this), true, true);
 }
 
 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");
 
-  return %StringTrim(TO_STRING_INLINE(this), false, true);
+  return %StringTrim(TO_STRING(this), false, true);
 }
 
 
@@ -837,14 +834,14 @@ function StringFromCharCode(code) {
 
 // ES6 draft, revision 26 (2014-07-18), section B.2.3.2.1
 function HtmlEscape(str) {
-  return %_CallFunction(TO_STRING_INLINE(str), /"/g, "&quot;", StringReplace);
+  return %_CallFunction(TO_STRING(str), /"/g, "&quot;", StringReplace);
 }
 
 
 // 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) +
          "</a>";
 }
 
@@ -852,35 +849,35 @@ function StringAnchor(name) {
 // 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");
-  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");
-  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");
-  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");
-  return "<font color=\"" + HtmlEscape(color) + "\">" + TO_STRING_INLINE(this) +
+  return "<font color=\"" + HtmlEscape(color) + "\">" + TO_STRING(this) +
          "</font>";
 }
 
@@ -888,7 +885,7 @@ function StringFontcolor(color) {
 // 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) +
          "</font>";
 }
 
@@ -896,49 +893,49 @@ function StringFontsize(size) {
 // 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");
-  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");
-  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");
-  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");
-  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");
-  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");
 
-  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.
@@ -958,13 +955,13 @@ function StringRepeat(count) {
 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");
   }
 
-  var ss = TO_STRING_INLINE(searchString);
+  var ss = TO_STRING(searchString);
   var pos = 0;
   if (%_ArgumentsLength() > 1) {
     var arg = %_Arguments(1);  // position
@@ -996,13 +993,13 @@ function StringStartsWith(searchString /* position */) {  // length == 1
 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");
   }
 
-  var ss = TO_STRING_INLINE(searchString);
+  var ss = TO_STRING(searchString);
   var s_len = s.length;
   var pos = s_len;
   if (%_ArgumentsLength() > 1) {
@@ -1035,13 +1032,13 @@ function StringEndsWith(searchString /* position */) {  // length == 1
 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");
   }
 
-  searchString = TO_STRING_INLINE(searchString);
+  searchString = TO_STRING(searchString);
   var pos = 0;
   if (%_ArgumentsLength() > 1) {
     pos = %_Arguments(1);  // position
@@ -1065,7 +1062,7 @@ function StringIncludes(searchString /* position */) {  // length == 1
 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) {
@@ -1121,13 +1118,13 @@ function StringRaw(callSite) {
   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) {
-      result += ToString(%_Arguments(i));
+      result += TO_STRING(%_Arguments(i));
     }
-    result += ToString(raw[i]);
+    result += TO_STRING(raw[i]);
   }
 
   return result;
index 600d4fd..1596169 100644 (file)
@@ -58,7 +58,7 @@ function SymbolValueOf() {
 
 
 function SymbolFor(key) {
-  key = TO_STRING_INLINE(key);
+  key = TO_STRING(key);
   var registry = %SymbolRegistry();
   if (IS_UNDEFINED(registry.for[key])) {
     var symbol = %CreateSymbol(key);
index bf3270f..bdb83d1 100644 (file)
 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.
@@ -169,7 +164,7 @@ function URIDecodeOctets(octets, result, index) {
 
 // ECMA-262, section 15.1.3
 function Encode(uri, unescape) {
-  uri = TO_STRING_INLINE(uri);
+  uri = TO_STRING(uri);
   var uriLength = uri.length;
   var array = new InternalArray(uriLength);
   var index = 0;
@@ -200,7 +195,7 @@ function Encode(uri, unescape) {
 
 // ECMA-262, section 15.1.3
 function Decode(uri, reserved) {
-  uri = TO_STRING_INLINE(uri);
+  uri = TO_STRING(uri);
   var uriLength = uri.length;
   var one_byte = %NewString(uriLength, NEW_ONE_BYTE_STRING);
   var index = 0;
@@ -278,14 +273,12 @@ function Decode(uri, reserved) {
 // 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.
-function URIUnescapeJS(str) {
-  var s = ToString(str);
+function URIUnescapeJS(s) {
   return %URIUnescape(s);
 }
 
@@ -309,15 +302,13 @@ function URIDecode(uri) {
 
     return false;
   };
-  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; };
-  var string = ToString(component);
-  return Decode(string, reservedPredicate);
+  return Decode(component, reservedPredicate);
 }
 
 // ECMA-262 - 15.1.3.3.
@@ -343,8 +334,7 @@ function URIEncode(uri) {
 
     return false;
   };
-  var string = ToString(uri);
-  return Encode(string, unescapePredicate);
+  return Encode(uri, unescapePredicate);
 }
 
 // ECMA-262 - 15.1.3.4
@@ -364,8 +354,7 @@ function URIEncodeComponent(component) {
 
     return false;
   };
-  var string = ToString(component);
-  return Encode(string, unescapePredicate);
+  return Encode(component, unescapePredicate);
 }
 
 // -------------------------------------------------------------------
index 2a235a2..168f97b 100644 (file)
@@ -24,13 +24,11 @@ var ProxyDerivedKeysTrap;
 var StringIndexOf;
 var ToBoolean = utils.ImportNow("ToBoolean");
 var ToNumber = utils.ImportNow("ToNumber");
-var ToString;
 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) {
@@ -72,11 +70,11 @@ function GlobalParseInt(string, radix) {
       // 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.
-    string = TO_STRING_INLINE(string);
+    string = TO_STRING(string);
     radix = TO_INT32(radix);
     if (!(radix == 0 || (2 <= radix && radix <= 36))) {
       return NAN;
@@ -93,7 +91,7 @@ function GlobalParseInt(string, radix) {
 
 // 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);
 }
@@ -806,7 +804,7 @@ function DefineArrayProperty(obj, p, desc, should_throw) {
   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;
@@ -974,7 +972,7 @@ function ObjectGetOwnPropertyKeys(obj, filter) {
         }
       } else {
         if (filter & PROPERTY_ATTRIBUTES_STRING) continue;
-        name = ToString(name);
+        name = TO_STRING(name);
       }
       if (seenKeys[name]) continue;
       seenKeys[name] = true;
@@ -1538,7 +1536,7 @@ function NumberToPrecisionJS(precision) {
     // 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";
@@ -1758,9 +1756,9 @@ function NewFunctionString(args, function_token) {
   var n = args.length;
   var p = '';
   if (n > 1) {
-    p = ToString(args[0]);
+    p = TO_STRING(args[0]);
     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
@@ -1773,7 +1771,7 @@ function NewFunctionString(args, function_token) {
     // 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})';
 }
 
index 63c12bf..621c1c3 100644 (file)
@@ -143,14 +143,11 @@ TEST(RuntimeCallCPP2) {
 
 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());
 }
 
 
index 2369763..74d88ba 100644 (file)
@@ -29,4 +29,4 @@
 
 // Test call of JS runtime functions.
 
-assertEquals("1", %to_string_fun(1));
+assertEquals(1, %to_number_fun("1"));
index 45443c7..b8c3114 100644 (file)
@@ -76,7 +76,8 @@ 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