Line data Source code
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
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_PARSING_BACKGROUND_PARSING_TASK_H_
6 : #define V8_PARSING_BACKGROUND_PARSING_TASK_H_
7 :
8 : #include <memory>
9 :
10 : #include "include/v8.h"
11 : #include "src/base/platform/platform.h"
12 : #include "src/base/platform/semaphore.h"
13 : #include "src/parsing/parse-info.h"
14 : #include "src/unicode-cache.h"
15 :
16 : namespace v8 {
17 : namespace internal {
18 :
19 : class Parser;
20 : class ScriptData;
21 :
22 : // Internal representation of v8::ScriptCompiler::StreamedSource. Contains all
23 : // data which needs to be transmitted between threads for background parsing,
24 : // finalizing it on the main thread, and compiling on the main thread.
25 220 : struct StreamedSource {
26 : StreamedSource(ScriptCompiler::ExternalSourceStream* source_stream,
27 : ScriptCompiler::StreamedSource::Encoding encoding)
28 110 : : source_stream(source_stream), encoding(encoding) {}
29 :
30 : void Release();
31 :
32 : // Internal implementation of v8::ScriptCompiler::StreamedSource.
33 : std::unique_ptr<ScriptCompiler::ExternalSourceStream> source_stream;
34 : ScriptCompiler::StreamedSource::Encoding encoding;
35 : std::unique_ptr<ScriptCompiler::CachedData> cached_data;
36 :
37 : // Data needed for parsing, and data needed to to be passed between thread
38 : // between parsing and compilation. These need to be initialized before the
39 : // compilation starts.
40 : UnicodeCache unicode_cache;
41 : std::unique_ptr<ParseInfo> info;
42 : std::unique_ptr<Parser> parser;
43 :
44 : // Prevent copying.
45 : StreamedSource(const StreamedSource&) = delete;
46 : StreamedSource& operator=(const StreamedSource&) = delete;
47 : };
48 :
49 220 : class BackgroundParsingTask : public ScriptCompiler::ScriptStreamingTask {
50 : public:
51 : BackgroundParsingTask(StreamedSource* source,
52 : ScriptCompiler::CompileOptions options, int stack_size,
53 : Isolate* isolate);
54 :
55 : virtual void Run();
56 :
57 : private:
58 : StreamedSource* source_; // Not owned.
59 : int stack_size_;
60 : ScriptData* script_data_;
61 : };
62 : } // namespace internal
63 : } // namespace v8
64 :
65 : #endif // V8_PARSING_BACKGROUND_PARSING_TASK_H_
|