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

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

Issue 1780483002: [wasm] Support a two-level namespace for imports. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 WasmModule(); 135 WasmModule();
136 136
137 // Get a pointer to a string stored in the module bytes representing a name. 137 // Get a pointer to a string stored in the module bytes representing a name.
138 const char* GetName(uint32_t offset) const { 138 const char* GetName(uint32_t offset) const {
139 if (offset == 0) return "<?>"; // no name. 139 if (offset == 0) return "<?>"; // no name.
140 CHECK(BoundsCheck(offset, offset + 1)); 140 CHECK(BoundsCheck(offset, offset + 1));
141 return reinterpret_cast<const char*>(module_start + offset); 141 return reinterpret_cast<const char*>(module_start + offset);
142 } 142 }
143 143
144 // Get a pointer to a string stored in the module bytes representing a name.
145 const char* GetNameOrNull(uint32_t offset) const {
146 if (offset == 0) return nullptr; // no name.
147 CHECK(BoundsCheck(offset, offset + 1));
148 return reinterpret_cast<const char*>(module_start + offset);
149 }
150
144 // Checks the given offset range is contained within the module bytes. 151 // Checks the given offset range is contained within the module bytes.
145 bool BoundsCheck(uint32_t start, uint32_t end) const { 152 bool BoundsCheck(uint32_t start, uint32_t end) const {
146 size_t size = module_end - module_start; 153 size_t size = module_end - module_start;
147 return start < size && end < size; 154 return start < size && end < size;
148 } 155 }
149 156
150 // Creates a new instantiation of the module in the given isolate. 157 // Creates a new instantiation of the module in the given isolate.
151 MaybeHandle<JSObject> Instantiate(Isolate* isolate, Handle<JSObject> ffi, 158 MaybeHandle<JSObject> Instantiate(Isolate* isolate, Handle<JSObject> ffi,
152 Handle<JSArrayBuffer> memory); 159 Handle<JSArrayBuffer> memory);
153 }; 160 };
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 263
257 // For testing. Decode, verify, and run the last exported function in the 264 // For testing. Decode, verify, and run the last exported function in the
258 // given decoded module. 265 // given decoded module.
259 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module); 266 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module);
260 267
261 } // namespace wasm 268 } // namespace wasm
262 } // namespace internal 269 } // namespace internal
263 } // namespace v8 270 } // namespace v8
264 271
265 #endif // V8_WASM_MODULE_H_ 272 #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