| Index: src/parser-thread.h
|
| diff --git a/src/parser-thread.h b/src/parser-thread.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5e2431e76e6452d56cc039c5148cac25f15e5da0
|
| --- /dev/null
|
| +++ b/src/parser-thread.h
|
| @@ -0,0 +1,95 @@
|
| +// Copyright 2014 the V8 project authors. All rights reserved.
|
| +// Redistribution and use in source and binary forms, with or without
|
| +// modification, are permitted provided that the following conditions are
|
| +// met:
|
| +//
|
| +// * Redistributions of source code must retain the above copyright
|
| +// notice, this list of conditions and the following disclaimer.
|
| +// * Redistributions in binary form must reproduce the above
|
| +// copyright notice, this list of conditions and the following
|
| +// disclaimer in the documentation and/or other materials provided
|
| +// with the distribution.
|
| +// * Neither the name of Google Inc. nor the names of its
|
| +// contributors may be used to endorse or promote products derived
|
| +// from this software without specific prior written permission.
|
| +//
|
| +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| +
|
| +#ifndef V8_PARSER_THREAD_H_
|
| +#define V8_PARSER_THREAD_H_
|
| +
|
| +#include "platform.h"
|
| +#include "platform/semaphore.h"
|
| +#include "preparser.h"
|
| +
|
| +// This thread does a fast pass over the source, and produced data on lazy
|
| +// functions. It won't interact with the V8 heap or the Isolate (for example,
|
| +// create or dereference Handles). This will only hold if the
|
| +// Utf16CharacterStream passed to the constructor does not interact with the V8
|
| +// heap either.
|
| +
|
| +namespace v8 {
|
| +namespace internal {
|
| +
|
| +class BackgroundParsingTask;
|
| +class SingletonLogger;
|
| +class Utf16CharacterStream;
|
| +
|
| +class FastParserThread : public Thread {
|
| + public:
|
| + // Used for signalling errors.
|
| + static const int kInvalidFunctionStart = -1;
|
| +
|
| + FastParserThread();
|
| +
|
| + // Should be only called by the main thread. Takes ownership of the
|
| + // stream. The thread can only handle one background parsing task at a time,
|
| + // so this cannot be called again before FinishBackgroundParsing has been
|
| + // called for the current task. (For the purposes of parallel preparsing, this
|
| + // is enough; we will never have more than one script to preparse.)
|
| + void StartBackgroundParsing(Utf16CharacterStream* stream,
|
| + bool allow_harmony_scoping,
|
| + bool allow_modules,
|
| + bool allow_natives_syntax,
|
| + bool allow_generators,
|
| + bool allow_for_of,
|
| + bool allow_harmony_numeric_literals);
|
| +
|
| + void FinishBackgroundParsing();
|
| +
|
| + void Run();
|
| +
|
| + // Should only be called when no background task is in progress.
|
| + void Stop();
|
| +
|
| + // Should be only called from the background thread.
|
| + void Produce(int start, int end, int literals, int properties,
|
| + StrictMode strict_mode);
|
| +
|
| + // Should be only called by the main thread.
|
| + void Consume(int* start, int* end, int* literals, int* properties,
|
| + StrictMode* strict_mode);
|
| +
|
| + PreParser::PreParseResult result() const;
|
| + const SingletonLogger* recorder() const;
|
| +
|
| + private:
|
| + BackgroundParsingTask* current_task_;
|
| + Semaphore have_work_;
|
| + Semaphore work_done_;
|
| + bool should_stop_;
|
| +};
|
| +
|
| +} } // namespace v8::internal
|
| +
|
| +#endif // V8_PARSER_THREAD_H_
|
|
|