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

Side by Side Diff: src/parsing/parser.h

Issue 2452403003: Changed statement ZoneList to a ZoneChunkList
Patch Set: Created 4 years, 1 month 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/isolate.cc ('k') | src/parsing/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 // 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_PARSING_PARSER_H_ 5 #ifndef V8_PARSING_PARSER_H_
6 #define V8_PARSING_PARSER_H_ 6 #define V8_PARSING_PARSER_H_
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/base/compiler-specific.h" 10 #include "src/base/compiler-specific.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 typedef const AstRawString* Identifier; 150 typedef const AstRawString* Identifier;
151 typedef v8::internal::Expression* Expression; 151 typedef v8::internal::Expression* Expression;
152 typedef v8::internal::FunctionLiteral* FunctionLiteral; 152 typedef v8::internal::FunctionLiteral* FunctionLiteral;
153 typedef ObjectLiteral::Property* ObjectLiteralProperty; 153 typedef ObjectLiteral::Property* ObjectLiteralProperty;
154 typedef ClassLiteral::Property* ClassLiteralProperty; 154 typedef ClassLiteral::Property* ClassLiteralProperty;
155 typedef ZoneList<v8::internal::Expression*>* ExpressionList; 155 typedef ZoneList<v8::internal::Expression*>* ExpressionList;
156 typedef ZoneList<ObjectLiteral::Property*>* ObjectPropertyList; 156 typedef ZoneList<ObjectLiteral::Property*>* ObjectPropertyList;
157 typedef ZoneList<ClassLiteral::Property*>* ClassPropertyList; 157 typedef ZoneList<ClassLiteral::Property*>* ClassPropertyList;
158 typedef ParserFormalParameters FormalParameters; 158 typedef ParserFormalParameters FormalParameters;
159 typedef v8::internal::Statement* Statement; 159 typedef v8::internal::Statement* Statement;
160 typedef ZoneList<v8::internal::Statement*>* StatementList; 160 typedef ZoneChunkList<v8::internal::Statement*>* StatementList;
161 typedef v8::internal::Block* Block; 161 typedef v8::internal::Block* Block;
162 typedef v8::internal::BreakableStatement* BreakableStatement; 162 typedef v8::internal::BreakableStatement* BreakableStatement;
163 typedef v8::internal::IterationStatement* IterationStatement; 163 typedef v8::internal::IterationStatement* IterationStatement;
164 164
165 // For constructing objects returned by the traversing functions. 165 // For constructing objects returned by the traversing functions.
166 typedef AstNodeFactory Factory; 166 typedef AstNodeFactory Factory;
167 167
168 typedef ParserTarget Target; 168 typedef ParserTarget Target;
169 typedef ParserTargetScope TargetScope; 169 typedef ParserTargetScope TargetScope;
170 }; 170 };
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 251 }
252 bool consume_cached_parse_data() const { 252 bool consume_cached_parse_data() const {
253 return allow_lazy() && 253 return allow_lazy() &&
254 compile_options_ == ScriptCompiler::kConsumeParserCache; 254 compile_options_ == ScriptCompiler::kConsumeParserCache;
255 } 255 }
256 bool produce_cached_parse_data() const { 256 bool produce_cached_parse_data() const {
257 return allow_lazy() && 257 return allow_lazy() &&
258 compile_options_ == ScriptCompiler::kProduceParserCache; 258 compile_options_ == ScriptCompiler::kProduceParserCache;
259 } 259 }
260 260
261 void ParseModuleItemList(ZoneList<Statement*>* body, bool* ok); 261 void ParseModuleItemList(ZoneChunkList<Statement*>* body, bool* ok);
262 Statement* ParseModuleItem(bool* ok); 262 Statement* ParseModuleItem(bool* ok);
263 const AstRawString* ParseModuleSpecifier(bool* ok); 263 const AstRawString* ParseModuleSpecifier(bool* ok);
264 void ParseImportDeclaration(bool* ok); 264 void ParseImportDeclaration(bool* ok);
265 Statement* ParseExportDeclaration(bool* ok); 265 Statement* ParseExportDeclaration(bool* ok);
266 Statement* ParseExportDefault(bool* ok); 266 Statement* ParseExportDefault(bool* ok);
267 void ParseExportClause(ZoneList<const AstRawString*>* export_names, 267 void ParseExportClause(ZoneList<const AstRawString*>* export_names,
268 ZoneList<Scanner::Location>* export_locations, 268 ZoneList<Scanner::Location>* export_locations,
269 ZoneList<const AstRawString*>* local_names, 269 ZoneList<const AstRawString*>* local_names,
270 Scanner::Location* reserved_loc, bool* ok); 270 Scanner::Location* reserved_loc, bool* ok);
271 struct NamedImport : public ZoneObject { 271 struct NamedImport : public ZoneObject {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 bool* ok); 496 bool* ok);
497 497
498 PreParser::PreParseResult ParseFunctionBodyWithPreParser( 498 PreParser::PreParseResult ParseFunctionBodyWithPreParser(
499 SingletonLogger* logger, bool is_inner_function, bool may_abort); 499 SingletonLogger* logger, bool is_inner_function, bool may_abort);
500 500
501 Block* BuildParameterInitializationBlock( 501 Block* BuildParameterInitializationBlock(
502 const ParserFormalParameters& parameters, bool* ok); 502 const ParserFormalParameters& parameters, bool* ok);
503 Block* BuildRejectPromiseOnException(Block* block, bool* ok); 503 Block* BuildRejectPromiseOnException(Block* block, bool* ok);
504 504
505 // Consumes the ending }. 505 // Consumes the ending }.
506 ZoneList<Statement*>* ParseEagerFunctionBody( 506 ZoneChunkList<Statement*>* ParseEagerFunctionBody(
507 const AstRawString* function_name, int pos, 507 const AstRawString* function_name, int pos,
508 const ParserFormalParameters& parameters, FunctionKind kind, 508 const ParserFormalParameters& parameters, FunctionKind kind,
509 FunctionLiteral::FunctionType function_type, bool* ok); 509 FunctionLiteral::FunctionType function_type, bool* ok);
510 510
511 void ThrowPendingError(Isolate* isolate, Handle<Script> script); 511 void ThrowPendingError(Isolate* isolate, Handle<Script> script);
512 512
513 class TemplateLiteral : public ZoneObject { 513 class TemplateLiteral : public ZoneObject {
514 public: 514 public:
515 TemplateLiteral(Zone* zone, int pos) 515 TemplateLiteral(Zone* zone, int pos)
516 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {} 516 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {}
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 // Generic AST generator for throwing errors from compiled code. 593 // Generic AST generator for throwing errors from compiled code.
594 Expression* NewThrowError(Runtime::FunctionId function_id, 594 Expression* NewThrowError(Runtime::FunctionId function_id,
595 MessageTemplate::Template message, 595 MessageTemplate::Template message,
596 const AstRawString* arg, int pos); 596 const AstRawString* arg, int pos);
597 597
598 void FinalizeIteratorUse(Variable* completion, Expression* condition, 598 void FinalizeIteratorUse(Variable* completion, Expression* condition,
599 Variable* iter, Block* iterator_use, Block* result); 599 Variable* iter, Block* iterator_use, Block* result);
600 600
601 Statement* FinalizeForOfStatement(ForOfStatement* loop, Variable* completion, 601 Statement* FinalizeForOfStatement(ForOfStatement* loop, Variable* completion,
602 int pos); 602 int pos);
603 void BuildIteratorClose(ZoneList<Statement*>* statements, Variable* iterator, 603 void BuildIteratorClose(ZoneChunkList<Statement*>* statements,
604 Variable* input, Variable* output); 604 Variable* iterator, Variable* input,
605 void BuildIteratorCloseForCompletion(ZoneList<Statement*>* statements, 605 Variable* output);
606 void BuildIteratorCloseForCompletion(ZoneChunkList<Statement*>* statements,
606 Variable* iterator, 607 Variable* iterator,
607 Expression* completion); 608 Expression* completion);
608 Statement* CheckCallable(Variable* var, Expression* error, int pos); 609 Statement* CheckCallable(Variable* var, Expression* error, int pos);
609 610
610 V8_INLINE Expression* RewriteAwaitExpression(Expression* value, int pos); 611 V8_INLINE Expression* RewriteAwaitExpression(Expression* value, int pos);
611 V8_INLINE void PrepareAsyncFunctionBody(ZoneList<Statement*>* body, 612 V8_INLINE void PrepareAsyncFunctionBody(ZoneChunkList<Statement*>* body,
612 FunctionKind kind, int pos); 613 FunctionKind kind, int pos);
613 V8_INLINE void RewriteAsyncFunctionBody(ZoneList<Statement*>* body, 614 V8_INLINE void RewriteAsyncFunctionBody(ZoneChunkList<Statement*>* body,
614 Block* block, 615 Block* block,
615 Expression* return_value, bool* ok); 616 Expression* return_value, bool* ok);
616 617
617 Expression* RewriteYieldStar(Expression* generator, Expression* expression, 618 Expression* RewriteYieldStar(Expression* generator, Expression* expression,
618 int pos); 619 int pos);
619 620
620 void AddArrowFunctionFormalParameters(ParserFormalParameters* parameters, 621 void AddArrowFunctionFormalParameters(ParserFormalParameters* parameters,
621 Expression* params, int end_pos, 622 Expression* params, int end_pos,
622 bool* ok); 623 bool* ok);
623 void SetFunctionName(Expression* value, const AstRawString* name); 624 void SetFunctionName(Expression* value, const AstRawString* name);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 return expr == nullptr; 885 return expr == nullptr;
885 } 886 }
886 887
887 // Used in error return values. 888 // Used in error return values.
888 V8_INLINE static ZoneList<Expression*>* NullExpressionList() { 889 V8_INLINE static ZoneList<Expression*>* NullExpressionList() {
889 return nullptr; 890 return nullptr;
890 } 891 }
891 V8_INLINE static bool IsNullExpressionList(ZoneList<Expression*>* exprs) { 892 V8_INLINE static bool IsNullExpressionList(ZoneList<Expression*>* exprs) {
892 return exprs == nullptr; 893 return exprs == nullptr;
893 } 894 }
894 V8_INLINE static ZoneList<Statement*>* NullStatementList() { return nullptr; } 895 V8_INLINE static ZoneChunkList<Statement*>* NullStatementList() {
895 V8_INLINE static bool IsNullStatementList(ZoneList<Statement*>* stmts) { 896 return nullptr;
897 }
898 V8_INLINE static bool IsNullStatementList(ZoneChunkList<Statement*>* stmts) {
896 return stmts == nullptr; 899 return stmts == nullptr;
897 } 900 }
898 V8_INLINE static Statement* NullStatement() { return nullptr; } 901 V8_INLINE static Statement* NullStatement() { return nullptr; }
899 V8_INLINE bool IsNullStatement(Statement* stmt) { return stmt == nullptr; } 902 V8_INLINE bool IsNullStatement(Statement* stmt) { return stmt == nullptr; }
900 V8_INLINE bool IsEmptyStatement(Statement* stmt) { 903 V8_INLINE bool IsEmptyStatement(Statement* stmt) {
901 DCHECK_NOT_NULL(stmt); 904 DCHECK_NOT_NULL(stmt);
902 return stmt->IsEmpty(); 905 return stmt->IsEmpty();
903 } 906 }
904 907
905 // Non-NULL empty string. 908 // Non-NULL empty string.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 return new (zone()) ZoneList<Expression*>(size, zone()); 964 return new (zone()) ZoneList<Expression*>(size, zone());
962 } 965 }
963 V8_INLINE ZoneList<ObjectLiteral::Property*>* NewObjectPropertyList( 966 V8_INLINE ZoneList<ObjectLiteral::Property*>* NewObjectPropertyList(
964 int size) const { 967 int size) const {
965 return new (zone()) ZoneList<ObjectLiteral::Property*>(size, zone()); 968 return new (zone()) ZoneList<ObjectLiteral::Property*>(size, zone());
966 } 969 }
967 V8_INLINE ZoneList<ClassLiteral::Property*>* NewClassPropertyList( 970 V8_INLINE ZoneList<ClassLiteral::Property*>* NewClassPropertyList(
968 int size) const { 971 int size) const {
969 return new (zone()) ZoneList<ClassLiteral::Property*>(size, zone()); 972 return new (zone()) ZoneList<ClassLiteral::Property*>(size, zone());
970 } 973 }
971 V8_INLINE ZoneList<Statement*>* NewStatementList(int size) const { 974 V8_INLINE ZoneChunkList<Statement*>* NewStatementList(int size) const {
972 return new (zone()) ZoneList<Statement*>(size, zone()); 975 return new (zone()) ZoneChunkList<Statement*>(zone());
973 } 976 }
974 V8_INLINE ZoneList<CaseClause*>* NewCaseClauseList(int size) const { 977 V8_INLINE ZoneList<CaseClause*>* NewCaseClauseList(int size) const {
975 return new (zone()) ZoneList<CaseClause*>(size, zone()); 978 return new (zone()) ZoneList<CaseClause*>(size, zone());
976 } 979 }
977 980
978 V8_INLINE Expression* NewV8Intrinsic(const AstRawString* name, 981 V8_INLINE Expression* NewV8Intrinsic(const AstRawString* name,
979 ZoneList<Expression*>* args, int pos, 982 ZoneList<Expression*>* args, int pos,
980 bool* ok); 983 bool* ok);
981 984
982 V8_INLINE Statement* NewThrowStatement(Expression* exception, int pos) { 985 V8_INLINE Statement* NewThrowStatement(Expression* exception, int pos) {
983 return factory()->NewExpressionStatement( 986 return factory()->NewExpressionStatement(
984 factory()->NewThrow(exception, pos), pos); 987 factory()->NewThrow(exception, pos), pos);
985 } 988 }
986 989
987 V8_INLINE void AddParameterInitializationBlock( 990 V8_INLINE void AddParameterInitializationBlock(
988 const ParserFormalParameters& parameters, ZoneList<Statement*>* body, 991 const ParserFormalParameters& parameters, ZoneChunkList<Statement*>* body,
989 bool is_async, bool* ok) { 992 bool is_async, bool* ok) {
990 if (parameters.is_simple) return; 993 if (parameters.is_simple) return;
991 auto* init_block = BuildParameterInitializationBlock(parameters, ok); 994 auto* init_block = BuildParameterInitializationBlock(parameters, ok);
992 if (!*ok) return; 995 if (!*ok) return;
993 if (is_async) { 996 if (is_async) {
994 init_block = BuildRejectPromiseOnException(init_block, ok); 997 init_block = BuildRejectPromiseOnException(init_block, ok);
995 if (!*ok) return; 998 if (!*ok) return;
996 } 999 }
997 if (init_block != nullptr) body->Add(init_block, zone()); 1000 if (init_block != nullptr) body->push_back(init_block);
998 } 1001 }
999 1002
1000 V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters, 1003 V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters,
1001 Expression* pattern, 1004 Expression* pattern,
1002 Expression* initializer, 1005 Expression* initializer,
1003 int initializer_end_position, 1006 int initializer_end_position,
1004 bool is_rest) { 1007 bool is_rest) {
1005 parameters->UpdateArityAndFunctionLength(initializer != nullptr, is_rest); 1008 parameters->UpdateArityAndFunctionLength(initializer != nullptr, is_rest);
1006 bool is_simple = pattern->IsVariableProxy() && initializer == nullptr; 1009 bool is_simple = pattern->IsVariableProxy() && initializer == nullptr;
1007 const AstRawString* name = is_simple 1010 const AstRawString* name = is_simple
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 1144
1142 private: 1145 private:
1143 ParserTarget** variable_; 1146 ParserTarget** variable_;
1144 ParserTarget* previous_; 1147 ParserTarget* previous_;
1145 }; 1148 };
1146 1149
1147 } // namespace internal 1150 } // namespace internal
1148 } // namespace v8 1151 } // namespace v8
1149 1152
1150 #endif // V8_PARSING_PARSER_H_ 1153 #endif // V8_PARSING_PARSER_H_
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698