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

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

Issue 2384483002: [wasm] Refactor handling of data segments in WasmModuleBuilder. (Closed)
Patch Set: Created 4 years, 2 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-module-builder.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 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 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "src/wasm/module-decoder.h" 8 #include "src/wasm/module-decoder.h"
9 #include "src/wasm/wasm-macro-gen.h" 9 #include "src/wasm/wasm-macro-gen.h"
10 #include "src/wasm/wasm-module-builder.h" 10 #include "src/wasm/wasm-module-builder.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 TestSignatures sigs; 103 TestSignatures sigs;
104 104
105 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); 105 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
106 WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v()); 106 WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
107 107
108 ExportAsMain(f); 108 ExportAsMain(f);
109 byte code[] = { 109 byte code[] = {
110 WASM_LOAD_MEM(MachineType::Int32(), WASM_I8(kDataSegmentDest0))}; 110 WASM_LOAD_MEM(MachineType::Int32(), WASM_I8(kDataSegmentDest0))};
111 f->EmitCode(code, sizeof(code)); 111 f->EmitCode(code, sizeof(code));
112 byte data[] = {0xaa, 0xbb, 0xcc, 0xdd}; 112 byte data[] = {0xaa, 0xbb, 0xcc, 0xdd};
113 builder->AddDataSegment(new (&zone) WasmDataSegmentEncoder( 113 builder->AddDataSegment(data, sizeof(data), kDataSegmentDest0);
114 &zone, data, sizeof(data), kDataSegmentDest0));
115 TestModule(&zone, builder, 0xddccbbaa); 114 TestModule(&zone, builder, 0xddccbbaa);
116 } 115 }
117 116
118 TEST(Run_WasmModule_CheckMemoryIsZero) { 117 TEST(Run_WasmModule_CheckMemoryIsZero) {
119 static const int kCheckSize = 16 * 1024; 118 static const int kCheckSize = 16 * 1024;
120 v8::internal::AccountingAllocator allocator; 119 v8::internal::AccountingAllocator allocator;
121 Zone zone(&allocator); 120 Zone zone(&allocator);
122 TestSignatures sigs; 121 TestSignatures sigs;
123 122
124 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); 123 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 392 }
394 393
395 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); 394 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
396 Handle<Object> params[1] = { 395 Handle<Object> params[1] = {
397 Handle<Object>(Smi::FromInt(25 * kPageSize), isolate)}; 396 Handle<Object>(Smi::FromInt(25 * kPageSize), isolate)};
398 testing::RunWasmModuleForTesting(isolate, instance, 1, params, 397 testing::RunWasmModuleForTesting(isolate, instance, 1, params,
399 ModuleOrigin::kWasmOrigin); 398 ModuleOrigin::kWasmOrigin);
400 CHECK(try_catch.HasCaught()); 399 CHECK(try_catch.HasCaught());
401 isolate->clear_pending_exception(); 400 isolate->clear_pending_exception();
402 } 401 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-module-builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698