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

Side by Side Diff: src/preparse-data.h

Issue 376223002: Refactor ScriptData class for cached compile data. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments, refactored test cases. Created 6 years, 5 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
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PREPARSE_DATA_H_ 5 #ifndef V8_PREPARSE_DATA_H_
6 #define V8_PREPARSE_DATA_H_ 6 #define V8_PREPARSE_DATA_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/hashmap.h" 9 #include "src/hashmap.h"
10 #include "src/preparse-data-format.h" 10 #include "src/preparse-data-format.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 int literals_; 112 int literals_;
113 int properties_; 113 int properties_;
114 StrictMode strict_mode_; 114 StrictMode strict_mode_;
115 // For error messages. 115 // For error messages.
116 const char* message_; 116 const char* message_;
117 const char* argument_opt_; 117 const char* argument_opt_;
118 bool is_reference_error_; 118 bool is_reference_error_;
119 }; 119 };
120 120
121 121
122 // Forward declaration for CompleteParserRecorder::GetScriptData.
marja 2014/07/10 08:48:11 Nit: This comment is unnecessary.
Yang 2014/07/10 10:27:58 Done.
123 class ScriptData;
124
125
122 class CompleteParserRecorder : public ParserRecorder { 126 class CompleteParserRecorder : public ParserRecorder {
123 public: 127 public:
124 struct Key { 128 struct Key {
125 bool is_one_byte; 129 bool is_one_byte;
126 Vector<const byte> literal_bytes; 130 Vector<const byte> literal_bytes;
127 }; 131 };
128 132
129 CompleteParserRecorder(); 133 CompleteParserRecorder();
130 virtual ~CompleteParserRecorder() {} 134 virtual ~CompleteParserRecorder() {}
131 135
(...skipping 10 matching lines...) Expand all
142 } 146 }
143 147
144 // Logs an error message and marks the log as containing an error. 148 // Logs an error message and marks the log as containing an error.
145 // Further logging will be ignored, and ExtractData will return a vector 149 // Further logging will be ignored, and ExtractData will return a vector
146 // representing the error only. 150 // representing the error only.
147 virtual void LogMessage(int start, 151 virtual void LogMessage(int start,
148 int end, 152 int end,
149 const char* message, 153 const char* message,
150 const char* argument_opt, 154 const char* argument_opt,
151 bool is_reference_error_); 155 bool is_reference_error_);
152 Vector<unsigned> ExtractData(); 156 ScriptData* GetScriptData();
157
158 bool HasError() {
159 return static_cast<bool>(preamble_[PreparseDataConstants::kHasErrorOffset]);
160 }
161 Vector<unsigned> ErrorMessageData() {
162 ASSERT(HasError());
163 return function_store_.ToVector();
164 }
153 165
154 private: 166 private:
155 bool has_error() {
156 return static_cast<bool>(preamble_[PreparseDataConstants::kHasErrorOffset]);
157 }
158
159 void WriteString(Vector<const char> str); 167 void WriteString(Vector<const char> str);
160 168
161 // Write a non-negative number to the symbol store. 169 // Write a non-negative number to the symbol store.
162 void WriteNumber(int number); 170 void WriteNumber(int number);
163 171
164 Collector<unsigned> function_store_; 172 Collector<unsigned> function_store_;
165 unsigned preamble_[PreparseDataConstants::kHeaderSize]; 173 unsigned preamble_[PreparseDataConstants::kHeaderSize];
166 174
167 #ifdef DEBUG 175 #ifdef DEBUG
168 int prev_start_; 176 int prev_start_;
169 #endif 177 #endif
170 }; 178 };
171 179
172 180
173 } } // namespace v8::internal. 181 } } // namespace v8::internal.
174 182
175 #endif // V8_PREPARSE_DATA_H_ 183 #endif // V8_PREPARSE_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698