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

Side by Side Diff: src/preparser.h

Issue 908173003: Parsing: Make Parser not know about Isolate during background parsing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: main thread check Created 5 years, 10 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
« no previous file with comments | « src/parser.cc ('k') | src/runtime/runtime-debug.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 // 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_PREPARSER_H 5 #ifndef V8_PREPARSER_H
6 #define V8_PREPARSER_H 6 #define V8_PREPARSER_H
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 template <typename Traits> 60 template <typename Traits>
61 class ParserBase : public Traits { 61 class ParserBase : public Traits {
62 public: 62 public:
63 // Shorten type names defined by Traits. 63 // Shorten type names defined by Traits.
64 typedef typename Traits::Type::Expression ExpressionT; 64 typedef typename Traits::Type::Expression ExpressionT;
65 typedef typename Traits::Type::Identifier IdentifierT; 65 typedef typename Traits::Type::Identifier IdentifierT;
66 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; 66 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT;
67 typedef typename Traits::Type::Literal LiteralT; 67 typedef typename Traits::Type::Literal LiteralT;
68 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; 68 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT;
69 69
70 ParserBase(Isolate* isolate, Zone* zone, Scanner* scanner, 70 ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit,
71 uintptr_t stack_limit, v8::Extension* extension, 71 v8::Extension* extension, AstValueFactory* ast_value_factory,
72 AstValueFactory* ast_value_factory, ParserRecorder* log, 72 ParserRecorder* log, typename Traits::Type::Parser this_object)
73 typename Traits::Type::Parser this_object)
74 : Traits(this_object), 73 : Traits(this_object),
75 parenthesized_function_(false), 74 parenthesized_function_(false),
76 scope_(NULL), 75 scope_(NULL),
77 function_state_(NULL), 76 function_state_(NULL),
78 extension_(extension), 77 extension_(extension),
79 fni_(NULL), 78 fni_(NULL),
80 ast_value_factory_(ast_value_factory), 79 ast_value_factory_(ast_value_factory),
81 log_(log), 80 log_(log),
82 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. 81 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly.
83 stack_limit_(stack_limit), 82 stack_limit_(stack_limit),
84 isolate_(isolate),
85 zone_(zone), 83 zone_(zone),
86 scanner_(scanner), 84 scanner_(scanner),
87 stack_overflow_(false), 85 stack_overflow_(false),
88 allow_lazy_(false), 86 allow_lazy_(false),
89 allow_natives_(false), 87 allow_natives_(false),
90 allow_harmony_arrow_functions_(false), 88 allow_harmony_arrow_functions_(false),
91 allow_harmony_object_literals_(false), 89 allow_harmony_object_literals_(false),
92 allow_harmony_sloppy_(false), 90 allow_harmony_sloppy_(false),
93 allow_harmony_computed_property_names_(false), 91 allow_harmony_computed_property_names_(false),
94 allow_harmony_rest_params_(false), 92 allow_harmony_rest_params_(false),
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 DCHECK((scope_type == FUNCTION_SCOPE && IsValidFunctionKind(kind)) || 309 DCHECK((scope_type == FUNCTION_SCOPE && IsValidFunctionKind(kind)) ||
312 kind == kNormalFunction); 310 kind == kNormalFunction);
313 Scope* result = 311 Scope* result =
314 new (zone()) Scope(zone(), parent, scope_type, ast_value_factory()); 312 new (zone()) Scope(zone(), parent, scope_type, ast_value_factory());
315 bool uninitialized_this = 313 bool uninitialized_this =
316 FLAG_experimental_classes && IsSubclassConstructor(kind); 314 FLAG_experimental_classes && IsSubclassConstructor(kind);
317 result->Initialize(uninitialized_this); 315 result->Initialize(uninitialized_this);
318 return result; 316 return result;
319 } 317 }
320 318
321 Isolate* isolate() const { return isolate_; }
322 Scanner* scanner() const { return scanner_; } 319 Scanner* scanner() const { return scanner_; }
323 AstValueFactory* ast_value_factory() const { return ast_value_factory_; } 320 AstValueFactory* ast_value_factory() const { return ast_value_factory_; }
324 int position() { return scanner_->location().beg_pos; } 321 int position() { return scanner_->location().beg_pos; }
325 int peek_position() { return scanner_->peek_location().beg_pos; } 322 int peek_position() { return scanner_->peek_location().beg_pos; }
326 bool stack_overflow() const { return stack_overflow_; } 323 bool stack_overflow() const { return stack_overflow_; }
327 void set_stack_overflow() { stack_overflow_ = true; } 324 void set_stack_overflow() { stack_overflow_ = true; }
328 Mode mode() const { return mode_; } 325 Mode mode() const { return mode_; }
329 Zone* zone() const { return zone_; } 326 Zone* zone() const { return zone_; }
330 327
331 INLINE(Token::Value peek()) { 328 INLINE(Token::Value peek()) {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 Scope* scope_; // Scope stack. 643 Scope* scope_; // Scope stack.
647 FunctionState* function_state_; // Function state stack. 644 FunctionState* function_state_; // Function state stack.
648 v8::Extension* extension_; 645 v8::Extension* extension_;
649 FuncNameInferrer* fni_; 646 FuncNameInferrer* fni_;
650 AstValueFactory* ast_value_factory_; // Not owned. 647 AstValueFactory* ast_value_factory_; // Not owned.
651 ParserRecorder* log_; 648 ParserRecorder* log_;
652 Mode mode_; 649 Mode mode_;
653 uintptr_t stack_limit_; 650 uintptr_t stack_limit_;
654 651
655 private: 652 private:
656 Isolate* isolate_;
657 Zone* zone_; 653 Zone* zone_;
658 654
659 Scanner* scanner_; 655 Scanner* scanner_;
660 bool stack_overflow_; 656 bool stack_overflow_;
661 657
662 bool allow_lazy_; 658 bool allow_lazy_;
663 bool allow_natives_; 659 bool allow_natives_;
664 bool allow_harmony_arrow_functions_; 660 bool allow_harmony_arrow_functions_;
665 bool allow_harmony_object_literals_; 661 bool allow_harmony_object_literals_;
666 bool allow_harmony_sloppy_; 662 bool allow_harmony_sloppy_;
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 public: 1496 public:
1501 typedef PreParserIdentifier Identifier; 1497 typedef PreParserIdentifier Identifier;
1502 typedef PreParserExpression Expression; 1498 typedef PreParserExpression Expression;
1503 typedef PreParserStatement Statement; 1499 typedef PreParserStatement Statement;
1504 1500
1505 enum PreParseResult { 1501 enum PreParseResult {
1506 kPreParseStackOverflow, 1502 kPreParseStackOverflow,
1507 kPreParseSuccess 1503 kPreParseSuccess
1508 }; 1504 };
1509 1505
1510 PreParser(Isolate* isolate, Zone* zone, Scanner* scanner, 1506 PreParser(Zone* zone, Scanner* scanner, AstValueFactory* ast_value_factory,
1511 AstValueFactory* ast_value_factory, ParserRecorder* log, 1507 ParserRecorder* log, uintptr_t stack_limit)
1512 uintptr_t stack_limit) 1508 : ParserBase<PreParserTraits>(zone, scanner, stack_limit, NULL,
1513 : ParserBase<PreParserTraits>(isolate, zone, scanner, stack_limit, NULL,
1514 ast_value_factory, log, this) {} 1509 ast_value_factory, log, this) {}
1515 1510
1516 // Pre-parse the program from the character stream; returns true on 1511 // Pre-parse the program from the character stream; returns true on
1517 // success (even if parsing failed, the pre-parse data successfully 1512 // success (even if parsing failed, the pre-parse data successfully
1518 // captured the syntax error), and false if a stack-overflow happened 1513 // captured the syntax error), and false if a stack-overflow happened
1519 // during parsing. 1514 // during parsing.
1520 PreParseResult PreParseProgram(int* materialized_literals = 0) { 1515 PreParseResult PreParseProgram(int* materialized_literals = 0) {
1521 Scope* scope = NewScope(scope_, SCRIPT_SCOPE); 1516 Scope* scope = NewScope(scope_, SCRIPT_SCOPE);
1522 PreParserFactory factory(NULL); 1517 PreParserFactory factory(NULL);
1523 FunctionState top_scope(&function_state_, &scope_, scope, kNormalFunction, 1518 FunctionState top_scope(&function_state_, &scope_, scope, kNormalFunction,
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after
3082 *ok = false; 3077 *ok = false;
3083 return; 3078 return;
3084 } 3079 }
3085 has_seen_constructor_ = true; 3080 has_seen_constructor_ = true;
3086 return; 3081 return;
3087 } 3082 }
3088 } 3083 }
3089 } } // v8::internal 3084 } } // v8::internal
3090 3085
3091 #endif // V8_PREPARSER_H 3086 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/runtime/runtime-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698