| OLD | NEW |
| 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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 zone_(info->zone()), | 556 zone_(info->zone()), |
| 557 info_(info) { | 557 info_(info) { |
| 558 ASSERT(!script_.is_null()); | 558 ASSERT(!script_.is_null()); |
| 559 isolate_->set_ast_node_id(0); | 559 isolate_->set_ast_node_id(0); |
| 560 set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping); | 560 set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping); |
| 561 set_allow_modules(!info->is_native() && FLAG_harmony_modules); | 561 set_allow_modules(!info->is_native() && FLAG_harmony_modules); |
| 562 set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native()); | 562 set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native()); |
| 563 set_allow_lazy(false); // Must be explicitly enabled. | 563 set_allow_lazy(false); // Must be explicitly enabled. |
| 564 set_allow_generators(FLAG_harmony_generators); | 564 set_allow_generators(FLAG_harmony_generators); |
| 565 set_allow_for_of(FLAG_harmony_iteration); | 565 set_allow_for_of(FLAG_harmony_iteration); |
| 566 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); |
| 566 } | 567 } |
| 567 | 568 |
| 568 | 569 |
| 569 FunctionLiteral* Parser::ParseProgram() { | 570 FunctionLiteral* Parser::ParseProgram() { |
| 570 HistogramTimerScope timer(isolate()->counters()->parse()); | 571 HistogramTimerScope timer(isolate()->counters()->parse()); |
| 571 Handle<String> source(String::cast(script_->source())); | 572 Handle<String> source(String::cast(script_->source())); |
| 572 isolate()->counters()->total_parse_size()->Increment(source->length()); | 573 isolate()->counters()->total_parse_size()->Increment(source->length()); |
| 573 int64_t start = FLAG_trace_parse ? OS::Ticks() : 0; | 574 int64_t start = FLAG_trace_parse ? OS::Ticks() : 0; |
| 574 fni_ = new(zone()) FuncNameInferrer(isolate(), zone()); | 575 fni_ = new(zone()) FuncNameInferrer(isolate(), zone()); |
| 575 | 576 |
| (...skipping 2990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3566 result = top_scope_->NewUnresolved( | 3567 result = top_scope_->NewUnresolved( |
| 3567 factory(), name, interface, scanner().location().beg_pos); | 3568 factory(), name, interface, scanner().location().beg_pos); |
| 3568 break; | 3569 break; |
| 3569 } | 3570 } |
| 3570 | 3571 |
| 3571 case Token::NUMBER: { | 3572 case Token::NUMBER: { |
| 3572 Consume(Token::NUMBER); | 3573 Consume(Token::NUMBER); |
| 3573 ASSERT(scanner().is_literal_ascii()); | 3574 ASSERT(scanner().is_literal_ascii()); |
| 3574 double value = StringToDouble(isolate()->unicode_cache(), | 3575 double value = StringToDouble(isolate()->unicode_cache(), |
| 3575 scanner().literal_ascii_string(), | 3576 scanner().literal_ascii_string(), |
| 3576 ALLOW_HEX | ALLOW_OCTALS); | 3577 ALLOW_HEX | ALLOW_OCTAL | |
| 3578 ALLOW_IMPLICIT_OCTAL | ALLOW_BINARY); |
| 3577 result = factory()->NewNumberLiteral(value); | 3579 result = factory()->NewNumberLiteral(value); |
| 3578 break; | 3580 break; |
| 3579 } | 3581 } |
| 3580 | 3582 |
| 3581 case Token::STRING: { | 3583 case Token::STRING: { |
| 3582 Consume(Token::STRING); | 3584 Consume(Token::STRING); |
| 3583 Handle<String> symbol = GetSymbol(); | 3585 Handle<String> symbol = GetSymbol(); |
| 3584 result = factory()->NewLiteral(symbol); | 3586 result = factory()->NewLiteral(symbol); |
| 3585 if (fni_ != NULL) fni_->PushLiteralName(symbol); | 3587 if (fni_ != NULL) fni_->PushLiteralName(symbol); |
| 3586 break; | 3588 break; |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4019 break; | 4021 break; |
| 4020 } | 4022 } |
| 4021 key = factory()->NewLiteral(string); | 4023 key = factory()->NewLiteral(string); |
| 4022 break; | 4024 break; |
| 4023 } | 4025 } |
| 4024 case Token::NUMBER: { | 4026 case Token::NUMBER: { |
| 4025 Consume(Token::NUMBER); | 4027 Consume(Token::NUMBER); |
| 4026 ASSERT(scanner().is_literal_ascii()); | 4028 ASSERT(scanner().is_literal_ascii()); |
| 4027 double value = StringToDouble(isolate()->unicode_cache(), | 4029 double value = StringToDouble(isolate()->unicode_cache(), |
| 4028 scanner().literal_ascii_string(), | 4030 scanner().literal_ascii_string(), |
| 4029 ALLOW_HEX | ALLOW_OCTALS); | 4031 ALLOW_HEX | ALLOW_OCTAL | |
| 4032 ALLOW_IMPLICIT_OCTAL | ALLOW_BINARY); |
| 4030 key = factory()->NewNumberLiteral(value); | 4033 key = factory()->NewNumberLiteral(value); |
| 4031 break; | 4034 break; |
| 4032 } | 4035 } |
| 4033 default: | 4036 default: |
| 4034 if (Token::IsKeyword(next)) { | 4037 if (Token::IsKeyword(next)) { |
| 4035 Consume(next); | 4038 Consume(next); |
| 4036 Handle<String> string = GetSymbol(); | 4039 Handle<String> string = GetSymbol(); |
| 4037 key = factory()->NewLiteral(string); | 4040 key = factory()->NewLiteral(string); |
| 4038 } else { | 4041 } else { |
| 4039 // Unexpected token. | 4042 // Unexpected token. |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4574 intptr_t stack_limit = isolate()->stack_guard()->real_climit(); | 4577 intptr_t stack_limit = isolate()->stack_guard()->real_climit(); |
| 4575 reusable_preparser_ = new preparser::PreParser(&scanner_, | 4578 reusable_preparser_ = new preparser::PreParser(&scanner_, |
| 4576 NULL, | 4579 NULL, |
| 4577 stack_limit); | 4580 stack_limit); |
| 4578 reusable_preparser_->set_allow_harmony_scoping(allow_harmony_scoping()); | 4581 reusable_preparser_->set_allow_harmony_scoping(allow_harmony_scoping()); |
| 4579 reusable_preparser_->set_allow_modules(allow_modules()); | 4582 reusable_preparser_->set_allow_modules(allow_modules()); |
| 4580 reusable_preparser_->set_allow_natives_syntax(allow_natives_syntax()); | 4583 reusable_preparser_->set_allow_natives_syntax(allow_natives_syntax()); |
| 4581 reusable_preparser_->set_allow_lazy(true); | 4584 reusable_preparser_->set_allow_lazy(true); |
| 4582 reusable_preparser_->set_allow_generators(allow_generators()); | 4585 reusable_preparser_->set_allow_generators(allow_generators()); |
| 4583 reusable_preparser_->set_allow_for_of(allow_for_of()); | 4586 reusable_preparser_->set_allow_for_of(allow_for_of()); |
| 4587 reusable_preparser_->set_allow_harmony_numeric_literals( |
| 4588 allow_harmony_numeric_literals()); |
| 4584 } | 4589 } |
| 4585 preparser::PreParser::PreParseResult result = | 4590 preparser::PreParser::PreParseResult result = |
| 4586 reusable_preparser_->PreParseLazyFunction(top_scope_->language_mode(), | 4591 reusable_preparser_->PreParseLazyFunction(top_scope_->language_mode(), |
| 4587 is_generator(), | 4592 is_generator(), |
| 4588 logger); | 4593 logger); |
| 4589 return result; | 4594 return result; |
| 4590 } | 4595 } |
| 4591 | 4596 |
| 4592 | 4597 |
| 4593 Expression* Parser::ParseV8Intrinsic(bool* ok) { | 4598 Expression* Parser::ParseV8Intrinsic(bool* ok) { |
| (...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5843 CompleteParserRecorder recorder; | 5848 CompleteParserRecorder recorder; |
| 5844 Isolate* isolate = Isolate::Current(); | 5849 Isolate* isolate = Isolate::Current(); |
| 5845 HistogramTimerScope timer(isolate->counters()->pre_parse()); | 5850 HistogramTimerScope timer(isolate->counters()->pre_parse()); |
| 5846 Scanner scanner(isolate->unicode_cache()); | 5851 Scanner scanner(isolate->unicode_cache()); |
| 5847 intptr_t stack_limit = isolate->stack_guard()->real_climit(); | 5852 intptr_t stack_limit = isolate->stack_guard()->real_climit(); |
| 5848 preparser::PreParser preparser(&scanner, &recorder, stack_limit); | 5853 preparser::PreParser preparser(&scanner, &recorder, stack_limit); |
| 5849 preparser.set_allow_lazy(true); | 5854 preparser.set_allow_lazy(true); |
| 5850 preparser.set_allow_generators(FLAG_harmony_generators); | 5855 preparser.set_allow_generators(FLAG_harmony_generators); |
| 5851 preparser.set_allow_for_of(FLAG_harmony_iteration); | 5856 preparser.set_allow_for_of(FLAG_harmony_iteration); |
| 5852 preparser.set_allow_harmony_scoping(FLAG_harmony_scoping); | 5857 preparser.set_allow_harmony_scoping(FLAG_harmony_scoping); |
| 5858 preparser.set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); |
| 5853 scanner.Initialize(source); | 5859 scanner.Initialize(source); |
| 5854 preparser::PreParser::PreParseResult result = preparser.PreParseProgram(); | 5860 preparser::PreParser::PreParseResult result = preparser.PreParseProgram(); |
| 5855 if (result == preparser::PreParser::kPreParseStackOverflow) { | 5861 if (result == preparser::PreParser::kPreParseStackOverflow) { |
| 5856 isolate->StackOverflow(); | 5862 isolate->StackOverflow(); |
| 5857 return NULL; | 5863 return NULL; |
| 5858 } | 5864 } |
| 5859 | 5865 |
| 5860 // Extract the accumulated data from the recorder as a single | 5866 // Extract the accumulated data from the recorder as a single |
| 5861 // contiguous vector that we are responsible for disposing. | 5867 // contiguous vector that we are responsible for disposing. |
| 5862 Vector<unsigned> store = recorder.ExtractData(); | 5868 Vector<unsigned> store = recorder.ExtractData(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5913 ASSERT(info()->isolate()->has_pending_exception()); | 5919 ASSERT(info()->isolate()->has_pending_exception()); |
| 5914 } else { | 5920 } else { |
| 5915 result = ParseProgram(); | 5921 result = ParseProgram(); |
| 5916 } | 5922 } |
| 5917 } | 5923 } |
| 5918 info()->SetFunction(result); | 5924 info()->SetFunction(result); |
| 5919 return (result != NULL); | 5925 return (result != NULL); |
| 5920 } | 5926 } |
| 5921 | 5927 |
| 5922 } } // namespace v8::internal | 5928 } } // namespace v8::internal |
| OLD | NEW |