| Index: src/parser-thread.h
|
| diff --git a/src/parser-thread.h b/src/parser-thread.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4b237fbac158a7cba0826f06eff6ac5e2d11afcb
|
| --- /dev/null
|
| +++ b/src/parser-thread.h
|
| @@ -0,0 +1,111 @@
|
| +// 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 "api.h"
|
| +#include "unbound-queue.h"
|
| +#include "platform/condition-variable.h"
|
| +#include "preparse-data.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 FastParserThread : public Thread {
|
| + public:
|
| + // Used for signalling errors.
|
| + static const int kInvalidFunctionStart = -1;
|
| +
|
| + // Take ownership of stream.
|
| + explicit FastParserThread(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);
|
| +
|
| + ~FastParserThread() {
|
| + delete stream_;
|
| + }
|
| +
|
| + void Run();
|
| + void Produce(int start, int end, int literals, int properties,
|
| + StrictMode strict_mode);
|
| + void Consume(int* start, int* end, int* literals, int* properties,
|
| + StrictMode* strict_mode);
|
| +
|
| + PreParser::PreParseResult GetResult() const {
|
| + return result_;
|
| + }
|
| +
|
| + const SingletonLogger* recorder() const {
|
| + return &recorder_;
|
| + }
|
| +
|
| + private:
|
| + struct LazyFunction {
|
| + int start;
|
| + int end;
|
| + int literals;
|
| + int properties;
|
| + StrictMode strict_mode;
|
| + LazyFunction(int s, int e, int l, int p, StrictMode st)
|
| + : start(s), end(e), literals(l), properties(p), strict_mode(st) {}
|
| + LazyFunction()
|
| + : start(-1),
|
| + end(-1),
|
| + literals(-1),
|
| + properties(-1),
|
| + strict_mode(SLOPPY) {}
|
| + };
|
| +
|
| + Utf16CharacterStream* stream_;
|
| + SingletonLogger recorder_;
|
| + Mutex mutex_;
|
| + ConditionVariable have_data_;
|
| + UnboundQueue<LazyFunction> data_;
|
| + PreParser::PreParseResult result_;
|
| + bool allow_harmony_scoping_;
|
| + bool allow_modules_;
|
| + bool allow_natives_syntax_;
|
| + bool allow_generators_;
|
| + bool allow_for_of_;
|
| + bool allow_harmony_numeric_literals_;
|
| +};
|
| +
|
| +} } // namespace v8::internal
|
| +
|
| +#endif // V8_PARSER_THREAD_H_
|
|
|