• Benedikt Meurer's avatar
    [console] Proper type conversions in console builtins. · 099cb420
    Benedikt Meurer authored
    This updates the following set of console builtins in V8 to match the
    Console Standard (https://console.spec.whatwg.org) with respect to
    (potentially side effecting) type conversions:
    
      - console.debug
      - console.error
      - console.info
      - console.log
      - console.trace
      - console.warn
      - console.group
      - console.groupCollapsed
      - console.assert
    
    The V8 implementation only performs the type conversions and updates
    the arguments in-place with the results from the %String% constructor,
    %parseInt%, or %parseFloat% invocations. The actual formatting is
    still left completely to the debugger front-end.
    
    To give a concrete example, the following code
    
    ```js
    const msgFmt = {
      toString() { return 'Message %i' }
    };
    console.log('LOG: %s`, msgFmt, 42);
    ```
    
    sends the following parameters to the debugger front-end
    
    ```js
    ["LOG: %s", "Message %i", 42]
    ```
    
    and it's then the job of the front-end to perform the actual string
    substitutions.
    
    It's also worth calling out that the console builtins are only
    concerned with %s, %f, %d, and %i formatting specifiers, since
    these are the only ones that trigger type conversions, and %o, %O,
    and %c can only be implemented in a meaningful way at a higher
    level.
    
    Fixed: chromium:1277944
    Bug: chromium:1282076
    Doc: https://bit.ly/v8-proper-console-type-conversions
    Spec: https://console.spec.whatwg.org
    Change-Id: I0996680811aa96236bd0d879e4a11101629ef1a7
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3352118Reviewed-by: 's avatarKim-Anh Tran <kimanh@chromium.org>
    Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
    Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
    Commit-Queue: Igor Sheludko <ishell@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#78432}
    099cb420
Name
Last commit
Last update
.github Loading commit data...
bazel Loading commit data...
build_overrides Loading commit data...
custom_deps Loading commit data...
docs Loading commit data...
gni Loading commit data...
include Loading commit data...
infra Loading commit data...
samples Loading commit data...
src Loading commit data...
test Loading commit data...
testing Loading commit data...
third_party Loading commit data...
tools Loading commit data...
.bazelrc Loading commit data...
.clang-format Loading commit data...
.clang-tidy Loading commit data...
.editorconfig Loading commit data...
.flake8 Loading commit data...
.git-blame-ignore-revs Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.gn Loading commit data...
.mailmap Loading commit data...
.vpython Loading commit data...
.vpython3 Loading commit data...
.ycm_extra_conf.py Loading commit data...
AUTHORS Loading commit data...
BUILD.bazel Loading commit data...
BUILD.gn Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
COMMON_OWNERS Loading commit data...
DEPS Loading commit data...
DIR_METADATA Loading commit data...
ENG_REVIEW_OWNERS Loading commit data...
INFRA_OWNERS Loading commit data...
INTL_OWNERS Loading commit data...
LICENSE Loading commit data...
LICENSE.fdlibm Loading commit data...
LICENSE.strongtalk Loading commit data...
LICENSE.v8 Loading commit data...
LOONG_OWNERS Loading commit data...
MIPS_OWNERS Loading commit data...
OWNERS Loading commit data...
PPC_OWNERS Loading commit data...
PRESUBMIT.py Loading commit data...
README.md Loading commit data...
RISCV_OWNERS Loading commit data...
S390_OWNERS Loading commit data...
WATCHLISTS Loading commit data...
WORKSPACE Loading commit data...
codereview.settings Loading commit data...