OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef V8_BACKGROUND_PARSING_TASK_H_ | 5 #ifndef V8_BACKGROUND_PARSING_TASK_H_ |
6 #define V8_BACKGROUND_PARSING_TASK_H_ | 6 #define V8_BACKGROUND_PARSING_TASK_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
9 #include "src/base/platform/semaphore.h" | 11 #include "src/base/platform/semaphore.h" |
10 #include "src/base/smart-pointers.h" | |
11 #include "src/compiler.h" | 12 #include "src/compiler.h" |
12 #include "src/parsing/parser.h" | 13 #include "src/parsing/parser.h" |
13 | 14 |
14 namespace v8 { | 15 namespace v8 { |
15 namespace internal { | 16 namespace internal { |
16 | 17 |
17 // Internal representation of v8::ScriptCompiler::StreamedSource. Contains all | 18 // Internal representation of v8::ScriptCompiler::StreamedSource. Contains all |
18 // data which needs to be transmitted between threads for background parsing, | 19 // data which needs to be transmitted between threads for background parsing, |
19 // finalizing it on the main thread, and compiling on the main thread. | 20 // finalizing it on the main thread, and compiling on the main thread. |
20 struct StreamedSource { | 21 struct StreamedSource { |
21 StreamedSource(ScriptCompiler::ExternalSourceStream* source_stream, | 22 StreamedSource(ScriptCompiler::ExternalSourceStream* source_stream, |
22 ScriptCompiler::StreamedSource::Encoding encoding) | 23 ScriptCompiler::StreamedSource::Encoding encoding) |
23 : source_stream(source_stream), encoding(encoding) {} | 24 : source_stream(source_stream), encoding(encoding) {} |
24 | 25 |
25 // Internal implementation of v8::ScriptCompiler::StreamedSource. | 26 // Internal implementation of v8::ScriptCompiler::StreamedSource. |
26 base::SmartPointer<ScriptCompiler::ExternalSourceStream> source_stream; | 27 std::unique_ptr<ScriptCompiler::ExternalSourceStream> source_stream; |
27 ScriptCompiler::StreamedSource::Encoding encoding; | 28 ScriptCompiler::StreamedSource::Encoding encoding; |
28 base::SmartPointer<ScriptCompiler::CachedData> cached_data; | 29 std::unique_ptr<ScriptCompiler::CachedData> cached_data; |
29 | 30 |
30 // Data needed for parsing, and data needed to to be passed between thread | 31 // Data needed for parsing, and data needed to to be passed between thread |
31 // between parsing and compilation. These need to be initialized before the | 32 // between parsing and compilation. These need to be initialized before the |
32 // compilation starts. | 33 // compilation starts. |
33 UnicodeCache unicode_cache; | 34 UnicodeCache unicode_cache; |
34 base::SmartPointer<Zone> zone; | 35 std::unique_ptr<Zone> zone; |
35 base::SmartPointer<ParseInfo> info; | 36 std::unique_ptr<ParseInfo> info; |
36 base::SmartPointer<Parser> parser; | 37 std::unique_ptr<Parser> parser; |
37 | 38 |
38 private: | 39 private: |
39 // Prevent copying. Not implemented. | 40 // Prevent copying. Not implemented. |
40 StreamedSource(const StreamedSource&); | 41 StreamedSource(const StreamedSource&); |
41 StreamedSource& operator=(const StreamedSource&); | 42 StreamedSource& operator=(const StreamedSource&); |
42 }; | 43 }; |
43 | 44 |
44 | 45 |
45 class BackgroundParsingTask : public ScriptCompiler::ScriptStreamingTask { | 46 class BackgroundParsingTask : public ScriptCompiler::ScriptStreamingTask { |
46 public: | 47 public: |
47 BackgroundParsingTask(StreamedSource* source, | 48 BackgroundParsingTask(StreamedSource* source, |
48 ScriptCompiler::CompileOptions options, int stack_size, | 49 ScriptCompiler::CompileOptions options, int stack_size, |
49 Isolate* isolate); | 50 Isolate* isolate); |
50 | 51 |
51 virtual void Run(); | 52 virtual void Run(); |
52 | 53 |
53 private: | 54 private: |
54 StreamedSource* source_; // Not owned. | 55 StreamedSource* source_; // Not owned. |
55 int stack_size_; | 56 int stack_size_; |
56 }; | 57 }; |
57 } // namespace internal | 58 } // namespace internal |
58 } // namespace v8 | 59 } // namespace v8 |
59 | 60 |
60 #endif // V8_BACKGROUND_PARSING_TASK_H_ | 61 #endif // V8_BACKGROUND_PARSING_TASK_H_ |
OLD | NEW |