Chromium Code Reviews| 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 "src/api.h" | 8 #include "src/api.h" | 
| 9 #include "src/handles.h" | 9 #include "src/handles.h" | 
| 10 #include "src/wasm/wasm-opcodes.h" | 10 #include "src/wasm/wasm-opcodes.h" | 
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 | 203 | 
| 204 // Checks the given offset range is contained within the module bytes. | 204 // Checks the given offset range is contained within the module bytes. | 
| 205 bool BoundsCheck(uint32_t start, uint32_t end) const { | 205 bool BoundsCheck(uint32_t start, uint32_t end) const { | 
| 206 size_t size = module_end - module_start; | 206 size_t size = module_end - module_start; | 
| 207 return start <= size && end <= size; | 207 return start <= size && end <= size; | 
| 208 } | 208 } | 
| 209 | 209 | 
| 210 // Creates a new instantiation of the module in the given isolate. | 210 // Creates a new instantiation of the module in the given isolate. | 
| 211 MaybeHandle<JSObject> Instantiate(Isolate* isolate, Handle<JSReceiver> ffi, | 211 MaybeHandle<JSObject> Instantiate(Isolate* isolate, Handle<JSReceiver> ffi, | 
| 212 Handle<JSArrayBuffer> memory) const; | 212 Handle<JSArrayBuffer> memory) const; | 
| 213 | |
| 214 Handle<FixedArray> Compile(Isolate* isolate) const; | |
| 213 }; | 215 }; | 
| 214 | 216 | 
| 215 // An instantiated WASM module, including memory, function table, etc. | 217 // An instantiated WASM module, including memory, function table, etc. | 
| 216 struct WasmModuleInstance { | 218 struct WasmModuleInstance { | 
| 217 const WasmModule* module; // static representation of the module. | 219 const WasmModule* module; // static representation of the module. | 
| 218 // -- Heap allocated -------------------------------------------------------- | 220 // -- Heap allocated -------------------------------------------------------- | 
| 219 Handle<JSObject> js_object; // JavaScript module object. | 221 Handle<JSObject> js_object; // JavaScript module object. | 
| 220 Handle<Context> context; // JavaScript native context. | 222 Handle<Context> context; // JavaScript native context. | 
| 221 Handle<JSArrayBuffer> mem_buffer; // Handle to array buffer of memory. | 223 Handle<JSArrayBuffer> mem_buffer; // Handle to array buffer of memory. | 
| 222 Handle<JSArrayBuffer> globals_buffer; // Handle to array buffer of globals. | 224 Handle<JSArrayBuffer> globals_buffer; // Handle to array buffer of globals. | 
| 223 Handle<FixedArray> function_table; // indirect function table. | 225 Handle<FixedArray> function_table; // indirect function table. | 
| 224 std::vector<Handle<Code>> function_code; // code objects for each function. | 226 std::vector<Handle<Code>> function_code; // code objects for each function. | 
| 225 std::vector<Handle<Code>> import_code; // code objects for each import. | 227 std::vector<Handle<Code>> import_code; // code objects for each import. | 
| 226 // -- raw memory ------------------------------------------------------------ | 228 // -- raw memory ------------------------------------------------------------ | 
| 227 byte* mem_start; // start of linear memory. | 229 byte* mem_start; // start of linear memory. | 
| 228 size_t mem_size; // size of the linear memory. | 230 uint32_t mem_size; // size of the linear memory. | 
| 
 
titzer
2016/06/16 23:12:14
I think this needs to be bigger, probably uint64_t
 
Mircea Trofin
2016/06/16 23:43:11
Oh, you mean the specific case when we allocate 4G
 
 | |
| 229 // -- raw globals ----------------------------------------------------------- | 231 // -- raw globals ----------------------------------------------------------- | 
| 230 byte* globals_start; // start of the globals area. | 232 byte* globals_start; // start of the globals area. | 
| 231 | 233 | 
| 232 explicit WasmModuleInstance(const WasmModule* m) | 234 explicit WasmModuleInstance(const WasmModule* m) | 
| 233 : module(m), | 235 : module(m), | 
| 234 function_code(m->functions.size()), | 236 function_code(m->functions.size()), | 
| 237 import_code(m->import_table.size()), | |
| 235 mem_start(nullptr), | 238 mem_start(nullptr), | 
| 236 mem_size(0), | 239 mem_size(0), | 
| 237 globals_start(nullptr) {} | 240 globals_start(nullptr) {} | 
| 238 }; | 241 }; | 
| 239 | 242 | 
| 240 // forward declaration. | 243 // forward declaration. | 
| 241 class WasmLinker; | 244 class WasmLinker; | 
| 242 | 245 | 
| 243 // Interface provided to the decoder/graph builder which contains only | 246 // Interface provided to the decoder/graph builder which contains only | 
| 244 // minimal information about the globals, functions, and function tables. | 247 // minimal information about the globals, functions, and function tables. | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 // secure. If it turns out that we need more complete checks, we could add a | 339 // secure. If it turns out that we need more complete checks, we could add a | 
| 337 // special marker as internal field, which will definitely never occur anywhere | 340 // special marker as internal field, which will definitely never occur anywhere | 
| 338 // else. | 341 // else. | 
| 339 bool IsWasmObject(Handle<JSObject> object); | 342 bool IsWasmObject(Handle<JSObject> object); | 
| 340 | 343 | 
| 341 } // namespace wasm | 344 } // namespace wasm | 
| 342 } // namespace internal | 345 } // namespace internal | 
| 343 } // namespace v8 | 346 } // namespace v8 | 
| 344 | 347 | 
| 345 #endif // V8_WASM_MODULE_H_ | 348 #endif // V8_WASM_MODULE_H_ | 
| OLD | NEW |