OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_WASM_MODULE_H_ | 5 #ifndef V8_WASM_MODULE_H_ |
6 #define V8_WASM_MODULE_H_ | 6 #define V8_WASM_MODULE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/api.h" | 10 #include "src/api.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 // Static representation of a WASM export. | 131 // Static representation of a WASM export. |
132 struct WasmExport { | 132 struct WasmExport { |
133 uint32_t name_length; // length in bytes of the exported name. | 133 uint32_t name_length; // length in bytes of the exported name. |
134 uint32_t name_offset; // offset in module bytes of the name to export. | 134 uint32_t name_offset; // offset in module bytes of the name to export. |
135 WasmExternalKind kind; // kind of the export. | 135 WasmExternalKind kind; // kind of the export. |
136 uint32_t index; // index into the respective space. | 136 uint32_t index; // index into the respective space. |
137 }; | 137 }; |
138 | 138 |
139 enum ModuleOrigin : uint8_t { kWasmOrigin, kAsmJsOrigin }; | 139 enum ModuleOrigin : uint8_t { kWasmOrigin, kAsmJsOrigin }; |
| 140 |
| 141 inline bool IsWasm(ModuleOrigin Origin) { |
| 142 return Origin == ModuleOrigin::kWasmOrigin; |
| 143 } |
| 144 inline bool IsAsmJs(ModuleOrigin Origin) { |
| 145 return Origin == ModuleOrigin::kAsmJsOrigin; |
| 146 } |
| 147 |
140 struct ModuleWireBytes; | 148 struct ModuleWireBytes; |
141 | 149 |
142 // Static representation of a module. | 150 // Static representation of a module. |
143 struct V8_EXPORT_PRIVATE WasmModule { | 151 struct V8_EXPORT_PRIVATE WasmModule { |
144 static const uint32_t kPageSize = 0x10000; // Page size, 64kb. | 152 static const uint32_t kPageSize = 0x10000; // Page size, 64kb. |
145 static const uint32_t kMinMemPages = 1; // Minimum memory size = 64kb | 153 static const uint32_t kMinMemPages = 1; // Minimum memory size = 64kb |
146 | 154 |
147 Zone* owned_zone; | 155 Zone* owned_zone; |
148 uint32_t min_mem_pages = 0; // minimum size of the memory in 64k pages | 156 uint32_t min_mem_pages = 0; // minimum size of the memory in 64k pages |
149 uint32_t max_mem_pages = 0; // maximum size of the memory in 64k pages | 157 uint32_t max_mem_pages = 0; // maximum size of the memory in 64k pages |
(...skipping 27 matching lines...) Expand all Loading... |
177 std::unique_ptr<base::Semaphore> pending_tasks; | 185 std::unique_ptr<base::Semaphore> pending_tasks; |
178 | 186 |
179 WasmModule() : WasmModule(nullptr) {} | 187 WasmModule() : WasmModule(nullptr) {} |
180 WasmModule(Zone* owned_zone); | 188 WasmModule(Zone* owned_zone); |
181 ~WasmModule() { | 189 ~WasmModule() { |
182 if (owned_zone) delete owned_zone; | 190 if (owned_zone) delete owned_zone; |
183 } | 191 } |
184 | 192 |
185 ModuleOrigin get_origin() const { return origin_; } | 193 ModuleOrigin get_origin() const { return origin_; } |
186 void set_origin(ModuleOrigin new_value) { origin_ = new_value; } | 194 void set_origin(ModuleOrigin new_value) { origin_ = new_value; } |
187 bool is_wasm() const { return origin_ == kWasmOrigin; } | 195 bool is_wasm() const { return wasm::IsWasm(origin_); } |
188 bool is_asm_js() const { return origin_ == kAsmJsOrigin; } | 196 bool is_asm_js() const { return wasm::IsAsmJs(origin_); } |
189 | 197 |
190 private: | 198 private: |
191 // TODO(kschimpf) - Encapsulate more fields. | 199 // TODO(kschimpf) - Encapsulate more fields. |
192 ModuleOrigin origin_ = kWasmOrigin; // origin of the module | 200 ModuleOrigin origin_ = kWasmOrigin; // origin of the module |
193 }; | 201 }; |
194 | 202 |
195 typedef Managed<WasmModule> WasmModuleWrapper; | 203 typedef Managed<WasmModule> WasmModuleWrapper; |
196 | 204 |
197 // An instantiated WASM module, including memory, function table, etc. | 205 // An instantiated WASM module, including memory, function table, etc. |
198 struct WasmInstance { | 206 struct WasmInstance { |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 int instance_count); | 520 int instance_count); |
513 void ValidateModuleState(Isolate* isolate, Handle<WasmModuleObject> module_obj); | 521 void ValidateModuleState(Isolate* isolate, Handle<WasmModuleObject> module_obj); |
514 void ValidateOrphanedInstance(Isolate* isolate, | 522 void ValidateOrphanedInstance(Isolate* isolate, |
515 Handle<WasmInstanceObject> instance); | 523 Handle<WasmInstanceObject> instance); |
516 } // namespace testing | 524 } // namespace testing |
517 } // namespace wasm | 525 } // namespace wasm |
518 } // namespace internal | 526 } // namespace internal |
519 } // namespace v8 | 527 } // namespace v8 |
520 | 528 |
521 #endif // V8_WASM_MODULE_H_ | 529 #endif // V8_WASM_MODULE_H_ |
OLD | NEW |