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.
5 #ifndef V8_BACKGROUND_PARSING_TASK_H_
6 #define V8_BACKGROUND_PARSING_TASK_H_
8 #include "src/base/platform/platform.h"
9 #include "src/base/platform/semaphore.h"
10 #include "src/compiler.h"
11 #include "src/parser.h"
12 #include "src/smart-pointers.h"
19 // Internal representation of v8::ScriptCompiler::StreamedSource. Contains all
20 // data which needs to be transmitted between threads for background parsing,
21 // finalizing it on the main thread, and compiling on the main thread.
22 struct StreamedSource {
23 StreamedSource(ScriptCompiler::ExternalSourceStream* source_stream,
24 ScriptCompiler::StreamedSource::Encoding encoding)
25 : source_stream(source_stream),
30 // Internal implementation of v8::ScriptCompiler::StreamedSource.
31 SmartPointer<ScriptCompiler::ExternalSourceStream> source_stream;
32 ScriptCompiler::StreamedSource::Encoding encoding;
33 SmartPointer<ScriptCompiler::CachedData> cached_data;
35 // Data needed for parsing, and data needed to to be passed between thread
36 // between parsing and compilation. These need to be initialized before the
37 // compilation starts.
38 UnicodeCache unicode_cache;
39 SmartPointer<CompilationInfo> info;
42 SmartPointer<Parser> parser;
45 // Prevent copying. Not implemented.
46 StreamedSource(const StreamedSource&);
47 StreamedSource& operator=(const StreamedSource&);
51 class BackgroundParsingTask : public ScriptCompiler::ScriptStreamingTask {
53 BackgroundParsingTask(StreamedSource* source,
54 ScriptCompiler::CompileOptions options, int stack_size,
60 StreamedSource* source_; // Not owned.
61 ScriptCompiler::CompileOptions options_;
65 } // namespace v8::internal
67 #endif // V8_BACKGROUND_PARSING_TASK_H_