// An builtin module func is a natively implemented function that may be // compiled into a 'builtin module', which may be instantiated with a provided // memory yielding an exported WebAssembly function wrapping the builtin module. class BuiltinModuleFunc { private:
SharedRecGroup recGroup_; constchar* exportName_; const SymbolicAddressSignature* sig_; bool usesMemory_;
BuiltinInlineOp inlineOp_;
public: // Default constructor so this can be used in an EnumeratedArray.
BuiltinModuleFunc() = default;
// Initialize this builtin. Must only be called once.
[[nodiscard]] bool init(const RefPtr<TypeContext>& types,
mozilla::Span<const ValType> params,
mozilla::Maybe<ValType> result, bool usesMemory, const SymbolicAddressSignature* sig,
BuiltinInlineOp inlineOp, constchar* exportName);
// The rec group for the function type for this builtin. const RecGroup* recGroup() const { return recGroup_.get(); } // The type definition for the function type for this builtin. constTypeDef* typeDef() const { return &recGroup_->type(0); } // The function type for this builtin. const FuncType* funcType() const { return &typeDef()->funcType(); }
// The name of the func as it is exported constchar* exportName() const { return exportName_; } // The signature of the builtin that implements this function. const SymbolicAddressSignature* sig() const { return sig_; } // Whether this function takes a pointer to the memory base as a hidden final // parameter. This parameter will show up in the SymbolicAddressSignature, // but not the function type. Compilers must pass the memoryBase to the // function call as the last parameter. bool usesMemory() const { return usesMemory_; } // An optional inline operation that can be used for this function instead of // calling `sig`.
BuiltinInlineOp inlineOp() const { return inlineOp_; }
};
// Static storage for all builtin module funcs in the system. class BuiltinModuleFuncs { using Storage =
mozilla::EnumeratedArray<BuiltinModuleFuncId, BuiltinModuleFunc,
size_t(BuiltinModuleFuncId::Limit)>;
Storage funcs_;
// Get the BuiltinModuleFunc for an BuiltinModuleFuncId. BuiltinModuleFuncId // must be validated. staticconst BuiltinModuleFunc& getFromId(BuiltinModuleFuncId id) { return singleton_->funcs_[id];
}
};
// Returns true if the import field matches a definition in the given builtin // module for the given definition kind. The out-params matchedFunc and // matchedFuncId are only used when kind == DefinitionKind::Function, and may // be null if the caller doesn't need them. bool ImportFieldMatchesBuiltinModuleDefinition(
mozilla::Span<constchar> importName, BuiltinModuleId module,
DefinitionKind kind, const BuiltinModuleFunc** matchedFunc = nullptr,
BuiltinModuleFuncId* matchedFuncId = nullptr);
// Compile and return the builtin module for a particular // builtin module. The `moduleMemoryImport` can be used if the builtin module // requires memory to set the import name that it will need when it is // instantiated, otherwise ("" "memory") is used instead.
[[nodiscard]] bool CompileBuiltinModule(
JSContext* cx, BuiltinModuleId module, const Import* moduleMemoryImport,
MutableHandle<WasmModuleObject*> result);
// Compile, instantiate and return the builtin module instance for a particular // builtin module.
[[nodiscard]] bool InstantiateBuiltinModule(JSContext* cx,
BuiltinModuleId module, const Import* moduleMemoryImport,
Handle<JSObject*> importObj,
MutableHandle<JSObject*> result);
} // namespace wasm
} // namespace js
#endif// wasm_builtin_module_h
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet am 2026-09-30)
¤
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.