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 "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/wasm-module-builder.h" | 9 #include "src/wasm/wasm-module-builder.h" |
10 #include "src/wasm/wasm-module.h" | 10 #include "src/wasm/wasm-module.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 if (i_isolate->has_pending_exception()) { | 29 if (i_isolate->has_pending_exception()) { |
30 i_isolate->clear_pending_exception(); | 30 i_isolate->clear_pending_exception(); |
31 } | 31 } |
32 | 32 |
33 v8::Isolate::Scope isolate_scope(isolate); | 33 v8::Isolate::Scope isolate_scope(isolate); |
34 v8::HandleScope handle_scope(isolate); | 34 v8::HandleScope handle_scope(isolate); |
35 v8::Context::Scope context_scope(support->GetContext()); | 35 v8::Context::Scope context_scope(support->GetContext()); |
36 v8::TryCatch try_catch(isolate); | 36 v8::TryCatch try_catch(isolate); |
37 | 37 |
38 v8::internal::AccountingAllocator allocator; | 38 v8::internal::AccountingAllocator allocator; |
39 v8::internal::Zone zone(&allocator); | 39 v8::internal::Zone zone(&allocator, ZONE_NAME); |
40 | 40 |
41 ZoneBuffer buffer(&zone); | 41 ZoneBuffer buffer(&zone); |
42 buffer.write_u32(kWasmMagic); | 42 buffer.write_u32(kWasmMagic); |
43 buffer.write_u32(kWasmVersion); | 43 buffer.write_u32(kWasmVersion); |
44 if (section == kNameSectionCode) { | 44 if (section == kNameSectionCode) { |
45 buffer.write_u8(kUnknownSectionCode); | 45 buffer.write_u8(kUnknownSectionCode); |
46 buffer.write_size(size + kNameStringLength + 1); | 46 buffer.write_size(size + kNameStringLength + 1); |
47 buffer.write_u8(kNameStringLength); | 47 buffer.write_u8(kNameStringLength); |
48 buffer.write(reinterpret_cast<const uint8_t*>(kNameString), | 48 buffer.write(reinterpret_cast<const uint8_t*>(kNameString), |
49 kNameStringLength); | 49 kNameStringLength); |
50 buffer.write(data, size); | 50 buffer.write(data, size); |
51 } else { | 51 } else { |
52 buffer.write_u8(section); | 52 buffer.write_u8(section); |
53 buffer.write_size(size); | 53 buffer.write_size(size); |
54 buffer.write(data, size); | 54 buffer.write(data, size); |
55 } | 55 } |
56 | 56 |
57 ErrorThrower thrower(i_isolate, "decoder"); | 57 ErrorThrower thrower(i_isolate, "decoder"); |
58 | 58 |
59 std::unique_ptr<const WasmModule> module(testing::DecodeWasmModuleForTesting( | 59 std::unique_ptr<const WasmModule> module(testing::DecodeWasmModuleForTesting( |
60 i_isolate, &zone, &thrower, buffer.begin(), buffer.end(), kWasmOrigin)); | 60 i_isolate, &zone, &thrower, buffer.begin(), buffer.end(), kWasmOrigin)); |
61 | 61 |
62 return 0; | 62 return 0; |
63 } | 63 } |
OLD | NEW |