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

Unified Diff: src/wasm/wasm-module.cc

Issue 1597163002: wasm: change the module memory size to be multiples of the page size, 64k. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-module.h ('k') | test/mjsunit/wasm/calls.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-module.cc
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
index b0b913406395005f5c1bb418434fd0089079dc26..1002b2dfe9ff8579979c7a10b1d8fa294d1bc3b9 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -21,8 +21,8 @@ namespace wasm {
std::ostream& operator<<(std::ostream& os, const WasmModule& module) {
os << "WASM module with ";
- os << (1 << module.min_mem_size_log2) << " min mem";
- os << (1 << module.max_mem_size_log2) << " max mem";
+ os << (module.min_mem_pages * module.kPageSize) << " min mem";
+ os << (module.max_mem_pages * module.kPageSize) << " max mem";
os << module.functions.size() << " functions";
os << module.functions.size() << " globals";
os << module.functions.size() << " data segments";
@@ -167,6 +167,7 @@ size_t AllocateGlobalsOffsets(std::vector<WasmGlobal>& globals) {
void LoadDataSegments(WasmModule* module, byte* mem_addr, size_t mem_size) {
for (const WasmDataSegment& segment : module->data_segments) {
if (!segment.init) continue;
+ if (!segment.source_size) continue;
CHECK_LT(segment.dest_addr, mem_size);
CHECK_LE(segment.source_size, mem_size);
CHECK_LE(segment.dest_addr + segment.source_size, mem_size);
@@ -192,7 +193,7 @@ Handle<FixedArray> BuildFunctionTable(Isolate* isolate, WasmModule* module) {
Handle<JSArrayBuffer> NewArrayBuffer(Isolate* isolate, size_t size,
byte** backing_store) {
- if (size > (1 << WasmModule::kMaxMemSize)) {
+ if (size > (WasmModule::kMaxMemPages * WasmModule::kPageSize)) {
// TODO(titzer): lift restriction on maximum memory allocated here.
*backing_store = nullptr;
return Handle<JSArrayBuffer>::null();
@@ -234,12 +235,11 @@ bool AllocateMemory(ErrorThrower* thrower, Isolate* isolate,
DCHECK(instance->module);
DCHECK(instance->mem_buffer.is_null());
- if (instance->module->min_mem_size_log2 > WasmModule::kMaxMemSize) {
+ if (instance->module->min_mem_pages > WasmModule::kMaxMemPages) {
thrower->Error("Out of memory: wasm memory too large");
return false;
}
- instance->mem_size = static_cast<size_t>(1)
- << instance->module->min_mem_size_log2;
+ instance->mem_size = WasmModule::kPageSize * instance->module->min_mem_pages;
instance->mem_buffer =
NewArrayBuffer(isolate, instance->mem_size, &instance->mem_start);
if (!instance->mem_start) {
@@ -271,8 +271,8 @@ WasmModule::WasmModule()
: shared_isolate(nullptr),
module_start(nullptr),
module_end(nullptr),
- min_mem_size_log2(0),
- max_mem_size_log2(0),
+ min_mem_pages(0),
+ max_mem_pages(0),
mem_export(false),
mem_external(false),
start_function_index(-1),
« no previous file with comments | « src/wasm/wasm-module.h ('k') | test/mjsunit/wasm/calls.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698