OLD | NEW |
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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 | 781 |
782 | 782 |
783 ClassLiteral* ParserTraits::ParseClassLiteral( | 783 ClassLiteral* ParserTraits::ParseClassLiteral( |
784 const AstRawString* name, Scanner::Location class_name_location, | 784 const AstRawString* name, Scanner::Location class_name_location, |
785 bool name_is_strict_reserved, int pos, bool* ok) { | 785 bool name_is_strict_reserved, int pos, bool* ok) { |
786 return parser_->ParseClassLiteral(name, class_name_location, | 786 return parser_->ParseClassLiteral(name, class_name_location, |
787 name_is_strict_reserved, pos, ok); | 787 name_is_strict_reserved, pos, ok); |
788 } | 788 } |
789 | 789 |
790 | 790 |
791 Parser::Parser(CompilationInfo* info, ParseInfo* parse_info) | 791 Parser::Parser(CompilationInfo* info, uintptr_t stack_limit, uint32_t hash_seed, |
| 792 UnicodeCache* unicode_cache) |
792 : ParserBase<ParserTraits>(info->isolate(), info->zone(), &scanner_, | 793 : ParserBase<ParserTraits>(info->isolate(), info->zone(), &scanner_, |
793 parse_info->stack_limit, info->extension(), | 794 stack_limit, info->extension(), |
794 info->ast_value_factory(), NULL, this), | 795 info->ast_value_factory(), NULL, this), |
795 scanner_(parse_info->unicode_cache), | 796 scanner_(unicode_cache), |
796 reusable_preparser_(NULL), | 797 reusable_preparser_(NULL), |
797 original_scope_(NULL), | 798 original_scope_(NULL), |
798 target_stack_(NULL), | 799 target_stack_(NULL), |
799 cached_parse_data_(NULL), | 800 cached_parse_data_(NULL), |
800 info_(info), | 801 info_(info), |
801 parsing_lazy_arrow_parameters_(false), | 802 parsing_lazy_arrow_parameters_(false), |
802 has_pending_error_(false), | 803 has_pending_error_(false), |
803 pending_error_message_(NULL), | 804 pending_error_message_(NULL), |
804 pending_error_arg_(NULL), | 805 pending_error_arg_(NULL), |
805 pending_error_char_arg_(NULL), | 806 pending_error_char_arg_(NULL), |
(...skipping 14 matching lines...) Expand all Loading... |
820 set_allow_harmony_computed_property_names( | 821 set_allow_harmony_computed_property_names( |
821 FLAG_harmony_computed_property_names); | 822 FLAG_harmony_computed_property_names); |
822 set_allow_harmony_rest_params(FLAG_harmony_rest_parameters); | 823 set_allow_harmony_rest_params(FLAG_harmony_rest_parameters); |
823 set_allow_strong_mode(FLAG_strong_mode); | 824 set_allow_strong_mode(FLAG_strong_mode); |
824 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; | 825 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; |
825 ++feature) { | 826 ++feature) { |
826 use_counts_[feature] = 0; | 827 use_counts_[feature] = 0; |
827 } | 828 } |
828 if (info->ast_value_factory() == NULL) { | 829 if (info->ast_value_factory() == NULL) { |
829 // info takes ownership of AstValueFactory. | 830 // info takes ownership of AstValueFactory. |
830 info->SetAstValueFactory( | 831 info->SetAstValueFactory(new AstValueFactory(zone(), hash_seed)); |
831 new AstValueFactory(zone(), parse_info->hash_seed)); | |
832 ast_value_factory_ = info->ast_value_factory(); | 832 ast_value_factory_ = info->ast_value_factory(); |
833 } | 833 } |
834 } | 834 } |
835 | 835 |
836 | 836 |
837 FunctionLiteral* Parser::ParseProgram() { | 837 FunctionLiteral* Parser::ParseProgram() { |
838 // TODO(bmeurer): We temporarily need to pass allow_nesting = true here, | 838 // TODO(bmeurer): We temporarily need to pass allow_nesting = true here, |
839 // see comment for HistogramTimerScope class. | 839 // see comment for HistogramTimerScope class. |
840 | 840 |
841 // It's OK to use the counters here, since this function is only called in | 841 // It's OK to use the counters here, since this function is only called in |
(...skipping 4402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5244 result->tree = tree; | 5244 result->tree = tree; |
5245 int capture_count = parser.captures_started(); | 5245 int capture_count = parser.captures_started(); |
5246 result->simple = tree->IsAtom() && parser.simple() && capture_count == 0; | 5246 result->simple = tree->IsAtom() && parser.simple() && capture_count == 0; |
5247 result->contains_anchor = parser.contains_anchor(); | 5247 result->contains_anchor = parser.contains_anchor(); |
5248 result->capture_count = capture_count; | 5248 result->capture_count = capture_count; |
5249 } | 5249 } |
5250 return !parser.failed(); | 5250 return !parser.failed(); |
5251 } | 5251 } |
5252 | 5252 |
5253 | 5253 |
| 5254 bool Parser::Parse(CompilationInfo* info, bool allow_lazy) { |
| 5255 Parser parser(info, info->isolate()->stack_guard()->real_climit(), |
| 5256 info->isolate()->heap()->HashSeed(), |
| 5257 info->isolate()->unicode_cache()); |
| 5258 parser.set_allow_lazy(allow_lazy); |
| 5259 if (parser.Parse()) { |
| 5260 info->SetLanguageMode(info->function()->language_mode()); |
| 5261 return true; |
| 5262 } |
| 5263 return false; |
| 5264 } |
| 5265 |
| 5266 |
5254 bool Parser::Parse() { | 5267 bool Parser::Parse() { |
5255 DCHECK(info()->function() == NULL); | 5268 DCHECK(info()->function() == NULL); |
5256 FunctionLiteral* result = NULL; | 5269 FunctionLiteral* result = NULL; |
5257 pre_parse_timer_ = isolate()->counters()->pre_parse(); | 5270 pre_parse_timer_ = isolate()->counters()->pre_parse(); |
5258 if (FLAG_trace_parse || allow_natives() || extension_ != NULL) { | 5271 if (FLAG_trace_parse || allow_natives() || extension_ != NULL) { |
5259 // If intrinsics are allowed, the Parser cannot operate independent of the | 5272 // If intrinsics are allowed, the Parser cannot operate independent of the |
5260 // V8 heap because of Runtime. Tell the string table to internalize strings | 5273 // V8 heap because of Runtime. Tell the string table to internalize strings |
5261 // and values right after they're created. | 5274 // and values right after they're created. |
5262 ast_value_factory()->Internalize(isolate()); | 5275 ast_value_factory()->Internalize(isolate()); |
5263 } | 5276 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5436 } else { | 5449 } else { |
5437 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); | 5450 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); |
5438 running_hash = StringHasher::ComputeRunningHash(running_hash, data, | 5451 running_hash = StringHasher::ComputeRunningHash(running_hash, data, |
5439 raw_string->length()); | 5452 raw_string->length()); |
5440 } | 5453 } |
5441 } | 5454 } |
5442 | 5455 |
5443 return running_hash; | 5456 return running_hash; |
5444 } | 5457 } |
5445 } } // namespace v8::internal | 5458 } } // namespace v8::internal |
OLD | NEW |