OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |