Skip to content

Commit 03f6029

Browse files
tebbiCommit Bot
authored andcommitted
[torque] generate C++ class definitions per Torque file
This CL splits the class definitions per .tq file, to realize the following relationship: A class defined in src/objects/foo.tq has a C++ definition in src/objects/foo.h. Torque then generates: - torque-generated/src/objects/foo-tq.inc An include file (no proper header) to be included in src/objects/foo.h containing the Torque-generated C++ class definition. - torque-generated/src/objects/foo-tq-inl.inc An include file (no proper header) to be included in src/objects/foo-inl.h containing inline function definitions. - torque-generated/src/objects/foo-tq.cc A source file including src/objects/foo-inl.h that contains non-inline function definitions. Advantages of this approach: - Avoid big monolithic headers and preserve the work that went into splitting objects.h - Moving a definition to Torque keeps everything in the same place from a C++ viewpoint, including a fully Torque-generated C++ class definition. - The Torque-generated include files do not need to be independent headers, necessary includes or forward declarations can just be added to the headers that include them. Drive-by changes: A bunch of definitions and files had to be moved or created to realize a consistent 1:1 relationship between .tq files and C++ headers. Bug: v8:7793 TBR: hpayer@chromium.org Change-Id: I239a89a16d0bc856a8669d7c92aeafe24a7c7663 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2470571 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Nico Hartmann <nicohartmann@chromium.org> Reviewed-by: Seth Brenith <seth.brenith@microsoft.com> Cr-Commit-Position: refs/heads/master@{#70853}
1 parent a308d3f commit 03f6029

173 files changed

Lines changed: 1078 additions & 649 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎BUILD.gn‎

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,8 +1153,8 @@ torque_files = [
11531153
"src/builtins/array.tq",
11541154
"src/builtins/arraybuffer.tq",
11551155
"src/builtins/base.tq",
1156-
"src/builtins/bigint.tq",
11571156
"src/builtins/boolean.tq",
1157+
"src/builtins/builtins-bigint.tq",
11581158
"src/builtins/builtins-string.tq",
11591159
"src/builtins/cast.tq",
11601160
"src/builtins/collections.tq",
@@ -1249,6 +1249,7 @@ torque_files = [
12491249
"src/objects/allocation-site.tq",
12501250
"src/objects/api-callbacks.tq",
12511251
"src/objects/arguments.tq",
1252+
"src/objects/bigint.tq",
12521253
"src/objects/cell.tq",
12531254
"src/objects/code.tq",
12541255
"src/objects/contexts.tq",
@@ -1263,11 +1264,11 @@ torque_files = [
12631264
"src/objects/free-space.tq",
12641265
"src/objects/heap-number.tq",
12651266
"src/objects/heap-object.tq",
1266-
"src/objects/intl-objects.tq",
12671267
"src/objects/js-array-buffer.tq",
12681268
"src/objects/js-array.tq",
12691269
"src/objects/js-collection-iterator.tq",
12701270
"src/objects/js-collection.tq",
1271+
"src/objects/js-function.tq",
12711272
"src/objects/js-generator.tq",
12721273
"src/objects/js-objects.tq",
12731274
"src/objects/js-promise.tq",
@@ -1298,14 +1299,29 @@ torque_files = [
12981299
"src/objects/struct.tq",
12991300
"src/objects/synthetic-module.tq",
13001301
"src/objects/template-objects.tq",
1301-
"src/objects/template.tq",
1302+
"src/objects/templates.tq",
1303+
"src/objects/torque-defined-classes.tq",
13021304
"src/wasm/wasm-objects.tq",
13031305
"test/torque/test-torque.tq",
13041306
"third_party/v8/builtins/array-sort.tq",
13051307
]
13061308

1307-
if (!v8_enable_i18n_support) {
1308-
torque_files -= [ "src/objects/intl-objects.tq" ]
1309+
if (v8_enable_i18n_support) {
1310+
torque_files += [
1311+
"src/objects/intl-objects.tq",
1312+
"src/objects/js-break-iterator.tq",
1313+
"src/objects/js-collator.tq",
1314+
"src/objects/js-date-time-format.tq",
1315+
"src/objects/js-display-names.tq",
1316+
"src/objects/js-list-format.tq",
1317+
"src/objects/js-locale.tq",
1318+
"src/objects/js-number-format.tq",
1319+
"src/objects/js-plural-rules.tq",
1320+
"src/objects/js-relative-time-format.tq",
1321+
"src/objects/js-segment-iterator.tq",
1322+
"src/objects/js-segmenter.tq",
1323+
"src/objects/js-segments.tq",
1324+
]
13091325
}
13101326

13111327
# Template for running torque
@@ -1348,21 +1364,15 @@ template("run_torque") {
13481364
"$target_gen_dir/torque-generated/enum-verifiers.cc",
13491365
"$target_gen_dir/torque-generated/objects-printer.cc",
13501366
"$target_gen_dir/torque-generated/objects-body-descriptors-inl.inc",
1351-
"$target_gen_dir/torque-generated/class-definitions.cc",
1352-
"$target_gen_dir/torque-generated/class-definitions-inl.h",
1353-
"$target_gen_dir/torque-generated/class-definitions.h",
13541367
"$target_gen_dir/torque-generated/class-debug-readers.cc",
13551368
"$target_gen_dir/torque-generated/class-debug-readers.h",
13561369
"$target_gen_dir/torque-generated/exported-macros-assembler.cc",
13571370
"$target_gen_dir/torque-generated/exported-macros-assembler.h",
13581371
"$target_gen_dir/torque-generated/csa-types.h",
13591372
"$target_gen_dir/torque-generated/instance-types.h",
1360-
"$target_gen_dir/torque-generated/internal-class-definitions.h",
1361-
"$target_gen_dir/torque-generated/internal-class-definitions-inl.h",
1362-
"$target_gen_dir/torque-generated/exported-class-definitions.h",
1363-
"$target_gen_dir/torque-generated/exported-class-definitions-inl.h",
13641373
"$target_gen_dir/torque-generated/runtime-macros.cc",
13651374
"$target_gen_dir/torque-generated/runtime-macros.h",
1375+
"$target_gen_dir/torque-generated/class-forward-declarations.h",
13661376
]
13671377

13681378
outputs = []
@@ -1373,10 +1383,13 @@ template("run_torque") {
13731383
}
13741384

13751385
foreach(file, torque_files) {
1376-
filetq = string_replace(file, ".tq", "-tq-csa")
1386+
filetq = string_replace(file, ".tq", "-tq")
13771387
outputs += [
1378-
"$destination_folder/$filetq.cc",
1379-
"$destination_folder/$filetq.h",
1388+
"$target_gen_dir/torque-generated/$filetq-csa.cc",
1389+
"$target_gen_dir/torque-generated/$filetq-csa.h",
1390+
"$target_gen_dir/torque-generated/$filetq-inl.inc",
1391+
"$target_gen_dir/torque-generated/$filetq.cc",
1392+
"$target_gen_dir/torque-generated/$filetq.inc",
13801393
]
13811394
}
13821395

@@ -1452,10 +1465,10 @@ v8_source_set("torque_generated_initializers") {
14521465
"src/torque/runtime-support.h",
14531466
]
14541467
foreach(file, torque_files) {
1455-
filetq = string_replace(file, ".tq", "-tq-csa")
1468+
filetq = string_replace(file, ".tq", "-tq")
14561469
sources += [
1457-
"$target_gen_dir/torque-generated/$filetq.cc",
1458-
"$target_gen_dir/torque-generated/$filetq.h",
1470+
"$target_gen_dir/torque-generated/$filetq-csa.cc",
1471+
"$target_gen_dir/torque-generated/$filetq-csa.h",
14591472
]
14601473
}
14611474

@@ -1474,13 +1487,21 @@ v8_source_set("torque_generated_definitions") {
14741487
public_deps = [ ":v8_maybe_icu" ]
14751488

14761489
sources = [
1477-
"$target_gen_dir/torque-generated/class-definitions.cc",
1490+
"$target_gen_dir/torque-generated/class-forward-declarations.h",
14781491
"$target_gen_dir/torque-generated/class-verifiers.cc",
14791492
"$target_gen_dir/torque-generated/class-verifiers.h",
14801493
"$target_gen_dir/torque-generated/factory.cc",
14811494
"$target_gen_dir/torque-generated/objects-printer.cc",
14821495
"$target_gen_dir/torque-generated/runtime-macros.cc",
14831496
]
1497+
foreach(file, torque_files) {
1498+
filetq = string_replace(file, ".tq", "-tq")
1499+
sources += [
1500+
"$target_gen_dir/torque-generated/$filetq-inl.inc",
1501+
"$target_gen_dir/torque-generated/$filetq.cc",
1502+
"$target_gen_dir/torque-generated/$filetq.inc",
1503+
]
1504+
}
14841505

14851506
configs = [ ":internal_config" ]
14861507
}
@@ -2825,6 +2846,7 @@ v8_source_set("v8_base_without_compiler") {
28252846
"src/numbers/math-random.h",
28262847
"src/numbers/strtod.cc",
28272848
"src/numbers/strtod.h",
2849+
"src/objects/all-objects-inl.h",
28282850
"src/objects/allocation-site-inl.h",
28292851
"src/objects/allocation-site-scopes-inl.h",
28302852
"src/objects/allocation-site-scopes.h",
@@ -2835,6 +2857,7 @@ v8_source_set("v8_base_without_compiler") {
28352857
"src/objects/arguments.h",
28362858
"src/objects/backing-store.cc",
28372859
"src/objects/backing-store.h",
2860+
"src/objects/bigint-inl.h",
28382861
"src/objects/bigint.cc",
28392862
"src/objects/bigint.h",
28402863
"src/objects/cell-inl.h",
@@ -2851,6 +2874,7 @@ v8_source_set("v8_base_without_compiler") {
28512874
"src/objects/contexts-inl.h",
28522875
"src/objects/contexts.cc",
28532876
"src/objects/contexts.h",
2877+
"src/objects/data-handler-inl.h",
28542878
"src/objects/data-handler.h",
28552879
"src/objects/debug-objects-inl.h",
28562880
"src/objects/debug-objects.cc",
@@ -2880,8 +2904,12 @@ v8_source_set("v8_base_without_compiler") {
28802904
"src/objects/field-type.h",
28812905
"src/objects/fixed-array-inl.h",
28822906
"src/objects/fixed-array.h",
2907+
"src/objects/foreign-inl.h",
2908+
"src/objects/foreign.h",
28832909
"src/objects/frame-array-inl.h",
28842910
"src/objects/frame-array.h",
2911+
"src/objects/free-space-inl.h",
2912+
"src/objects/free-space.h",
28852913
"src/objects/function-kind.h",
28862914
"src/objects/hash-table-inl.h",
28872915
"src/objects/hash-table.h",
@@ -3049,6 +3077,7 @@ v8_source_set("v8_base_without_compiler") {
30493077
"src/objects/string.h",
30503078
"src/objects/struct-inl.h",
30513079
"src/objects/struct.h",
3080+
"src/objects/synthetic-module-inl.h",
30523081
"src/objects/synthetic-module.cc",
30533082
"src/objects/synthetic-module.h",
30543083
"src/objects/tagged-field-inl.h",
@@ -3064,6 +3093,8 @@ v8_source_set("v8_base_without_compiler") {
30643093
"src/objects/template-objects.h",
30653094
"src/objects/templates-inl.h",
30663095
"src/objects/templates.h",
3096+
"src/objects/torque-defined-classes-inl.h",
3097+
"src/objects/torque-defined-classes.h",
30673098
"src/objects/transitions-inl.h",
30683099
"src/objects/transitions.cc",
30693100
"src/objects/transitions.h",

‎src/api/api.cc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
#include "src/objects/slots.h"
8888
#include "src/objects/smi.h"
8989
#include "src/objects/stack-frame-info-inl.h"
90+
#include "src/objects/synthetic-module-inl.h"
9091
#include "src/objects/templates.h"
9192
#include "src/objects/value-serializer.h"
9293
#include "src/parsing/parse-info.h"
Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,6 @@
44

55
#include 'src/builtins/builtins-bigint-gen.h'
66

7-
// TODO(nicohartmann): Discuss whether types used by multiple builtins should be
8-
// in global namespace
9-
extern class BigIntBase extends PrimitiveHeapObject
10-
generates 'TNode<BigInt>' {}
11-
12-
type BigInt extends BigIntBase;
13-
14-
@noVerifier
15-
@hasSameInstanceTypeAsParent
16-
@doNotGenerateCast
17-
extern class MutableBigInt extends BigIntBase generates 'TNode<BigInt>' {
18-
}
19-
20-
Convert<BigInt, MutableBigInt>(i: MutableBigInt): BigInt {
21-
assert(bigint::IsCanonicalized(i));
22-
return %RawDownCast<BigInt>(Convert<BigIntBase>(i));
23-
}
24-
257
namespace bigint {
268

279
const kPositiveSign: uint32 = 0;

‎src/compiler/access-builder.cc‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "src/objects/objects-inl.h"
1818
#include "src/objects/ordered-hash-table.h"
1919
#include "src/objects/source-text-module.h"
20-
#include "torque-generated/exported-class-definitions.h"
2120

2221
namespace v8 {
2322
namespace internal {

‎src/compiler/allocation-builder-inl.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77

88
#include "src/compiler/access-builder.h"
99
#include "src/compiler/allocation-builder.h"
10+
#include "src/objects/arguments-inl.h"
1011
#include "src/objects/map-inl.h"
11-
#include "torque-generated/exported-class-definitions-inl.h"
12-
#include "torque-generated/exported-class-definitions.h"
1312

1413
namespace v8 {
1514
namespace internal {

‎src/compiler/js-create-lowering.cc‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "src/objects/js-regexp-inl.h"
2929
#include "src/objects/objects-inl.h"
3030
#include "src/objects/template-objects.h"
31-
#include "torque-generated/exported-class-definitions.h"
3231

3332
namespace v8 {
3433
namespace internal {

‎src/deoptimizer/deoptimizer.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
#include "src/interpreter/interpreter.h"
2424
#include "src/logging/counters.h"
2525
#include "src/logging/log.h"
26+
#include "src/objects/arguments.h"
2627
#include "src/objects/debug-objects-inl.h"
2728
#include "src/objects/heap-number-inl.h"
2829
#include "src/objects/smi.h"
2930
#include "src/snapshot/embedded/embedded-data.h"
3031
#include "src/tracing/trace-event.h"
31-
#include "torque-generated/exported-class-definitions.h"
3232

3333
// Has to be the last include (doesn't have include guards)
3434
#include "src/objects/object-macros.h"

‎src/diagnostics/basic-block-profiler.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include "src/base/lazy-instance.h"
1212
#include "src/heap/heap-inl.h"
13-
#include "torque-generated/exported-class-definitions-inl.h"
13+
#include "src/objects/shared-function-info-inl.h"
1414

1515
namespace v8 {
1616
namespace internal {

‎src/diagnostics/basic-block-profiler.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
#include "src/base/macros.h"
1515
#include "src/base/platform/mutex.h"
1616
#include "src/common/globals.h"
17-
#include "torque-generated/exported-class-definitions.h"
17+
#include "src/objects/shared-function-info.h"
1818

1919
namespace v8 {
2020
namespace internal {
2121

22+
class OnHeapBasicBlockProfilerData;
23+
2224
class BasicBlockProfilerData {
2325
public:
2426
explicit BasicBlockProfilerData(size_t n_blocks);

‎src/diagnostics/objects-debug.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@
6767
#include "src/objects/property-descriptor-object-inl.h"
6868
#include "src/objects/stack-frame-info-inl.h"
6969
#include "src/objects/struct-inl.h"
70+
#include "src/objects/synthetic-module-inl.h"
7071
#include "src/objects/template-objects-inl.h"
72+
#include "src/objects/torque-defined-classes-inl.h"
7173
#include "src/objects/transitions-inl.h"
7274
#include "src/regexp/regexp.h"
7375
#include "src/utils/ostreams.h"
7476
#include "src/wasm/wasm-objects-inl.h"
7577
#include "torque-generated/class-verifiers.h"
76-
#include "torque-generated/exported-class-definitions-inl.h"
77-
#include "torque-generated/internal-class-definitions-inl.h"
7878
#include "torque-generated/runtime-macros.h"
7979

8080
namespace v8 {

0 commit comments

Comments
 (0)