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

Side by Side Diff: test/cctest/wasm/test-run-wasm-interpreter.cc

Issue 2341653002: [wasm] Implement GrowMemory in the wasm interpreter (Closed)
Patch Set: Add comment Created 4 years, 3 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/wasm-interpreter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 #include <stdint.h> 5 #include <stdint.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 279
280 // Check the thread finished with the right value. 280 // Check the thread finished with the right value.
281 CHECK_EQ(WasmInterpreter::FINISHED, thread->state()); 281 CHECK_EQ(WasmInterpreter::FINISHED, thread->state());
282 uint32_t expected = (*a) & (b); 282 uint32_t expected = (*a) & (b);
283 CHECK_EQ(expected, thread->GetReturnValue().to<uint32_t>()); 283 CHECK_EQ(expected, thread->GetReturnValue().to<uint32_t>());
284 } 284 }
285 } 285 }
286 } 286 }
287 } 287 }
288 288
289 TEST(GrowMemory) {
290 TestingModule module(kExecuteInterpreted);
291 WasmRunner<int32_t> r(&module, MachineType::Uint32());
292 module.AddMemory(WasmModule::kPageSize);
293 BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0)));
294 CHECK_EQ(1, r.Call(1));
295 }
296
297 TEST(GrowMemoryPreservesData) {
298 int32_t index = 16;
299 int32_t value = 2335;
300 TestingModule module(kExecuteInterpreted);
301 WasmRunner<int32_t> r(&module, MachineType::Uint32());
302 module.AddMemory(WasmModule::kPageSize);
303 BUILD(r, WASM_BLOCK(WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index),
304 WASM_I32V(value)),
305 WASM_GROW_MEMORY(WASM_GET_LOCAL(0)),
306 WASM_LOAD_MEM(MachineType::Int32(), WASM_I32V(index))));
307 CHECK_EQ(value, r.Call(1));
308 }
289 } // namespace wasm 309 } // namespace wasm
290 } // namespace internal 310 } // namespace internal
291 } // namespace v8 311 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/wasm-interpreter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698