Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/wasm/wasm-module.h')
-rw-r--r--deps/v8/src/wasm/wasm-module.h103
1 files changed, 77 insertions, 26 deletions
diff --git a/deps/v8/src/wasm/wasm-module.h b/deps/v8/src/wasm/wasm-module.h
index 6c782607bbe..a189964ad73 100644
--- a/deps/v8/src/wasm/wasm-module.h
+++ b/deps/v8/src/wasm/wasm-module.h
@@ -12,6 +12,7 @@
#include "src/handles/handles.h"
#include "src/utils/vector.h"
#include "src/wasm/signature-map.h"
+#include "src/wasm/struct-types.h"
#include "src/wasm/wasm-constants.h"
#include "src/wasm/wasm-opcodes.h"
@@ -167,9 +168,8 @@ enum class WasmCompilationHintStrategy : uint8_t {
enum class WasmCompilationHintTier : uint8_t {
kDefault = 0,
- kInterpreter = 1,
- kBaseline = 2,
- kOptimized = 3,
+ kBaseline = 1,
+ kOptimized = 2,
};
// Static representation of a wasm compilation hint
@@ -191,34 +191,33 @@ enum ModuleOrigin : uint8_t {
struct ModuleWireBytes;
-class V8_EXPORT_PRIVATE DecodedFunctionNames {
+class V8_EXPORT_PRIVATE LazilyGeneratedNames {
public:
- WireBytesRef Lookup(const ModuleWireBytes& wire_bytes,
- uint32_t function_index,
- Vector<const WasmExport> export_table) const;
+ WireBytesRef LookupFunctionName(const ModuleWireBytes& wire_bytes,
+ uint32_t function_index,
+ Vector<const WasmExport> export_table) const;
+
+ // For memory and global.
+ std::pair<WireBytesRef, WireBytesRef> LookupNameFromImportsAndExports(
+ ImportExportKindCode kind, uint32_t index,
+ const Vector<const WasmImport> import_table,
+ const Vector<const WasmExport> export_table) const;
+
void AddForTesting(int function_index, WireBytesRef name);
private:
- // {function_names_} is populated lazily after decoding, and therefore needs a
- // mutex to protect concurrent modifications from multiple {WasmModuleObject}.
+ // {function_names_}, {global_names_} and {memory_names_} are
+ // populated lazily after decoding, and therefore need a mutex to protect
+ // concurrent modifications from multiple {WasmModuleObject}.
mutable base::Mutex mutex_;
mutable std::unique_ptr<std::unordered_map<uint32_t, WireBytesRef>>
function_names_;
-};
-
-class V8_EXPORT_PRIVATE DecodedGlobalNames {
- public:
- std::pair<WireBytesRef, WireBytesRef> Lookup(
- uint32_t global_index, Vector<const WasmImport> import_table,
- Vector<const WasmExport> export_table) const;
-
- private:
- // {global_names_} is populated lazily after decoding, and therefore needs a
- // mutex to protect concurrent modifications from multiple {WasmModuleObject}.
- mutable base::Mutex mutex_;
mutable std::unique_ptr<
std::unordered_map<uint32_t, std::pair<WireBytesRef, WireBytesRef>>>
global_names_;
+ mutable std::unique_ptr<
+ std::unordered_map<uint32_t, std::pair<WireBytesRef, WireBytesRef>>>
+ memory_names_;
};
class V8_EXPORT_PRIVATE AsmJsOffsetInformation {
@@ -249,6 +248,23 @@ class V8_EXPORT_PRIVATE AsmJsOffsetInformation {
std::unique_ptr<AsmJsOffsets> decoded_offsets_;
};
+struct TypeDefinition {
+ explicit TypeDefinition(const FunctionSig* sig) : function_sig(sig) {}
+ explicit TypeDefinition(const StructType* type) : struct_type(type) {}
+ explicit TypeDefinition(const ArrayType* type) : array_type(type) {}
+ union {
+ const FunctionSig* function_sig;
+ const StructType* struct_type;
+ const ArrayType* array_type;
+ };
+};
+
+struct V8_EXPORT_PRIVATE WasmDebugSymbols {
+ enum class Type { None, SourceMap, EmbeddedDWARF, ExternalDWARF };
+ Type type = Type::None;
+ WireBytesRef external_url;
+};
+
// Static representation of a module.
struct V8_EXPORT_PRIVATE WasmModule {
std::unique_ptr<Zone> signature_zone;
@@ -273,8 +289,44 @@ struct V8_EXPORT_PRIVATE WasmModule {
uint32_t num_declared_data_segments = 0; // From the DataCount section.
WireBytesRef code = {0, 0};
WireBytesRef name = {0, 0};
- std::vector<const FunctionSig*> signatures; // by signature index
- std::vector<uint32_t> signature_ids; // by signature index
+ std::vector<TypeDefinition> types; // by type index
+ std::vector<uint8_t> type_kinds; // by type index
+ std::vector<uint32_t> signature_ids; // by signature index
+ void add_signature(const FunctionSig* sig) {
+ types.push_back(TypeDefinition(sig));
+ type_kinds.push_back(kWasmFunctionTypeCode);
+ uint32_t canonical_id = sig ? signature_map.FindOrInsert(*sig) : 0;
+ signature_ids.push_back(canonical_id);
+ }
+ const FunctionSig* signature(uint32_t index) const {
+ DCHECK(type_kinds[index] == kWasmFunctionTypeCode);
+ return types[index].function_sig;
+ }
+ bool has_signature(uint32_t index) const {
+ return index < types.size() && type_kinds[index] == kWasmFunctionTypeCode;
+ }
+ void add_struct_type(const StructType* type) {
+ types.push_back(TypeDefinition(type));
+ type_kinds.push_back(kWasmStructTypeCode);
+ }
+ const StructType* struct_type(uint32_t index) const {
+ DCHECK(type_kinds[index] == kWasmStructTypeCode);
+ return types[index].struct_type;
+ }
+ bool has_struct(uint32_t index) const {
+ return index < types.size() && type_kinds[index] == kWasmStructTypeCode;
+ }
+ void add_array_type(const ArrayType* type) {
+ types.push_back(TypeDefinition(type));
+ type_kinds.push_back(kWasmArrayTypeCode);
+ }
+ const ArrayType* array_type(uint32_t index) const {
+ DCHECK(type_kinds[index] == kWasmArrayTypeCode);
+ return types[index].array_type;
+ }
+ bool has_array(uint32_t index) const {
+ return index < types.size() && type_kinds[index] == kWasmArrayTypeCode;
+ }
std::vector<WasmFunction> functions;
std::vector<WasmDataSegment> data_segments;
std::vector<WasmTable> tables;
@@ -286,9 +338,8 @@ struct V8_EXPORT_PRIVATE WasmModule {
SignatureMap signature_map; // canonicalizing map for signature indexes.
ModuleOrigin origin = kWasmOrigin; // origin of the module
- DecodedFunctionNames function_names;
- DecodedGlobalNames global_names;
- std::string source_map_url;
+ LazilyGeneratedNames lazily_generated_names;
+ WasmDebugSymbols debug_symbols;
// Asm.js source position information. Only available for modules compiled
// from asm.js.