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

Side by Side Diff: test/fuzzer/wasm-code.cc

Issue 2540133002: [wasm] Remove raw byte pointers from WasmModule (Closed)
Patch Set: Address comments Created 4 years 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/fuzzer/wasm-call.cc ('k') | test/unittests/wasm/ast-decoder-unittest.cc » ('j') | 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "include/v8.h" 8 #include "include/v8.h"
9 #include "src/isolate.h" 9 #include "src/isolate.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 if (generate_test) { 98 if (generate_test) {
99 v8::internal::OFStream os(stdout); 99 v8::internal::OFStream os(stdout);
100 os << " ])" << std::endl; 100 os << " ])" << std::endl;
101 os << " .exportFunc();" << std::endl; 101 os << " .exportFunc();" << std::endl;
102 os << " var module = builder.instantiate();" << std::endl; 102 os << " var module = builder.instantiate();" << std::endl;
103 os << " module.exports.test(1, 2, 3);" << std::endl; 103 os << " module.exports.test(1, 2, 3);" << std::endl;
104 os << "})();" << std::endl; 104 os << "})();" << std::endl;
105 } 105 }
106 106
107 ModuleWireBytes wire_bytes(buffer.begin(), buffer.end());
107 int32_t result_interpreted; 108 int32_t result_interpreted;
108 bool possible_nondeterminism = false; 109 bool possible_nondeterminism = false;
109 { 110 {
110 WasmVal args[] = {WasmVal(1), WasmVal(2), WasmVal(3)}; 111 WasmVal args[] = {WasmVal(1), WasmVal(2), WasmVal(3)};
111 result_interpreted = testing::InterpretWasmModule( 112 result_interpreted = testing::InterpretWasmModule(
112 i_isolate, &interpreter_thrower, module.get(), 0, args, 113 i_isolate, &interpreter_thrower, module.get(), wire_bytes, 0, args,
113 &possible_nondeterminism); 114 &possible_nondeterminism);
114 } 115 }
115 116
116 ErrorThrower compiler_thrower(i_isolate, "Compiler"); 117 ErrorThrower compiler_thrower(i_isolate, "Compiler");
117 v8::internal::Handle<v8::internal::JSObject> instance = 118 v8::internal::Handle<v8::internal::JSObject> instance =
118 testing::InstantiateModuleForTesting(i_isolate, &compiler_thrower, 119 testing::InstantiateModuleForTesting(i_isolate, &compiler_thrower,
119 module.get()); 120 module.get(), wire_bytes);
120 // Restore the flag. 121 // Restore the flag.
121 v8::internal::FLAG_wasm_code_fuzzer_gen_test = generate_test; 122 v8::internal::FLAG_wasm_code_fuzzer_gen_test = generate_test;
122 if (!interpreter_thrower.error()) { 123 if (!interpreter_thrower.error()) {
123 CHECK(!instance.is_null()); 124 CHECK(!instance.is_null());
124 } else { 125 } else {
125 return 0; 126 return 0;
126 } 127 }
127 int32_t result_compiled; 128 int32_t result_compiled;
128 { 129 {
129 v8::internal::Handle<v8::internal::Object> arguments[] = { 130 v8::internal::Handle<v8::internal::Object> arguments[] = {
(...skipping 13 matching lines...) Expand all
143 // result_compiled. Therefore we do not check the equality of the results 144 // result_compiled. Therefore we do not check the equality of the results
144 // if the execution may have produced a NaN at some point. 145 // if the execution may have produced a NaN at some point.
145 if (!possible_nondeterminism && (result_interpreted != result_compiled)) { 146 if (!possible_nondeterminism && (result_interpreted != result_compiled)) {
146 V8_Fatal(__FILE__, __LINE__, "WasmCodeFuzzerHash=%x", 147 V8_Fatal(__FILE__, __LINE__, "WasmCodeFuzzerHash=%x",
147 v8::internal::StringHasher::HashSequentialString( 148 v8::internal::StringHasher::HashSequentialString(
148 data, static_cast<int>(size), WASM_CODE_FUZZER_HASH_SEED)); 149 data, static_cast<int>(size), WASM_CODE_FUZZER_HASH_SEED));
149 } 150 }
150 } 151 }
151 return 0; 152 return 0;
152 } 153 }
OLDNEW
« no previous file with comments | « test/fuzzer/wasm-call.cc ('k') | test/unittests/wasm/ast-decoder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698