Commit 25f0e329 authored by Seth Brenith's avatar Seth Brenith Committed by V8 LUCI CQ

[torque] Make return types required

Currently, it is possible to declare macros, builtins, etc., without
specifying a return type, in which case the return type is treated as
void. This is confusing; the code is more clear if we require the return
type to be specified.

Aside from src/torque, this change is almost entirely just adding
`: void` until the compiler is happy. However, two intrinsics in
src/builtins/torque-internal.tq have been corrected to declare an
appropriate return type. Those two intrinsics were only used in code
generated within the compiler after the type-checking phase, so we never
noticed that their return types were declared incorrectly.

Bug: v8:7793
Change-Id: Ib7df88678c25393a9e3eba389a6a1c4d9233dcbb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3176502
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77178}
parent c9f69db9
......@@ -97,7 +97,7 @@ transitioning builtin ArrayFilterLoopContinuation(implicit context: Context)(
transitioning macro FastArrayFilter(implicit context: Context)(
fastO: FastJSArray, len: Smi, callbackfn: Callable, thisArg: JSAny,
output: FastJSArray) labels
output: FastJSArray): void labels
Bailout(Number, Number) {
let k: Smi = 0;
let to: Smi = 0;
......
......@@ -147,7 +147,7 @@ macro StoreAndGrowFixedArray<T: type>(
// Buffer.AddSeparators().
struct Buffer {
macro Add(implicit context: Context)(
str: String, nofSeparators: intptr, separatorLength: intptr) {
str: String, nofSeparators: intptr, separatorLength: intptr): void {
// Add separators if necessary (at the beginning or more than one)
const writeSeparators: bool = this.index == 0 | nofSeparators > 1;
this.AddSeparators(nofSeparators, separatorLength, writeSeparators);
......@@ -161,7 +161,7 @@ struct Buffer {
}
macro AddSeparators(implicit context: Context)(
nofSeparators: intptr, separatorLength: intptr, write: bool) {
nofSeparators: intptr, separatorLength: intptr, write: bool): void {
if (nofSeparators == 0 || separatorLength == 0) return;
const nofSeparatorsInt: intptr = nofSeparators;
......@@ -504,7 +504,8 @@ builtin JoinStackPop(implicit context: Context)(
}
// Fast path the common non-nested calls.
macro JoinStackPopInline(implicit context: Context)(receiver: JSReceiver) {
macro JoinStackPopInline(implicit context: Context)(receiver: JSReceiver):
void {
const stack: FixedArray = LoadJoinStack()
otherwise unreachable;
const len: intptr = stack.length_intptr;
......
......@@ -97,7 +97,7 @@ transitioning builtin ArrayMapLoopContinuation(implicit context: Context)(
}
struct Vector {
macro ReportSkippedElement() {
macro ReportSkippedElement(): void {
this.skippedElements = true;
}
......@@ -153,7 +153,8 @@ struct Vector {
return a;
}
macro StoreResult(implicit context: Context)(index: Smi, result: JSAny) {
macro StoreResult(implicit context: Context)(
index: Smi, result: JSAny): void {
typeswitch (result) {
case (s: Smi): {
this.fixedArray.objects[index] = s;
......
......@@ -27,23 +27,24 @@ LoadElement<array::FastPackedDoubleElements, float64>(
}
macro StoreElement<ElementsAccessor : type extends ElementsKind, T: type>(
implicit context: Context)(elements: FixedArrayBase, index: Smi, value: T);
implicit context: Context)(
elements: FixedArrayBase, index: Smi, value: T): void;
StoreElement<array::FastPackedSmiElements, Smi>(implicit context: Context)(
elements: FixedArrayBase, index: Smi, value: Smi) {
elements: FixedArrayBase, index: Smi, value: Smi): void {
const elems: FixedArray = UnsafeCast<FixedArray>(elements);
StoreFixedArrayElement(elems, index, value);
}
StoreElement<array::FastPackedObjectElements, JSAny>(implicit context: Context)(
elements: FixedArrayBase, index: Smi, value: JSAny) {
elements: FixedArrayBase, index: Smi, value: JSAny): void {
const elements: FixedArray = UnsafeCast<FixedArray>(elements);
elements.objects[index] = value;
}
StoreElement<array::FastPackedDoubleElements, float64>(
implicit context: Context)(
elements: FixedArrayBase, index: Smi, value: float64) {
elements: FixedArrayBase, index: Smi, value: float64): void {
const elems: FixedDoubleArray = UnsafeCast<FixedDoubleArray>(elements);
StoreFixedDoubleArrayElement(elems, index, value);
}
......@@ -52,7 +53,7 @@ StoreElement<array::FastPackedDoubleElements, float64>(
// whether a property is present, so we can simply swap them using fast
// FixedArray loads/stores.
macro FastPackedArrayReverse<Accessor: type, T: type>(
implicit context: Context)(elements: FixedArrayBase, length: Smi) {
implicit context: Context)(elements: FixedArrayBase, length: Smi): void {
let lower: Smi = 0;
let upper: Smi = length - 1;
......@@ -138,8 +139,8 @@ transitioning macro GenericArrayReverse(
return object;
}
macro TryFastPackedArrayReverse(implicit context: Context)(receiver: JSAny)
labels Slow {
macro TryFastPackedArrayReverse(implicit context: Context)(receiver: JSAny):
void labels Slow {
const array: FastJSArray = Cast<FastJSArray>(receiver) otherwise Slow;
const kind: ElementsKind = array.map.elements_kind;
......
......@@ -16,7 +16,8 @@ type FastSmiOrObjectElements extends ElementsKind;
type FastDoubleElements extends ElementsKind;
type DictionaryElements extends ElementsKind;
macro EnsureWriteableFastElements(implicit context: Context)(array: JSArray) {
macro EnsureWriteableFastElements(implicit context: Context)(array: JSArray):
void {
dcheck(IsFastElementsKind(array.map.elements_kind));
const elements: FixedArrayBase = array.elements;
......@@ -51,7 +52,7 @@ macro StoreArrayHole(elements: FixedArray, k: Smi): void {
elements.objects[k] = TheHole;
}
extern macro SetPropertyLength(implicit context: Context)(JSAny, Number);
extern macro SetPropertyLength(implicit context: Context)(JSAny, Number): void;
const kLengthDescriptorIndex:
constexpr int31 generates 'JSArray::kLengthDescriptorIndex';
......
......@@ -576,11 +576,11 @@ extern macro Is64(): constexpr bool;
extern macro SelectBooleanConstant(bool): Boolean;
extern macro Print(constexpr string);
extern macro Print(constexpr string, Object);
extern macro Comment(constexpr string);
extern macro Print(Object);
extern macro DebugBreak();
extern macro Print(constexpr string): void;
extern macro Print(constexpr string, Object): void;
extern macro Comment(constexpr string): void;
extern macro Print(Object): void;
extern macro DebugBreak(): void;
// ES6 7.1.4 ToInteger ( argument )
transitioning macro ToIntegerImpl(implicit context: Context)(input: JSAny):
......@@ -739,9 +739,9 @@ transitioning macro ToPrimitiveDefault(implicit context: Context)(v: JSAny):
}
}
extern transitioning runtime NormalizeElements(Context, JSObject);
extern transitioning runtime NormalizeElements(Context, JSObject): void;
extern transitioning runtime TransitionElementsKindWithKind(
Context, JSObject, Smi);
Context, JSObject, Smi): void;
extern macro LoadBufferObject(RawPtr, constexpr int32): Object;
extern macro LoadBufferPointer(RawPtr, constexpr int32): RawPtr;
......@@ -1226,7 +1226,7 @@ extern operator '.elements_kind' macro LoadElementsKind(JSTypedArray):
extern operator '.length' macro LoadFastJSArrayLength(FastJSArray): Smi;
operator '.length=' macro StoreFastJSArrayLength(
array: FastJSArray, length: Smi) {
array: FastJSArray, length: Smi): void {
const array: JSArray = array;
array.length = length;
}
......@@ -1360,7 +1360,7 @@ macro NumberIsNaN(number: Number): bool {
}
}
extern macro GotoIfForceSlowPath() labels Taken;
extern macro GotoIfForceSlowPath(): void labels Taken;
macro IsForceSlowPath(): bool {
GotoIfForceSlowPath() otherwise return true;
return false;
......@@ -1392,7 +1392,7 @@ macro SameValue(a: JSAny, b: JSAny): bool {
// Does "if (index1 + index2 > limit) goto IfOverflow" in an uintptr overflow
// friendly way where index1 and index2 are in [0, kMaxSafeInteger] range.
macro CheckIntegerIndexAdditionOverflow(
index1: uintptr, index2: uintptr, limit: uintptr) labels IfOverflow {
index1: uintptr, index2: uintptr, limit: uintptr): void labels IfOverflow {
if constexpr (Is64()) {
dcheck(index1 <= kMaxSafeIntegerUint64);
dcheck(index2 <= kMaxSafeIntegerUint64);
......@@ -1711,10 +1711,10 @@ macro IsFastJSArrayForReadWithNoCustomIteration(context: Context, o: Object):
}
extern transitioning runtime
CreateDataProperty(implicit context: Context)(JSReceiver, JSAny, JSAny);
CreateDataProperty(implicit context: Context)(JSReceiver, JSAny, JSAny): void;
extern transitioning runtime SetOwnPropertyIgnoreAttributes(
implicit context: Context)(JSObject, String, JSAny, Smi);
implicit context: Context)(JSObject, String, JSAny, Smi): void;
namespace runtime {
extern runtime
......
......@@ -514,13 +514,14 @@ extern macro TruncateFloat64ToWord32(float64): uint32;
extern macro DataViewBuiltinsAssembler::StoreWord8(
RawPtr, uintptr, uint32): void;
macro StoreDataView8(buffer: JSArrayBuffer, offset: uintptr, value: uint32) {
macro StoreDataView8(
buffer: JSArrayBuffer, offset: uintptr, value: uint32): void {
StoreWord8(buffer.backing_store_ptr, offset, value & 0xFF);
}
macro StoreDataView16(
buffer: JSArrayBuffer, offset: uintptr, value: uint32,
requestedLittleEndian: bool) {
requestedLittleEndian: bool): void {
const dataPointer: RawPtr = buffer.backing_store_ptr;
const b0: uint32 = value & 0xFF;
......@@ -537,7 +538,7 @@ macro StoreDataView16(
macro StoreDataView32(
buffer: JSArrayBuffer, offset: uintptr, value: uint32,
requestedLittleEndian: bool) {
requestedLittleEndian: bool): void {
const dataPointer: RawPtr = buffer.backing_store_ptr;
const b0: uint32 = value & 0xFF;
......@@ -560,7 +561,7 @@ macro StoreDataView32(
macro StoreDataView64(
buffer: JSArrayBuffer, offset: uintptr, lowWord: uint32, highWord: uint32,
requestedLittleEndian: bool) {
requestedLittleEndian: bool): void {
const dataPointer: RawPtr = buffer.backing_store_ptr;
const b0: uint32 = lowWord & 0xFF;
......@@ -604,7 +605,7 @@ extern macro DataViewBuiltinsAssembler::DataViewDecodeBigIntSign(BigIntBase):
// on 64-bit platforms, and the 2 lowest BigInt digits on 32-bit ones.
macro StoreDataViewBigInt(
buffer: JSArrayBuffer, offset: uintptr, bigIntValue: BigInt,
requestedLittleEndian: bool) {
requestedLittleEndian: bool): void {
const length: uint32 = DataViewDecodeBigIntLength(bigIntValue);
const sign: uint32 = DataViewDecodeBigIntSign(bigIntValue);
......
......@@ -55,7 +55,7 @@ PopClearedCell(finalizationRegistry: JSFinalizationRegistry): WeakCell|
}
transitioning macro PushCell(
finalizationRegistry: JSFinalizationRegistry, cell: WeakCell) {
finalizationRegistry: JSFinalizationRegistry, cell: WeakCell): void {
cell.next = finalizationRegistry.active_cells;
typeswitch (finalizationRegistry.active_cells) {
case (Undefined): {
......@@ -69,7 +69,7 @@ transitioning macro PushCell(
transitioning macro
FinalizationRegistryCleanupLoop(implicit context: Context)(
finalizationRegistry: JSFinalizationRegistry, callback: Callable) {
finalizationRegistry: JSFinalizationRegistry, callback: Callable): void {
while (true) {
const weakCellHead = PopClearedCell(finalizationRegistry);
typeswitch (weakCellHead) {
......
......@@ -24,7 +24,8 @@ const kMinDescriptorsForFastBind:
constexpr int31 generates 'JSFunction::kMinDescriptorsForFastBind';
macro CheckAccessor(implicit context: Context)(
array: DescriptorArray, index: constexpr int32, name: Name) labels Slow {
array: DescriptorArray, index: constexpr int32,
name: Name): void labels Slow {
const descriptor: DescriptorEntry = array.descriptors[index];
const key: Name|Undefined = descriptor.key;
if (!TaggedEqual(key, name)) goto Slow;
......
......@@ -5,7 +5,7 @@
namespace growable_fixed_array {
// TODO(pwong): Support FixedTypedArrays.
struct GrowableFixedArray {
macro Push(obj: Object) {
macro Push(obj: Object): void {
this.EnsureCapacity();
this.array.objects[this.length++] = obj;
}
......@@ -16,7 +16,7 @@ struct GrowableFixedArray {
const first: intptr = 0;
return ExtractFixedArray(this.array, first, this.length, newCapacity);
}
macro EnsureCapacity() {
macro EnsureCapacity(): void {
dcheck(this.length <= this.capacity);
if (this.capacity == this.length) {
// Growth rate is analog to JSObject::NewElementsCapacity:
......
......@@ -62,7 +62,8 @@ extern macro StoreFeedbackVectorSlot(
constexpr int32): void;
extern macro StoreWeakReferenceInFeedbackVector(
FeedbackVector, uintptr, HeapObject): MaybeObject;
extern macro ReportFeedbackUpdate(FeedbackVector, uintptr, constexpr string);
extern macro ReportFeedbackUpdate(
FeedbackVector, uintptr, constexpr string): void;
extern operator '.length_intptr' macro LoadFeedbackVectorLength(FeedbackVector):
intptr;
......
......@@ -17,7 +17,7 @@ macro GetCoverageInfo(implicit context: Context)(function: JSFunction):
}
macro IncrementBlockCount(implicit context: Context)(
coverageInfo: CoverageInfo, slot: Smi) {
coverageInfo: CoverageInfo, slot: Smi): void {
dcheck(Convert<int32>(slot) < coverageInfo.slot_count);
++coverageInfo.slots[slot].block_count;
}
......
......@@ -52,7 +52,7 @@ extern transitioning builtin ForInFilter(implicit context: Context)(
extern enum ForInFeedback extends uint31 { kAny, ...}
extern macro UpdateFeedback(
SmiTagged<ForInFeedback>, Undefined | FeedbackVector, uintptr,
constexpr UpdateFeedbackMode);
constexpr UpdateFeedbackMode): void;
@export
transitioning macro ForInNextSlow(
......
......@@ -117,7 +117,7 @@ transitioning builtin CallIteratorWithFeedback(
// https://tc39.es/ecma262/#sec-iteratorclose
@export
transitioning macro IteratorCloseOnException(implicit context: Context)(
iterator: IteratorRecord) {
iterator: IteratorRecord): void {
try {
// 4. Let innerResult be GetMethod(iterator, "return").
const method = GetProperty(iterator.object, kReturnString);
......
......@@ -103,7 +103,7 @@ macro NewPromiseRejectReactionJobTask(implicit context: Context)(
@export
transitioning macro RunContextPromiseHookInit(implicit context: Context)(
promise: JSPromise, parent: Object) {
promise: JSPromise, parent: Object): void {
const maybeHook = *NativeContextSlot(
ContextSlot::PROMISE_HOOK_INIT_FUNCTION_INDEX);
const hook = Cast<Callable>(maybeHook) otherwise return;
......@@ -119,7 +119,7 @@ transitioning macro RunContextPromiseHookInit(implicit context: Context)(
@export
transitioning macro RunContextPromiseHookResolve(implicit context: Context)(
promise: JSPromise) {
promise: JSPromise): void {
RunContextPromiseHook(
ContextSlot::PROMISE_HOOK_RESOLVE_FUNCTION_INDEX, promise,
PromiseHookFlags());
......@@ -127,14 +127,14 @@ transitioning macro RunContextPromiseHookResolve(implicit context: Context)(
@export
transitioning macro RunContextPromiseHookResolve(implicit context: Context)(
promise: JSPromise, flags: uint32) {
promise: JSPromise, flags: uint32): void {
RunContextPromiseHook(
ContextSlot::PROMISE_HOOK_RESOLVE_FUNCTION_INDEX, promise, flags);
}
@export
transitioning macro RunContextPromiseHookBefore(implicit context: Context)(
promiseOrCapability: JSPromise|PromiseCapability|Undefined) {
promiseOrCapability: JSPromise|PromiseCapability|Undefined): void {
RunContextPromiseHook(
ContextSlot::PROMISE_HOOK_BEFORE_FUNCTION_INDEX, promiseOrCapability,
PromiseHookFlags());
......@@ -142,7 +142,8 @@ transitioning macro RunContextPromiseHookBefore(implicit context: Context)(
@export
transitioning macro RunContextPromiseHookBefore(implicit context: Context)(
promiseOrCapability: JSPromise|PromiseCapability|Undefined, flags: uint32) {
promiseOrCapability: JSPromise|PromiseCapability|Undefined, flags: uint32):
void {
RunContextPromiseHook(
ContextSlot::PROMISE_HOOK_BEFORE_FUNCTION_INDEX, promiseOrCapability,
flags);
......@@ -150,7 +151,7 @@ transitioning macro RunContextPromiseHookBefore(implicit context: Context)(
@export
transitioning macro RunContextPromiseHookAfter(implicit context: Context)(
promiseOrCapability: JSPromise|PromiseCapability|Undefined) {
promiseOrCapability: JSPromise|PromiseCapability|Undefined): void {
RunContextPromiseHook(
ContextSlot::PROMISE_HOOK_AFTER_FUNCTION_INDEX, promiseOrCapability,
PromiseHookFlags());
......@@ -158,7 +159,8 @@ transitioning macro RunContextPromiseHookAfter(implicit context: Context)(
@export
transitioning macro RunContextPromiseHookAfter(implicit context: Context)(
promiseOrCapability: JSPromise|PromiseCapability|Undefined, flags: uint32) {
promiseOrCapability: JSPromise|PromiseCapability|Undefined, flags: uint32):
void {
RunContextPromiseHook(
ContextSlot::PROMISE_HOOK_AFTER_FUNCTION_INDEX, promiseOrCapability,
flags);
......@@ -166,7 +168,8 @@ transitioning macro RunContextPromiseHookAfter(implicit context: Context)(
transitioning macro RunContextPromiseHook(implicit context: Context)(
slot: Slot<NativeContext, Undefined|Callable>,
promiseOrCapability: JSPromise|PromiseCapability|Undefined, flags: uint32) {
promiseOrCapability: JSPromise|PromiseCapability|Undefined,
flags: uint32): void {
if (!IsContextPromiseHookEnabled(flags)) return;
const maybeHook = *NativeContextSlot(slot);
const hook = Cast<Callable>(maybeHook) otherwise return;
......@@ -192,7 +195,7 @@ transitioning macro RunContextPromiseHook(implicit context: Context)(
}
transitioning macro RunAnyPromiseHookInit(implicit context: Context)(
promise: JSPromise, parent: Object) {
promise: JSPromise, parent: Object): void {
const promiseHookFlags = PromiseHookFlags();
// Fast return if no hooks are set.
if (promiseHookFlags == 0) return;
......
......@@ -11,7 +11,7 @@ SetPropertyWithReceiver(implicit context: Context)(
Object, Name, Object, Object): void;
transitioning macro CallThrowTypeErrorIfStrict(implicit context: Context)(
message: constexpr MessageTemplate) {
message: constexpr MessageTemplate): void {
ThrowTypeErrorIfStrict(SmiConstant(message), Null, Null);
}
......
......@@ -11,13 +11,13 @@ extern macro ProxiesCodeStubAssembler::AllocateProxy(implicit context: Context)(
extern transitioning macro ProxiesCodeStubAssembler::CheckGetSetTrapResult(
implicit context: Context)(
JSReceiver, JSProxy, Name, Object, constexpr int31);
JSReceiver, JSProxy, Name, Object, constexpr int31): void;
extern transitioning macro ProxiesCodeStubAssembler::CheckDeleteTrapResult(
implicit context: Context)(JSReceiver, JSProxy, Name);
implicit context: Context)(JSReceiver, JSProxy, Name): void;
extern transitioning macro ProxiesCodeStubAssembler::CheckHasTrapResult(
implicit context: Context)(JSReceiver, JSProxy, Name);
implicit context: Context)(JSReceiver, JSProxy, Name): void;
const kProxyGet: constexpr int31
generates 'JSProxy::AccessKind::kGet';
......
......@@ -22,7 +22,7 @@ StringReplaceNonGlobalRegExpWithFunction(implicit context: Context)(
transitioning macro RegExpReplaceCallableNoExplicitCaptures(
implicit context: Context)(
matchesElements: FixedArray, matchesLength: intptr, string: String,
replaceFn: Callable) {
replaceFn: Callable): void {
let matchStart: Smi = 0;
for (let i: intptr = 0; i < matchesLength; i++) {
typeswitch (matchesElements.objects[i]) {
......@@ -63,7 +63,8 @@ transitioning macro RegExpReplaceCallableNoExplicitCaptures(
transitioning macro
RegExpReplaceCallableWithExplicitCaptures(implicit context: Context)(
matchesElements: FixedArray, matchesLength: intptr, replaceFn: Callable) {
matchesElements: FixedArray, matchesLength: intptr,
replaceFn: Callable): void {
for (let i: intptr = 0; i < matchesLength; i++) {
const elArray =
Cast<JSArray>(matchesElements.objects[i]) otherwise continue;
......
......@@ -243,7 +243,7 @@ macro AllocateFromNew(
}
macro InitializeFieldsFromIterator<T: type, Iterator: type>(
target: MutableSlice<T>, originIterator: Iterator) {
target: MutableSlice<T>, originIterator: Iterator): void {
let targetIterator = target.Iterator();
let originIterator = originIterator;
while (true) {
......@@ -253,12 +253,14 @@ macro InitializeFieldsFromIterator<T: type, Iterator: type>(
}
// Dummy implementations: do not initialize for UninitializedIterator.
InitializeFieldsFromIterator<char8, UninitializedIterator>(
_target: MutableSlice<char8>, _originIterator: UninitializedIterator) {}
_target: MutableSlice<char8>,
_originIterator: UninitializedIterator): void {}
InitializeFieldsFromIterator<char16, UninitializedIterator>(
_target: MutableSlice<char16>, _originIterator: UninitializedIterator) {}
_target: MutableSlice<char16>,
_originIterator: UninitializedIterator): void {}
extern macro IsDoubleHole(HeapObject, intptr): bool;
extern macro StoreDoubleHole(HeapObject, intptr);
extern macro StoreDoubleHole(HeapObject, intptr): void;
macro LoadFloat64OrHole(r:&float64_or_hole): float64_or_hole {
return float64_or_hole{
......@@ -267,7 +269,7 @@ macro LoadFloat64OrHole(r:&float64_or_hole): float64_or_hole {
value: *unsafe::NewReference<float64>(r.object, r.offset)
};
}
macro StoreFloat64OrHole(r:&float64_or_hole, value: float64_or_hole) {
macro StoreFloat64OrHole(r:&float64_or_hole, value: float64_or_hole): void {
if (value.is_hole) {
StoreDoubleHole(
%RawDownCast<HeapObject>(r.object), r.offset - kHeapObjectTag);
......@@ -297,12 +299,12 @@ macro DownCastForTorqueClass<T : type extends HeapObject>(o: HeapObject):
return %RawDownCast<T>(o);
}
extern macro StaticAssert(bool, constexpr string);
extern macro StaticAssert(bool, constexpr string): void;
// This is for the implementation of the dot operator. In any context where the
// dot operator is available, the correct way to get the length of an indexed
// field x from object o is `(&o.x).length`.
intrinsic %IndexedFieldLength<T: type>(o: T, f: constexpr string);
intrinsic %IndexedFieldLength<T: type>(o: T, f: constexpr string): intptr;
// If field x is defined as optional, then &o.x returns a reference to the field
// or crashes the program (unreachable) if the field is not present. Usually
......@@ -311,7 +313,8 @@ intrinsic %IndexedFieldLength<T: type>(o: T, f: constexpr string);
// optional field, which is either length zero or one depending on whether the
// field is present. This intrinsic provides Slices for both indexed fields
// (equivalent to &o.x) and optional fields.
intrinsic %FieldSlice<T: type>(o: T, f: constexpr string);
intrinsic %FieldSlice<T: type, TSlice: type>(
o: T, f: constexpr string): TSlice;
} // namespace torque_internal
......
......@@ -12,7 +12,7 @@ extern macro TypedArrayBuiltinsAssembler::CallCCopyTypedArrayElementsSlice(
macro FastCopy(
src: typed_array::AttachedJSTypedArray, dest: JSTypedArray, k: uintptr,
count: uintptr) labels IfSlow {
count: uintptr): void labels IfSlow {
if (IsForceSlowPath()) goto IfSlow;
const srcKind: ElementsKind = src.elements_kind;
......@@ -48,7 +48,7 @@ macro FastCopy(
}
macro SlowCopy(implicit context: Context)(
src: JSTypedArray, dest: JSTypedArray, k: uintptr, final: uintptr) {
src: JSTypedArray, dest: JSTypedArray, k: uintptr, final: uintptr): void {
if (typed_array::IsBigInt64ElementsKind(src.elements_kind) !=
typed_array::IsBigInt64ElementsKind(dest.elements_kind))
deferred {
......
......@@ -33,7 +33,7 @@ transitioning macro
TypedArrayMerge(
implicit context: Context, array: JSTypedArray, comparefn: Callable)(
source: FixedArray, from: uintptr, middle: uintptr, to: uintptr,
target: FixedArray) {
target: FixedArray): void {
let left: uintptr = from;
let right: uintptr = middle;
......
......@@ -82,10 +82,10 @@ extern macro TypedArrayBuiltinsAssembler::IsBigInt64ElementsKind(ElementsKind):
extern macro LoadFixedTypedArrayElementAsTagged(
RawPtr, uintptr, constexpr ElementsKind): Numeric;
extern macro TypedArrayBuiltinsAssembler::StoreJSTypedArrayElementFromNumeric(
Context, JSTypedArray, uintptr, Numeric, constexpr ElementsKind);
Context, JSTypedArray, uintptr, Numeric, constexpr ElementsKind): void;
extern macro TypedArrayBuiltinsAssembler::StoreJSTypedArrayElementFromTagged(
Context, JSTypedArray, uintptr, JSAny, constexpr ElementsKind)
labels IfDetached;
Context, JSTypedArray, uintptr, JSAny,
constexpr ElementsKind): void labels IfDetached;
extern macro LoadJSTypedArrayLengthAndCheckDetached(JSTypedArray): uintptr
labels IfDetached;
......@@ -105,15 +105,16 @@ struct TypedArrayAccessor {
}
macro StoreNumeric(
context: Context, array: JSTypedArray, index: uintptr, value: Numeric) {
context: Context, array: JSTypedArray, index: uintptr,
value: Numeric): void {
const storefn: StoreNumericFn = this.storeNumericFn;
const result = storefn(context, array, index, value);
dcheck(result == kStoreSucceded);
}
macro StoreJSAny(
context: Context, array: JSTypedArray, index: uintptr, value: JSAny)
labels IfDetached {
context: Context, array: JSTypedArray, index: uintptr,
value: JSAny): void labels IfDetached {
const storefn: StoreJSAnyFn = this.storeJSAnyFn;
const result = storefn(context, array, index, value);
if (result == kStoreFailureArrayDetached) {
......@@ -194,7 +195,7 @@ struct AttachedJSTypedArrayWitness {
return this.stable;
}
macro Recheck() labels Detached {
macro Recheck(): void labels Detached {
if (IsDetachedBuffer(this.stable.buffer)) goto Detached;
this.unstable = %RawDownCast<AttachedJSTypedArray>(this.stable);
}
......
......@@ -372,7 +372,7 @@ builtin WasmArrayCopyWithChecks(
// Redeclaration with different typing (value is an Object, not JSAny).
extern transitioning runtime
CreateDataProperty(implicit context: Context)(JSReceiver, JSAny, Object);
CreateDataProperty(implicit context: Context)(JSReceiver, JSAny, Object): void;
transitioning builtin WasmAllocateObjectWrapper(implicit context: Context)(
obj: Object): JSObject {
......
......@@ -4,7 +4,8 @@
namespace runtime {
extern runtime JSWeakRefAddToKeptObjects(implicit context: Context)(JSReceiver);
extern runtime JSWeakRefAddToKeptObjects(implicit context: Context)(JSReceiver):
void;
} // namespace runtime
......
......@@ -61,7 +61,8 @@ type Slot<Container : type extends Context, T : type extends Object> extends
// slot has the right type already.
macro InitContextSlot<
ArgumentContext: type, AnnotatedContext: type, T: type, U: type>(
context: ArgumentContext, index: Slot<AnnotatedContext, T>, value: U) {
context: ArgumentContext, index: Slot<AnnotatedContext, T>,
value: U): void {
// Make sure the arguments have the right type.
const context: AnnotatedContext = context;
const value: T = value;
......@@ -179,17 +180,17 @@ macro LoadContextElement(c: Context, i: constexpr int32): Object {
}
@export
macro StoreContextElement(c: Context, i: intptr, o: Object) {
macro StoreContextElement(c: Context, i: intptr, o: Object): void {
c.elements[i] = o;
}
@export
macro StoreContextElement(c: Context, i: Smi, o: Object) {
macro StoreContextElement(c: Context, i: Smi, o: Object): void {
c.elements[i] = o;
}
@export
macro StoreContextElement(c: Context, i: constexpr int32, o: Object) {
macro StoreContextElement(c: Context, i: constexpr int32, o: Object): void {
c.elements[i] = o;
}
......
......@@ -86,10 +86,11 @@ extern operator '.floats[]=' macro StoreFixedDoubleArrayElement(
extern operator '.floats[]' macro LoadFixedDoubleArrayElement(
FixedDoubleArray, intptr): float64;
operator '[]=' macro StoreFixedDoubleArrayDirect(
a: FixedDoubleArray, i: Smi, v: Number) {
a: FixedDoubleArray, i: Smi, v: Number): void {
a.floats[i] = Convert<float64_or_hole>(Convert<float64>(v));
}
operator '[]=' macro StoreFixedArrayDirect(a: FixedArray, i: Smi, v: Object) {
operator '[]=' macro StoreFixedArrayDirect(
a: FixedArray, i: Smi, v: Object): void {
a.objects[i] = v;
}
......
......@@ -187,7 +187,7 @@ struct FastJSArrayWitness {
return this.unstable;
}
macro Recheck() labels CastError {
macro Recheck(): void labels CastError {
if (this.stable.map != this.map) goto CastError;
// We don't need to check elements kind or whether the prototype
// has changed away from the default JSArray prototype, because
......@@ -210,7 +210,7 @@ struct FastJSArrayWitness {
}
}
macro StoreHole(k: Smi) {
macro StoreHole(k: Smi): void {
if (this.hasDoubles) {
const elements = Cast<FixedDoubleArray>(this.unstable.elements)
otherwise unreachable;
......@@ -230,18 +230,18 @@ struct FastJSArrayWitness {
}
}
macro EnsureArrayPushable(implicit context: Context)() labels Failed {
macro EnsureArrayPushable(implicit context: Context)(): void labels Failed {
EnsureArrayPushable(this.map) otherwise Failed;
array::EnsureWriteableFastElements(this.unstable);
this.arrayIsPushable = true;
}
macro ChangeLength(newLength: Smi) {
macro ChangeLength(newLength: Smi): void {
dcheck(this.arrayIsPushable);
this.unstable.length = newLength;
}
macro Push(value: JSAny) labels Failed {
macro Push(value: JSAny): void labels Failed {
dcheck(this.arrayIsPushable);
if (this.hasDoubles) {
BuildAppendJSArray(
......@@ -259,7 +259,7 @@ struct FastJSArrayWitness {
}
}
macro MoveElements(dst: intptr, src: intptr, length: intptr) {
macro MoveElements(dst: intptr, src: intptr, length: intptr): void {
dcheck(this.arrayIsPushable);
if (this.hasDoubles) {
const elements: FixedDoubleArray =
......@@ -303,7 +303,7 @@ struct FastJSArrayForReadWitness {
return this.unstable;
}
macro Recheck() labels CastError {
macro Recheck(): void labels CastError {
if (this.stable.map != this.map) goto CastError;
// We don't need to check elements kind or whether the prototype
// has changed away from the default JSArray prototype, because
......
......@@ -177,8 +177,10 @@ macro AllocateSeqTwoByteString(length: uint32): SeqTwoByteString|EmptyString {
return AllocateSeqTwoByteString(length, UninitializedIterator{});
}
extern macro StringWriteToFlatOneByte(String, RawPtr<char8>, int32, int32);
extern macro StringWriteToFlatTwoByte(String, RawPtr<char16>, int32, int32);
extern macro StringWriteToFlatOneByte(
String, RawPtr<char8>, int32, int32): void;
extern macro StringWriteToFlatTwoByte(
String, RawPtr<char16>, int32, int32): void;
// Corresponds to String::SlowFlatten in the C++ runtime.
builtin StringSlowFlatten(cons: ConsString): String {
......
......@@ -31,7 +31,7 @@ extern macro LoadSwissNameDictionaryCtrlTableGroup(intptr): uint64;
// Counterpart to swiss_table::ProbeSequence in C++ implementation.
struct ProbeSequence {
macro Next() {
macro Next(): void {
this.index = this.index + Unsigned(FromConstexpr<int32>(kGroupWidth));
this.offset = (this.offset + this.index) & this.mask;
}
......@@ -64,7 +64,7 @@ struct ByteMask {
}
// Counterpart to operator++() in C++ version.
macro ClearLowestSetBit() {
macro ClearLowestSetBit(): void {
this.mask = ClearLowestSetBit<uint64>(this.mask);
}
......@@ -83,7 +83,7 @@ struct BitMask {
}
// Counterpart to operator++() in C++ version.
macro ClearLowestSetBit() {
macro ClearLowestSetBit(): void {
this.mask = ClearLowestSetBit<uint32>(this.mask);
}
......
......@@ -31,13 +31,13 @@ const kNotFoundSentinel:
extern macro LoadSwissNameDictionaryKey(SwissNameDictionary, intptr): Name;
extern macro StoreSwissNameDictionaryKeyAndValue(
SwissNameDictionary, intptr, Object, Object);
SwissNameDictionary, intptr, Object, Object): void;
extern macro SwissNameDictionarySetCtrl(
SwissNameDictionary, intptr, intptr, uint8);
SwissNameDictionary, intptr, intptr, uint8): void;
extern macro StoreSwissNameDictionaryPropertyDetails(
SwissNameDictionary, intptr, intptr, uint8);
SwissNameDictionary, intptr, intptr, uint8): void;
extern macro
SwissNameDictionaryIncreaseElementCountOrBailout(
......@@ -45,7 +45,7 @@ SwissNameDictionaryIncreaseElementCountOrBailout(
extern macro
StoreSwissNameDictionaryEnumToEntryMapping(
SwissNameDictionary, intptr, intptr, int32);
SwissNameDictionary, intptr, intptr, int32): void;
extern macro
SwissNameDictionaryUpdateCountsForDeletion(ByteArray, intptr): uint32;
......@@ -214,8 +214,7 @@ macro FindFirstEmpty<GroupLoader: type>(
macro Add<GroupLoader: type>(
table: SwissNameDictionary, key: Name, value: Object,
propertyDetails: uint8)
labels Bailout {
propertyDetails: uint8): void labels Bailout {
const capacity: intptr = Convert<intptr>(table.capacity);
const maxUsable: uint32 =
Unsigned(Convert<int32>(SwissNameDictionaryMaxUsableCapacity(capacity)));
......@@ -249,9 +248,8 @@ macro Add<GroupLoader: type>(
}
@export
macro SwissNameDictionaryDelete(table: SwissNameDictionary, entry: intptr)
labels
Shrunk(SwissNameDictionary) {
macro SwissNameDictionaryDelete(table: SwissNameDictionary, entry: intptr):
void labels Shrunk(SwissNameDictionary) {
const capacity = Convert<intptr>(table.capacity);
// Update present and deleted element counts at once, without needing to do
......@@ -304,7 +302,7 @@ Found(intptr),
@export
macro SwissNameDictionaryAddSIMD(
table: SwissNameDictionary, key: Name, value: Object,
propertyDetails: uint8) labels Bailout {
propertyDetails: uint8): void labels Bailout {
Add<GroupSse2Loader>(table, key, value, propertyDetails)
otherwise Bailout;
}
......@@ -312,7 +310,7 @@ macro SwissNameDictionaryAddSIMD(
@export
macro SwissNameDictionaryAddPortable(
table: SwissNameDictionary, key: Name, value: Object,
propertyDetails: uint8) labels Bailout {
propertyDetails: uint8): void labels Bailout {
Add<GroupPortableLoader>(table, key, value, propertyDetails)
otherwise Bailout;
}
......
......@@ -3107,10 +3107,20 @@ VisitResult ImplementationVisitor::GenerateCall(
const Type* type = specialization_types[0];
const ClassType* class_type = ClassType::DynamicCast(type);
if (!class_type) {
ReportError("%FieldSlice must take a class type parameter");
ReportError("The first type parameter to %FieldSlice must be a class");
}
const Field& field =
class_type->LookupField(StringLiteralUnquote(constexpr_arguments[0]));
const Type* expected_slice_type =
field.const_qualified
? TypeOracle::GetConstSliceType(field.name_and_type.type)
: TypeOracle::GetMutableSliceType(field.name_and_type.type);
const Type* declared_slice_type = specialization_types[1];
if (expected_slice_type != declared_slice_type) {
Error(
"The second type parameter to %FieldSlice must be the precise "
"slice type for the named field");
}
LocationReference ref = GenerateFieldReference(
VisitResult(type, argument_range), field, class_type,
/*treat_optional_as_indexed=*/true);
......
......@@ -523,13 +523,6 @@ base::Optional<ParseResult> MakeDebugStatement(
return ParseResult{result};
}
base::Optional<ParseResult> MakeVoidType(ParseResultIterator* child_results) {
TypeExpression* result = MakeNode<BasicTypeExpression>(
std::vector<std::string>{}, MakeNode<Identifier>("void"),
std::vector<TypeExpression*>{});
return ParseResult{result};
}
base::Optional<ParseResult> MakeExternalMacro(
ParseResultIterator* child_results) {
auto transitioning = child_results->NextAs<bool>();
......@@ -2269,10 +2262,6 @@ struct TorqueGrammar : Grammar {
TryOrDefault<TypeList>(Sequence({Token("("), typeList, Token(")")}))},
MakeLabelAndTypes)};
// Result: TypeExpression*
Symbol optionalReturnType = {Rule({Token(":"), &type}),
Rule({}, MakeVoidType)};
// Result: LabelAndTypesVector
Symbol* optionalLabelList{TryOrDefault<LabelAndTypesVector>(
Sequence({Token("labels"),
......@@ -2580,7 +2569,7 @@ struct TorqueGrammar : Grammar {
Symbol method = {Rule(
{CheckIf(Token("transitioning")),
Optional<std::string>(Sequence({Token("operator"), &externalString})),
Token("macro"), &name, &parameterListNoVararg, &optionalReturnType,
Token("macro"), &name, &parameterListNoVararg, Token(":"), &type,
optionalLabelList, &block},
MakeMethodDeclaration)};
......@@ -2627,7 +2616,7 @@ struct TorqueGrammar : Grammar {
AsSingletonVector<Declaration*, MakeTypeAliasDeclaration>()),
Rule({Token("intrinsic"), &intrinsicName,
TryOrDefault<GenericParameters>(&genericParameters),
&parameterListNoVararg, &optionalReturnType, &optionalBody},
&parameterListNoVararg, Token(":"), &type, &optionalBody},
AsSingletonVector<Declaration*, MakeIntrinsicDeclaration>()),
Rule({Token("extern"), CheckIf(Token("transitioning")),
Optional<std::string>(
......@@ -2635,33 +2624,33 @@ struct TorqueGrammar : Grammar {
Token("macro"),
Optional<std::string>(Sequence({&identifier, Token("::")})), &name,
TryOrDefault<GenericParameters>(&genericParameters),
&typeListMaybeVarArgs, &optionalReturnType, optionalLabelList,
&typeListMaybeVarArgs, Token(":"), &type, optionalLabelList,
Token(";")},
AsSingletonVector<Declaration*, MakeExternalMacro>()),
Rule({Token("extern"), CheckIf(Token("transitioning")),
CheckIf(Token("javascript")), Token("builtin"), &name,
TryOrDefault<GenericParameters>(&genericParameters),
&typeListMaybeVarArgs, &optionalReturnType, Token(";")},
&typeListMaybeVarArgs, Token(":"), &type, Token(";")},
AsSingletonVector<Declaration*, MakeExternalBuiltin>()),
Rule({Token("extern"), CheckIf(Token("transitioning")), Token("runtime"),
&name, &typeListMaybeVarArgs, &optionalReturnType, Token(";")},
&name, &typeListMaybeVarArgs, Token(":"), &type, Token(";")},
AsSingletonVector<Declaration*, MakeExternalRuntime>()),
Rule({annotations, CheckIf(Token("transitioning")),
Optional<std::string>(
Sequence({Token("operator"), &externalString})),
Token("macro"), &name,
TryOrDefault<GenericParameters>(&genericParameters),
&parameterListNoVararg, &optionalReturnType, optionalLabelList,
&parameterListNoVararg, Token(":"), &type, optionalLabelList,
&optionalBody},
AsSingletonVector<Declaration*, MakeTorqueMacroDeclaration>()),
Rule({CheckIf(Token("transitioning")), CheckIf(Token("javascript")),
Token("builtin"), &name,
TryOrDefault<GenericParameters>(&genericParameters),
&parameterListAllowVararg, &optionalReturnType, &optionalBody},
&parameterListAllowVararg, Token(":"), &type, &optionalBody},
AsSingletonVector<Declaration*, MakeTorqueBuiltinDeclaration>()),
Rule({CheckIf(Token("transitioning")), &name,
&genericSpecializationTypeList, &parameterListAllowVararg,
&optionalReturnType, optionalLabelList, &block},
Token(":"), &type, optionalLabelList, &block},
AsSingletonVector<Declaration*, MakeSpecializationDeclaration>()),
Rule({Token("#include"), &externalString},
AsSingletonVector<Declaration*, MakeCppIncludeDeclaration>()),
......
......@@ -818,10 +818,10 @@ void ClassType::GenerateSliceAccessor(size_t field_index) {
// );
// }
//
// If the field has an unknown offset, and the previous field is named p, and
// an item in the previous field has size 4:
// If the field has an unknown offset, and the previous field is named p, is
// not const, and is of type PType with size 4:
// FieldSliceClassNameFieldName(o: ClassName) {
// const previous = %FieldSlice<ClassName>(o, "p");
// const previous = %FieldSlice<ClassName, MutableSlice<PType>>(o, "p");
// return torque_internal::unsafe::New{Const,Mutable}Slice<FieldType>(
// /*object:*/ o,
// /*offset:*/ previous.offset + 4 * previous.length,
......@@ -853,14 +853,21 @@ void ClassType::GenerateSliceAccessor(size_t field_index) {
const Field* previous = GetFieldPreceding(field_index);
DCHECK_NOT_NULL(previous);
// %FieldSlice<ClassName>(o, "p")
const Type* previous_slice_type =
previous->const_qualified
? TypeOracle::GetConstSliceType(previous->name_and_type.type)
: TypeOracle::GetMutableSliceType(previous->name_and_type.type);
// %FieldSlice<ClassName, MutableSlice<PType>>(o, "p")
Expression* previous_expression = MakeCallExpression(
MakeIdentifierExpression({"torque_internal"}, "%FieldSlice",
{MakeNode<PrecomputedTypeExpression>(this)}),
MakeIdentifierExpression(
{"torque_internal"}, "%FieldSlice",
{MakeNode<PrecomputedTypeExpression>(this),
MakeNode<PrecomputedTypeExpression>(previous_slice_type)}),
{parameter, MakeNode<StringLiteralExpression>(
StringLiteralQuote(previous->name_and_type.name))});
// const previous = %FieldSlice<ClassName>(o, "p");
// const previous = %FieldSlice<ClassName, MutableSlice<PType>>(o, "p");
Statement* define_previous =
MakeConstDeclarationStatement("previous", previous_expression);
statements.push_back(define_previous);
......
This diff is collapsed.
......@@ -100,7 +100,7 @@ TEST(LanguageServer, GotoLabelDefinitionInSignature) {
"macro Foo(): never labels Fail {\n"
" goto Fail;\n"
"}\n"
"macro Bar() labels Bailout {\n"
"macro Bar(): void labels Bailout {\n"
" Foo() otherwise Bailout;\n"
"}\n";
......@@ -113,8 +113,8 @@ TEST(LanguageServer, GotoLabelDefinitionInSignature) {
id, LineAndColumn::WithUnknownOffset(6, 18));
ASSERT_TRUE(maybe_position.has_value());
EXPECT_EQ(*maybe_position,
(SourcePosition{id, LineAndColumn::WithUnknownOffset(5, 19),
LineAndColumn::WithUnknownOffset(5, 26)}));
(SourcePosition{id, LineAndColumn::WithUnknownOffset(5, 25),
LineAndColumn::WithUnknownOffset(5, 32)}));
}
#endif
......@@ -125,7 +125,7 @@ TEST(LanguageServer, GotoLabelDefinitionInTryBlock) {
"macro Foo(): never labels Fail {\n"
" goto Fail;\n"
"}\n"
"macro Bar() {\n"
"macro Bar(): void {\n"
" try { Foo() otherwise Bailout; }\n"
" label Bailout {}\n"
"}\n";
......@@ -193,7 +193,7 @@ TEST(LanguageServer, GotoLabelDefinitionInTryBlockGoto) {
const std::string source =
"type void;\n"
"type never;\n"
"macro Bar() {\n"
"macro Bar(): void {\n"
" try { goto Bailout; }\n"
" label Bailout {}\n"
"}\n";
......@@ -218,7 +218,7 @@ TEST(LanguageServer, GotoLabelDefinitionGotoInOtherwise) {
"macro Foo(): never labels Fail {\n"
" goto Fail;\n"
"}\n"
"macro Bar() {\n"
"macro Bar(): void {\n"
" try { Foo() otherwise goto Bailout; }\n"
" label Bailout {}\n"
"}\n";
......
This diff is collapsed.
......@@ -20,7 +20,7 @@ class SortState extends HeapObject {
return sortCompare(context, this.userCmpFn, x, y);
}
macro CheckAccessor(implicit context: Context)() labels Bailout {
macro CheckAccessor(implicit context: Context)(): void labels Bailout {
if (!IsFastJSArray(this.receiver, context)) goto Bailout;
const canUseSameAccessorFn: CanUseSameAccessorFn =
......@@ -33,7 +33,7 @@ class SortState extends HeapObject {
}
}
macro ResetToGenericAccessor() {
macro ResetToGenericAccessor(): void {
this.loadFn = Load<GenericElementsAccessor>;
this.storeFn = Store<GenericElementsAccessor>;
this.deleteFn = Delete<GenericElementsAccessor>;
......@@ -410,7 +410,7 @@ macro GetPendingRunBase(implicit context: Context)(
return UnsafeCast<Smi>(pendingRuns.objects[run << 1]);
}
macro SetPendingRunBase(pendingRuns: FixedArray, run: Smi, value: Smi) {
macro SetPendingRunBase(pendingRuns: FixedArray, run: Smi, value: Smi): void {
pendingRuns.objects[run << 1] = value;
}
......@@ -419,12 +419,12 @@ macro GetPendingRunLength(implicit context: Context)(
return UnsafeCast<Smi>(pendingRuns.objects[(run << 1) + 1]);
}
macro SetPendingRunLength(pendingRuns: FixedArray, run: Smi, value: Smi) {
macro SetPendingRunLength(pendingRuns: FixedArray, run: Smi, value: Smi): void {
pendingRuns.objects[(run << 1) + 1] = value;
}
macro PushRun(implicit context: Context)(
sortState: SortState, base: Smi, length: Smi) {
sortState: SortState, base: Smi, length: Smi): void {
dcheck(GetPendingRunsSize(sortState) < kMaxMergePending);
const stackSize: Smi = GetPendingRunsSize(sortState);
......@@ -498,7 +498,7 @@ Copy(implicit context: Context)(
// On entry, must have low <= start <= high, and that [low, start) is
// already sorted. Pass start == low if you do not know!.
macro BinaryInsertionSort(implicit context: Context, sortState: SortState)(
low: Smi, startArg: Smi, high: Smi) {
low: Smi, startArg: Smi, high: Smi): void {
dcheck(low <= startArg && startArg <= high);
const workArray = sortState.workArray;
......@@ -604,7 +604,7 @@ macro CountAndMakeRun(implicit context: Context, sortState: SortState)(
return runLength;
}
macro ReverseRange(array: FixedArray, from: Smi, to: Smi) {
macro ReverseRange(array: FixedArray, from: Smi, to: Smi): void {
let low: Smi = from;
let high: Smi = to - 1;
......@@ -890,7 +890,7 @@ builtin GallopRight(implicit context: Context, sortState: SortState)(
// that array[baseA + lengthA - 1] belongs at the end of the merge,
// and should have lengthA <= lengthB.
transitioning macro MergeLow(implicit context: Context, sortState: SortState)(
baseA: Smi, lengthAArg: Smi, baseB: Smi, lengthBArg: Smi) {
baseA: Smi, lengthAArg: Smi, baseB: Smi, lengthBArg: Smi): void {
dcheck(0 < lengthAArg && 0 < lengthBArg);
dcheck(0 <= baseA && 0 < baseB);
dcheck(baseA + lengthAArg == baseB);
......@@ -1020,7 +1020,7 @@ transitioning macro MergeLow(implicit context: Context, sortState: SortState)(
// be > 0. Must also have that array[baseA + lengthA - 1] belongs at the
// end of the merge and should have lengthA >= lengthB.
transitioning macro MergeHigh(implicit context: Context, sortState: SortState)(
baseA: Smi, lengthAArg: Smi, baseB: Smi, lengthBArg: Smi) {
baseA: Smi, lengthAArg: Smi, baseB: Smi, lengthBArg: Smi): void {
dcheck(0 < lengthAArg && 0 < lengthBArg);
dcheck(0 <= baseA && 0 < baseB);
dcheck(baseA + lengthAArg == baseB);
......@@ -1198,7 +1198,8 @@ macro RunInvariantEstablished(implicit context: Context)(
// TODO(szuend): Remove unnecessary loads. This macro was refactored to
// improve readability, introducing unnecessary loads in the
// process. Determine if all these extra loads are ok.
transitioning macro MergeCollapse(context: Context, sortState: SortState) {
transitioning macro MergeCollapse(
context: Context, sortState: SortState): void {
const pendingRuns: FixedArray = sortState.pendingRuns;
// Reload the stack size because MergeAt might change it.
......@@ -1226,7 +1227,7 @@ transitioning macro MergeCollapse(context: Context, sortState: SortState) {
// Regardless of invariants, merge all runs on the stack until only one
// remains. This is used at the end of the mergesort.
transitioning macro
MergeForceCollapse(context: Context, sortState: SortState) {
MergeForceCollapse(context: Context, sortState: SortState): void {
const pendingRuns: FixedArray = sortState.pendingRuns;
// Reload the stack size becuase MergeAt might change it.
......@@ -1243,7 +1244,7 @@ MergeForceCollapse(context: Context, sortState: SortState) {
}
transitioning macro
ArrayTimSortImpl(context: Context, sortState: SortState, length: Smi) {
ArrayTimSortImpl(context: Context, sortState: SortState, length: Smi): void {
if (length < 2) return;
let remaining: Smi = length;
......@@ -1322,7 +1323,7 @@ CompactReceiverElementsIntoWorkArray(
transitioning macro
CopyWorkArrayToReceiver(implicit context: Context, sortState: SortState)(
numberOfNonUndefined: Smi) {
numberOfNonUndefined: Smi): void {
const storeFn = sortState.storeFn;
const workArray = sortState.workArray;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment