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

Side by Side Diff: src/parser.h

Issue 10534006: Remove TLS access for current Zone. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review. Created 8 years, 6 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
« no previous file with comments | « src/objects.h ('k') | src/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // allocated. 193 // allocated.
194 // Elements must not be NULL pointers. 194 // Elements must not be NULL pointers.
195 template <typename T, int initial_size> 195 template <typename T, int initial_size>
196 class BufferedZoneList { 196 class BufferedZoneList {
197 public: 197 public:
198 BufferedZoneList() : list_(NULL), last_(NULL) {} 198 BufferedZoneList() : list_(NULL), last_(NULL) {}
199 199
200 // Adds element at end of list. This element is buffered and can 200 // Adds element at end of list. This element is buffered and can
201 // be read using last() or removed using RemoveLast until a new Add or until 201 // be read using last() or removed using RemoveLast until a new Add or until
202 // RemoveLast or GetList has been called. 202 // RemoveLast or GetList has been called.
203 void Add(T* value) { 203 void Add(T* value, Zone* zone) {
204 if (last_ != NULL) { 204 if (last_ != NULL) {
205 if (list_ == NULL) { 205 if (list_ == NULL) {
206 list_ = new ZoneList<T*>(initial_size); 206 list_ = new(zone) ZoneList<T*>(initial_size, zone);
207 } 207 }
208 list_->Add(last_); 208 list_->Add(last_, zone);
209 } 209 }
210 last_ = value; 210 last_ = value;
211 } 211 }
212 212
213 T* last() { 213 T* last() {
214 ASSERT(last_ != NULL); 214 ASSERT(last_ != NULL);
215 return last_; 215 return last_;
216 } 216 }
217 217
218 T* RemoveLast() { 218 T* RemoveLast() {
(...skipping 24 matching lines...) Expand all
243 void Clear() { 243 void Clear() {
244 list_ = NULL; 244 list_ = NULL;
245 last_ = NULL; 245 last_ = NULL;
246 } 246 }
247 247
248 int length() { 248 int length() {
249 int length = (list_ == NULL) ? 0 : list_->length(); 249 int length = (list_ == NULL) ? 0 : list_->length();
250 return length + ((last_ == NULL) ? 0 : 1); 250 return length + ((last_ == NULL) ? 0 : 1);
251 } 251 }
252 252
253 ZoneList<T*>* GetList() { 253 ZoneList<T*>* GetList(Zone* zone) {
254 if (list_ == NULL) { 254 if (list_ == NULL) {
255 list_ = new ZoneList<T*>(initial_size); 255 list_ = new(zone) ZoneList<T*>(initial_size, zone);
256 } 256 }
257 if (last_ != NULL) { 257 if (last_ != NULL) {
258 list_->Add(last_); 258 list_->Add(last_, zone);
259 last_ = NULL; 259 last_ = NULL;
260 } 260 }
261 return list_; 261 return list_;
262 } 262 }
263 263
264 private: 264 private:
265 ZoneList<T*>* list_; 265 ZoneList<T*>* list_;
266 T* last_; 266 T* last_;
267 }; 267 };
268 268
269 269
270 // Accumulates RegExp atoms and assertions into lists of terms and alternatives. 270 // Accumulates RegExp atoms and assertions into lists of terms and alternatives.
271 class RegExpBuilder: public ZoneObject { 271 class RegExpBuilder: public ZoneObject {
272 public: 272 public:
273 explicit RegExpBuilder(Zone* zone); 273 explicit RegExpBuilder(Zone* zone);
274 void AddCharacter(uc16 character); 274 void AddCharacter(uc16 character);
275 // "Adds" an empty expression. Does nothing except consume a 275 // "Adds" an empty expression. Does nothing except consume a
276 // following quantifier 276 // following quantifier
277 void AddEmpty(); 277 void AddEmpty();
278 void AddAtom(RegExpTree* tree); 278 void AddAtom(RegExpTree* tree);
279 void AddAssertion(RegExpTree* tree); 279 void AddAssertion(RegExpTree* tree);
280 void NewAlternative(); // '|' 280 void NewAlternative(); // '|'
281 void AddQuantifierToAtom(int min, int max, RegExpQuantifier::Type type); 281 void AddQuantifierToAtom(int min, int max, RegExpQuantifier::Type type);
282 RegExpTree* ToRegExp(); 282 RegExpTree* ToRegExp();
283 283
284 private: 284 private:
285 void FlushCharacters(); 285 void FlushCharacters();
286 void FlushText(); 286 void FlushText();
287 void FlushTerms(); 287 void FlushTerms();
288 Zone* zone() { return zone_; } 288 Zone* zone() const { return zone_; }
289 289
290 Zone* zone_; 290 Zone* zone_;
291 bool pending_empty_; 291 bool pending_empty_;
292 ZoneList<uc16>* characters_; 292 ZoneList<uc16>* characters_;
293 BufferedZoneList<RegExpTree, 2> terms_; 293 BufferedZoneList<RegExpTree, 2> terms_;
294 BufferedZoneList<RegExpTree, 2> text_; 294 BufferedZoneList<RegExpTree, 2> text_;
295 BufferedZoneList<RegExpTree, 2> alternatives_; 295 BufferedZoneList<RegExpTree, 2> alternatives_;
296 #ifdef DEBUG 296 #ifdef DEBUG
297 enum {ADD_NONE, ADD_CHAR, ADD_TERM, ADD_ASSERT, ADD_ATOM} last_added_; 297 enum {ADD_NONE, ADD_CHAR, ADD_TERM, ADD_ASSERT, ADD_ATOM} last_added_;
298 #define LAST(x) last_added_ = x; 298 #define LAST(x) last_added_ = x;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 GROUPING 364 GROUPING
365 }; 365 };
366 366
367 class RegExpParserState : public ZoneObject { 367 class RegExpParserState : public ZoneObject {
368 public: 368 public:
369 RegExpParserState(RegExpParserState* previous_state, 369 RegExpParserState(RegExpParserState* previous_state,
370 SubexpressionType group_type, 370 SubexpressionType group_type,
371 int disjunction_capture_index, 371 int disjunction_capture_index,
372 Zone* zone) 372 Zone* zone)
373 : previous_state_(previous_state), 373 : previous_state_(previous_state),
374 builder_(new RegExpBuilder(zone)), 374 builder_(new(zone) RegExpBuilder(zone)),
375 group_type_(group_type), 375 group_type_(group_type),
376 disjunction_capture_index_(disjunction_capture_index) {} 376 disjunction_capture_index_(disjunction_capture_index) {}
377 // Parser state of containing expression, if any. 377 // Parser state of containing expression, if any.
378 RegExpParserState* previous_state() { return previous_state_; } 378 RegExpParserState* previous_state() { return previous_state_; }
379 bool IsSubexpression() { return previous_state_ != NULL; } 379 bool IsSubexpression() { return previous_state_ != NULL; }
380 // RegExpBuilder building this regexp's AST. 380 // RegExpBuilder building this regexp's AST.
381 RegExpBuilder* builder() { return builder_; } 381 RegExpBuilder* builder() { return builder_; }
382 // Type of regexp being parsed (parenthesized group or entire regexp). 382 // Type of regexp being parsed (parenthesized group or entire regexp).
383 SubexpressionType group_type() { return group_type_; } 383 SubexpressionType group_type() { return group_type_; }
384 // Index in captures array of first capture in this sub-expression, if any. 384 // Index in captures array of first capture in this sub-expression, if any.
385 // Also the capture index of this sub-expression itself, if group_type 385 // Also the capture index of this sub-expression itself, if group_type
386 // is CAPTURE. 386 // is CAPTURE.
387 int capture_index() { return disjunction_capture_index_; } 387 int capture_index() { return disjunction_capture_index_; }
388 388
389 private: 389 private:
390 // Linked list implementation of stack of states. 390 // Linked list implementation of stack of states.
391 RegExpParserState* previous_state_; 391 RegExpParserState* previous_state_;
392 // Builder for the stored disjunction. 392 // Builder for the stored disjunction.
393 RegExpBuilder* builder_; 393 RegExpBuilder* builder_;
394 // Stored disjunction type (capture, look-ahead or grouping), if any. 394 // Stored disjunction type (capture, look-ahead or grouping), if any.
395 SubexpressionType group_type_; 395 SubexpressionType group_type_;
396 // Stored disjunction's capture index (if any). 396 // Stored disjunction's capture index (if any).
397 int disjunction_capture_index_; 397 int disjunction_capture_index_;
398 }; 398 };
399 399
400 Isolate* isolate() { return isolate_; } 400 Isolate* isolate() { return isolate_; }
401 Zone* zone() { return isolate_->zone(); } 401 Zone* zone() const { return isolate_->zone(); }
402 402
403 uc32 current() { return current_; } 403 uc32 current() { return current_; }
404 bool has_more() { return has_more_; } 404 bool has_more() { return has_more_; }
405 bool has_next() { return next_pos_ < in()->length(); } 405 bool has_next() { return next_pos_ < in()->length(); }
406 uc32 Next(); 406 uc32 Next();
407 FlatStringReader* in() { return in_; } 407 FlatStringReader* in() { return in_; }
408 void ScanForCaptures(); 408 void ScanForCaptures();
409 409
410 Isolate* isolate_; 410 Isolate* isolate_;
411 Handle<String>* error_; 411 Handle<String>* error_;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 }; 541 };
542 542
543 543
544 544
545 545
546 FunctionLiteral* ParseLazy(CompilationInfo* info, 546 FunctionLiteral* ParseLazy(CompilationInfo* info,
547 Utf16CharacterStream* source, 547 Utf16CharacterStream* source,
548 ZoneScope* zone_scope); 548 ZoneScope* zone_scope);
549 549
550 Isolate* isolate() { return isolate_; } 550 Isolate* isolate() { return isolate_; }
551 Zone* zone() { return zone_; } 551 Zone* zone() const { return zone_; }
552 552
553 // Called by ParseProgram after setting up the scanner. 553 // Called by ParseProgram after setting up the scanner.
554 FunctionLiteral* DoParseProgram(CompilationInfo* info, 554 FunctionLiteral* DoParseProgram(CompilationInfo* info,
555 Handle<String> source, 555 Handle<String> source,
556 ZoneScope* zone_scope); 556 ZoneScope* zone_scope);
557 557
558 // Report syntax error 558 // Report syntax error
559 void ReportUnexpectedToken(Token::Value token); 559 void ReportUnexpectedToken(Token::Value token);
560 void ReportInvalidPreparseData(Handle<String> name, bool* ok); 560 void ReportInvalidPreparseData(Handle<String> name, bool* ok);
561 void ReportMessage(const char* message, Vector<const char*> args); 561 void ReportMessage(const char* message, Vector<const char*> args);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 private: 868 private:
869 static const int kTypeSlot = 0; 869 static const int kTypeSlot = 0;
870 static const int kElementsSlot = 1; 870 static const int kElementsSlot = 1;
871 871
872 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 872 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
873 }; 873 };
874 874
875 } } // namespace v8::internal 875 } } // namespace v8::internal
876 876
877 #endif // V8_PARSER_H_ 877 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698