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/fuzzer-support.h" | 5 #include "test/fuzzer/fuzzer-support.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 void* data = AllocateUninitialized(length); | 33 void* data = AllocateUninitialized(length); |
34 return data == NULL ? data : memset(data, 0, length); | 34 return data == NULL ? data : memset(data, 0, length); |
35 } | 35 } |
36 virtual void* AllocateUninitialized(size_t length) { return malloc(length); } | 36 virtual void* AllocateUninitialized(size_t length) { return malloc(length); } |
37 virtual void Free(void* data, size_t) { free(data); } | 37 virtual void Free(void* data, size_t) { free(data); } |
38 }; | 38 }; |
39 | 39 |
40 FuzzerSupport::FuzzerSupport(int* argc, char*** argv) { | 40 FuzzerSupport::FuzzerSupport(int* argc, char*** argv) { |
41 v8::internal::FLAG_expose_gc = true; | 41 v8::internal::FLAG_expose_gc = true; |
42 v8::V8::SetFlagsFromCommandLine(argc, *argv, true); | 42 v8::V8::SetFlagsFromCommandLine(argc, *argv, true); |
43 v8::V8::InitializeICU(); | 43 v8::V8::InitializeICUDefaultLocation((*argv)[0]); |
44 v8::V8::InitializeExternalStartupData((*argv)[0]); | 44 v8::V8::InitializeExternalStartupData((*argv)[0]); |
45 platform_ = v8::platform::CreateDefaultPlatform(); | 45 platform_ = v8::platform::CreateDefaultPlatform(); |
46 v8::V8::InitializePlatform(platform_); | 46 v8::V8::InitializePlatform(platform_); |
47 v8::V8::Initialize(); | 47 v8::V8::Initialize(); |
48 | 48 |
49 allocator_ = new ArrayBufferAllocator; | 49 allocator_ = new ArrayBufferAllocator; |
50 v8::Isolate::CreateParams create_params; | 50 v8::Isolate::CreateParams create_params; |
51 create_params.array_buffer_allocator = allocator_; | 51 create_params.array_buffer_allocator = allocator_; |
52 isolate_ = v8::Isolate::New(create_params); | 52 isolate_ = v8::Isolate::New(create_params); |
53 | 53 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 return handle_scope.Escape(context); | 95 return handle_scope.Escape(context); |
96 } | 96 } |
97 | 97 |
98 } // namespace v8_fuzzer | 98 } // namespace v8_fuzzer |
99 | 99 |
100 extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) { | 100 extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) { |
101 v8_fuzzer::g_fuzzer_support = new v8_fuzzer::FuzzerSupport(argc, argv); | 101 v8_fuzzer::g_fuzzer_support = new v8_fuzzer::FuzzerSupport(argc, argv); |
102 atexit(&v8_fuzzer::DeleteFuzzerSupport); | 102 atexit(&v8_fuzzer::DeleteFuzzerSupport); |
103 return 0; | 103 return 0; |
104 } | 104 } |
OLD | NEW |