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

Side by Side Diff: test/cctest/wasm/wasm-run-utils.h

Issue 2034093002: Implement WASM big-endian support (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Small fixes. Rebase to master Created 4 years, 6 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 | « test/cctest/wasm/test-run-wasm-64.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 #ifndef WASM_RUN_UTILS_H 5 #ifndef WASM_RUN_UTILS_H
6 #define WASM_RUN_UTILS_H 6 #define WASM_RUN_UTILS_H
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 template <typename T> 134 template <typename T>
135 T* raw_mem_end() { 135 T* raw_mem_end() {
136 DCHECK(instance->mem_start); 136 DCHECK(instance->mem_start);
137 return reinterpret_cast<T*>(instance->mem_start + instance->mem_size); 137 return reinterpret_cast<T*>(instance->mem_start + instance->mem_size);
138 } 138 }
139 139
140 template <typename T> 140 template <typename T>
141 T raw_mem_at(int i) { 141 T raw_mem_at(int i) {
142 DCHECK(instance->mem_start); 142 DCHECK(instance->mem_start);
143 return reinterpret_cast<T*>(instance->mem_start)[i]; 143 return ReadMemory(&(reinterpret_cast<T*>(instance->mem_start)[i]));
144 } 144 }
145 145
146 template <typename T> 146 template <typename T>
147 T raw_val_at(int i) { 147 T raw_val_at(int i) {
148 T val; 148 return ReadMemory(reinterpret_cast<T*>(instance->mem_start + i));
149 memcpy(&val, reinterpret_cast<void*>(instance->mem_start + i), sizeof(T)); 149 }
150 return val; 150
151 template <typename T>
152 void WriteMemory(T* p, T val) {
153 WriteLittleEndianValue<T>(p, val);
154 }
155
156 template <typename T>
157 T ReadMemory(T* p) {
158 return ReadLittleEndianValue<T>(p);
151 } 159 }
152 160
153 // Zero-initialize the memory. 161 // Zero-initialize the memory.
154 void BlankMemory() { 162 void BlankMemory() {
155 byte* raw = raw_mem_start<byte>(); 163 byte* raw = raw_mem_start<byte>();
156 memset(raw, 0, instance->mem_size); 164 memset(raw, 0, instance->mem_size);
157 } 165 }
158 166
159 // Pseudo-randomly intialize the memory. 167 // Pseudo-randomly intialize the memory.
160 void RandomizeMemory(unsigned int seed = 88) { 168 void RandomizeMemory(unsigned int seed = 88) {
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 // interpreter. 763 // interpreter.
756 #define WASM_EXEC_TEST(name) \ 764 #define WASM_EXEC_TEST(name) \
757 void RunWasm_##name(WasmExecutionMode execution_mode); \ 765 void RunWasm_##name(WasmExecutionMode execution_mode); \
758 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ 766 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \
759 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ 767 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \
760 void RunWasm_##name(WasmExecutionMode execution_mode) 768 void RunWasm_##name(WasmExecutionMode execution_mode)
761 769
762 } // namespace 770 } // namespace
763 771
764 #endif 772 #endif
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm-64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698