Log Message
Cherry-pick r283293. rdar://problem/83951351
Print values in a nicer way in the jsc shell
https://bugs.webkit.org/show_bug.cgi?id=230931
Reviewed by Tadeu Zagallo.
JSTests:
* ChakraCore/test/jsc-lib.js:
Source/_javascript_Core:
Currently, print(1), print("1"), and print([1]) all print to stdout
simply as "1" (without the quotes). Same for values when running the
REPL. This isn't super helpful. Let's print quotes for strings, and
brackets for arrays.
Some tests rely on the old print behavior. Those tests now use the legacyPrint
instead.
* jsc.cpp:
(toCString):
(printInternal):
(JSC_DEFINE_HOST_FUNCTION):
(runInteractive):
(cStringFromViewWithString): Deleted.
* runtime/JSCJSValue.cpp:
(JSC::JSValue::toWTFStringForConsole const):
* runtime/JSCJSValue.h:
LayoutTests:
* resources/standalone-pre.js:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283293 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
- branches/safari-613.1.4-branch/JSTests/ChakraCore/test/jsc-lib.js
- branches/safari-613.1.4-branch/JSTests/ChangeLog
- branches/safari-613.1.4-branch/JSTests/exceptionFuzz/3d-cube.js
- branches/safari-613.1.4-branch/JSTests/exceptionFuzz/date-format-xparb.js
- branches/safari-613.1.4-branch/JSTests/exceptionFuzz/earley-boyer.js
- branches/safari-613.1.4-branch/LayoutTests/ChangeLog
- branches/safari-613.1.4-branch/LayoutTests/resources/standalone-pre.js
- branches/safari-613.1.4-branch/Source/_javascript_Core/ChangeLog
- branches/safari-613.1.4-branch/Source/_javascript_Core/jsc.cpp
- branches/safari-613.1.4-branch/Source/_javascript_Core/runtime/JSCJSValue.cpp
- branches/safari-613.1.4-branch/Source/_javascript_Core/runtime/JSCJSValue.h
Diff
Modified: branches/safari-613.1.4-branch/JSTests/ChakraCore/test/jsc-lib.js (283662 => 283663)
--- branches/safari-613.1.4-branch/JSTests/ChakraCore/test/jsc-lib.js 2021-10-06 21:20:35 UTC (rev 283662)
+++ branches/safari-613.1.4-branch/JSTests/ChakraCore/test/jsc-lib.js 2021-10-06 21:23:54 UTC (rev 283663)
@@ -1,3 +1,5 @@
+print = legacyPrint;
+
WScript = {
_jscGC: gc,
_jscLoad: load,
Modified: branches/safari-613.1.4-branch/JSTests/ChangeLog (283662 => 283663)
--- branches/safari-613.1.4-branch/JSTests/ChangeLog 2021-10-06 21:20:35 UTC (rev 283662)
+++ branches/safari-613.1.4-branch/JSTests/ChangeLog 2021-10-06 21:23:54 UTC (rev 283663)
@@ -1,3 +1,52 @@
+2021-10-06 Alan Coon <[email protected]>
+
+ Cherry-pick r283293. rdar://problem/83951351
+
+ Print values in a nicer way in the jsc shell
+ https://bugs.webkit.org/show_bug.cgi?id=230931
+
+ Reviewed by Tadeu Zagallo.
+
+ JSTests:
+
+ * ChakraCore/test/jsc-lib.js:
+
+ Source/_javascript_Core:
+
+ Currently, print(1), print("1"), and print([1]) all print to stdout
+ simply as "1" (without the quotes). Same for values when running the
+ REPL. This isn't super helpful. Let's print quotes for strings, and
+ brackets for arrays.
+
+ Some tests rely on the old print behavior. Those tests now use the legacyPrint
+ instead.
+
+ * jsc.cpp:
+ (toCString):
+ (printInternal):
+ (JSC_DEFINE_HOST_FUNCTION):
+ (runInteractive):
+ (cStringFromViewWithString): Deleted.
+ * runtime/JSCJSValue.cpp:
+ (JSC::JSValue::toWTFStringForConsole const):
+ * runtime/JSCJSValue.h:
+
+ LayoutTests:
+
+ * resources/standalone-pre.js:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283293 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-09-29 Saam Barati <[email protected]>
+
+ Print values in a nicer way in the jsc shell
+ https://bugs.webkit.org/show_bug.cgi?id=230931
+
+ Reviewed by Tadeu Zagallo.
+
+ * ChakraCore/test/jsc-lib.js:
+
2021-10-02 Yusuke Suzuki <[email protected]>
[JSC] Update test262 config.yaml since OSS WebKit now uses ICU 64.2 header
Modified: branches/safari-613.1.4-branch/JSTests/exceptionFuzz/3d-cube.js (283662 => 283663)
--- branches/safari-613.1.4-branch/JSTests/exceptionFuzz/3d-cube.js 2021-10-06 21:20:35 UTC (rev 283662)
+++ branches/safari-613.1.4-branch/JSTests/exceptionFuzz/3d-cube.js 2021-10-06 21:23:54 UTC (rev 283663)
@@ -358,5 +358,5 @@
})();
} catch (e) {
- print("JSC EXCEPTION FUZZ: Caught exception: " + e);
+ legacyPrint("JSC EXCEPTION FUZZ: Caught exception: " + e);
}
Modified: branches/safari-613.1.4-branch/JSTests/exceptionFuzz/date-format-xparb.js (283662 => 283663)
--- branches/safari-613.1.4-branch/JSTests/exceptionFuzz/date-format-xparb.js 2021-10-06 21:20:35 UTC (rev 283662)
+++ branches/safari-613.1.4-branch/JSTests/exceptionFuzz/date-format-xparb.js 2021-10-06 21:23:54 UTC (rev 283663)
@@ -424,5 +424,5 @@
})();
} catch (e) {
- print("JSC EXCEPTION FUZZ: Caught exception: " + e);
+ legacyPrint("JSC EXCEPTION FUZZ: Caught exception: " + e);
}
Modified: branches/safari-613.1.4-branch/JSTests/exceptionFuzz/earley-boyer.js (283662 => 283663)
--- branches/safari-613.1.4-branch/JSTests/exceptionFuzz/earley-boyer.js 2021-10-06 21:20:35 UTC (rev 283662)
+++ branches/safari-613.1.4-branch/JSTests/exceptionFuzz/earley-boyer.js 2021-10-06 21:23:54 UTC (rev 283663)
@@ -4684,6 +4684,6 @@
}
})();
} catch (e) {
- print("JSC EXCEPTION FUZZ: Caught exception: " + e);
+ legacyPrint("JSC EXCEPTION FUZZ: Caught exception: " + e);
}
Modified: branches/safari-613.1.4-branch/LayoutTests/ChangeLog (283662 => 283663)
--- branches/safari-613.1.4-branch/LayoutTests/ChangeLog 2021-10-06 21:20:35 UTC (rev 283662)
+++ branches/safari-613.1.4-branch/LayoutTests/ChangeLog 2021-10-06 21:23:54 UTC (rev 283663)
@@ -1,3 +1,52 @@
+2021-10-06 Alan Coon <[email protected]>
+
+ Cherry-pick r283293. rdar://problem/83951351
+
+ Print values in a nicer way in the jsc shell
+ https://bugs.webkit.org/show_bug.cgi?id=230931
+
+ Reviewed by Tadeu Zagallo.
+
+ JSTests:
+
+ * ChakraCore/test/jsc-lib.js:
+
+ Source/_javascript_Core:
+
+ Currently, print(1), print("1"), and print([1]) all print to stdout
+ simply as "1" (without the quotes). Same for values when running the
+ REPL. This isn't super helpful. Let's print quotes for strings, and
+ brackets for arrays.
+
+ Some tests rely on the old print behavior. Those tests now use the legacyPrint
+ instead.
+
+ * jsc.cpp:
+ (toCString):
+ (printInternal):
+ (JSC_DEFINE_HOST_FUNCTION):
+ (runInteractive):
+ (cStringFromViewWithString): Deleted.
+ * runtime/JSCJSValue.cpp:
+ (JSC::JSValue::toWTFStringForConsole const):
+ * runtime/JSCJSValue.h:
+
+ LayoutTests:
+
+ * resources/standalone-pre.js:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283293 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-09-29 Saam Barati <[email protected]>
+
+ Print values in a nicer way in the jsc shell
+ https://bugs.webkit.org/show_bug.cgi?id=230931
+
+ Reviewed by Tadeu Zagallo.
+
+ * resources/standalone-pre.js:
+
2021-10-04 Ziran Sun <[email protected]>
[css-grid] Resync web-platform-tests/css/css-grid tests from upstream
Modified: branches/safari-613.1.4-branch/LayoutTests/resources/standalone-pre.js (283662 => 283663)
--- branches/safari-613.1.4-branch/LayoutTests/resources/standalone-pre.js 2021-10-06 21:20:35 UTC (rev 283662)
+++ branches/safari-613.1.4-branch/LayoutTests/resources/standalone-pre.js 2021-10-06 21:23:54 UTC (rev 283663)
@@ -13,6 +13,8 @@
didPassSomeTestsSilently = false;
didFailSomeTests = false;
+print = legacyPrint;
+
function description(msg)
{
print(msg);
Modified: branches/safari-613.1.4-branch/Source/_javascript_Core/ChangeLog (283662 => 283663)
--- branches/safari-613.1.4-branch/Source/_javascript_Core/ChangeLog 2021-10-06 21:20:35 UTC (rev 283662)
+++ branches/safari-613.1.4-branch/Source/_javascript_Core/ChangeLog 2021-10-06 21:23:54 UTC (rev 283663)
@@ -1,3 +1,68 @@
+2021-10-06 Alan Coon <[email protected]>
+
+ Cherry-pick r283293. rdar://problem/83951351
+
+ Print values in a nicer way in the jsc shell
+ https://bugs.webkit.org/show_bug.cgi?id=230931
+
+ Reviewed by Tadeu Zagallo.
+
+ JSTests:
+
+ * ChakraCore/test/jsc-lib.js:
+
+ Source/_javascript_Core:
+
+ Currently, print(1), print("1"), and print([1]) all print to stdout
+ simply as "1" (without the quotes). Same for values when running the
+ REPL. This isn't super helpful. Let's print quotes for strings, and
+ brackets for arrays.
+
+ Some tests rely on the old print behavior. Those tests now use the legacyPrint
+ instead.
+
+ * jsc.cpp:
+ (toCString):
+ (printInternal):
+ (JSC_DEFINE_HOST_FUNCTION):
+ (runInteractive):
+ (cStringFromViewWithString): Deleted.
+ * runtime/JSCJSValue.cpp:
+ (JSC::JSValue::toWTFStringForConsole const):
+ * runtime/JSCJSValue.h:
+
+ LayoutTests:
+
+ * resources/standalone-pre.js:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283293 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-09-29 Saam Barati <[email protected]>
+
+ Print values in a nicer way in the jsc shell
+ https://bugs.webkit.org/show_bug.cgi?id=230931
+
+ Reviewed by Tadeu Zagallo.
+
+ Currently, print(1), print("1"), and print([1]) all print to stdout
+ simply as "1" (without the quotes). Same for values when running the
+ REPL. This isn't super helpful. Let's print quotes for strings, and
+ brackets for arrays.
+
+ Some tests rely on the old print behavior. Those tests now use the legacyPrint
+ instead.
+
+ * jsc.cpp:
+ (toCString):
+ (printInternal):
+ (JSC_DEFINE_HOST_FUNCTION):
+ (runInteractive):
+ (cStringFromViewWithString): Deleted.
+ * runtime/JSCJSValue.cpp:
+ (JSC::JSValue::toWTFStringForConsole const):
+ * runtime/JSCJSValue.h:
+
2021-10-03 Don Olmstead <[email protected]>
Non-unified build fixes, early October 2021 edition
Modified: branches/safari-613.1.4-branch/Source/_javascript_Core/jsc.cpp (283662 => 283663)
--- branches/safari-613.1.4-branch/Source/_javascript_Core/jsc.cpp 2021-10-06 21:20:35 UTC (rev 283662)
+++ branches/safari-613.1.4-branch/Source/_javascript_Core/jsc.cpp 2021-10-06 21:23:54 UTC (rev 283663)
@@ -278,6 +278,7 @@
static JSC_DECLARE_HOST_FUNCTION(functionPrintStdOut);
static JSC_DECLARE_HOST_FUNCTION(functionPrintStdErr);
+static JSC_DECLARE_HOST_FUNCTION(functionLegacyPrint);
static JSC_DECLARE_HOST_FUNCTION(functionDebug);
static JSC_DECLARE_HOST_FUNCTION(functionDescribe);
static JSC_DECLARE_HOST_FUNCTION(functionDescribeArray);
@@ -527,6 +528,7 @@
addFunction(vm, "describeArray", functionDescribeArray, 1);
addFunction(vm, "print", functionPrintStdOut, 1);
addFunction(vm, "printErr", functionPrintStdErr, 1);
+ addFunction(vm, "legacyPrint", functionLegacyPrint, 1);
addFunction(vm, "quit", functionQuit, 0);
addFunction(vm, "gc", functionGCAndSweep, 0);
addFunction(vm, "fullGC", functionFullGC, 0);
@@ -1238,9 +1240,10 @@
return metaProperties;
}
-static CString cStringFromViewWithString(JSGlobalObject* globalObject, ThrowScope& scope, StringViewWithUnderlyingString& viewWithString)
+template <typename T>
+static CString toCString(JSGlobalObject* globalObject, ThrowScope& scope, T& string)
{
- Expected<CString, UTF8ConversionError> expectedString = viewWithString.view.tryGetUtf8();
+ Expected<CString, UTF8ConversionError> expectedString = string.tryGetUtf8();
if (expectedString)
return expectedString.value();
switch (expectedString.error()) {
@@ -1259,7 +1262,7 @@
return { };
}
-static EncodedJSValue printInternal(JSGlobalObject* globalObject, CallFrame* callFrame, FILE* out)
+static EncodedJSValue printInternal(JSGlobalObject* globalObject, CallFrame* callFrame, FILE* out, bool legacy)
{
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
@@ -1277,13 +1280,11 @@
if (EOF == fputc(' ', out))
goto fail;
- auto* jsString = callFrame->uncheckedArgument(i).toString(globalObject);
+ String string = legacy ? callFrame->uncheckedArgument(i).toWTFString(globalObject) : callFrame->uncheckedArgument(i).toWTFStringForConsole(globalObject);
RETURN_IF_EXCEPTION(scope, { });
- auto viewWithString = jsString->viewWithUnderlyingString(globalObject);
+ auto cString = toCString(globalObject, scope, string);
RETURN_IF_EXCEPTION(scope, { });
- auto string = cStringFromViewWithString(globalObject, scope, viewWithString);
- RETURN_IF_EXCEPTION(scope, { });
- fwrite(string.data(), sizeof(char), string.length(), out);
+ fwrite(cString.data(), sizeof(char), cString.length(), out);
if (ferror(out))
goto fail;
}
@@ -1296,14 +1297,19 @@
JSC_DEFINE_HOST_FUNCTION(functionPrintStdOut, (JSGlobalObject* globalObject, CallFrame* callFrame))
{
- return printInternal(globalObject, callFrame, stdout);
+ return printInternal(globalObject, callFrame, stdout, false);
}
JSC_DEFINE_HOST_FUNCTION(functionPrintStdErr, (JSGlobalObject* globalObject, CallFrame* callFrame))
{
- return printInternal(globalObject, callFrame, stderr);
+ return printInternal(globalObject, callFrame, stderr, false);
}
+JSC_DEFINE_HOST_FUNCTION(functionLegacyPrint, (JSGlobalObject* globalObject, CallFrame* callFrame))
+{
+ return printInternal(globalObject, callFrame, stdout, true);
+}
+
JSC_DEFINE_HOST_FUNCTION(functionDebug, (JSGlobalObject* globalObject, CallFrame* callFrame))
{
VM& vm = globalObject->vm();
@@ -1312,7 +1318,7 @@
RETURN_IF_EXCEPTION(scope, { });
auto viewWithString = jsString->viewWithUnderlyingString(globalObject);
RETURN_IF_EXCEPTION(scope, { });
- auto string = cStringFromViewWithString(globalObject, scope, viewWithString);
+ auto string = toCString(globalObject, scope, viewWithString.view);
RETURN_IF_EXCEPTION(scope, { });
fputs("--> ", stderr);
fwrite(string.data(), sizeof(char), string.length(), stderr);
@@ -3271,7 +3277,7 @@
fputs("Exception: ", stdout);
utf8 = evaluationException->value().toWTFString(globalObject).tryGetUtf8();
} else
- utf8 = returnValue.toWTFString(globalObject).tryGetUtf8();
+ utf8 = returnValue.toWTFStringForConsole(globalObject).tryGetUtf8();
CString result;
if (utf8)
Modified: branches/safari-613.1.4-branch/Source/_javascript_Core/runtime/JSCJSValue.cpp (283662 => 283663)
--- branches/safari-613.1.4-branch/Source/_javascript_Core/runtime/JSCJSValue.cpp 2021-10-06 21:20:35 UTC (rev 283662)
+++ branches/safari-613.1.4-branch/Source/_javascript_Core/runtime/JSCJSValue.cpp 2021-10-06 21:23:54 UTC (rev 283663)
@@ -471,4 +471,19 @@
}
#endif
+WTF::String JSValue::toWTFStringForConsole(JSGlobalObject* globalObject) const
+{
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ JSString* string = toString(globalObject);
+ RETURN_IF_EXCEPTION(scope, { });
+ String result = string->value(globalObject);
+ RETURN_IF_EXCEPTION(scope, { });
+ if (isString())
+ return makeString("\"", result, "\"");
+ if (jsDynamicCast<JSArray*>(vm, *this))
+ return makeString("[", result, "]");
+ return result;
+}
+
} // namespace JSC
Modified: branches/safari-613.1.4-branch/Source/_javascript_Core/runtime/JSCJSValue.h (283662 => 283663)
--- branches/safari-613.1.4-branch/Source/_javascript_Core/runtime/JSCJSValue.h 2021-10-06 21:20:35 UTC (rev 283662)
+++ branches/safari-613.1.4-branch/Source/_javascript_Core/runtime/JSCJSValue.h 2021-10-06 21:23:54 UTC (rev 283663)
@@ -289,6 +289,7 @@
Identifier toPropertyKey(JSGlobalObject*) const;
JSValue toPropertyKeyValue(JSGlobalObject*) const;
WTF::String toWTFString(JSGlobalObject*) const;
+ JS_EXPORT_PRIVATE WTF::String toWTFStringForConsole(JSGlobalObject*) const;
JSObject* toObject(JSGlobalObject*) const;
// Integer conversions.
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
