/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- * vim: set ts=8 sts=2 et sw=2 tw=80: * * Copyright 2015 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/
enumclass SectionId {
Custom = 0,
Type = 1,
Import = 2,
Function = 3,
Table = 4,
Memory = 5,
Global = 6,
Export = 7,
Start = 8,
Elem = 9,
Code = 10,
Data = 11,
DataCount = 12,
Tag = 13,
};
// WebAssembly type encodings are all single-byte negative SLEB128s, hence: // forall tc:TypeCode. ((tc & SLEB128SignMask) == SLEB128SignBit staticconst uint8_t SLEB128SignMask = 0xc0; staticconst uint8_t SLEB128SignBit = 0x40;
enumclass TypeCode {
// If more "simple primitive" (non-reference, non-constructor, // non-special-purpose) types are added here then you MUST update // LowestPrimitiveTypeCode, below.
// A function pointer with any signature
FuncRef = 0x70, // SLEB128(-0x10)
// A reference to any host value.
ExternRef = 0x6f, // SLEB128(-0x11)
// A reference to any wasm gc value.
AnyRef = 0x6e, // SLEB128(-0x12)
// A reference to a struct/array value.
EqRef = 0x6d, // SLEB128(-0x13)
// Type constructor for nullable reference types.
NullableRef = 0x63, // SLEB128(-0x1D)
// Type constructor for non-nullable reference types.
Ref = 0x64, // SLEB128(-0x1C)
// A reference to an unboxed 31-bit integer.
I31Ref = 0x6c, // SLEB128(-0x14)
// A null reference in the extern hierarchy.
NullExternRef = 0x72, // SLEB128(-0x0E)
// A null reference in the func hierarchy.
NullFuncRef = 0x73, // SLEB128(-0x0D)
// A null reference in the exn hierarchy.
NullExnRef = 0x74, // SLEB128(-0x0C)
// A reference to any struct value.
StructRef = 0x6b, // SLEB128(-0x15)
// A reference to any array value.
ArrayRef = 0x6a, // SLEB128(-0x16)
// A reference to an exception value.
ExnRef = 0x69, // SLEB128(-0x17)
// A null reference in the any hierarchy.
NullAnyRef = 0x71, // SLEB128(-0x0F)
// Type constructor for function types
Func = 0x60, // SLEB128(-0x20)
// Type constructor for structure types - gc proposal Struct = 0x5f, // SLEB128(-0x21)
// Type constructor for array types - gc proposal
Array = 0x5e, // SLEB128(-0x22)
// Value for non-nullable type present.
TableHasInitExpr = 0x40,
// The 'empty' case of blocktype.
BlockVoid = 0x40, // SLEB128(-0x40)
// Type constructor for recursion groups - gc proposal
RecGroup = 0x4e, // SLEB128(-0x31)
// Type prefix for parent types - gc proposal
SubNoFinalType = 0x50, // SLEB128(-0x30)
// Type prefix for final types - gc proposal
SubFinalType = 0x4f, // SLEB128(-0x32)
Limit = 0x80
};
// This is the lowest-valued TypeCode that is a primitive type, used in // UnpackTypeCodeTypeAbstracted(). If primitive typecodes are added below any // reference typecode then the logic in that function MUST change.
// wasm traps are machine instructions that can fail to execute for reasons // that have to do with some condition in the wasm that they were compiled // from. The failure manifests as a (machine-level) exception of some sort, // which leads execution to a signal handler, and is eventually reported as a // WebAssembly.RuntimeError. Generated code may also jump to a Trap // symbolically, passing the bytecode offset to report as the trap offset. // The generated jump will be bound to a tiny stub which fills the offset and // then jumps to a per-Trap shared stub at the end of the module. // // Traps are described by a value from Trap and, in debug builds only, a value // from TrapInsn. // // * A Trap indicates why the trap has happened and is used to construct the // WebAssembly.Runtime message. // // * A TrapMachineInsn (not defined in this file) describes roughly what kind // of machine instruction has caused the trap. This is used only for // validation of trap placement in debug builds, in // ModuleGenerator::finishMetadataTier, and is not necessary for execution // of wasm code.
enumclass Trap { // The Unreachable opcode has been executed.
Unreachable, // An integer arithmetic operation led to an overflow.
IntegerOverflow, // Trying to coerce NaN to an integer.
InvalidConversionToInteger, // Integer division by zero.
IntegerDivideByZero, // Out of bounds on wasm memory accesses.
OutOfBounds, // Unaligned on wasm atomic accesses; also used for non-standard ARM // unaligned access faults.
UnalignedAccess, // call_indirect to null.
IndirectCallToNull, // call_indirect signature mismatch.
IndirectCallBadSig, // Dereference null pointer in operation on (Ref T)
NullPointerDereference, // Failed to cast a (Ref T) in a ref.cast instruction
BadCast,
// The internal stack space was exhausted. For compatibility, this throws // the same over-recursed error as JS.
StackOverflow,
// The wasm execution has potentially run too long and the engine must call // CheckForInterrupt(). This trap is resumable.
CheckInterrupt,
// Signal an error that was reported in C++ code.
ThrowReported,
Limit
};
enumclass DefinitionKind {
Function = 0x00,
Table = 0x01,
Memory = 0x02,
Global = 0x03,
Tag = 0x04,
};
// Opcode list from the SIMD proposal post-renumbering in May, 2020.
// Opcodes with suffix 'Experimental' are proposed but not standardized, and are // compatible with those same opcodes in V8. No opcode labeled 'Experimental' // will ship in a Release build where SIMD is enabled by default.
// ------------------------------------------------------------------------ // These are part/suffix of the MozOp::CallBuiltinModuleFunc operators that are // emitted internally when compiling intrinsic modules and are rejected by wasm // validation. // See wasm/WasmBuiltinModule.yaml for the list. #define VISIT_BUILTIN_FUNC(op, export, sa_name, abitype, entry, uses_memory, \
inline_op, idx) \
op = idx + 1, // NOLINT
FOR_EACH_BUILTIN_MODULE_FUNC(VISIT_BUILTIN_FUNC) #undef VISIT_BUILTIN_FUNC
enumclass MozOp { // ------------------------------------------------------------------------ // These operators are emitted internally when compiling asm.js and are // rejected by wasm validation. They are prefixed by MozPrefix.
// asm.js-specific operators. They start at 1 so as to check for // uninitialized (zeroed) storage.
TeeGlobal = 0x01,
I32Min,
I32Max,
I32Neg,
I32BitNot,
I32Abs,
F32TeeStoreF64,
F64TeeStoreF32,
I32TeeStore8,
I32TeeStore16,
I64TeeStore8,
I64TeeStore16,
I64TeeStore32,
I32TeeStore,
I64TeeStore,
F32TeeStore,
F64TeeStore,
F64Mod,
F64SinNative,
F64SinFdlibm,
F64CosNative,
F64CosFdlibm,
F64TanNative,
F64TanFdlibm,
F64Asin,
F64Acos,
F64Atan,
F64Exp,
F64Log,
F64Pow,
F64Atan2,
// asm.js-style call_indirect with the callee evaluated first.
OldCallDirect,
OldCallIndirect,
// Call a builtin module funcs. The operator has argument leb u32 to specify // particular operation id. See BuiltinModuleFuncId above.
CallBuiltinModuleFunc,
StackSwitch,
Limit
};
struct OpBytes { // b0 is a byte value but has a 16-bit representation to allow for a full // 256-value range plus a sentinel Limit value.
uint16_t b0; // b1 is a LEB128 value but 32 bits is enough for now.
uint32_t b1;
// Whether this opcode should have a breakpoint site inserted directly before // the opcode in baseline when debugging. We use this as a heuristic to // reduce the number of breakpoint sites. bool shouldHaveBreakpoint() const { switch (Op(b0)) { // Block-like instructions don't get their own breakpoint site, a // breakpoint can be used on instructions in the block. case Op::Block: case Op::Loop: case Op::If: case Op::Else: case Op::Try: case Op::Delegate: case Op::Catch: case Op::CatchAll: case Op::End: // Effect-less instructions without inputs are leaf nodes in expressions, // a breakpoint can be used on instructions that consume these values. case Op::LocalGet: case Op::GlobalGet: case Op::I32Const: case Op::I64Const: case Op::F32Const: case Op::F64Const: case Op::RefNull: case Op::Drop: returnfalse; default: returntrue;
}
}
#ifdef DEBUG // Defined in WasmOpIter.cpp constchar* toString() const; #endif
};
// Maximum payload size, in bytes, of a gc-proposal Array. Puts it fairly // close to 2^31 without exposing us to potential danger at the signed-i32 // wraparound boundary. Note that gc-proposal Struct sizes are limited by // MaxStructFields above. Some code assumes that the payload size will fit in // a uint32_t, hence the static assert. staticconstunsigned MaxArrayPayloadBytes = 1987654321;
static_assert(uint64_t(MaxArrayPayloadBytes) <
(uint64_t(1) << (8 * sizeof(uint32_t))));
// These limits pertain to our WebAssembly implementation only.
// 512KiB should be enough, considering how Rabaldr uses the stack and // what the standard limits are: // // - 1,000 parameters // - 50,000 locals // - 10,000 values on the eval stack (not an official limit) // // At sizeof(int64) bytes per slot this works out to about 480KiB.
staticconstunsigned MaxFrameSize = 512 * 1024;
// Limit for the amount of stacks present in the runtime. staticconst size_t SuspendableStacksMaxCount = 100;
// Max size of an allocated stack. staticconst size_t SuspendableStackSize = 0x100000;
// Size of additional space at the top of a suspendable stack. // The space is allocated to C++ handlers such as error/trap handlers, // or stack snapshots utilities. staticconst size_t SuspendableRedZoneSize = 0x6000;
// Total size of a suspendable stack to be reserved. static constexpr size_t SuspendableStackPlusRedZoneSize =
SuspendableStackSize + SuspendableRedZoneSize;
// Asserted by Decoder::readVarU32.
staticconstunsigned MaxVarU32DecodedBytes = 5;
// The CompileMode controls how compilation of a module is performed. enumclass CompileMode { // Compile the module just once using a given tier.
Once, // Compile the module first with baseline, then eagerly launch an ion // background compile to compile the module again.
EagerTiering, // Compile the module first with baseline, then lazily compile functions with // ion when they trigger a hotness threshold.
LazyTiering,
};
// CompileState tracks where in the compilation process we are for a module. enumclass CompileState { // We're compiling the module using the 'once' mode.
Once, // We're compiling the module using the eager tiering mode. We're // currently compiling the first tier. The second tier task will be launched // once we're done compiling the first tier.
EagerTier1, // We're compiling the module using the eager tiering mode. We're now // compiling the second tier.
EagerTier2, // We're compiling the module eagerly using the lazy tiering mode. We're // compiling the first tier.
LazyTier1, // We're compiling the module eagerly using the lazy tiering strategy. We're // compiling the second tier.
LazyTier2,
};
// Typed enum for whether debugging is enabled.
enumclass DebugEnabled { False, True };
} // namespace wasm
} // namespace js
#endif// wasm_constants_h
Messung V0.5
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.