Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: src/parser-thread.h

Issue 214883002: Two-threaded parser (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: code review (svenpanne) Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #ifndef V8_PARSER_THREAD_H_
29 #define V8_PARSER_THREAD_H_
30
31 #include "api.h"
32 #include "unbound-queue.h"
33 #include "platform/condition-variable.h"
34 #include "preparse-data.h"
35 #include "preparser.h"
36
37 // This thread does a fast pass over the source, and produced data on lazy
38 // functions. It won't interact with the V8 heap or the Isolate (for example,
39 // create or dereference Handles). This will only hold if the
40 // Utf16CharacterStream passed to the constructor does not interact with the V8
41 // heap either.
42
43 namespace v8 {
44 namespace internal {
45
46 class FastParserThread : public Thread {
47 public:
48 // Used for signalling errors.
49 static const int kInvalidFunctionStart = -1;
50
51 // Take ownership of stream.
52 explicit FastParserThread(Utf16CharacterStream* stream,
53 bool allow_harmony_scoping,
54 bool allow_modules,
55 bool allow_natives_syntax,
56 bool allow_generators,
57 bool allow_for_of,
58 bool allow_harmony_numeric_literals);
59
60 ~FastParserThread() {
61 delete stream_;
62 }
63
64 void Run();
65 void Produce(int start, int end, int literals, int properties,
66 StrictMode strict_mode);
67 void Consume(int* start, int* end, int* literals, int* properties,
68 StrictMode* strict_mode);
69
70 PreParser::PreParseResult GetResult() const {
71 return result_;
72 }
73
74 const SingletonLogger* recorder() const {
75 return &recorder_;
76 }
77
78 private:
79 struct LazyFunction {
80 int start;
81 int end;
82 int literals;
83 int properties;
84 StrictMode strict_mode;
85 LazyFunction(int s, int e, int l, int p, StrictMode st)
86 : start(s), end(e), literals(l), properties(p), strict_mode(st) {}
87 LazyFunction()
88 : start(-1),
89 end(-1),
90 literals(-1),
91 properties(-1),
92 strict_mode(SLOPPY) {}
93 };
94
95 Utf16CharacterStream* stream_;
96 SingletonLogger recorder_;
97 Mutex mutex_;
98 ConditionVariable have_data_;
99 UnboundQueue<LazyFunction> data_;
100 PreParser::PreParseResult result_;
101 bool allow_harmony_scoping_;
102 bool allow_modules_;
103 bool allow_natives_syntax_;
104 bool allow_generators_;
105 bool allow_for_of_;
106 bool allow_harmony_numeric_literals_;
107 };
108
109 } } // namespace v8::internal
110
111 #endif // V8_PARSER_THREAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698