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

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

Issue 2594993002: [wasm] Rename wasm::LocalType to wasm::ValueType and kAst* to kWasm* (Closed)
Patch Set: Fix inspector tests 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/common/wasm/test-signatures.h ('k') | test/inspector/debugger/wasm-scripts.js » ('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 17 matching lines...) Expand all
28 // that a value of type V can be read without problems. 28 // that a value of type V can be read without problems.
29 *ok &= (*size > sizeof(V)); 29 *ok &= (*size > sizeof(V));
30 if (!(*ok)) return 0; 30 if (!(*ok)) return 0;
31 V result = v8::internal::ReadLittleEndianValue<V>(*data); 31 V result = v8::internal::ReadLittleEndianValue<V>(*data);
32 *data += sizeof(V); 32 *data += sizeof(V);
33 *size -= sizeof(V); 33 *size -= sizeof(V);
34 return result; 34 return result;
35 } 35 }
36 36
37 static void add_argument( 37 static void add_argument(
38 v8::internal::Isolate* isolate, LocalType type, WasmVal* interpreter_args, 38 v8::internal::Isolate* isolate, ValueType type, WasmVal* interpreter_args,
39 v8::internal::Handle<v8::internal::Object>* compiled_args, int* argc, 39 v8::internal::Handle<v8::internal::Object>* compiled_args, int* argc,
40 const uint8_t** data, size_t* size, bool* ok) { 40 const uint8_t** data, size_t* size, bool* ok) {
41 if (!(*ok)) return; 41 if (!(*ok)) return;
42 switch (type) { 42 switch (type) {
43 case kAstF32: { 43 case kWasmF32: {
44 float value = read_value<float>(data, size, ok); 44 float value = read_value<float>(data, size, ok);
45 interpreter_args[*argc] = WasmVal(value); 45 interpreter_args[*argc] = WasmVal(value);
46 compiled_args[*argc] = 46 compiled_args[*argc] =
47 isolate->factory()->NewNumber(static_cast<double>(value)); 47 isolate->factory()->NewNumber(static_cast<double>(value));
48 break; 48 break;
49 } 49 }
50 case kAstF64: { 50 case kWasmF64: {
51 double value = read_value<double>(data, size, ok); 51 double value = read_value<double>(data, size, ok);
52 interpreter_args[*argc] = WasmVal(value); 52 interpreter_args[*argc] = WasmVal(value);
53 compiled_args[*argc] = isolate->factory()->NewNumber(value); 53 compiled_args[*argc] = isolate->factory()->NewNumber(value);
54 break; 54 break;
55 } 55 }
56 case kAstI32: { 56 case kWasmI32: {
57 int32_t value = read_value<int32_t>(data, size, ok); 57 int32_t value = read_value<int32_t>(data, size, ok);
58 interpreter_args[*argc] = WasmVal(value); 58 interpreter_args[*argc] = WasmVal(value);
59 compiled_args[*argc] = 59 compiled_args[*argc] =
60 isolate->factory()->NewNumber(static_cast<double>(value)); 60 isolate->factory()->NewNumber(static_cast<double>(value));
61 break; 61 break;
62 } 62 }
63 default: 63 default:
64 UNREACHABLE(); 64 UNREACHABLE();
65 } 65 }
66 (*argc)++; 66 (*argc)++;
(...skipping 15 matching lines...) Expand all
82 v8::Context::Scope context_scope(support->GetContext()); 82 v8::Context::Scope context_scope(support->GetContext());
83 v8::TryCatch try_catch(isolate); 83 v8::TryCatch try_catch(isolate);
84 84
85 v8::internal::AccountingAllocator allocator; 85 v8::internal::AccountingAllocator allocator;
86 v8::internal::Zone zone(&allocator, ZONE_NAME); 86 v8::internal::Zone zone(&allocator, ZONE_NAME);
87 87
88 bool ok = true; 88 bool ok = true;
89 uint8_t num_functions = 89 uint8_t num_functions =
90 (read_value<uint8_t>(&data, &size, &ok) % MAX_NUM_FUNCTIONS) + 1; 90 (read_value<uint8_t>(&data, &size, &ok) % MAX_NUM_FUNCTIONS) + 1;
91 91
92 LocalType types[] = {kAstF32, kAstF64, kAstI32, kAstI64}; 92 ValueType types[] = {kWasmF32, kWasmF64, kWasmI32, kWasmI64};
93 WasmVal interpreter_args[3]; 93 WasmVal interpreter_args[3];
94 v8::internal::Handle<v8::internal::Object> compiled_args[3]; 94 v8::internal::Handle<v8::internal::Object> compiled_args[3];
95 int argc = 0; 95 int argc = 0;
96 96
97 WasmModuleBuilder builder(&zone); 97 WasmModuleBuilder builder(&zone);
98 for (int fun = 0; fun < num_functions; fun++) { 98 for (int fun = 0; fun < num_functions; fun++) {
99 size_t num_params = static_cast<size_t>( 99 size_t num_params = static_cast<size_t>(
100 (read_value<uint8_t>(&data, &size, &ok) % MAX_NUM_PARAMS) + 1); 100 (read_value<uint8_t>(&data, &size, &ok) % MAX_NUM_PARAMS) + 1);
101 FunctionSig::Builder sig_builder(&zone, 1, num_params); 101 FunctionSig::Builder sig_builder(&zone, 1, num_params);
102 sig_builder.AddReturn(kAstI32); 102 sig_builder.AddReturn(kWasmI32);
103 for (size_t param = 0; param < num_params; param++) { 103 for (size_t param = 0; param < num_params; param++) {
104 // The main function cannot handle int64 parameters. 104 // The main function cannot handle int64 parameters.
105 LocalType param_type = types[(read_value<uint8_t>(&data, &size, &ok) % 105 ValueType param_type = types[(read_value<uint8_t>(&data, &size, &ok) %
106 (arraysize(types) - (fun == 0 ? 1 : 0)))]; 106 (arraysize(types) - (fun == 0 ? 1 : 0)))];
107 sig_builder.AddParam(param_type); 107 sig_builder.AddParam(param_type);
108 if (fun == 0) { 108 if (fun == 0) {
109 add_argument(i_isolate, param_type, interpreter_args, compiled_args, 109 add_argument(i_isolate, param_type, interpreter_args, compiled_args,
110 &argc, &data, &size, &ok); 110 &argc, &data, &size, &ok);
111 } 111 }
112 } 112 }
113 v8::internal::wasm::WasmFunctionBuilder* f = 113 v8::internal::wasm::WasmFunctionBuilder* f =
114 builder.AddFunction(sig_builder.Build()); 114 builder.AddFunction(sig_builder.Build());
115 uint32_t code_size = static_cast<uint32_t>(size / num_functions); 115 uint32_t code_size = static_cast<uint32_t>(size / num_functions);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // result_compiled. Therefore we do not check the equality of the results 175 // result_compiled. Therefore we do not check the equality of the results
176 // if the execution may have produced a NaN at some point. 176 // if the execution may have produced a NaN at some point.
177 if (!possible_nondeterminism && (result_interpreted != result_compiled)) { 177 if (!possible_nondeterminism && (result_interpreted != result_compiled)) {
178 V8_Fatal(__FILE__, __LINE__, "WasmCodeFuzzerHash=%x", 178 V8_Fatal(__FILE__, __LINE__, "WasmCodeFuzzerHash=%x",
179 v8::internal::StringHasher::HashSequentialString( 179 v8::internal::StringHasher::HashSequentialString(
180 data, static_cast<int>(size), WASM_CODE_FUZZER_HASH_SEED)); 180 data, static_cast<int>(size), WASM_CODE_FUZZER_HASH_SEED));
181 } 181 }
182 } 182 }
183 return 0; 183 return 0;
184 } 184 }
OLDNEW
« no previous file with comments | « test/common/wasm/test-signatures.h ('k') | test/inspector/debugger/wasm-scripts.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698