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

Side by Side Diff: src/parser.cc

Issue 151603004: A64: Synchronize with r16587. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/parser.h ('k') | src/platform.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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 function_state.materialized_literal_count(), 680 function_state.materialized_literal_count(),
681 function_state.expected_property_count(), 681 function_state.expected_property_count(),
682 function_state.handler_count(), 682 function_state.handler_count(),
683 0, 683 0,
684 FunctionLiteral::kNoDuplicateParameters, 684 FunctionLiteral::kNoDuplicateParameters,
685 FunctionLiteral::ANONYMOUS_EXPRESSION, 685 FunctionLiteral::ANONYMOUS_EXPRESSION,
686 FunctionLiteral::kGlobalOrEval, 686 FunctionLiteral::kGlobalOrEval,
687 FunctionLiteral::kNotParenthesized, 687 FunctionLiteral::kNotParenthesized,
688 FunctionLiteral::kNotGenerator); 688 FunctionLiteral::kNotGenerator);
689 result->set_ast_properties(factory()->visitor()->ast_properties()); 689 result->set_ast_properties(factory()->visitor()->ast_properties());
690 result->set_dont_optimize_reason(
691 factory()->visitor()->dont_optimize_reason());
690 } else if (stack_overflow_) { 692 } else if (stack_overflow_) {
691 isolate()->StackOverflow(); 693 isolate()->StackOverflow();
692 } 694 }
693 } 695 }
694 696
695 // Make sure the target stack is empty. 697 // Make sure the target stack is empty.
696 ASSERT(target_stack_ == NULL); 698 ASSERT(target_stack_ == NULL);
697 699
698 return result; 700 return result;
699 } 701 }
(...skipping 3037 matching lines...) Expand 10 before | Expand all | Expand 10 after
3737 } 3739 }
3738 3740
3739 3741
3740 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) { 3742 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) {
3741 if (expression->AsLiteral() != NULL) return true; 3743 if (expression->AsLiteral() != NULL) return true;
3742 MaterializedLiteral* lit = expression->AsMaterializedLiteral(); 3744 MaterializedLiteral* lit = expression->AsMaterializedLiteral();
3743 return lit != NULL && lit->is_simple(); 3745 return lit != NULL && lit->is_simple();
3744 } 3746 }
3745 3747
3746 3748
3747 Handle<FixedArray> CompileTimeValue::GetValue(Expression* expression) { 3749 Handle<FixedArray> CompileTimeValue::GetValue(Isolate* isolate,
3748 Factory* factory = Isolate::Current()->factory(); 3750 Expression* expression) {
3751 Factory* factory = isolate->factory();
3749 ASSERT(IsCompileTimeValue(expression)); 3752 ASSERT(IsCompileTimeValue(expression));
3750 Handle<FixedArray> result = factory->NewFixedArray(2, TENURED); 3753 Handle<FixedArray> result = factory->NewFixedArray(2, TENURED);
3751 ObjectLiteral* object_literal = expression->AsObjectLiteral(); 3754 ObjectLiteral* object_literal = expression->AsObjectLiteral();
3752 if (object_literal != NULL) { 3755 if (object_literal != NULL) {
3753 ASSERT(object_literal->is_simple()); 3756 ASSERT(object_literal->is_simple());
3754 if (object_literal->fast_elements()) { 3757 if (object_literal->fast_elements()) {
3755 result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_FAST_ELEMENTS)); 3758 result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_FAST_ELEMENTS));
3756 } else { 3759 } else {
3757 result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_SLOW_ELEMENTS)); 3760 result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_SLOW_ELEMENTS));
3758 } 3761 }
(...skipping 18 matching lines...) Expand all
3777 Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) { 3780 Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) {
3778 return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot))); 3781 return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot)));
3779 } 3782 }
3780 3783
3781 3784
3782 Handle<Object> Parser::GetBoilerplateValue(Expression* expression) { 3785 Handle<Object> Parser::GetBoilerplateValue(Expression* expression) {
3783 if (expression->AsLiteral() != NULL) { 3786 if (expression->AsLiteral() != NULL) {
3784 return expression->AsLiteral()->value(); 3787 return expression->AsLiteral()->value();
3785 } 3788 }
3786 if (CompileTimeValue::IsCompileTimeValue(expression)) { 3789 if (CompileTimeValue::IsCompileTimeValue(expression)) {
3787 return CompileTimeValue::GetValue(expression); 3790 return CompileTimeValue::GetValue(isolate(), expression);
3788 } 3791 }
3789 return isolate()->factory()->uninitialized_value(); 3792 return isolate()->factory()->uninitialized_value();
3790 } 3793 }
3791 3794
3792 3795
3793 // Validation per 11.1.5 Object Initialiser 3796 // Validation per 11.1.5 Object Initialiser
3794 class ObjectLiteralPropertyChecker { 3797 class ObjectLiteralPropertyChecker {
3795 public: 3798 public:
3796 ObjectLiteralPropertyChecker(Parser* parser, LanguageMode language_mode) : 3799 ObjectLiteralPropertyChecker(Parser* parser, LanguageMode language_mode) :
3797 props_(Literal::Match), 3800 props_(Literal::Match),
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
4326 int handler_count = 0; 4329 int handler_count = 0;
4327 FunctionLiteral::ParameterFlag duplicate_parameters = 4330 FunctionLiteral::ParameterFlag duplicate_parameters =
4328 FunctionLiteral::kNoDuplicateParameters; 4331 FunctionLiteral::kNoDuplicateParameters;
4329 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_ 4332 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_
4330 ? FunctionLiteral::kIsParenthesized 4333 ? FunctionLiteral::kIsParenthesized
4331 : FunctionLiteral::kNotParenthesized; 4334 : FunctionLiteral::kNotParenthesized;
4332 FunctionLiteral::IsGeneratorFlag generator = is_generator 4335 FunctionLiteral::IsGeneratorFlag generator = is_generator
4333 ? FunctionLiteral::kIsGenerator 4336 ? FunctionLiteral::kIsGenerator
4334 : FunctionLiteral::kNotGenerator; 4337 : FunctionLiteral::kNotGenerator;
4335 AstProperties ast_properties; 4338 AstProperties ast_properties;
4339 BailoutReason dont_optimize_reason = kNoReason;
4336 // Parse function body. 4340 // Parse function body.
4337 { FunctionState function_state(this, scope, isolate()); 4341 { FunctionState function_state(this, scope, isolate());
4338 top_scope_->SetScopeName(function_name); 4342 top_scope_->SetScopeName(function_name);
4339 4343
4340 if (is_generator) { 4344 if (is_generator) {
4341 // For generators, allocating variables in contexts is currently a win 4345 // For generators, allocating variables in contexts is currently a win
4342 // because it minimizes the work needed to suspend and resume an 4346 // because it minimizes the work needed to suspend and resume an
4343 // activation. 4347 // activation.
4344 top_scope_->ForceContextAllocation(); 4348 top_scope_->ForceContextAllocation();
4345 4349
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
4585 ReportMessageAt(reserved_loc, "strict_reserved_word", 4589 ReportMessageAt(reserved_loc, "strict_reserved_word",
4586 Vector<const char*>::empty()); 4590 Vector<const char*>::empty());
4587 *ok = false; 4591 *ok = false;
4588 return NULL; 4592 return NULL;
4589 } 4593 }
4590 CheckOctalLiteral(scope->start_position(), 4594 CheckOctalLiteral(scope->start_position(),
4591 scope->end_position(), 4595 scope->end_position(),
4592 CHECK_OK); 4596 CHECK_OK);
4593 } 4597 }
4594 ast_properties = *factory()->visitor()->ast_properties(); 4598 ast_properties = *factory()->visitor()->ast_properties();
4599 dont_optimize_reason = factory()->visitor()->dont_optimize_reason();
4595 } 4600 }
4596 4601
4597 if (is_extended_mode()) { 4602 if (is_extended_mode()) {
4598 CheckConflictingVarDeclarations(scope, CHECK_OK); 4603 CheckConflictingVarDeclarations(scope, CHECK_OK);
4599 } 4604 }
4600 4605
4601 FunctionLiteral* function_literal = 4606 FunctionLiteral* function_literal =
4602 factory()->NewFunctionLiteral(function_name, 4607 factory()->NewFunctionLiteral(function_name,
4603 scope, 4608 scope,
4604 body, 4609 body,
4605 materialized_literal_count, 4610 materialized_literal_count,
4606 expected_property_count, 4611 expected_property_count,
4607 handler_count, 4612 handler_count,
4608 num_parameters, 4613 num_parameters,
4609 duplicate_parameters, 4614 duplicate_parameters,
4610 function_type, 4615 function_type,
4611 FunctionLiteral::kIsFunction, 4616 FunctionLiteral::kIsFunction,
4612 parenthesized, 4617 parenthesized,
4613 generator); 4618 generator);
4614 function_literal->set_function_token_position(function_token_position); 4619 function_literal->set_function_token_position(function_token_position);
4615 function_literal->set_ast_properties(&ast_properties); 4620 function_literal->set_ast_properties(&ast_properties);
4621 function_literal->set_dont_optimize_reason(dont_optimize_reason);
4616 4622
4617 if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal); 4623 if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal);
4618 return function_literal; 4624 return function_literal;
4619 } 4625 }
4620 4626
4621 4627
4622 preparser::PreParser::PreParseResult Parser::LazyParseFunctionLiteral( 4628 preparser::PreParser::PreParseResult Parser::LazyParseFunctionLiteral(
4623 SingletonLogger* logger) { 4629 SingletonLogger* logger) {
4624 HistogramTimerScope preparse_scope(isolate()->counters()->pre_parse()); 4630 HistogramTimerScope preparse_scope(isolate()->counters()->pre_parse());
4625 ASSERT_EQ(Token::LBRACE, scanner().current_token()); 4631 ASSERT_EQ(Token::LBRACE, scanner().current_token());
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
5016 5022
5017 5023
5018 // ---------------------------------------------------------------------------- 5024 // ----------------------------------------------------------------------------
5019 // Regular expressions 5025 // Regular expressions
5020 5026
5021 5027
5022 RegExpParser::RegExpParser(FlatStringReader* in, 5028 RegExpParser::RegExpParser(FlatStringReader* in,
5023 Handle<String>* error, 5029 Handle<String>* error,
5024 bool multiline, 5030 bool multiline,
5025 Zone* zone) 5031 Zone* zone)
5026 : isolate_(Isolate::Current()), 5032 : isolate_(zone->isolate()),
5027 zone_(zone), 5033 zone_(zone),
5028 error_(error), 5034 error_(error),
5029 captures_(NULL), 5035 captures_(NULL),
5030 in_(in), 5036 in_(in),
5031 current_(kEndMarker), 5037 current_(kEndMarker),
5032 next_pos_(0), 5038 next_pos_(0),
5033 capture_count_(0), 5039 capture_count_(0),
5034 has_more_(true), 5040 has_more_(true),
5035 multiline_(multiline), 5041 multiline_(multiline),
5036 simple_(false), 5042 simple_(false),
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
5888 input = *data; 5894 input = *data;
5889 result = (result << 7) | (input & 0x7f); 5895 result = (result << 7) | (input & 0x7f);
5890 data++; 5896 data++;
5891 } 5897 }
5892 *source = data; 5898 *source = data;
5893 return result; 5899 return result;
5894 } 5900 }
5895 5901
5896 5902
5897 // Create a Scanner for the preparser to use as input, and preparse the source. 5903 // Create a Scanner for the preparser to use as input, and preparse the source.
5898 ScriptDataImpl* PreParserApi::PreParse(Utf16CharacterStream* source) { 5904 ScriptDataImpl* PreParserApi::PreParse(Isolate* isolate,
5905 Utf16CharacterStream* source) {
5899 CompleteParserRecorder recorder; 5906 CompleteParserRecorder recorder;
5900 Isolate* isolate = Isolate::Current();
5901 HistogramTimerScope timer(isolate->counters()->pre_parse()); 5907 HistogramTimerScope timer(isolate->counters()->pre_parse());
5902 Scanner scanner(isolate->unicode_cache()); 5908 Scanner scanner(isolate->unicode_cache());
5903 intptr_t stack_limit = isolate->stack_guard()->real_climit(); 5909 intptr_t stack_limit = isolate->stack_guard()->real_climit();
5904 preparser::PreParser preparser(&scanner, &recorder, stack_limit); 5910 preparser::PreParser preparser(&scanner, &recorder, stack_limit);
5905 preparser.set_allow_lazy(true); 5911 preparser.set_allow_lazy(true);
5906 preparser.set_allow_generators(FLAG_harmony_generators); 5912 preparser.set_allow_generators(FLAG_harmony_generators);
5907 preparser.set_allow_for_of(FLAG_harmony_iteration); 5913 preparser.set_allow_for_of(FLAG_harmony_iteration);
5908 preparser.set_allow_harmony_scoping(FLAG_harmony_scoping); 5914 preparser.set_allow_harmony_scoping(FLAG_harmony_scoping);
5909 preparser.set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); 5915 preparser.set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals);
5910 scanner.Initialize(source); 5916 scanner.Initialize(source);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
5970 ASSERT(info()->isolate()->has_pending_exception()); 5976 ASSERT(info()->isolate()->has_pending_exception());
5971 } else { 5977 } else {
5972 result = ParseProgram(); 5978 result = ParseProgram();
5973 } 5979 }
5974 } 5980 }
5975 info()->SetFunction(result); 5981 info()->SetFunction(result);
5976 return (result != NULL); 5982 return (result != NULL);
5977 } 5983 }
5978 5984
5979 } } // namespace v8::internal 5985 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698