Bug 1454207 - Part 2: Renames |ValueToPrintable| to |ValueToPrintableLatin1|, in preparation for introducing a new function |ValueToPrintableUtf8| r=arai
authorZhang Junzhi <zjz@zjz.name>
Sun, 15 Apr 2018 13:09:22 +0800
changeset 467517 4a202b7736923f1858b92459d8e9d5251df59cbd
parent 467516 16eb62f2681a58a741fcf6a19150e8ba5bb8866a
child 467518 9e8c23aa94e4ddffc4b3fb6ed502b35ac09494e5
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1454207
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1454207 - Part 2: Renames |ValueToPrintable| to |ValueToPrintableLatin1|, in preparation for introducing a new function |ValueToPrintableUtf8| r=arai MozReview-Commit-ID: CXTbJnKZMiH
js/src/vm/BytecodeUtil.cpp
js/src/vm/EnvironmentObject.cpp
js/src/vm/Interpreter.cpp
js/src/vm/JSContext.cpp
js/src/vm/StringType.cpp
js/src/vm/StringType.h
--- a/js/src/vm/BytecodeUtil.cpp
+++ b/js/src/vm/BytecodeUtil.cpp
@@ -1172,17 +1172,17 @@ ToDisassemblySource(JSContext* cx, Handl
         if (obj.is<RegExpObject>()) {
             JSString* source = obj.as<RegExpObject>().toString(cx);
             if (!source)
                 return false;
             return bytes->encodeLatin1(cx, source);
         }
     }
 
-    return !!ValueToPrintable(cx, v, bytes, true);
+    return !!ValueToPrintableLatin1(cx, v, bytes, true);
 }
 
 static bool
 ToDisassemblySource(JSContext* cx, HandleScope scope, JSAutoByteString* bytes)
 {
     UniqueChars source = JS_smprintf("%s {", ScopeKindString(scope->kind()));
     if (!source) {
         ReportOutOfMemory(cx);
--- a/js/src/vm/EnvironmentObject.cpp
+++ b/js/src/vm/EnvironmentObject.cpp
@@ -1413,17 +1413,17 @@ LiveEnvironmentVal::staticAsserts()
 /*****************************************************************************/
 
 namespace {
 
 static void
 ReportOptimizedOut(JSContext* cx, HandleId id)
 {
     JSAutoByteString printable;
-    if (ValueToPrintable(cx, IdToValue(id), &printable)) {
+    if (ValueToPrintableLatin1(cx, IdToValue(id), &printable)) {
         JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_OPTIMIZED_OUT,
                                    printable.ptr());
     }
 }
 
 /*
  * DebugEnvironmentProxy is the handler for DebugEnvironmentProxy proxy
  * objects. Having a custom handler (rather than trying to reuse js::Wrapper)
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -5061,17 +5061,17 @@ js::NewArrayOperationWithTemplate(JSCont
 }
 
 void
 js::ReportRuntimeLexicalError(JSContext* cx, unsigned errorNumber, HandleId id)
 {
     MOZ_ASSERT(errorNumber == JSMSG_UNINITIALIZED_LEXICAL ||
                errorNumber == JSMSG_BAD_CONST_ASSIGN);
     JSAutoByteString printable;
-    if (ValueToPrintable(cx, IdToValue(id), &printable))
+    if (ValueToPrintableLatin1(cx, IdToValue(id), &printable))
         JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, errorNumber, printable.ptr());
 }
 
 void
 js::ReportRuntimeLexicalError(JSContext* cx, unsigned errorNumber, HandlePropertyName name)
 {
     RootedId id(cx, NameToId(name));
     ReportRuntimeLexicalError(cx, errorNumber, id);
--- a/js/src/vm/JSContext.cpp
+++ b/js/src/vm/JSContext.cpp
@@ -879,17 +879,17 @@ js::ReportErrorNumberUCArray(JSContext* 
 
     return warning;
 }
 
 void
 js::ReportIsNotDefined(JSContext* cx, HandleId id)
 {
     JSAutoByteString printable;
-    if (!ValueToPrintable(cx, IdToValue(id), &printable))
+    if (!ValueToPrintableLatin1(cx, IdToValue(id), &printable))
         return;
     JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_NOT_DEFINED, printable.ptr());
 }
 
 void
 js::ReportIsNotDefined(JSContext* cx, HandlePropertyName name)
 {
     RootedId id(cx, NameToId(name));
--- a/js/src/vm/StringType.cpp
+++ b/js/src/vm/StringType.cpp
@@ -1904,17 +1904,18 @@ JSString::fillWithRepresentatives(JSCont
     MOZ_ASSERT(index == 22);
     return true;
 }
 
 
 /*** Conversions *********************************************************************************/
 
 const char*
-js::ValueToPrintable(JSContext* cx, const Value& vArg, JSAutoByteString* bytes, bool asSource)
+js::ValueToPrintableLatin1(JSContext* cx, const Value& vArg, JSAutoByteString* bytes,
+                           bool asSource)
 {
     RootedValue v(cx, vArg);
     JSString* str;
     if (asSource)
         str = ValueToSource(cx, v);
     else
         str = ToString<CanGC>(cx, v);
     if (!str)
--- a/js/src/vm/StringType.h
+++ b/js/src/vm/StringType.h
@@ -1583,19 +1583,25 @@ HasSubstringAt(JSLinearString* text, JSL
 JSString*
 SubstringKernel(JSContext* cx, HandleString str, int32_t beginInt, int32_t lengthInt);
 
 
 /*** Conversions *********************************************************************************/
 
 /*
  * Convert a value to a printable C string.
+ *
+ * As the function name implies, any characters in a converted printable string will be Latin1
+ * characters. If there are any non-Latin1 characters in the original value, then those characters
+ * will be changed to Unicode escape sequences(I.e. \udddd, dddd are 4 hex digits) in the printable
+ * string.
  */
 extern const char*
-ValueToPrintable(JSContext* cx, const Value&, JSAutoByteString* bytes, bool asSource = false);
+ValueToPrintableLatin1(JSContext* cx, const Value&, JSAutoByteString* bytes,
+                       bool asSource = false);
 
 /*
  * Convert a non-string value to a string, returning null after reporting an
  * error, otherwise returning a new string reference.
  */
 template <AllowGC allowGC>
 extern JSString*
 ToStringSlow(JSContext* cx, typename MaybeRooted<Value, allowGC>::HandleType arg);