• Home
  • Raw
  • Download

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