Skip to content

Commit f088840

Browse files
expatdannoCommit Bot
authored andcommitted
[torque] Improve formatting in format-torque
Issues/problems addressed: - Fix line-wrapping and indenting for long declarations including strings, e.g. generates and constexpr clauses. - Implement proper formatting for typeswitch statements - Fix formatting of operator declarations - Fix formatting of constexpr if-clauses (the constexpr is now included on the same line as the if and it doesn't mess up the formatting that - Fix formatting of label declarations on callables, the "label" keyword now always starts a new line with indentation. - Remove space after identifier name in generic parameter declarations, e.g. "<a : T>" is now "<a: T>" which is consistent with type specification formatting elsewhere. - Indent "otherwise" clauses that have been pushed to the next line. Also ran the formatter over all existing .tq files. Bug: v8:7793 Change-Id: I5adbb2ffa3d573deed062f9a5c1da57348c8fc71 Reviewed-on: https://chromium-review.googlesource.com/1238580 Commit-Queue: Daniel Clifford <danno@chromium.org> Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#56158}
1 parent c0f871a commit f088840

12 files changed

Lines changed: 621 additions & 639 deletions

File tree

src/builtins/array-foreach.tq

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ module array {
7272
}
7373
}
7474

75-
macro VisitAllElements<FixedArrayType : type>(
75+
macro VisitAllElements<FixedArrayType: type>(
7676
context: Context, a: JSArray, len: Smi, callbackfn: Callable,
77-
thisArg: Object): void labels
78-
Bailout(Smi) {
77+
thisArg: Object): void
78+
labels Bailout(Smi) {
7979
let k: Smi = 0;
8080
const map: Map = a.map;
8181

@@ -108,8 +108,8 @@ module array {
108108

109109
macro FastArrayForEach(
110110
context: Context, o: JSReceiver, len: Number, callbackfn: Callable,
111-
thisArg: Object): Object labels
112-
Bailout(Smi) {
111+
thisArg: Object): Object
112+
labels Bailout(Smi) {
113113
let k: Smi = 0;
114114
try {
115115
const smiLen: Smi = Cast<Smi>(len) otherwise Slow;
@@ -123,10 +123,10 @@ module array {
123123
if (IsElementsKindGreaterThan(elementsKind, HOLEY_ELEMENTS)) {
124124
VisitAllElements<FixedDoubleArray>(
125125
context, a, smiLen, callbackfn, thisArg)
126-
otherwise Bailout;
126+
otherwise Bailout;
127127
} else {
128128
VisitAllElements<FixedArray>(context, a, smiLen, callbackfn, thisArg)
129-
otherwise Bailout;
129+
otherwise Bailout;
130130
}
131131
}
132132
label Slow deferred {
@@ -163,7 +163,7 @@ module array {
163163
let k: Number = 0;
164164
try {
165165
return FastArrayForEach(context, o, len, callbackfn, thisArg)
166-
otherwise Bailout;
166+
otherwise Bailout;
167167
}
168168
label Bailout(kValue: Smi) deferred {
169169
k = kValue;

src/builtins/array-lastindexof.tq

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,36 @@
33
// found in the LICENSE file.
44

55
module array {
6-
macro LoadWithHoleCheck<Elements : type>(
6+
macro LoadWithHoleCheck<Elements: type>(
77
elements: FixedArrayBase, index: Smi): Object
8-
labels IfHole;
8+
labels IfHole;
99

1010
LoadWithHoleCheck<FixedArray>(elements: FixedArrayBase, index: Smi): Object
11-
labels IfHole {
11+
labels IfHole {
1212
const elements: FixedArray = UnsafeCast<FixedArray>(elements);
1313
const element: Object = elements[index];
1414
if (element == Hole) goto IfHole;
1515
return element;
1616
}
1717

18-
LoadWithHoleCheck<FixedDoubleArray>(
19-
elements: FixedArrayBase, index: Smi): Object
20-
labels IfHole {
18+
LoadWithHoleCheck<FixedDoubleArray>(elements: FixedArrayBase, index: Smi):
19+
Object
20+
labels IfHole {
2121
const elements: FixedDoubleArray = UnsafeCast<FixedDoubleArray>(elements);
2222
const element: float64 = LoadDoubleWithHoleCheck(elements, index)
23-
otherwise IfHole;
23+
otherwise IfHole;
2424
return AllocateHeapNumberWithValue(element);
2525
}
2626

27-
macro FastArrayLastIndexOf<Elements : type>(
27+
macro FastArrayLastIndexOf<Elements: type>(
2828
context: Context, array: JSArray, length: Smi, from: Smi,
2929
searchElement: Object): Smi {
3030
const elements: FixedArrayBase = array.elements;
3131
let k: Smi = from;
3232
while (k >= 0) {
3333
try {
3434
const element: Object = LoadWithHoleCheck<Elements>(elements, k)
35-
otherwise Hole;
35+
otherwise Hole;
3636

3737
const same: Boolean = StrictEqual(searchElement, element);
3838
if (same == True) {
@@ -74,7 +74,7 @@ module array {
7474
macro TryFastArrayLastIndexOf(
7575
context: Context, receiver: JSReceiver, searchElement: Object,
7676
from: Number): Object
77-
labels Slow {
77+
labels Slow {
7878
EnsureFastJSArray(context, receiver) otherwise Slow;
7979
const array: JSArray = UnsafeCast<JSArray>(receiver);
8080

@@ -142,7 +142,7 @@ module array {
142142

143143
try {
144144
return TryFastArrayLastIndexOf(context, object, searchElement, from)
145-
otherwise Baseline;
145+
otherwise Baseline;
146146
}
147147
label Baseline {
148148
return GenericArrayLastIndexOf(context, object, searchElement, from);

src/builtins/array-reverse.tq

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// found in the LICENSE file.
44

55
module array {
6-
macro LoadElement<ElementsAccessor : type, T : type>(
6+
macro LoadElement<ElementsAccessor: type, T: type>(
77
elements: FixedArrayBase, index: Smi): T;
88

99
LoadElement<FastPackedSmiElements, Smi>(
@@ -31,7 +31,7 @@ module array {
3131
}
3232
}
3333

34-
macro StoreElement<ElementsAccessor : type, T : type>(
34+
macro StoreElement<ElementsAccessor: type, T: type>(
3535
elements: FixedArrayBase, index: Smi, value: T);
3636

3737
StoreElement<FastPackedSmiElements, Smi>(
@@ -57,7 +57,7 @@ module array {
5757
// Fast-path for all PACKED_* elements kinds. These do not need to check
5858
// whether a property is present, so we can simply swap them using fast
5959
// FixedArray loads/stores.
60-
macro FastPackedArrayReverse<Accessor : type, T : type>(
60+
macro FastPackedArrayReverse<Accessor: type, T: type>(
6161
elements: FixedArrayBase, length: Smi) {
6262
let lower: Smi = 0;
6363
let upper: Smi = length - 1;

src/builtins/array-splice.tq

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module array {
77
// FixedArrayType. Most of this behavior is outsourced to ExtractFixedArray(),
88
// but the special case of wanting to have a FixedDoubleArray when given a
99
// zero-length input FixedArray is handled here.
10-
macro Extract<FixedArrayType : type>(
10+
macro Extract<FixedArrayType: type>(
1111
elements: FixedArrayBase, first: Smi, count: Smi,
1212
capacity: Smi): FixedArrayType {
1313
return UnsafeCast<FixedArrayType>(
@@ -24,10 +24,11 @@ module array {
2424
ExtractFixedArray(elements, first, count, capacity));
2525
}
2626

27-
macro FastSplice<FixedArrayType : type, ElementType : type>(
27+
macro FastSplice<FixedArrayType: type, ElementType: type>(
2828
args: constexpr Arguments, a: JSArray, length: Smi, newLength: Smi,
2929
lengthDelta: Smi, actualStart: Smi, insertCount: Smi,
30-
actualDeleteCount: Smi): void labels Bailout {
30+
actualDeleteCount: Smi): void
31+
labels Bailout {
3132
const elements: FixedArrayBase = a.elements;
3233
const elementsMap: Map = elements.map;
3334

@@ -88,7 +89,7 @@ module array {
8889
context: Context, args: constexpr Arguments, o: JSReceiver,
8990
originalLengthNumber: Number, actualStartNumber: Number, insertCount: Smi,
9091
actualDeleteCountNumber: Number): Object
91-
labels Bailout {
92+
labels Bailout {
9293
const originalLength: Smi =
9394
Cast<Smi>(originalLengthNumber) otherwise Bailout;
9495
const actualStart: Smi = Cast<Smi>(actualStartNumber) otherwise Bailout;

src/builtins/array-unshift.tq

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ module array {
66
extern builtin ArrayUnshift(Context, JSFunction, Object, int32);
77

88
macro TryFastArrayUnshift(
9-
context: Context, receiver: Object, arguments: constexpr Arguments): never
10-
labels Slow {
9+
context: Context, receiver: Object, arguments: constexpr Arguments):
10+
never
11+
labels Slow {
1112
EnsureFastJSArray(context, receiver) otherwise Slow;
1213
const array: JSArray = UnsafeCast<JSArray>(receiver);
1314
EnsureWriteableFastElements(array);

src/builtins/array.tq

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ module array {
3535
assert(IsFastSmiOrTaggedElementsKind(array.map.elements_kind));
3636

3737
const length: Smi = array.length_fast;
38-
array.elements = ExtractFixedArray(
39-
elements, 0, length, length, kFixedArrays);
38+
array.elements =
39+
ExtractFixedArray(elements, 0, length, length, kFixedArrays);
4040
assert(array.elements.map != kCOWMap);
4141
}
4242

@@ -69,7 +69,7 @@ module array {
6969
to: Smi): void {
7070
try {
7171
const floatValue: float64 = LoadDoubleWithHoleCheck(elements, from)
72-
otherwise FoundHole;
72+
otherwise FoundHole;
7373
newElements[to] = floatValue;
7474
}
7575
label FoundHole {

0 commit comments

Comments
 (0)