v8/test/cctest
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
..
compiler [wasm] Remove test line from TestFPLinkageStubCall 2020-04-22 19:32:13 +00:00
heap [heap] Make retained maps list be per context 2020-04-20 11:12:37 +00:00
interpreter [class] improve error message of private brand checks 2020-03-31 14:06:27 +00:00
libplatform [tracing] Migrate tracing to Perfetto track events 2020-04-17 21:31:24 +00:00
libsampler [cpu-profiler] Only record SIGPROF-based samples for samplers that request samples 2019-02-13 09:29:38 +00:00
parsing Reland^5 "[parser] Introduce UnoptimizedCompileFlags" 2020-04-22 11:35:35 +00:00
torque [torque] generate int accessors for Smi fields 2020-03-18 09:24:08 +00:00
wasm [wasm-simd] Fix decoding of load splats 2020-04-22 23:58:38 +00:00
assembler-helper-arm.cc [cleanup] Drop some dead (Macro)Assembler code 2019-05-27 08:53:28 +00:00
assembler-helper-arm.h Move handles-related files to src/handles 2019-05-23 06:00:15 +00:00
BUILD.gn [wasm-gc] Add a basic test case for structs 2020-04-21 17:32:16 +00:00
cctest.cc [tracing] Migrate tracing to Perfetto track events 2020-04-17 21:31:24 +00:00
cctest.h [api] Create v8::String::NewFromLiteral that returns Local<String> 2020-03-09 12:02:07 +00:00
cctest.status [snapshot] Rename partial snapshot to context snapshot 2020-04-22 10:39:45 +00:00
collector.h Move remaining files in src/ 2019-05-24 18:24:36 +00:00
DEPS Reland "[tracing] Roll perfetto @ 28b633cd" 2019-09-06 13:42:02 +00:00
disasm-regex-helper.cc [turbofan] Improve load poisoning tests. 2019-07-02 17:55:04 +00:00
disasm-regex-helper.h [turbofan] Improve load poisoning tests. 2019-07-02 17:55:04 +00:00
expression-type-collector-macros.h [cleanup] Fix remaining (D)CHECK macro usages 2017-10-18 10:12:31 +00:00
gay-fixed.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
gay-fixed.h Move utility code to src/utils 2019-05-23 14:13:34 +00:00
gay-precision.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
gay-precision.h Move utility code to src/utils 2019-05-23 14:13:34 +00:00
gay-shortest.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
gay-shortest.h Move utility code to src/utils 2019-05-23 14:13:34 +00:00
manually-externalized-buffer.h [api] Deprecate [Shared]ArrayBuffer::Externalize/GetContents and constructors 2019-10-29 22:01:54 +00:00
OWNERS [owners] Remove redundant OWNERS files in test/ 2019-06-24 12:44:32 +00:00
print-extension.cc Use nullptr instead of NULL where possible 2017-10-13 17:21:49 +00:00
print-extension.h [cleanup] Mark test/ methods in subclasses with override. 2018-09-17 07:40:00 +00:00
profiler-extension.cc Reland "[Compile] Ensure we don't access the native context during bytecode finalization." 2018-10-26 22:33:56 +00:00
profiler-extension.h [cleanup] Mark test/ methods in subclasses with override. 2018-09-17 07:40:00 +00:00
scope-test-helper.h [parser] Various Scope and Context speedups 2019-01-28 13:06:03 +00:00
setup-isolate-for-tests.cc [interpreter] Always put bytecode handlers in builtins table 2018-09-20 09:58:15 +00:00
setup-isolate-for-tests.h Move initialization code into src/init 2019-05-16 12:36:15 +00:00
test-access-checks.cc Replace CHECK(false) by UNREACHABLE() 2017-12-19 18:58:07 +00:00
test-accessor-assembler.cc [cleanpup][ic] Tnodify accessor-assembler 2019-11-13 14:45:34 +00:00
test-accessors.cc [api] Create v8::String::NewFromLiteral that returns Local<String> 2020-03-09 12:02:07 +00:00
test-allocation.cc [utils] Fix Malloced implementation 2019-07-15 09:59:22 +00:00
test-api-accessors.cc [inspector] Add "disableBreaks" parameter to "Runtime.evaluate". 2019-09-27 12:16:01 +00:00
test-api-array-buffer.cc [api] Support v8::BackingStores with empty deleters 2020-03-17 08:10:24 +00:00
test-api-icu.cc Correct typo of Chinese locale zn_CN to zh_CN 2020-04-21 08:05:43 +00:00
test-api-interceptors.cc Rename and retype Symbol name to description 2019-10-30 10:38:55 +00:00
test-api-stack-traces.cc [api] Create v8::String::NewFromLiteral that returns Local<String> 2020-03-09 12:02:07 +00:00
test-api-typed-array.cc [api] Deprecate [Shared]ArrayBuffer::Externalize/GetContents and constructors 2019-10-29 22:01:54 +00:00
test-api-wasm.cc [wasm] Deprecate unused {DeserializeOrCompile} API 2020-01-22 08:46:23 +00:00
test-api.cc [builtins] Clean up the use of class_name / ES5 [[Class]] 2020-04-23 00:05:38 +00:00
test-api.h [test-api] Extract arraybufs and typed arrays 2019-06-17 15:27:01 +00:00
test-array-list.cc Move more relevant files to src/objects 2019-05-23 08:52:30 +00:00
test-assembler-arm64.cc [arm64] Use BTI instructions for forward CFI 2020-03-17 17:52:28 +00:00
test-assembler-arm.cc [wasm-simd] Fix unsigned narrow instructions 2019-11-19 18:51:09 +00:00
test-assembler-ia32.cc [cleanup] Replace function typedefs by using declarations 2019-05-28 08:35:08 +00:00
test-assembler-mips64.cc [mips][heap] Remove dynamic allocation flag on NewNumber functions 2019-09-17 14:07:59 +00:00
test-assembler-mips.cc [mips][heap] Remove dynamic allocation flag on NewNumber functions 2019-09-17 14:07:59 +00:00
test-assembler-ppc.cc Move architecture dependent files 2019-05-28 14:02:15 +00:00
test-assembler-s390.cc [s390]tm family test: change a label name 2019-07-22 20:05:10 +00:00
test-assembler-x64.cc [cleanup] Replace function typedefs by using declarations 2019-05-28 08:35:08 +00:00
test-atomicops.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-backing-store.cc Reland x6 [arraybuffer] Rearchitect backing store ownership 2019-09-09 13:07:42 +00:00
test-bignum-dtoa.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-bignum.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-bit-vector.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-circular-queue.cc Reland "[d8] Remove maximum workers limitation" 2019-07-30 07:56:17 +00:00
test-code-layout.cc Move more relevant files to src/objects 2019-05-23 08:52:30 +00:00
test-code-pages.cc heap: Avoid allocating a code range when running in jitless mode 2020-02-21 12:41:50 +00:00
test-code-stub-assembler.cc [wasm] Fix compilation error on GCC 2020-04-22 17:49:33 +00:00
test-compiler.cc [compiler] Ensure source positions collected when required 2019-11-28 20:14:37 +00:00
test-constantpool.cc [ppc64][ppc] Split up ARCH_PPC and ARCH_PPC64 2020-02-21 15:42:20 +00:00
test-conversions.cc [cleanup] Split out bit-field.h and bounds.h from utils/utils.h 2019-11-15 13:00:08 +00:00
test-cpu-profiler.cc [tracing] Migrate tracing to Perfetto track events 2020-04-17 21:31:24 +00:00
test-date.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-debug-helper.cc [tools] Fix v8windbg behavior on Map's bit_field2 2020-03-09 17:36:27 +00:00
test-debug.cc [class] implement inspector support for static private methods 2020-03-09 20:19:17 +00:00
test-decls.cc [api] Create v8::String::NewFromLiteral that returns Local<String> 2020-03-09 12:02:07 +00:00
test-deoptimization.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-dictionary.cc Update Dictionary classes to use InternalIndex 2019-10-16 13:11:55 +00:00
test-disasm-arm64.cc [arm64] Add support for BTI instruction 2020-02-03 15:21:59 +00:00
test-disasm-arm.cc [wasm-simd] Implement i64x2.mul on arm 2020-01-17 18:02:17 +00:00
test-disasm-ia32.cc [wasm-simd][ia32] Bitmask instructions 2020-04-03 16:41:44 +00:00
test-disasm-mips64.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-disasm-mips.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-disasm-ppc.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-disasm-s390.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-disasm-x64.cc [x64] Add some ops to disasm tests 2020-04-09 01:16:07 +00:00
test-diy-fp.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-double.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-dtoa.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-elements-kind.cc Add new nonextensible element kinds 2019-08-28 17:24:49 +00:00
test-factory.cc heap: Avoid allocating a code range when running in jitless mode 2020-02-21 12:41:50 +00:00
test-fast-dtoa.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-feedback-vector.cc [Turbofan] Allow CallIC to be polymorphic for same SharedFunctionInfos 2020-02-29 09:09:42 +00:00
test-feedback-vector.h Move more relevant files to src/objects 2019-05-23 08:52:30 +00:00
test-field-type-tracking.cc [offthread] OffThreadFactory support for literals 2020-02-06 16:49:04 +00:00
test-fixed-dtoa.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-flags.cc [regexp] Multiple interpreter executions tier-up 2019-09-09 15:43:42 +00:00
test-func-name-inference.cc [api] Create v8::String::NewFromLiteral that returns Local<String> 2020-03-09 12:02:07 +00:00
test-fuzz-arm64.cc Move architecture dependent files 2019-05-28 14:02:15 +00:00
test-global-handles.cc [heap] Report allocated size of global handles 2020-03-10 16:46:48 +00:00
test-global-object.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-hashcode.cc [ptr-compr] Pass Isolate to JSObject::NormalizeProperties() 2019-06-11 11:11:10 +00:00
test-hashmap.cc [cleanup] Replace function typedefs by using declarations 2019-05-28 08:35:08 +00:00
test-heap-profiler.cc [api] Create v8::String::NewFromLiteral that returns Local<String> 2020-03-09 12:02:07 +00:00
test-icache.cc [arm64] Use BTI instructions for forward CFI 2020-03-17 17:52:28 +00:00
test-identity-map.cc Move utility code to src/utils 2019-05-23 14:13:34 +00:00
test-inobject-slack-tracking.cc Use consistent capitalization rules for instance types 2019-10-09 17:44:42 +00:00
test-inspector.cc [inspector] Remove extra byte swapping on BE machines 2020-02-06 18:00:54 +00:00
test-intl.cc [lookup] Refactor LookupIterator "property or element" creation 2020-01-09 18:39:11 +00:00
test-javascript-arm64.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-js-arm64-variables.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-js-weak-refs.cc [weakrefs] Port FinalizationRegistry cleanup loop to Torque 2020-04-16 03:31:04 +00:00
test-liveedit.cc Add quotes around unexpected token SyntaxError 2019-06-11 06:11:58 +00:00
test-local-handles.cc [heap] Introduce LocalHandleScope for background threads 2020-03-25 10:23:33 +00:00
test-lockers.cc Replace base::make_unique by std::make_unique 2019-09-10 11:21:51 +00:00
test-log-stack-tracer.cc [cleanup] Remove unused TickSample class from the public API 2019-08-22 07:27:35 +00:00
test-log.cc s390: [arm] Add missing RELATIVE_CODE_TARGET iteration 2020-03-10 12:04:08 +00:00
test-macro-assembler-arm64.cc [ptr-compr][arm64] Use ldr_w to load on 32 bits for CompressedHeapConstants 2019-06-21 07:37:04 +00:00
test-macro-assembler-arm.cc [cleanup] Remove 'typedef struct' and 'typedef enum' 2019-05-28 12:17:35 +00:00
test-macro-assembler-mips64.cc [mips64][codegen] Remove dead argument to Assember::stop 2019-07-12 12:06:27 +00:00
test-macro-assembler-mips.cc [cleanup] Replace function typedefs by using declarations 2019-05-28 08:35:08 +00:00
test-macro-assembler-x64.cc Revert "[ptr-compr] Fix 32-bit smis on non-ptr-compr builds" 2020-02-27 11:22:12 +00:00
test-managed.cc Move more relevant files to src/objects 2019-05-23 08:52:30 +00:00
test-mementos.cc Move more relevant files to src/objects 2019-05-23 08:52:30 +00:00
test-modules.cc [runtime] Use TLA in more tests 2020-03-16 14:43:53 +00:00
test-object.cc Make ToInteger always truncate -0 2020-03-02 20:40:01 +00:00
test-orderedhashtable.cc [offthread] Deisolatify dictionaries 2020-03-03 20:08:54 +00:00
test-parsing.cc Reland^5 "[parser] Introduce UnoptimizedCompileFlags" 2020-04-22 11:35:35 +00:00
test-persistent-handles.cc [heap] Add PersistentHandles container 2020-04-06 07:37:34 +00:00
test-platform.cc s390: Edited Generate_CEntry to correctly return buffer when built with clang 2018-09-05 07:01:16 +00:00
test-pointer-auth-arm64.cc [arm64] Add support for pointer authentication instructions 2019-07-24 17:00:26 +00:00
test-poison-disasm-arm64.cc [arm64] Intentionally corrupt the upper half of decompressed SMIs 2019-11-19 12:14:12 +00:00
test-poison-disasm-arm.cc Reland "[TurboProp] Add MidTierMachineLoweringPhase to avoid Late/MemoryOptimizationPhases" 2019-09-26 16:39:15 +00:00
test-profile-generator.cc [cleanup] Eliminate non-const reference parameters 2019-09-10 09:31:07 +00:00
test-random-number-generator.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-regexp.cc [regexp] Consistent expectations for output registers 2020-04-21 10:13:03 +00:00
test-representation.cc Move relevant files to src/objects 2019-05-20 08:57:47 +00:00
test-roots.cc [heap] Make retained maps list be per context 2020-04-20 11:12:37 +00:00
test-sampler-api.cc Reland "[arm64] Protect return addresses stored on stack" 2020-02-13 12:26:25 +00:00
test-serialize.cc [snapshot] Rename partial snapshot to context snapshot 2020-04-22 10:39:45 +00:00
test-smi-lexicographic-compare.cc [cleanup] Eliminate non-const reference parameters 2019-09-10 09:31:07 +00:00
test-stack-unwinding-win64.cc Unwind V8 frames correctly on Windows ARM64 2019-07-31 06:24:45 +00:00
test-strings.cc [api] Create v8::String::NewFromLiteral that returns Local<String> 2020-03-09 12:02:07 +00:00
test-strtod.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-symbols.cc Move utility code to src/utils 2019-05-23 14:13:34 +00:00
test-sync-primitives-arm64.cc [arm64] Use BTI instructions for forward CFI 2020-03-17 17:52:28 +00:00
test-sync-primitives-arm.cc Reland "[d8] Remove maximum workers limitation" 2019-07-30 07:56:17 +00:00
test-thread-termination.cc [weakrefs] Call Isolate::ClearKeptObjects() as part of microtask checkpoint 2020-02-19 02:25:34 +00:00
test-threads.cc Replace base::make_unique by std::make_unique 2019-09-10 11:21:51 +00:00
test-trace-event.cc Replace base::make_unique by std::make_unique 2019-09-10 11:21:51 +00:00
test-traced-value.cc [tracing] Improve tracing signals for compilation/optimization. 2019-03-25 14:49:08 +00:00
test-transitions.cc [ptr-compr] Isolatify Map::MigrateToMap() and friends 2019-07-03 08:08:05 +00:00
test-transitions.h Move relevant files to src/objects 2019-05-20 08:57:47 +00:00
test-typedarrays.cc [api] Deprecate [Shared]ArrayBuffer::Externalize/GetContents and constructors 2019-10-29 22:01:54 +00:00
test-types.cc [turbofan] Normalize types for Oddball constants 2020-03-12 14:28:52 +00:00
test-unboxed-doubles.cc Update DescriptorArray and Map to use InternalIndex 2019-10-11 14:40:43 +00:00
test-unscopables-hidden-prototype.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-unwinder-code-pages.cc Reland "[arm64] Protect return addresses stored on stack" 2020-02-13 12:26:25 +00:00
test-unwinder.cc Reland "[arm64] Protect return addresses stored on stack" 2020-02-13 12:26:25 +00:00
test-usecounters.cc Adding counters for elements on Array.prototype and Object.prototype 2020-02-04 00:07:49 +00:00
test-utils-arm64.cc [arm64][cleanup] Remove CPURegister::Is and CPURegister::is 2019-11-14 12:58:09 +00:00
test-utils-arm64.h Move architecture dependent files 2019-05-28 14:02:15 +00:00
test-utils.cc [cleanup] Split out bit-field.h and bounds.h from utils/utils.h 2019-11-15 13:00:08 +00:00
test-v8windbg.cc [tools] Add v8windbg, a WinDbg extension for V8 2020-02-18 19:16:18 +00:00
test-version.cc Move remaining files in src/ 2019-05-24 18:24:36 +00:00
test-weakmaps.cc [heap] Add flag to promote young objects in MC 2019-10-17 13:38:21 +00:00
test-weaksets.cc [objects] rename kSize to kHeaderSize for JSObject subclasses 2019-11-18 15:17:52 +00:00
testcfg.py Reland "Preparing v8 to use with python3 /test" 2019-03-20 09:56:06 +00:00
trace-extension.cc [api] Create v8::String::NewFromLiteral that returns Local<String> 2020-03-09 12:02:07 +00:00
trace-extension.h [cleanup] Remove unused TickSample class from the public API 2019-08-22 07:27:35 +00:00
unicode-helpers.cc Move string-related files to src/strings 2019-05-21 07:17:48 +00:00
unicode-helpers.h Move string-related files to src/strings 2019-05-21 07:17:48 +00:00