Lines Matching defs:wasm

5 #include "src/wasm/wasm-objects.h"
11 #include "src/compiler/wasm-compiler.h"
21 #include "src/wasm/code-space-access.h"
22 #include "src/wasm/jump-table-assembler.h"
23 #include "src/wasm/module-compiler.h"
24 #include "src/wasm/module-decoder.h"
25 #include "src/wasm/module-instantiate.h"
26 #include "src/wasm/value-type.h"
27 #include "src/wasm/wasm-code-manager.h"
28 #include "src/wasm/wasm-engine.h"
29 #include "src/wasm/wasm-limits.h"
30 #include "src/wasm/wasm-module.h"
31 #include "src/wasm/wasm-objects-inl.h"
32 #include "src/wasm/wasm-subtyping.h"
33 #include "src/wasm/wasm-value.h"
43 // Import a few often used types from the wasm namespace.
44 using WasmFunction = wasm::WasmFunction;
45 using WasmModule = wasm::WasmModule;
101 Isolate* isolate, std::shared_ptr<wasm::NativeModule> native_module,
109 Isolate* isolate, std::shared_ptr<wasm::NativeModule> native_module,
111 Handle<Managed<wasm::NativeModule>> managed_native_module;
114 Managed<wasm::NativeModule>::cast(script->wasm_managed_native_module()),
120 wasm::WasmCodeManager::EstimateNativeModuleMetaDataSize(module);
121 managed_native_module = Managed<wasm::NativeModule>::FromSharedPtr(
134 wasm::WireBytesRef ref, InternalizeString internalize) {
143 wasm::WireBytesRef ref, InternalizeString internalize) {
169 wasm::WireBytesRef name =
171 wasm::ModuleWireBytes(module_object->native_module()->wire_bytes()),
180 if (func_index == wasm::kAnonymousFuncIndex) {
184 wasm::ModuleWireBytes wire_bytes(native_module()->wire_bytes());
185 wasm::WireBytesRef name_ref =
188 wasm::WasmName name = wire_bytes.GetNameOrNull(name_ref);
193 Isolate* isolate, Handle<WasmInstanceObject> instance, wasm::ValueType type,
200 CHECK(wasm::WasmTable::IsValidTableType(type, module));
274 STATIC_ASSERT(wasm::kV8MaxWasmTableSize <= kMaxInt / 2);
335 return wasm::TypecheckJSObject(isolate, module, entry, table->type(),
383 case wasm::HeapType::kAny:
386 case wasm::HeapType::kFunc:
389 case wasm::HeapType::kEq:
390 case wasm::HeapType::kData:
391 case wasm::HeapType::kArray:
392 case wasm::HeapType::kI31:
395 case wasm::HeapType::kBottom:
425 case wasm::HeapType::kAny:
427 case wasm::HeapType::kFunc:
430 case wasm::HeapType::kEq:
431 case wasm::HeapType::kI31:
432 case wasm::HeapType::kData:
433 case wasm::HeapType::kArray:
437 case wasm::HeapType::kBottom:
480 const wasm::WasmFunction* func,
494 // For wasm functions, just pass the target instance.
510 // TODO(7748): wasm-gc signatures cannot be canonicalized this way because
559 PodArray<wasm::ValueType> serialized_sig =
562 std::unique_ptr<wasm::ValueType[]> reps(new wasm::ValueType[total_count]);
564 static const wasm::ValueType kMarker = wasm::kWasmVoid;
573 wasm::FunctionSig sig(result_count, param_count, reps.get());
583 wasm::NativeModule* native_module =
585 wasm::WasmImportWrapperCache* cache = native_module->import_wrapper_cache();
587 wasm::WasmCode* wasm_code =
588 cache->MaybeGet(kind, &sig, param_count, wasm::kNoSuspend);
590 wasm::WasmCodeRefScope code_ref_scope;
591 wasm::WasmImportWrapperCache::ModificationScope cache_scope(cache);
593 wasm::WasmImportWrapperCache::CacheKey key(kind, &sig, param_count,
594 wasm::kNoSuspend);
653 DCHECK(wasm::IsSubtypeOf(table->type(), wasm::kWasmFuncRef, module));
782 bool is_wasm_module = instance->module()->origin == wasm::kWasmOrigin;
785 wasm::kTrapHandler;
800 for (size_t offset = 0; offset < mem_size; offset += wasm::kWasmPageSize) {
848 heuristic_maximum = static_cast<int>(wasm::max_mem_pages());
854 constexpr int kGBPages = 1024 * 1024 * 1024 / wasm::kWasmPageSize;
922 TRACE_EVENT0("v8.wasm", "wasm.GrowMemory");
932 // Note: The {wasm::max_mem_pages()} limit is already checked in
937 DCHECK_EQ(0, old_size % wasm::kWasmPageSize);
938 size_t old_pages = old_size / wasm::kWasmPageSize;
939 uint32_t max_pages = wasm::kSpecMaxMemoryPages;
956 FATAL("could not grow wasm memory");
966 size_t new_byte_length = new_pages * wasm::kWasmPageSize;
1009 FATAL("could not grow wasm memory");
1030 MaybeHandle<FixedArray> maybe_tagged_buffer, wasm::ValueType type,
1096 const wasm::WasmCode* wasm_to_js_wrapper, Handle<HeapObject> suspender) {
1101 DCHECK(wasm_to_js_wrapper->kind() == wasm::WasmCode::kWasmToJsWrapper ||
1102 wasm_to_js_wrapper->kind() == wasm::WasmCode::kWasmToCapiWrapper);
1158 CHECK_LE(mem_size, wasm::max_mem_bytes());
1264 const wasm::WasmDataSegment& segment = module->data_segments[i];
1286 wasm::WasmElemSegment::kStatusDeclarative
1293 wasm::NativeModule* native_module = module_object().native_module();
1365 return wasm::LoadElemSegment(isolate, instance, table_index, segment_index,
1413 wasm::JSToWasmWrapperCompilationUnit::CompileJSToWasmWrapper(
1434 // Lazily allocate the wasm external functions array.
1453 const wasm::FunctionSig* sig = js_function->GetSignature(&zone);
1458 wasm::WasmCodeRefScope code_ref_scope;
1461 wasm::NativeModule* native_module =
1463 // TODO(wasm): Cache and reuse wrapper code, to avoid repeated compilation
1465 const wasm::WasmFeatures enabled = native_module->enabled_features();
1471 wasm::CompilationEnv env = native_module->CreateCompilationEnv();
1479 wasm::Suspend suspend =
1481 ? wasm::kNoSuspend
1482 : wasm::kSuspend;
1484 wasm::WasmCompilationResult result = compiler::CompileWasmImportCallWrapper(
1486 wasm::CodeSpaceWriteScope write_scope(native_module);
1487 std::unique_ptr<wasm::WasmCode> wasm_code = native_module->AddCode(
1492 wasm::ExecutionTier::kNone, wasm::kNoDebugging);
1493 wasm::WasmCode* published_code =
1513 Handle<WasmInstanceObject> instance, const wasm::WasmGlobal& global) {
1526 const wasm::WasmGlobal& global) {
1542 wasm::WasmValue WasmInstanceObject::GetGlobalValue(
1543 Handle<WasmInstanceObject> instance, const wasm::WasmGlobal& global) {
1550 return wasm::WasmValue(handle(global_buffer->get(global_index), isolate),
1554 using wasm::Simd128;
1557 case wasm::valuetype: \
1558 return wasm::WasmValue(base::ReadUnalignedValue<ctype>(ptr));
1566 wasm::WasmValue WasmStruct::GetFieldValue(uint32_t index) {
1567 wasm::ValueType field_type = type()->field(index);
1570 using wasm::Simd128;
1573 case wasm::valuetype: \
1574 return wasm::WasmValue(base::ReadUnalignedValue<ctype>(field_address));
1579 case wasm::kRef:
1580 case wasm::kOptRef: {
1583 return wasm::WasmValue(ref, field_type);
1585 case wasm::kRtt:
1588 case wasm::kVoid:
1589 case wasm::kBottom:
1594 wasm::WasmValue WasmArray::GetElement(uint32_t index) {
1595 wasm::ValueType element_type = type()->element_type();
1599 using wasm::Simd128;
1602 case wasm::value_type: \
1603 return wasm::WasmValue(base::ReadUnalignedValue<ctype>(element_address));
1608 case wasm::kRef:
1609 case wasm::kOptRef: {
1612 return wasm::WasmValue(ref, element_type);
1614 case wasm::kRtt:
1617 case wasm::kVoid:
1618 case wasm::kBottom:
1625 const wasm::FunctionSig* sig,
1634 Handle<PodArray<wasm::ValueType>> serialized_sig =
1635 PodArray<wasm::ValueType>::New(isolate, sig_size, AllocationType::kOld);
1637 for (wasm::ValueType param : sig->parameters()) {
1651 bool WasmTagObject::MatchesSignature(const wasm::FunctionSig* sig) {
1665 bool WasmCapiFunction::MatchesSignature(const wasm::FunctionSig* sig) const {
1669 PodArray<wasm::ValueType> serialized_sig =
1678 if (serialized_sig.get(serialized_index) != wasm::kWasmVoid) return false;
1768 Isolate* isolate, std::unique_ptr<wasm::StackMemory> stack,
1773 wasm::JumpBuffer* jmpbuf = stack->jmpbuf();
1775 Handle<Foreign> managed_stack = Managed<wasm::StackMemory>::FromUniquePtr(
1789 Isolate* isolate, std::unique_ptr<wasm::StackMemory> stack) {
1798 std::unique_ptr<wasm::StackMemory>(wasm::StackMemory::New(isolate));
1833 size_t ComputeEncodedElementSize(wasm::ValueType type) {
1845 uint32_t WasmExceptionPackage::GetEncodedSize(const wasm::WasmTag* tag) {
1846 const wasm::WasmTagSig* sig = tag->sig;
1850 case wasm::kI32:
1851 case wasm::kF32:
1855 case wasm::kI64:
1856 case wasm::kF64:
1860 case wasm::kS128:
1864 case wasm::kRef:
1865 case wasm::kOptRef:
1868 case wasm::kRtt:
1869 case wasm::kVoid:
1870 case wasm::kBottom:
1871 case wasm::kI8:
1872 case wasm::kI16:
1907 Handle<PodArray<wasm::ValueType>> serialized_signature) {
1955 const wasm::FunctionSig* sig = instance->module()->functions[func_index].sig;
1971 reinterpret_cast<Address>(sig), wasm::kGenericWrapperBudget, rtt);
1992 case wasm::kWasmOrigin:
1995 case wasm::kAsmJsSloppyOrigin:
1998 case wasm::kAsmJsStrictOrigin:
2026 const wasm::FunctionSig* WasmExportedFunction::sig() {
2031 const WasmModule* other_module, const wasm::FunctionSig* other_sig) {
2032 const wasm::FunctionSig* sig = this->sig();
2039 if (!wasm::EquivalentTypes(sig->all()[i], other_sig->all()[i],
2049 const wasm::FunctionSig* sig) {
2050 constexpr const char kPrefix[] = "js-to-wasm:";
2067 const wasm::FunctionSig* sig,
2074 Handle<PodArray<wasm::ValueType>> serialized_sig =
2075 PodArray<wasm::ValueType>::New(isolate, sig_size, AllocationType::kOld);
2079 // TODO(wasm): Think about caching and sharing the JS-to-JS wrappers per
2101 if (wasm::WasmFeatures::FromIsolate(isolate).has_typed_funcref()) {
2113 // TODO(wasm): Think about caching and sharing the wasm-to-JS wrappers per
2115 wasm::Suspend suspend =
2116 suspender.is_null() ? wasm::kNoSuspend : wasm::kSuspend;
2156 const wasm::FunctionSig* WasmJSFunction::GetSignature(Zone* zone) {
2159 wasm::ValueType* types = zone->NewArray<wasm::ValueType>(sig_size);
2165 return zone->New<wasm::FunctionSig>(return_count, parameter_count, types);
2168 bool WasmJSFunction::MatchesSignatureForSuspend(const wasm::FunctionSig* sig) {
2182 CHECK_EQ(function_data.serialized_signature().get(0), wasm::kWasmAnyRef);
2183 const wasm::ValueType* expected = sig->all().begin();
2189 bool WasmJSFunction::MatchesSignature(const wasm::FunctionSig* sig) {
2201 const wasm::ValueType* expected = sig->all().begin();
2205 PodArray<wasm::ValueType> WasmCapiFunction::GetSerializedSignature() const {
2237 Isolate* isolate, std::shared_ptr<wasm::NativeModule> native_module,
2242 wasm::WasmCodeManager::EstimateNativeModuleCodeSize(
2243 module, kUsesLiftoff, wasm::DynamicTiering::kDisabled) +
2244 wasm::WasmCodeManager::EstimateNativeModuleMetaDataSize(module);
2245 Handle<Managed<wasm::NativeModule>> managed_native_module =
2246 Managed<wasm::NativeModule>::FromSharedPtr(isolate, memory_estimate,
2256 namespace wasm {
2294 "wrapped with the wasm object wrapper";
2311 *error_message = "object incompatible with wasm type";
2345 // TODO(manoskouk): Change this if wasm types can be exported.
2360 // TODO(manoskouk): Change this if wasm types can be exported.
2404 } // namespace wasm