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

Side by Side Diff: src/parser.cc

Issue 102563004: Zonify types in compiler frontend (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 7 years 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/parser.h ('k') | src/prettyprinter.h » ('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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 } 478 }
479 479
480 ~BlockState() { parser_->top_scope_ = outer_scope_; } 480 ~BlockState() { parser_->top_scope_ = outer_scope_; }
481 481
482 private: 482 private:
483 Parser* parser_; 483 Parser* parser_;
484 Scope* outer_scope_; 484 Scope* outer_scope_;
485 }; 485 };
486 486
487 487
488 Parser::FunctionState::FunctionState(Parser* parser, 488 Parser::FunctionState::FunctionState(Parser* parser, Scope* scope)
489 Scope* scope,
490 Isolate* isolate)
491 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), 489 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize),
492 next_handler_index_(0), 490 next_handler_index_(0),
493 expected_property_count_(0), 491 expected_property_count_(0),
494 generator_object_variable_(NULL), 492 generator_object_variable_(NULL),
495 parser_(parser), 493 parser_(parser),
496 outer_function_state_(parser->current_function_state_), 494 outer_function_state_(parser->current_function_state_),
497 outer_scope_(parser->top_scope_), 495 outer_scope_(parser->top_scope_),
498 saved_ast_node_id_(isolate->ast_node_id()), 496 saved_ast_node_id_(parser->zone()->isolate()->ast_node_id()),
499 factory_(isolate, parser->zone()) { 497 factory_(parser->zone()) {
500 parser->top_scope_ = scope; 498 parser->top_scope_ = scope;
501 parser->current_function_state_ = this; 499 parser->current_function_state_ = this;
502 isolate->set_ast_node_id(BailoutId::FirstUsable().ToInt()); 500 parser->zone()->isolate()->set_ast_node_id(BailoutId::FirstUsable().ToInt());
503 } 501 }
504 502
505 503
506 Parser::FunctionState::~FunctionState() { 504 Parser::FunctionState::~FunctionState() {
507 parser_->top_scope_ = outer_scope_; 505 parser_->top_scope_ = outer_scope_;
508 parser_->current_function_state_ = outer_function_state_; 506 parser_->current_function_state_ = outer_function_state_;
509 if (outer_function_state_ != NULL) { 507 if (outer_function_state_ != NULL) {
510 parser_->isolate()->set_ast_node_id(saved_ast_node_id_); 508 parser_->isolate()->set_ast_node_id(saved_ast_node_id_);
511 } 509 }
512 } 510 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 // Compute the parsing mode. 636 // Compute the parsing mode.
639 Mode mode = (FLAG_lazy && allow_lazy()) ? PARSE_LAZILY : PARSE_EAGERLY; 637 Mode mode = (FLAG_lazy && allow_lazy()) ? PARSE_LAZILY : PARSE_EAGERLY;
640 if (allow_natives_syntax() || 638 if (allow_natives_syntax() ||
641 extension_ != NULL || 639 extension_ != NULL ||
642 scope->is_eval_scope()) { 640 scope->is_eval_scope()) {
643 mode = PARSE_EAGERLY; 641 mode = PARSE_EAGERLY;
644 } 642 }
645 ParsingModeScope parsing_mode(this, mode); 643 ParsingModeScope parsing_mode(this, mode);
646 644
647 // Enters 'scope'. 645 // Enters 'scope'.
648 FunctionState function_state(this, scope, isolate()); 646 FunctionState function_state(this, scope);
649 647
650 top_scope_->SetLanguageMode(info->language_mode()); 648 top_scope_->SetLanguageMode(info->language_mode());
651 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); 649 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone());
652 bool ok = true; 650 bool ok = true;
653 int beg_pos = scanner().location().beg_pos; 651 int beg_pos = scanner().location().beg_pos;
654 ParseSourceElements(body, Token::EOS, info->is_eval(), true, &ok); 652 ParseSourceElements(body, Token::EOS, info->is_eval(), true, &ok);
655 if (ok && !top_scope_->is_classic_mode()) { 653 if (ok && !top_scope_->is_classic_mode()) {
656 CheckOctalLiteral(beg_pos, scanner().location().end_pos, &ok); 654 CheckOctalLiteral(beg_pos, scanner().location().end_pos, &ok);
657 } 655 }
658 656
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 750
753 { 751 {
754 // Parse the function literal. 752 // Parse the function literal.
755 Scope* scope = NewScope(top_scope_, GLOBAL_SCOPE); 753 Scope* scope = NewScope(top_scope_, GLOBAL_SCOPE);
756 info()->SetGlobalScope(scope); 754 info()->SetGlobalScope(scope);
757 if (!info()->closure().is_null()) { 755 if (!info()->closure().is_null()) {
758 scope = Scope::DeserializeScopeChain(info()->closure()->context(), scope, 756 scope = Scope::DeserializeScopeChain(info()->closure()->context(), scope,
759 zone()); 757 zone());
760 } 758 }
761 original_scope_ = scope; 759 original_scope_ = scope;
762 FunctionState function_state(this, scope, isolate()); 760 FunctionState function_state(this, scope);
763 ASSERT(scope->language_mode() != STRICT_MODE || !info()->is_classic_mode()); 761 ASSERT(scope->language_mode() != STRICT_MODE || !info()->is_classic_mode());
764 ASSERT(scope->language_mode() != EXTENDED_MODE || 762 ASSERT(scope->language_mode() != EXTENDED_MODE ||
765 info()->is_extended_mode()); 763 info()->is_extended_mode());
766 ASSERT(info()->language_mode() == shared_info->language_mode()); 764 ASSERT(info()->language_mode() == shared_info->language_mode());
767 scope->SetLanguageMode(shared_info->language_mode()); 765 scope->SetLanguageMode(shared_info->language_mode());
768 FunctionLiteral::FunctionType function_type = shared_info->is_expression() 766 FunctionLiteral::FunctionType function_type = shared_info->is_expression()
769 ? (shared_info->is_anonymous() 767 ? (shared_info->is_anonymous()
770 ? FunctionLiteral::ANONYMOUS_EXPRESSION 768 ? FunctionLiteral::ANONYMOUS_EXPRESSION
771 : FunctionLiteral::NAMED_EXPRESSION) 769 : FunctionLiteral::NAMED_EXPRESSION)
772 : FunctionLiteral::DECLARATION; 770 : FunctionLiteral::DECLARATION;
(...skipping 3055 matching lines...) Expand 10 before | Expand all | Expand 10 after
3828 } 3826 }
3829 } 3827 }
3830 3828
3831 // Validate the property 3829 // Validate the property
3832 checker.CheckProperty(next, kValueProperty, CHECK_OK); 3830 checker.CheckProperty(next, kValueProperty, CHECK_OK);
3833 3831
3834 Expect(Token::COLON, CHECK_OK); 3832 Expect(Token::COLON, CHECK_OK);
3835 Expression* value = ParseAssignmentExpression(true, CHECK_OK); 3833 Expression* value = ParseAssignmentExpression(true, CHECK_OK);
3836 3834
3837 ObjectLiteral::Property* property = 3835 ObjectLiteral::Property* property =
3838 new(zone()) ObjectLiteral::Property(key, value, isolate()); 3836 factory()->NewObjectLiteralProperty(key, value);
3839 3837
3840 // Mark top-level object literals that contain function literals and 3838 // Mark top-level object literals that contain function literals and
3841 // pretenure the literal so it can be added as a constant function 3839 // pretenure the literal so it can be added as a constant function
3842 // property. 3840 // property.
3843 if (top_scope_->DeclarationScope()->is_global_scope() && 3841 if (top_scope_->DeclarationScope()->is_global_scope() &&
3844 value->AsFunctionLiteral() != NULL) { 3842 value->AsFunctionLiteral() != NULL) {
3845 has_function = true; 3843 has_function = true;
3846 value->AsFunctionLiteral()->set_pretenure(); 3844 value->AsFunctionLiteral()->set_pretenure();
3847 } 3845 }
3848 3846
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
4077 FunctionLiteral::kNoDuplicateParameters; 4075 FunctionLiteral::kNoDuplicateParameters;
4078 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_ 4076 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_
4079 ? FunctionLiteral::kIsParenthesized 4077 ? FunctionLiteral::kIsParenthesized
4080 : FunctionLiteral::kNotParenthesized; 4078 : FunctionLiteral::kNotParenthesized;
4081 FunctionLiteral::IsGeneratorFlag generator = is_generator 4079 FunctionLiteral::IsGeneratorFlag generator = is_generator
4082 ? FunctionLiteral::kIsGenerator 4080 ? FunctionLiteral::kIsGenerator
4083 : FunctionLiteral::kNotGenerator; 4081 : FunctionLiteral::kNotGenerator;
4084 AstProperties ast_properties; 4082 AstProperties ast_properties;
4085 BailoutReason dont_optimize_reason = kNoReason; 4083 BailoutReason dont_optimize_reason = kNoReason;
4086 // Parse function body. 4084 // Parse function body.
4087 { FunctionState function_state(this, scope, isolate()); 4085 { FunctionState function_state(this, scope);
4088 top_scope_->SetScopeName(function_name); 4086 top_scope_->SetScopeName(function_name);
4089 4087
4090 if (is_generator) { 4088 if (is_generator) {
4091 // For generators, allocating variables in contexts is currently a win 4089 // For generators, allocating variables in contexts is currently a win
4092 // because it minimizes the work needed to suspend and resume an 4090 // because it minimizes the work needed to suspend and resume an
4093 // activation. 4091 // activation.
4094 top_scope_->ForceContextAllocation(); 4092 top_scope_->ForceContextAllocation();
4095 4093
4096 // Calling a generator returns a generator object. That object is stored 4094 // Calling a generator returns a generator object. That object is stored
4097 // in a temporary variable, a definition that is used by "yield" 4095 // in a temporary variable, a definition that is used by "yield"
(...skipping 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after
5686 ASSERT(info()->isolate()->has_pending_exception()); 5684 ASSERT(info()->isolate()->has_pending_exception());
5687 } else { 5685 } else {
5688 result = ParseProgram(); 5686 result = ParseProgram();
5689 } 5687 }
5690 } 5688 }
5691 info()->SetFunction(result); 5689 info()->SetFunction(result);
5692 return (result != NULL); 5690 return (result != NULL);
5693 } 5691 }
5694 5692
5695 } } // namespace v8::internal 5693 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/prettyprinter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698