Changeset 283293 in webkit
- Timestamp:
- Sep 29, 2021, 6:39:22 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
-
JSTests/ChakraCore/test/jsc-lib.js (modified) (1 diff)
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/exceptionFuzz/3d-cube.js (modified) (1 diff)
-
JSTests/exceptionFuzz/date-format-xparb.js (modified) (1 diff)
-
JSTests/exceptionFuzz/earley-boyer.js (modified) (1 diff)
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/resources/standalone-pre.js (modified) (1 diff)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/jsc.cpp (modified) (8 diffs)
-
Source/JavaScriptCore/runtime/JSCJSValue.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSCJSValue.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChakraCore/test/jsc-lib.js
r205387 r283293 1 print = legacyPrint; 2 1 3 WScript = { 2 4 _jscGC: gc, -
trunk/JSTests/ChangeLog
r283288 r283293 1 2021-09-29 Saam Barati <sbarati@apple.com> 2 3 Print values in a nicer way in the jsc shell 4 https://bugs.webkit.org/show_bug.cgi?id=230931 5 6 Reviewed by Tadeu Zagallo. 7 8 * ChakraCore/test/jsc-lib.js: 9 1 10 2021-09-29 Saam Barati <sbarati@apple.com> 2 11 -
trunk/JSTests/exceptionFuzz/3d-cube.js
r262383 r283293 359 359 })(); 360 360 } catch (e) { 361 print("JSC EXCEPTION FUZZ: Caught exception: " + e);362 } 361 legacyPrint("JSC EXCEPTION FUZZ: Caught exception: " + e); 362 } -
trunk/JSTests/exceptionFuzz/date-format-xparb.js
r262383 r283293 425 425 })(); 426 426 } catch (e) { 427 print("JSC EXCEPTION FUZZ: Caught exception: " + e);428 } 427 legacyPrint("JSC EXCEPTION FUZZ: Caught exception: " + e); 428 } -
trunk/JSTests/exceptionFuzz/earley-boyer.js
r262383 r283293 4685 4685 })(); 4686 4686 } catch (e) { 4687 print("JSC EXCEPTION FUZZ: Caught exception: " + e);4688 } 4689 4687 legacyPrint("JSC EXCEPTION FUZZ: Caught exception: " + e); 4688 } 4689 -
trunk/LayoutTests/ChangeLog
r283283 r283293 1 2021-09-29 Saam Barati <sbarati@apple.com> 2 3 Print values in a nicer way in the jsc shell 4 https://bugs.webkit.org/show_bug.cgi?id=230931 5 6 Reviewed by Tadeu Zagallo. 7 8 * resources/standalone-pre.js: 9 1 10 2021-09-29 Chris Dumez <cdumez@apple.com> 2 11 -
trunk/LayoutTests/resources/standalone-pre.js
r252196 r283293 13 13 didPassSomeTestsSilently = false; 14 14 didFailSomeTests = false; 15 16 print = legacyPrint; 15 17 16 18 function description(msg) -
trunk/Source/JavaScriptCore/ChangeLog
r283288 r283293 1 2021-09-29 Saam Barati <sbarati@apple.com> 2 3 Print values in a nicer way in the jsc shell 4 https://bugs.webkit.org/show_bug.cgi?id=230931 5 6 Reviewed by Tadeu Zagallo. 7 8 Currently, print(1), print("1"), and print([1]) all print to stdout 9 simply as "1" (without the quotes). Same for values when running the 10 REPL. This isn't super helpful. Let's print quotes for strings, and 11 brackets for arrays. 12 13 Some tests rely on the old print behavior. Those tests now use the legacyPrint 14 instead. 15 16 * jsc.cpp: 17 (toCString): 18 (printInternal): 19 (JSC_DEFINE_HOST_FUNCTION): 20 (runInteractive): 21 (cStringFromViewWithString): Deleted. 22 * runtime/JSCJSValue.cpp: 23 (JSC::JSValue::toWTFStringForConsole const): 24 * runtime/JSCJSValue.h: 25 1 26 2021-09-29 Saam Barati <sbarati@apple.com> 2 27 -
trunk/Source/JavaScriptCore/jsc.cpp
r283286 r283293 279 279 static JSC_DECLARE_HOST_FUNCTION(functionPrintStdOut); 280 280 static JSC_DECLARE_HOST_FUNCTION(functionPrintStdErr); 281 static JSC_DECLARE_HOST_FUNCTION(functionLegacyPrint); 281 282 static JSC_DECLARE_HOST_FUNCTION(functionDebug); 282 283 static JSC_DECLARE_HOST_FUNCTION(functionDescribe); … … 528 529 addFunction(vm, "print", functionPrintStdOut, 1); 529 530 addFunction(vm, "printErr", functionPrintStdErr, 1); 531 addFunction(vm, "legacyPrint", functionLegacyPrint, 1); 530 532 addFunction(vm, "quit", functionQuit, 0); 531 533 addFunction(vm, "gc", functionGCAndSweep, 0); … … 1239 1241 } 1240 1242 1241 static CString cStringFromViewWithString(JSGlobalObject* globalObject, ThrowScope& scope, StringViewWithUnderlyingString& viewWithString) 1242 { 1243 Expected<CString, UTF8ConversionError> expectedString = viewWithString.view.tryGetUtf8(); 1243 template <typename T> 1244 static CString toCString(JSGlobalObject* globalObject, ThrowScope& scope, T& string) 1245 { 1246 Expected<CString, UTF8ConversionError> expectedString = string.tryGetUtf8(); 1244 1247 if (expectedString) 1245 1248 return expectedString.value(); … … 1260 1263 } 1261 1264 1262 static EncodedJSValue printInternal(JSGlobalObject* globalObject, CallFrame* callFrame, FILE* out )1265 static EncodedJSValue printInternal(JSGlobalObject* globalObject, CallFrame* callFrame, FILE* out, bool legacy) 1263 1266 { 1264 1267 VM& vm = globalObject->vm(); … … 1278 1281 goto fail; 1279 1282 1280 auto* jsString = callFrame->uncheckedArgument(i).toString(globalObject);1283 String string = legacy ? callFrame->uncheckedArgument(i).toWTFString(globalObject) : callFrame->uncheckedArgument(i).toWTFStringForConsole(globalObject); 1281 1284 RETURN_IF_EXCEPTION(scope, { }); 1282 auto viewWithString = jsString->viewWithUnderlyingString(globalObject);1285 auto cString = toCString(globalObject, scope, string); 1283 1286 RETURN_IF_EXCEPTION(scope, { }); 1284 auto string = cStringFromViewWithString(globalObject, scope, viewWithString); 1285 RETURN_IF_EXCEPTION(scope, { }); 1286 fwrite(string.data(), sizeof(char), string.length(), out); 1287 fwrite(cString.data(), sizeof(char), cString.length(), out); 1287 1288 if (ferror(out)) 1288 1289 goto fail; … … 1297 1298 JSC_DEFINE_HOST_FUNCTION(functionPrintStdOut, (JSGlobalObject* globalObject, CallFrame* callFrame)) 1298 1299 { 1299 return printInternal(globalObject, callFrame, stdout );1300 return printInternal(globalObject, callFrame, stdout, false); 1300 1301 } 1301 1302 1302 1303 JSC_DEFINE_HOST_FUNCTION(functionPrintStdErr, (JSGlobalObject* globalObject, CallFrame* callFrame)) 1303 1304 { 1304 return printInternal(globalObject, callFrame, stderr); 1305 return printInternal(globalObject, callFrame, stderr, false); 1306 } 1307 1308 JSC_DEFINE_HOST_FUNCTION(functionLegacyPrint, (JSGlobalObject* globalObject, CallFrame* callFrame)) 1309 { 1310 return printInternal(globalObject, callFrame, stdout, true); 1305 1311 } 1306 1312 … … 1313 1319 auto viewWithString = jsString->viewWithUnderlyingString(globalObject); 1314 1320 RETURN_IF_EXCEPTION(scope, { }); 1315 auto string = cStringFromViewWithString(globalObject, scope, viewWithString);1321 auto string = toCString(globalObject, scope, viewWithString.view); 1316 1322 RETURN_IF_EXCEPTION(scope, { }); 1317 1323 fputs("--> ", stderr); … … 3272 3278 utf8 = evaluationException->value().toWTFString(globalObject).tryGetUtf8(); 3273 3279 } else 3274 utf8 = returnValue.toWTFString (globalObject).tryGetUtf8();3280 utf8 = returnValue.toWTFStringForConsole(globalObject).tryGetUtf8(); 3275 3281 3276 3282 CString result; -
trunk/Source/JavaScriptCore/runtime/JSCJSValue.cpp
r282664 r283293 472 472 #endif 473 473 474 WTF::String JSValue::toWTFStringForConsole(JSGlobalObject* globalObject) const 475 { 476 VM& vm = globalObject->vm(); 477 auto scope = DECLARE_THROW_SCOPE(vm); 478 JSString* string = toString(globalObject); 479 RETURN_IF_EXCEPTION(scope, { }); 480 String result = string->value(globalObject); 481 RETURN_IF_EXCEPTION(scope, { }); 482 if (isString()) 483 return makeString("\"", result, "\""); 484 if (jsDynamicCast<JSArray*>(vm, *this)) 485 return makeString("[", result, "]"); 486 return result; 487 } 488 474 489 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSCJSValue.h
r278253 r283293 290 290 JSValue toPropertyKeyValue(JSGlobalObject*) const; 291 291 WTF::String toWTFString(JSGlobalObject*) const; 292 JS_EXPORT_PRIVATE WTF::String toWTFStringForConsole(JSGlobalObject*) const; 292 293 JSObject* toObject(JSGlobalObject*) const; 293 294
Note:
See TracChangeset
for help on using the changeset viewer.