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

Unified Diff: test/cctest/wasm/wasm-run-utils.h

Issue 1745863002: [wasm] Allocate WasmModule and WasmModuleInstance vectors inline. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « test/cctest/wasm/test-run-wasm-js.cc ('k') | test/unittests/wasm/ast-decoder-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/wasm/wasm-run-utils.h
diff --git a/test/cctest/wasm/wasm-run-utils.h b/test/cctest/wasm/wasm-run-utils.h
index 012cd16e0c2e8443540b9de5361f0b5d14a305d2..77e15a437460fd8169184c1a257f6dd9a07a86c2 100644
--- a/test/cctest/wasm/wasm-run-utils.h
+++ b/test/cctest/wasm/wasm-run-utils.h
@@ -89,7 +89,6 @@ class TestingModule : public ModuleEnv {
instance->globals_size = kMaxGlobalsSize;
instance->mem_start = nullptr;
instance->mem_size = 0;
- instance->function_code = nullptr;
linker = nullptr;
origin = kWasmOrigin;
memset(global_data, 0, sizeof(global_data));
@@ -99,9 +98,6 @@ class TestingModule : public ModuleEnv {
if (instance->mem_start) {
free(instance->mem_start);
}
- if (instance->function_code) {
- delete instance->function_code;
- }
}
byte* AddMemory(size_t size) {
@@ -127,11 +123,8 @@ class TestingModule : public ModuleEnv {
}
byte AddSignature(FunctionSig* sig) {
- if (!module->signatures) {
- module->signatures = new std::vector<FunctionSig*>();
- }
- module->signatures->push_back(sig);
- size_t size = module->signatures->size();
+ module->signatures.push_back(sig);
+ size_t size = module->signatures.size();
CHECK(size < 127);
return static_cast<byte>(size - 1);
}
@@ -177,23 +170,21 @@ class TestingModule : public ModuleEnv {
}
int AddFunction(FunctionSig* sig, Handle<Code> code) {
- if (module->functions == nullptr) {
- module->functions = new std::vector<WasmFunction>();
+ if (module->functions.size() == 0) {
// TODO(titzer): Reserving space here to avoid the underlying WasmFunction
// structs from moving.
- module->functions->reserve(kMaxFunctions);
- instance->function_code = new std::vector<Handle<Code>>();
+ module->functions.reserve(kMaxFunctions);
}
- uint32_t index = static_cast<uint32_t>(module->functions->size());
- module->functions->push_back(
+ uint32_t index = static_cast<uint32_t>(module->functions.size());
+ module->functions.push_back(
{sig, index, 0, 0, 0, 0, 0, 0, 0, false, false});
- instance->function_code->push_back(code);
+ instance->function_code.push_back(code);
DCHECK_LT(index, kMaxFunctions); // limited for testing.
return index;
}
void SetFunctionCode(uint32_t index, Handle<Code> code) {
- instance->function_code->at(index) = code;
+ instance->function_code[index] = code;
}
void AddIndirectFunctionTable(int* functions, int table_size) {
@@ -201,21 +192,21 @@ class TestingModule : public ModuleEnv {
Handle<FixedArray> fixed =
isolate->factory()->NewFixedArray(2 * table_size);
instance->function_table = fixed;
- module->function_table = new std::vector<uint16_t>();
+ DCHECK_EQ(0u, module->function_table.size());
for (int i = 0; i < table_size; i++) {
- module->function_table->push_back(functions[i]);
+ module->function_table.push_back(functions[i]);
}
}
void PopulateIndirectFunctionTable() {
if (instance->function_table.is_null()) return;
- int table_size = static_cast<int>(module->function_table->size());
+ int table_size = static_cast<int>(module->function_table.size());
for (int i = 0; i < table_size; i++) {
- int function_index = module->function_table->at(i);
- WasmFunction* function = &module->functions->at(function_index);
+ int function_index = module->function_table[i];
+ WasmFunction* function = &module->functions[function_index];
instance->function_table->set(i, Smi::FromInt(function->sig_index));
- instance->function_table->set(
- i + table_size, *instance->function_code->at(function_index));
+ instance->function_table->set(i + table_size,
+ *instance->function_code[function_index]);
}
}
@@ -226,16 +217,13 @@ class TestingModule : public ModuleEnv {
V8_ALIGNED(8) byte global_data[kMaxGlobalsSize]; // preallocated global data.
WasmGlobal* AddGlobal(MachineType mem_type) {
- if (!module->globals) {
- module->globals = new std::vector<WasmGlobal>();
- }
byte size = WasmOpcodes::MemSize(mem_type);
global_offset = (global_offset + size - 1) & ~(size - 1); // align
- module->globals->push_back({0, mem_type, global_offset, false});
+ module->globals.push_back({0, mem_type, global_offset, false});
global_offset += size;
// limit number of globals.
CHECK_LT(global_offset, kMaxGlobalsSize);
- return &module->globals->back();
+ return &module->globals.back();
}
};
@@ -501,7 +489,7 @@ class WasmFunctionCompiler : public HandleAndZoneScope,
WasmFunction* function() {
if (function_) return function_;
- return &testing_module_->module->functions->at(function_index_);
+ return &testing_module_->module->functions[function_index_];
}
};
« no previous file with comments | « test/cctest/wasm/test-run-wasm-js.cc ('k') | test/unittests/wasm/ast-decoder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698