diff options
author | Yagiz Nizipli <yagiz@nizipli.com> | 2022-11-22 09:57:37 -0500 |
---|---|---|
committer | Node.js GitHub Bot <github-bot@iojs.org> | 2022-11-27 17:27:13 +0000 |
commit | 16e03e79688d51f95dfdbc90f5b8f56e3e995c6c (patch) | |
tree | ff2da950ca09063638de42c3ba0fd05cef610698 /deps/v8/src/wasm/wasm-module.h | |
parent | fac00cd432dc28264859a7b304d9a59affbb6144 (diff) | |
download | node-new-16e03e79688d51f95dfdbc90f5b8f56e3e995c6c.tar.gz |
deps: update V8 to 10.9.194.4
PR-URL: https://github.com/nodejs/node/pull/45579
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'deps/v8/src/wasm/wasm-module.h')
-rw-r--r-- | deps/v8/src/wasm/wasm-module.h | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/deps/v8/src/wasm/wasm-module.h b/deps/v8/src/wasm/wasm-module.h index ac90527ff9..235d9de4d1 100644 --- a/deps/v8/src/wasm/wasm-module.h +++ b/deps/v8/src/wasm/wasm-module.h @@ -59,13 +59,13 @@ class WireBytesRef { // Static representation of a wasm function. struct WasmFunction { - const FunctionSig* sig; // signature of the function. - uint32_t func_index; // index into the function table. - uint32_t sig_index; // index into the signature table. - WireBytesRef code; // code of this function. - bool imported; - bool exported; - bool declared; + const FunctionSig* sig = nullptr; // signature of the function. + uint32_t func_index = 0; // index into the function table. + uint32_t sig_index = 0; // index into the signature table. + WireBytesRef code = {}; // code of this function. + bool imported = false; + bool exported = false; + bool declared = false; }; // Static representation of a wasm global variable. @@ -494,9 +494,11 @@ struct V8_EXPORT_PRIVATE WasmModule { // mutable. uint32_t untagged_globals_buffer_size = 0; uint32_t tagged_globals_buffer_size = 0; + uint32_t num_imported_globals = 0; uint32_t num_imported_mutable_globals = 0; uint32_t num_imported_functions = 0; uint32_t num_imported_tables = 0; + uint32_t num_imported_tags = 0; uint32_t num_declared_functions = 0; // excluding imported uint32_t num_exported_functions = 0; uint32_t num_declared_data_segments = 0; // From the DataCount section. @@ -508,6 +510,8 @@ struct V8_EXPORT_PRIVATE WasmModule { // ID and length). WireBytesRef name_section = {0, 0}; + AccountingAllocator* allocator() const { return signature_zone->allocator(); } + void add_type(TypeDefinition type) { types.push_back(type); // Isorecursive canonical type will be computed later. @@ -568,6 +572,36 @@ struct V8_EXPORT_PRIVATE WasmModule { isorecursive_canonical_type_ids.end()); } + bool function_was_validated(int func_index) const { + DCHECK_NOT_NULL(validated_functions); + static_assert(sizeof(validated_functions[0]) == 1); + DCHECK_LE(num_imported_functions, func_index); + int pos = func_index - num_imported_functions; + DCHECK_LE(pos, num_declared_functions); + uint8_t byte = + validated_functions[pos >> 3].load(std::memory_order_relaxed); + return byte & (1 << (pos & 7)); + } + + void set_function_validated(int func_index) const { + DCHECK_NOT_NULL(validated_functions); + DCHECK_LE(num_imported_functions, func_index); + int pos = func_index - num_imported_functions; + DCHECK_LE(pos, num_declared_functions); + std::atomic<uint8_t>* atomic_byte = &validated_functions[pos >> 3]; + uint8_t old_byte = atomic_byte->load(std::memory_order_relaxed); + uint8_t new_bit = 1 << (pos & 7); + while ((old_byte & new_bit) == 0 && + !atomic_byte->compare_exchange_weak(old_byte, old_byte | new_bit, + std::memory_order_relaxed)) { + // Retry with updated {old_byte}. + } + } + + base::Vector<const WasmFunction> declared_functions() const { + return base::VectorOf(functions) + num_imported_functions; + } + std::vector<TypeDefinition> types; // by type index // Maps each type index to its global (cross-module) canonical index as per // isorecursive type canonicalization. @@ -595,6 +629,12 @@ struct V8_EXPORT_PRIVATE WasmModule { // from asm.js. std::unique_ptr<AsmJsOffsetInformation> asm_js_offset_information; + // {validated_functions} is atomically updated when functions get validated + // (during compilation, streaming decoding, or via explicit validation). + static_assert(sizeof(std::atomic<uint8_t>) == 1); + static_assert(alignof(std::atomic<uint8_t>) == 1); + mutable std::unique_ptr<std::atomic<uint8_t>[]> validated_functions; + explicit WasmModule(std::unique_ptr<Zone> signature_zone = nullptr); WasmModule(const WasmModule&) = delete; WasmModule& operator=(const WasmModule&) = delete; |