v8/test
Timothy Gu 29c1eab92e [builtins] Clean up the use of class_name / ES5 [[Class]]
Before ES2015, the ES spec had a [[Class]] internal slot for all
objects, which Object.prototype.toString() would use to figure the
returned string. Post-ES2015, the [[Class]] slot was removed in spec for
all objects, with the @@toStringTag well-known symbol the proper way to
change Object.prototype.toString() output.

At the time, spec-identical handling without the use of [[Class]] was
implemented in V8 for all objects other than API objects, where issues
with the Web IDL spec [1] prevented Blink, and hence V8, to totally
migrate to @@toStringTag. However, since 2016 [2] Blink has been setting
@@toStringTag on API class prototypes to manage the
Object.prototype.toString() output, so the legacy [[Class]] handling in
V8 has not been necessary for the past couple of years.

This CL removes the remaining legacy [[Class]] handling in
Object.prototype.toString(), JSReceiver::class_name(), and
GetConstructorName(). However, it does not remove the class_name field
in FunctionTemplateInfo, as it is still used for the `name` property of
created functions.

This CL also cleans up other places in the codebase that still reference
[[Class]].

This change should have minimal impact on web-compatibility. For the
change to be observable, a script must do one of the following:

1. delete APIConstructor.prototype[Symbol.toStringTag];
2. Object.setPrototypeOf(apiObject, somethingElse);

Before this CL, these changes will not change the apiObject.toString()
output. But after this CL, they will make apiObject.toString() show
"[object Object]" (in the first case) or the @@toStringTag of the other
prototype (in the latter case).

However, both are deemed unlikely. @@toStringTag is not well-known
feature of JavaScript, nor does it get tampered much on API
constructors. In the second case, setting the prototype of an API object
would effectly render the object useless, as all its methods (including
property getters/setters) would no longer be accessible.

Currently, @@toStringTag-based API object branding is not yet
implemented by other browsers. This V8 bug in particular has been an
impediment to standardizing toString behavior. Fixing this bug will
unblock [3] and lead to a better Web IDL spec, and better toString()
compatibility for all.

[1]: https://www.w3.org/Bugs/Public/show_bug.cgi?id=28244
[2]: https://crrev.com/909c0d7d5a53c8526ded351683c65ea7d17531d4
[3]: https://github.com/heycam/webidl/pull/357

Bug: chromium:793406
Cq-Include-Trybots: luci.chromium.try:linux-rel
Change-Id: Iceded24e37afa2646ec385d5018909f55b177f93
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2146996
Commit-Queue: Timothy Gu <timothygu@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67327}
2020-04-23 00:05:38 +00:00
..
benchmarks Create master files per benchmark in csuite 2020-02-26 10:37:33 +00:00
cctest [builtins] Clean up the use of class_name / ES5 [[Class]] 2020-04-23 00:05:38 +00:00
common [wasm-gc] Add a basic test case for structs 2020-04-21 17:32:16 +00:00
debugger [debug] Reenable tests in stress_incremental_marking 2020-04-16 16:31:27 +00:00
debugging Add initial support for Wasm debugging with LLDB: implements a GDB-remote stub 2020-02-20 22:27:58 +00:00
fuzzer Reland^5 "[parser] Introduce UnoptimizedCompileFlags" 2020-04-22 11:35:35 +00:00
inspector [inspector] guard against missing CommandLineAPIScope 2020-04-17 13:36:02 +00:00
intl Fix special case timezone RangeError 2020-04-15 18:19:00 +00:00
js-perf-test [cleanup][test] Fix typo in js-perf-test/Scope/with.js 2020-02-12 10:59:54 +00:00
memory [owners] Remove redundant OWNERS files in test/ 2019-06-24 12:44:32 +00:00
message [weakrefs] Port FinalizationRegistry cleanup loop to Torque 2020-04-16 03:31:04 +00:00
mjsunit [builtins] Clean up the use of class_name / ES5 [[Class]] 2020-04-23 00:05:38 +00:00
mkgrokdump [heap] Enable Verify for RO_SPACE when it is shared 2019-11-04 09:55:45 +00:00
mozilla Remove and update some outdated TODO(mstarzinger). 2019-12-13 10:18:04 +00:00
test262 [test262] Un-skip fixed test 2020-04-20 20:04:27 +00:00
torque [torque] support multiline comments 2020-04-07 13:32:16 +00:00
unittests [builtins] Clean up the use of class_name / ES5 [[Class]] 2020-04-23 00:05:38 +00:00
wasm-api-tests [wasm] Clean up WASM_CALL_INDIRECT macros 2019-11-28 14:44:06 +00:00
wasm-js [wasm] Remove remaining multi-value tests 2020-04-22 19:49:03 +00:00
wasm-spec-tests [wasm] Remove remaining multi-value tests 2020-04-22 19:49:03 +00:00
webkit [class] Improve error message for calling anonymous class constructors 2019-12-05 21:13:07 +00:00
BUILD.gn [preparser] deprecate stand-alone "preparser" test-suite 2019-11-20 08:52:59 +00:00
OWNERS Use relative paths to OWNERS files 2019-08-12 13:52:52 +00:00