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