Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1620)

Side by Side Diff: src/wasm/wasm-module.h

Issue 1637923002: [wasm] Factor out WasmModuleInstance from ModuleEnv. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Finish comment. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/module-decoder.cc ('k') | src/wasm/wasm-module.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "src/wasm/wasm-opcodes.h" 8 #include "src/wasm/wasm-opcodes.h"
9 #include "src/wasm/wasm-result.h" 9 #include "src/wasm/wasm-result.h"
10 10
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 bool BoundsCheck(uint32_t start, uint32_t end) { 114 bool BoundsCheck(uint32_t start, uint32_t end) {
115 size_t size = module_end - module_start; 115 size_t size = module_end - module_start;
116 return start < size && end < size; 116 return start < size && end < size;
117 } 117 }
118 118
119 // Creates a new instantiation of the module in the given isolate. 119 // Creates a new instantiation of the module in the given isolate.
120 MaybeHandle<JSObject> Instantiate(Isolate* isolate, Handle<JSObject> ffi, 120 MaybeHandle<JSObject> Instantiate(Isolate* isolate, Handle<JSObject> ffi,
121 Handle<JSArrayBuffer> memory); 121 Handle<JSArrayBuffer> memory);
122 }; 122 };
123 123
124 // An instantiated WASM module, including memory, function table, etc.
125 struct WasmModuleInstance {
126 WasmModule* module; // static representation of the module.
127 // -- Heap allocated --------------------------------------------------------
128 Handle<JSObject> js_object; // JavaScript module object.
129 Handle<Context> context; // JavaScript native context.
130 Handle<JSArrayBuffer> mem_buffer; // Handle to array buffer of memory.
131 Handle<JSArrayBuffer> globals_buffer; // Handle to array buffer of globals.
132 Handle<FixedArray> function_table; // indirect function table.
133 std::vector<Handle<Code>>* function_code; // code objects for each function.
134 // -- raw memory ------------------------------------------------------------
135 byte* mem_start; // start of linear memory.
136 size_t mem_size; // size of the linear memory.
137 // -- raw globals -----------------------------------------------------------
138 byte* globals_start; // start of the globals area.
139 size_t globals_size; // size of the globals area.
140
141 explicit WasmModuleInstance(WasmModule* m)
142 : module(m),
143 function_code(nullptr),
144 mem_start(nullptr),
145 mem_size(0),
146 globals_start(nullptr),
147 globals_size(0) {}
148 };
149
124 // forward declaration. 150 // forward declaration.
125 class WasmLinker; 151 class WasmLinker;
126 152
127 // Interface provided to the decoder/graph builder which contains only 153 // Interface provided to the decoder/graph builder which contains only
128 // minimal information about the globals, functions, and function tables. 154 // minimal information about the globals, functions, and function tables.
129 struct ModuleEnv { 155 struct ModuleEnv {
130 uintptr_t globals_area; // address of the globals area.
131 uintptr_t mem_start; // address of the start of linear memory.
132 uintptr_t mem_end; // address of the end of linear memory.
133
134 WasmModule* module; 156 WasmModule* module;
157 WasmModuleInstance* instance;
135 WasmLinker* linker; 158 WasmLinker* linker;
136 std::vector<Handle<Code>>* function_code;
137 Handle<FixedArray> function_table;
138 Handle<JSArrayBuffer> memory;
139 Handle<Context> context;
140 bool asm_js; // true if the module originated from asm.js. 159 bool asm_js; // true if the module originated from asm.js.
141 160
142 bool IsValidGlobal(uint32_t index) { 161 bool IsValidGlobal(uint32_t index) {
143 return module && index < module->globals->size(); 162 return module && index < module->globals->size();
144 } 163 }
145 bool IsValidFunction(uint32_t index) { 164 bool IsValidFunction(uint32_t index) {
146 return module && index < module->functions->size(); 165 return module && index < module->functions->size();
147 } 166 }
148 bool IsValidSignature(uint32_t index) { 167 bool IsValidSignature(uint32_t index) {
149 return module && index < module->signatures->size(); 168 return module && index < module->signatures->size();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 const byte* module_end, bool asm_js = false); 202 const byte* module_end, bool asm_js = false);
184 203
185 // For testing. Decode, verify, and run the last exported function in the 204 // For testing. Decode, verify, and run the last exported function in the
186 // given decoded module. 205 // given decoded module.
187 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module); 206 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module);
188 } // namespace wasm 207 } // namespace wasm
189 } // namespace internal 208 } // namespace internal
190 } // namespace v8 209 } // namespace v8
191 210
192 #endif // V8_WASM_MODULE_H_ 211 #endif // V8_WASM_MODULE_H_
OLDNEW
« no previous file with comments | « src/wasm/module-decoder.cc ('k') | src/wasm/wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698