wasm.tq 20.3 KB
Newer Older
1 2 3 4
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7
#include 'src/builtins/builtins-wasm-gen.h'

namespace runtime {
8 9
extern runtime WasmMemoryGrow(Context, WasmInstanceObject, Smi): Smi;
extern runtime WasmRefFunc(Context, WasmInstanceObject, Smi): JSAny;
10 11 12 13
extern runtime WasmTableInit(
    Context, WasmInstanceObject, Object, Object, Smi, Smi, Smi): JSAny;
extern runtime WasmTableCopy(
    Context, WasmInstanceObject, Object, Object, Smi, Smi, Smi): JSAny;
14 15
extern runtime WasmTableFill(
    Context, WasmInstanceObject, Smi, Smi, Object, Smi): JSAny;
16 17
extern runtime WasmTableGrow(
    Context, WasmInstanceObject, Smi, Object, Smi): Smi;
18 19 20 21 22
extern runtime WasmFunctionTableGet(
    Context, WasmInstanceObject, Smi, Smi): JSAny;
extern runtime WasmFunctionTableSet(
    Context, WasmInstanceObject, Smi, Smi, Object): JSAny;
extern runtime ThrowWasmError(Context, Smi): JSAny;
23
extern runtime WasmThrow(Context, Object, FixedArray): JSAny;
24
extern runtime WasmReThrow(Context, Object): JSAny;
25
extern runtime WasmTriggerTierUp(Context, WasmInstanceObject): JSAny;
26 27 28
extern runtime WasmStackGuard(Context): JSAny;
extern runtime ThrowWasmStackOverflow(Context): JSAny;
extern runtime WasmTraceMemory(Context, Smi): JSAny;
29
extern runtime WasmTraceEnter(Context): JSAny;
30
extern runtime WasmTraceExit(Context, Smi): JSAny;
31 32 33 34 35 36
extern runtime WasmAtomicNotify(
    Context, WasmInstanceObject, Number, Number): Smi;
extern runtime WasmI32AtomicWait(
    Context, WasmInstanceObject, Number, Number, BigInt): Smi;
extern runtime WasmI64AtomicWait(
    Context, WasmInstanceObject, Number, BigInt, BigInt): Smi;
37
extern runtime WasmAllocateRtt(Context, Smi, Map, Smi): Map;
38 39
extern runtime WasmArrayCopy(
    Context, WasmArray, Smi, WasmArray, Smi, Smi): JSAny;
40 41 42 43
}

namespace unsafe {
extern macro TimesTaggedSize(intptr): intptr;
44
extern macro Allocate(intptr, constexpr AllocationFlag): HeapObject;
45 46
extern macro AllocateWasmArray(
    intptr, constexpr InitializationMode): HeapObject;
47 48
}

49
namespace wasm {
50 51 52 53
const kExternTableType: constexpr int31
    generates 'wasm::kWasmExternRef.raw_bit_field()';
const kExternNonNullTableType: constexpr int31
    generates 'wasm::kWasmExternNonNullableRef.raw_bit_field()';
54

55 56 57 58
const kRttSubCanonicalize: constexpr int31
    generates 'WasmRttSubMode::kCanonicalize';
const kRttSubFresh: constexpr int31 generates 'WasmRttSubMode::kFresh';

59 60 61 62 63 64 65 66 67 68
extern macro WasmBuiltinsAssembler::LoadInstanceFromFrame(): WasmInstanceObject;

// WasmInstanceObject has a field layout that Torque can't handle yet.
// TODO(bbudge) Eliminate these functions when Torque is ready.
extern macro WasmBuiltinsAssembler::LoadContextFromInstance(WasmInstanceObject):
    NativeContext;
extern macro WasmBuiltinsAssembler::LoadTablesFromInstance(WasmInstanceObject):
    FixedArray;
extern macro WasmBuiltinsAssembler::LoadExternalFunctionsFromInstance(
    WasmInstanceObject): FixedArray;
69 70
extern macro WasmBuiltinsAssembler::LoadManagedObjectMapsFromInstance(
    WasmInstanceObject): FixedArray;
71 72 73 74

macro LoadContextFromFrame(): NativeContext {
  return LoadContextFromInstance(LoadInstanceFromFrame());
}
75

76 77 78
builtin WasmInt32ToHeapNumber(val: int32): HeapNumber {
  return AllocateHeapNumberWithValue(Convert<float64>(val));
}
79

80 81 82 83
builtin WasmTaggedNonSmiToInt32(implicit context: Context)(val: JSAnyNotSmi):
    int32 {
  return ChangeTaggedNonSmiToInt32(val);
}
84

85 86 87
builtin WasmTaggedToFloat64(implicit context: Context)(val: JSAny): float64 {
  return ChangeTaggedToFloat64(val);
}
88

89 90 91 92 93 94 95 96 97
builtin WasmMemoryGrow(numPages: int32): int32 {
  if (!IsValidPositiveSmi(ChangeInt32ToIntPtr(numPages)))
    return Int32Constant(-1);
  const instance: WasmInstanceObject = LoadInstanceFromFrame();
  const context: NativeContext = LoadContextFromInstance(instance);
  const result: Smi =
      runtime::WasmMemoryGrow(context, instance, SmiFromInt32(numPages));
  return SmiToInt32(result);
}
98

99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
builtin WasmTableInit(
    dstRaw: uint32, srcRaw: uint32, sizeRaw: uint32, tableIndex: Smi,
    segmentIndex: Smi): JSAny {
  try {
    const instance: WasmInstanceObject = LoadInstanceFromFrame();
    const dst: Smi = Convert<PositiveSmi>(dstRaw) otherwise TableOutOfBounds;
    const src: Smi = Convert<PositiveSmi>(srcRaw) otherwise TableOutOfBounds;
    const size: Smi = Convert<PositiveSmi>(sizeRaw) otherwise TableOutOfBounds;
    tail runtime::WasmTableInit(
        LoadContextFromInstance(instance), instance, tableIndex, segmentIndex,
        dst, src, size);
  } label TableOutOfBounds deferred {
    tail ThrowWasmTrapTableOutOfBounds();
  }
}

builtin WasmTableCopy(
    dstRaw: uint32, srcRaw: uint32, sizeRaw: uint32, dstTable: Smi,
    srcTable: Smi): JSAny {
  try {
    const instance: WasmInstanceObject = LoadInstanceFromFrame();
    const dst: Smi = Convert<PositiveSmi>(dstRaw) otherwise TableOutOfBounds;
    const src: Smi = Convert<PositiveSmi>(srcRaw) otherwise TableOutOfBounds;
    const size: Smi = Convert<PositiveSmi>(sizeRaw) otherwise TableOutOfBounds;
    tail runtime::WasmTableCopy(
        LoadContextFromInstance(instance), instance, dstTable, srcTable, dst,
        src, size);
  } label TableOutOfBounds deferred {
    tail ThrowWasmTrapTableOutOfBounds();
  }
}

131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
builtin WasmTableFill(
    table: Smi, startRaw: uint32, countRaw: uint32, value: Object): JSAny {
  try {
    const instance: WasmInstanceObject = LoadInstanceFromFrame();
    const start: Smi =
        Convert<PositiveSmi>(startRaw) otherwise TableOutOfBounds;
    const count: Smi =
        Convert<PositiveSmi>(countRaw) otherwise TableOutOfBounds;
    tail runtime::WasmTableFill(
        LoadContextFromInstance(instance), instance, table, start, value,
        count);
  } label TableOutOfBounds deferred {
    tail ThrowWasmTrapTableOutOfBounds();
  }
}

147 148 149 150 151 152 153 154 155 156 157 158
builtin WasmTableGrow(table: Smi, deltaRaw: uint32, value: Object): Smi {
  try {
    const instance: WasmInstanceObject = LoadInstanceFromFrame();
    const delta: Smi =
        Convert<PositiveSmi>(deltaRaw) otherwise TableOutOfBounds;
    tail runtime::WasmTableGrow(
        LoadContextFromInstance(instance), instance, table, value, delta);
  } label TableOutOfBounds deferred {
    return -1;
  }
}

159 160 161 162 163 164
builtin WasmTableGet(tableIndex: intptr, index: int32): Object {
  const instance: WasmInstanceObject = LoadInstanceFromFrame();
  const entryIndex: intptr = ChangeInt32ToIntPtr(index);
  try {
    assert(IsValidPositiveSmi(tableIndex));
    if (!IsValidPositiveSmi(entryIndex)) goto IndexOutOfRange;
165

166 167 168 169 170 171 172 173
    const tables: FixedArray = LoadTablesFromInstance(instance);
    const table: WasmTableObject = %RawDownCast<WasmTableObject>(
        LoadFixedArrayElement(tables, tableIndex));
    const entriesCount: intptr = Convert<intptr, Smi>(table.current_length);
    if (entryIndex >= entriesCount) goto IndexOutOfRange;

    const entries: FixedArray = table.entries;
    const entry: Object = LoadFixedArrayElement(entries, entryIndex);
174 175

    try {
176 177 178 179 180 181
      const entryObject: HeapObject =
          TaggedToHeapObject<HeapObject>(entry) otherwise ReturnEntry;
      if (IsTuple2Map(entryObject.map)) goto CallRuntime;
      goto ReturnEntry;
    } label ReturnEntry {
      return entry;
182
    }
183 184 185 186 187 188
  } label CallRuntime deferred {
    tail runtime::WasmFunctionTableGet(
        LoadContextFromInstance(instance), instance, SmiFromIntPtr(tableIndex),
        SmiFromIntPtr(entryIndex));
  } label IndexOutOfRange deferred {
    tail ThrowWasmTrapTableOutOfBounds();
189
  }
190
}
191

192 193 194 195 196 197 198 199 200 201 202 203 204
builtin WasmTableSet(tableIndex: intptr, index: int32, value: Object): Object {
  const instance: WasmInstanceObject = LoadInstanceFromFrame();
  const entryIndex: intptr = ChangeInt32ToIntPtr(index);
  try {
    assert(IsValidPositiveSmi(tableIndex));
    if (!IsValidPositiveSmi(entryIndex)) goto IndexOutOfRange;

    const tables: FixedArray = LoadTablesFromInstance(instance);
    const table: WasmTableObject = %RawDownCast<WasmTableObject>(
        LoadFixedArrayElement(tables, tableIndex));

    // Fall back to the runtime to set funcrefs, since we have to update
    // function dispatch tables.
205
    // TODO(7748): Update this if further table types are supported.
206
    const tableType: Smi = table.raw_type;
207 208 209 210
    if (tableType != SmiConstant(kExternTableType) &&
        tableType != SmiConstant(kExternNonNullTableType)) {
      goto CallRuntime;
    }
211 212 213 214 215 216 217 218 219 220 221 222 223

    const entriesCount: intptr = Convert<intptr, Smi>(table.current_length);
    if (entryIndex >= entriesCount) goto IndexOutOfRange;

    const entries: FixedArray = table.entries;
    StoreFixedArrayElement(entries, entryIndex, value);
    return Undefined;
  } label CallRuntime deferred {
    tail runtime::WasmFunctionTableSet(
        LoadContextFromInstance(instance), instance, SmiFromIntPtr(tableIndex),
        SmiFromIntPtr(entryIndex), value);
  } label IndexOutOfRange deferred {
    tail ThrowWasmTrapTableOutOfBounds();
224
  }
225
}
226

227 228 229 230 231 232 233 234 235 236 237 238
builtin WasmRefFunc(index: uint32): Object {
  const instance: WasmInstanceObject = LoadInstanceFromFrame();
  try {
    const table: FixedArray = LoadExternalFunctionsFromInstance(instance);
    if (table == Undefined) goto CallRuntime;
    const functionIndex: intptr = Signed(ChangeUint32ToWord(index));
    const result: Object = LoadFixedArrayElement(table, functionIndex);
    if (result == Undefined) goto CallRuntime;
    return result;
  } label CallRuntime deferred {
    tail runtime::WasmRefFunc(
        LoadContextFromInstance(instance), instance, SmiFromUint32(index));
239
  }
240
}
241

242 243 244 245 246 247
builtin WasmAllocateFixedArray(size: intptr): FixedArray {
  if (size == 0) return kEmptyFixedArray;
  return UnsafeCast<FixedArray>(AllocateFixedArray(
      ElementsKind::PACKED_ELEMENTS, size, AllocationFlag::kNone));
}

248 249
builtin WasmThrow(tag: Object, values: FixedArray): JSAny {
  tail runtime::WasmThrow(LoadContextFromFrame(), tag, values);
250
}
251

252
builtin WasmRethrow(exception: Object): JSAny {
253
  if (exception == Null) tail ThrowWasmTrapRethrowNull();
254
  tail runtime::WasmReThrow(LoadContextFromFrame(), exception);
255
}
256

257 258 259 260 261
builtin WasmTriggerTierUp(): JSAny {
  const instance: WasmInstanceObject = LoadInstanceFromFrame();
  tail runtime::WasmTriggerTierUp(LoadContextFromFrame(), instance);
}

262 263 264
builtin WasmStackGuard(): JSAny {
  tail runtime::WasmStackGuard(LoadContextFromFrame());
}
265

266 267 268 269 270 271 272 273
builtin WasmStackOverflow(): JSAny {
  tail runtime::ThrowWasmStackOverflow(LoadContextFromFrame());
}

builtin WasmTraceMemory(info: Smi): JSAny {
  tail runtime::WasmTraceMemory(LoadContextFromFrame(), info);
}

274 275 276 277
builtin WasmTraceEnter(): JSAny {
  tail runtime::WasmTraceEnter(LoadContextFromFrame());
}

278 279 280 281
builtin WasmTraceExit(info: Smi): JSAny {
  tail runtime::WasmTraceExit(LoadContextFromFrame(), info);
}

282 283 284 285
builtin WasmAllocateJSArray(implicit context: Context)(size: Smi): JSArray {
  const map: Map = GetFastPackedElementsJSArrayMap();
  return AllocateJSArray(ElementsKind::PACKED_ELEMENTS, map, size, size);
}
286

287 288 289 290 291
builtin WasmAllocatePair(first: Object, second: Object): Tuple2 {
  const tuple2Map: Map = %GetClassMapConstant<Tuple2>();
  return new Tuple2{map: tuple2Map, value1: first, value2: second};
}

292 293
builtin WasmAllocateRtt(typeIndex: intptr, parent: Map): Map {
  tail runtime::WasmAllocateRtt(
294 295 296 297 298 299 300 301
      LoadContextFromFrame(), SmiTag(typeIndex), parent,
      SmiConstant(kRttSubCanonicalize));
}

builtin WasmAllocateFreshRtt(typeIndex: intptr, parent: Map): Map {
  tail runtime::WasmAllocateRtt(
      LoadContextFromFrame(), SmiTag(typeIndex), parent,
      SmiConstant(kRttSubFresh));
302 303
}

304
builtin WasmAllocateStructWithRtt(rtt: Map): HeapObject {
305 306 307
  const typeInfo: WasmTypeInfo = %RawDownCast<WasmTypeInfo>(
      rtt.constructor_or_back_pointer_or_native_context);
  const instanceSize: intptr = SmiUntag(typeInfo.instance_size);
308 309
  const result: HeapObject = unsafe::Allocate(
      instanceSize, AllocationFlag::kAllowLargeObjectAllocation);
310
  *UnsafeConstCast(&result.map) = rtt;
311 312
  // TODO(ishell): consider removing properties_or_hash field from WasmObjects.
  %RawDownCast<WasmStruct>(result).properties_or_hash = kEmptyFixedArray;
313 314 315
  return result;
}

316 317 318
macro WasmAllocateArray(
    rtt: Map, length: uint32, elementSize: uint32,
    initializationMode: constexpr InitializationMode): HeapObject {
319 320 321 322 323 324
  // instanceSize = RoundUp(elementSize * length, kObjectAlignment)
  //              + WasmArray::kHeaderSize
  const instanceSize: intptr =
      torque_internal::AlignTagged(
          Convert<intptr>(length) * Convert<intptr>(elementSize)) +
      Convert<intptr>(kWasmArrayHeaderSize);
325 326
  const result: HeapObject =
      unsafe::AllocateWasmArray(instanceSize, initializationMode);
327
  *UnsafeConstCast(&result.map) = rtt;
328 329
  // TODO(ishell): consider removing properties_or_hash field from WasmObjects.
  %RawDownCast<WasmArray>(result).properties_or_hash = kEmptyFixedArray;
330 331 332 333
  %RawDownCast<WasmArray>(result).length = length;
  return result;
}

334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
builtin WasmAllocateArray_Uninitialized(
    rtt: Map, length: uint32, elementSize: uint32): HeapObject {
  return WasmAllocateArray(
      rtt, length, elementSize, InitializationMode::kUninitialized);
}

builtin WasmAllocateArray_InitZero(
    rtt: Map, length: uint32, elementSize: uint32): HeapObject {
  return WasmAllocateArray(
      rtt, length, elementSize, InitializationMode::kInitializeToZero);
}

builtin WasmAllocateArray_InitNull(
    rtt: Map, length: uint32, elementSize: uint32): HeapObject {
  return WasmAllocateArray(
      rtt, length, elementSize, InitializationMode::kInitializeToNull);
}

352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
// We put all uint32 parameters at the beginning so that they are assigned to
// registers.
builtin WasmArrayCopyWithChecks(
    dstIndex: uint32, srcIndex: uint32, length: uint32, dstObject: Object,
    srcObject: Object): JSAny {
  if (dstObject == Null) tail ThrowWasmTrapNullDereference();
  if (srcObject == Null) tail ThrowWasmTrapNullDereference();
  const dstArray = %RawDownCast<WasmArray>(dstObject);
  const srcArray = %RawDownCast<WasmArray>(srcObject);
  // Check that the end of the copying range is in-bounds and that the range
  // does not overflow.
  if (dstIndex + length > dstArray.length || dstIndex + length < dstIndex ||
      srcIndex + length > srcArray.length || srcIndex + length < srcIndex) {
    tail ThrowWasmTrapArrayOutOfBounds();
  }
  tail runtime::WasmArrayCopy(
      LoadContextFromFrame(), dstArray, SmiFromUint32(dstIndex), srcArray,
      SmiFromUint32(srcIndex), SmiFromUint32(length));
}

// We put all uint32 parameters at the beginning so that they are assigned to
// registers.
builtin WasmArrayCopy(
    dstIndex: uint32, srcIndex: uint32, length: uint32, dstArray: WasmArray,
    srcArray: WasmArray): JSAny {
  tail runtime::WasmArrayCopy(
      LoadContextFromFrame(), dstArray, SmiFromUint32(dstIndex), srcArray,
      SmiFromUint32(srcIndex), SmiFromUint32(length));
}

382 383 384 385 386 387 388 389 390 391 392 393 394
// Redeclaration with different typing (value is an Object, not JSAny).
extern transitioning runtime
CreateDataProperty(implicit context: Context)(JSReceiver, JSAny, Object);

transitioning builtin WasmAllocateObjectWrapper(implicit context: Context)(
    obj: Object): JSObject {
  // Note: {obj} can be null, or i31ref. The code below is agnostic to that.
  const wrapper = NewJSObject();
  const symbol = WasmWrappedObjectSymbolConstant();
  CreateDataProperty(wrapper, symbol, obj);
  return wrapper;
}

395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411
builtin WasmSubtypeCheck(objectSupertypes: FixedArray, rtt: Map): int32 {
  const rttSupertypeLength: Smi =
      %RawDownCast<WasmTypeInfo>(
          rtt.constructor_or_back_pointer_or_native_context)
          .supertypes.length;

  if (objectSupertypes.length <= rttSupertypeLength) {
    return 0;
  }

  const supertype: Map = %RawDownCast<Map>(
      LoadFixedArrayElement(objectSupertypes, rttSupertypeLength));

  if (supertype == rtt) return 1;
  return 0;
}

412 413 414 415 416 417 418 419
builtin WasmInt32ToNumber(value: int32): Number {
  return ChangeInt32ToTagged(value);
}

builtin WasmUint32ToNumber(value: uint32): Number {
  return ChangeUint32ToTagged(value);
}

420 421 422 423 424 425 426 427 428
builtin UintPtr53ToNumber(value: uintptr): Number {
  if (value <= kSmiMaxValue) return Convert<Smi>(Convert<intptr>(value));
  const valueFloat = ChangeUintPtrToFloat64(value);
  // Values need to be within [0..2^53], such that they can be represented as
  // float64.
  assert(ChangeFloat64ToUintPtr(valueFloat) == value);
  return AllocateHeapNumberWithValue(valueFloat);
}

429 430
extern builtin I64ToBigInt(intptr): BigInt;

431
builtin WasmAtomicNotify(offset: uintptr, count: uint32): uint32 {
432 433
  const instance: WasmInstanceObject = LoadInstanceFromFrame();
  const result: Smi = runtime::WasmAtomicNotify(
434
      LoadContextFromInstance(instance), instance, UintPtr53ToNumber(offset),
435 436 437 438 439
      WasmUint32ToNumber(count));
  return Unsigned(SmiToInt32(result));
}

builtin WasmI32AtomicWait64(
440
    offset: uintptr, expectedValue: int32, timeout: intptr): uint32 {
441 442 443
  if constexpr (Is64()) {
    const instance: WasmInstanceObject = LoadInstanceFromFrame();
    const result: Smi = runtime::WasmI32AtomicWait(
444 445
        LoadContextFromInstance(instance), instance, UintPtr53ToNumber(offset),
        WasmInt32ToNumber(expectedValue), I64ToBigInt(timeout));
446 447 448 449 450 451 452
    return Unsigned(SmiToInt32(result));
  } else {
    unreachable;
  }
}

builtin WasmI64AtomicWait64(
453
    offset: uintptr, expectedValue: intptr, timeout: intptr): uint32 {
454 455 456
  if constexpr (Is64()) {
    const instance: WasmInstanceObject = LoadInstanceFromFrame();
    const result: Smi = runtime::WasmI64AtomicWait(
457 458
        LoadContextFromInstance(instance), instance, UintPtr53ToNumber(offset),
        I64ToBigInt(expectedValue), I64ToBigInt(timeout));
459 460 461 462 463 464
    return Unsigned(SmiToInt32(result));
  } else {
    unreachable;
  }
}

465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480
extern macro TryHasOwnProperty(HeapObject, Map, InstanceType, Name): never
    labels Found, NotFound, Bailout;
type OnNonExistent constexpr 'OnNonExistent';
const kReturnUndefined: constexpr OnNonExistent
    generates 'OnNonExistent::kReturnUndefined';
extern macro SmiConstant(constexpr OnNonExistent): Smi;
extern transitioning builtin GetPropertyWithReceiver(implicit context: Context)(
    JSAny, Name, JSAny, Smi): JSAny;

transitioning builtin WasmGetOwnProperty(implicit context: Context)(
    object: Object, uniqueName: Name): JSAny {
  try {
    const heapObject: HeapObject =
        TaggedToHeapObject(object) otherwise NotFound;
    const receiver: JSReceiver =
        Cast<JSReceiver>(heapObject) otherwise NotFound;
481
    try {
482 483
      TryHasOwnProperty(
          receiver, receiver.map, receiver.instanceType, uniqueName)
484
          otherwise Found, NotFound, NotFound;
485 486 487
    } label Found {
      tail GetPropertyWithReceiver(
          receiver, uniqueName, receiver, SmiConstant(kReturnUndefined));
488
    }
489 490
  } label NotFound deferred {
    return Undefined;
491
  }
492
}
493

494
// Trap builtins.
495

496 497 498
builtin WasmTrap(error: Smi): JSAny {
  tail runtime::ThrowWasmError(LoadContextFromFrame(), error);
}
499

500 501 502
builtin ThrowWasmTrapUnreachable(): JSAny {
  tail WasmTrap(SmiConstant(MessageTemplate::kWasmTrapUnreachable));
}
503

504 505 506
builtin ThrowWasmTrapMemOutOfBounds(): JSAny {
  tail WasmTrap(SmiConstant(MessageTemplate::kWasmTrapMemOutOfBounds));
}
507

508 509 510
builtin ThrowWasmTrapUnalignedAccess(): JSAny {
  tail WasmTrap(SmiConstant(MessageTemplate::kWasmTrapUnalignedAccess));
}
511

512 513 514
builtin ThrowWasmTrapDivByZero(): JSAny {
  tail WasmTrap(SmiConstant(MessageTemplate::kWasmTrapDivByZero));
}
515

516 517 518
builtin ThrowWasmTrapDivUnrepresentable(): JSAny {
  tail WasmTrap(SmiConstant(MessageTemplate::kWasmTrapDivUnrepresentable));
}
519

520 521 522
builtin ThrowWasmTrapRemByZero(): JSAny {
  tail WasmTrap(SmiConstant(MessageTemplate::kWasmTrapRemByZero));
}
523

524 525 526
builtin ThrowWasmTrapFloatUnrepresentable(): JSAny {
  tail WasmTrap(SmiConstant(MessageTemplate::kWasmTrapFloatUnrepresentable));
}
527

528 529 530
builtin ThrowWasmTrapFuncSigMismatch(): JSAny {
  tail WasmTrap(SmiConstant(MessageTemplate::kWasmTrapFuncSigMismatch));
}
531

532 533 534
builtin ThrowWasmTrapDataSegmentDropped(): JSAny {
  tail WasmTrap(SmiConstant(MessageTemplate::kWasmTrapDataSegmentDropped));
}
535

536 537 538
builtin ThrowWasmTrapElemSegmentDropped(): JSAny {
  tail WasmTrap(SmiConstant(MessageTemplate::kWasmTrapElemSegmentDropped));
}
539

540 541 542
builtin ThrowWasmTrapTableOutOfBounds(): JSAny {
  tail WasmTrap(SmiConstant(MessageTemplate::kWasmTrapTableOutOfBounds));
}
543

544 545
builtin ThrowWasmTrapRethrowNull(): JSAny {
  tail WasmTrap(SmiConstant(MessageTemplate::kWasmTrapRethrowNull));
546
}
547

548 549 550
builtin ThrowWasmTrapNullDereference(): JSAny {
  tail WasmTrap(SmiConstant(MessageTemplate::kWasmTrapNullDereference));
}
551

552 553 554
builtin ThrowWasmTrapIllegalCast(): JSAny {
  tail WasmTrap(SmiConstant(MessageTemplate::kWasmTrapIllegalCast));
}
555

556 557 558
builtin ThrowWasmTrapArrayOutOfBounds(): JSAny {
  tail WasmTrap(SmiConstant(MessageTemplate::kWasmTrapArrayOutOfBounds));
}
559 560 561 562

builtin ThrowWasmTrapArrayTooLarge(): JSAny {
  tail WasmTrap(SmiConstant(MessageTemplate::kWasmTrapArrayTooLarge));
}
563
}