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

Side by Side Diff: test/fuzzer/wasm-section-fuzzers.cc

Issue 2344143003: Moved zones and zone related stuff in its own directory. (Closed)
Patch Set: Merge branch 'master' into zonefolder Created 4 years, 3 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/fuzzer/wasm-code.cc ('k') | test/unittests/compiler/control-equivalence-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 "test/fuzzer/wasm-section-fuzzers.h" 5 #include "test/fuzzer/wasm-section-fuzzers.h"
6 6
7 #include "include/v8.h" 7 #include "include/v8.h"
8 #include "src/isolate.h" 8 #include "src/isolate.h"
9 #include "src/wasm/encoder.h" 9 #include "src/wasm/encoder.h"
10 #include "src/wasm/wasm-module.h" 10 #include "src/wasm/wasm-module.h"
11 #include "src/zone.h" 11 #include "src/zone/accounting-allocator.h"
12 #include "src/zone/zone.h"
12 #include "test/common/wasm/wasm-module-runner.h" 13 #include "test/common/wasm/wasm-module-runner.h"
13 #include "test/fuzzer/fuzzer-support.h" 14 #include "test/fuzzer/fuzzer-support.h"
14 15
15 using namespace v8::internal::wasm; 16 using namespace v8::internal::wasm;
16 17
17 int fuzz_wasm_section(WasmSection::Code section, const uint8_t* data, 18 int fuzz_wasm_section(WasmSection::Code section, const uint8_t* data,
18 size_t size) { 19 size_t size) {
19 v8_fuzzer::FuzzerSupport* support = v8_fuzzer::FuzzerSupport::Get(); 20 v8_fuzzer::FuzzerSupport* support = v8_fuzzer::FuzzerSupport::Get();
20 v8::Isolate* isolate = support->GetIsolate(); 21 v8::Isolate* isolate = support->GetIsolate();
21 v8::internal::Isolate* i_isolate = 22 v8::internal::Isolate* i_isolate =
22 reinterpret_cast<v8::internal::Isolate*>(isolate); 23 reinterpret_cast<v8::internal::Isolate*>(isolate);
23 24
24 // Clear any pending exceptions from a prior run. 25 // Clear any pending exceptions from a prior run.
25 if (i_isolate->has_pending_exception()) { 26 if (i_isolate->has_pending_exception()) {
26 i_isolate->clear_pending_exception(); 27 i_isolate->clear_pending_exception();
27 } 28 }
28 29
29 v8::Isolate::Scope isolate_scope(isolate); 30 v8::Isolate::Scope isolate_scope(isolate);
30 v8::HandleScope handle_scope(isolate); 31 v8::HandleScope handle_scope(isolate);
31 v8::Context::Scope context_scope(support->GetContext()); 32 v8::Context::Scope context_scope(support->GetContext());
32 v8::TryCatch try_catch(isolate); 33 v8::TryCatch try_catch(isolate);
33 34
34 v8::base::AccountingAllocator allocator; 35 v8::internal::AccountingAllocator allocator;
35 v8::internal::Zone zone(&allocator); 36 v8::internal::Zone zone(&allocator);
36 37
37 ZoneBuffer buffer(&zone); 38 ZoneBuffer buffer(&zone);
38 buffer.write_u32(kWasmMagic); 39 buffer.write_u32(kWasmMagic);
39 buffer.write_u32(kWasmVersion); 40 buffer.write_u32(kWasmVersion);
40 const char* name = WasmSection::getName(section); 41 const char* name = WasmSection::getName(section);
41 size_t length = WasmSection::getNameLength(section); 42 size_t length = WasmSection::getNameLength(section);
42 buffer.write_size(length); // Section name string size. 43 buffer.write_size(length); // Section name string size.
43 buffer.write(reinterpret_cast<const uint8_t*>(name), length); 44 buffer.write(reinterpret_cast<const uint8_t*>(name), length);
44 buffer.write_u32v(static_cast<uint32_t>(size)); 45 buffer.write_u32v(static_cast<uint32_t>(size));
45 buffer.write(data, size); 46 buffer.write(data, size);
46 47
47 ErrorThrower thrower(i_isolate, "decoder"); 48 ErrorThrower thrower(i_isolate, "decoder");
48 49
49 std::unique_ptr<const WasmModule> module(testing::DecodeWasmModuleForTesting( 50 std::unique_ptr<const WasmModule> module(testing::DecodeWasmModuleForTesting(
50 i_isolate, &zone, &thrower, buffer.begin(), buffer.end(), kWasmOrigin)); 51 i_isolate, &zone, &thrower, buffer.begin(), buffer.end(), kWasmOrigin));
51 52
52 return 0; 53 return 0;
53 } 54 }
OLDNEW
« no previous file with comments | « test/fuzzer/wasm-code.cc ('k') | test/unittests/compiler/control-equivalence-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698