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 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
808 set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions); | 808 set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions); |
809 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); | 809 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); |
810 set_allow_harmony_classes(FLAG_harmony_classes); | 810 set_allow_harmony_classes(FLAG_harmony_classes); |
811 set_allow_harmony_object_literals(FLAG_harmony_object_literals); | 811 set_allow_harmony_object_literals(FLAG_harmony_object_literals); |
812 set_allow_harmony_templates(FLAG_harmony_templates); | 812 set_allow_harmony_templates(FLAG_harmony_templates); |
813 set_allow_harmony_sloppy(FLAG_harmony_sloppy); | 813 set_allow_harmony_sloppy(FLAG_harmony_sloppy); |
814 set_allow_harmony_unicode(FLAG_harmony_unicode); | 814 set_allow_harmony_unicode(FLAG_harmony_unicode); |
815 set_allow_harmony_computed_property_names( | 815 set_allow_harmony_computed_property_names( |
816 FLAG_harmony_computed_property_names); | 816 FLAG_harmony_computed_property_names); |
817 set_allow_harmony_rest_params(FLAG_harmony_rest_parameters); | 817 set_allow_harmony_rest_params(FLAG_harmony_rest_parameters); |
818 set_allow_harmony_spreadcalls(FLAG_harmony_spreadcalls); | |
818 set_allow_strong_mode(FLAG_strong_mode); | 819 set_allow_strong_mode(FLAG_strong_mode); |
819 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; | 820 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; |
820 ++feature) { | 821 ++feature) { |
821 use_counts_[feature] = 0; | 822 use_counts_[feature] = 0; |
822 } | 823 } |
823 if (info->ast_value_factory() == NULL) { | 824 if (info->ast_value_factory() == NULL) { |
824 // info takes ownership of AstValueFactory. | 825 // info takes ownership of AstValueFactory. |
825 info->SetAstValueFactory(new AstValueFactory(zone(), hash_seed)); | 826 info->SetAstValueFactory(new AstValueFactory(zone(), hash_seed)); |
826 ast_value_factory_ = info->ast_value_factory(); | 827 ast_value_factory_ = info->ast_value_factory(); |
827 } | 828 } |
(...skipping 3208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4036 reusable_preparser_->set_allow_harmony_classes(allow_harmony_classes()); | 4037 reusable_preparser_->set_allow_harmony_classes(allow_harmony_classes()); |
4037 reusable_preparser_->set_allow_harmony_object_literals( | 4038 reusable_preparser_->set_allow_harmony_object_literals( |
4038 allow_harmony_object_literals()); | 4039 allow_harmony_object_literals()); |
4039 reusable_preparser_->set_allow_harmony_templates(allow_harmony_templates()); | 4040 reusable_preparser_->set_allow_harmony_templates(allow_harmony_templates()); |
4040 reusable_preparser_->set_allow_harmony_sloppy(allow_harmony_sloppy()); | 4041 reusable_preparser_->set_allow_harmony_sloppy(allow_harmony_sloppy()); |
4041 reusable_preparser_->set_allow_harmony_unicode(allow_harmony_unicode()); | 4042 reusable_preparser_->set_allow_harmony_unicode(allow_harmony_unicode()); |
4042 reusable_preparser_->set_allow_harmony_computed_property_names( | 4043 reusable_preparser_->set_allow_harmony_computed_property_names( |
4043 allow_harmony_computed_property_names()); | 4044 allow_harmony_computed_property_names()); |
4044 reusable_preparser_->set_allow_harmony_rest_params( | 4045 reusable_preparser_->set_allow_harmony_rest_params( |
4045 allow_harmony_rest_params()); | 4046 allow_harmony_rest_params()); |
4047 reusable_preparser_->set_allow_harmony_spreadcalls( | |
4048 allow_harmony_spreadcalls()); | |
4046 reusable_preparser_->set_allow_strong_mode(allow_strong_mode()); | 4049 reusable_preparser_->set_allow_strong_mode(allow_strong_mode()); |
4047 } | 4050 } |
4048 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( | 4051 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( |
4049 language_mode(), function_state_->kind(), logger); | 4052 language_mode(), function_state_->kind(), logger); |
4050 if (pre_parse_timer_ != NULL) { | 4053 if (pre_parse_timer_ != NULL) { |
4051 pre_parse_timer_->Stop(); | 4054 pre_parse_timer_->Stop(); |
4052 } | 4055 } |
4053 return result; | 4056 return result; |
4054 } | 4057 } |
4055 | 4058 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4147 | 4150 |
4148 | 4151 |
4149 Expression* Parser::ParseV8Intrinsic(bool* ok) { | 4152 Expression* Parser::ParseV8Intrinsic(bool* ok) { |
4150 // CallRuntime :: | 4153 // CallRuntime :: |
4151 // '%' Identifier Arguments | 4154 // '%' Identifier Arguments |
4152 | 4155 |
4153 int pos = peek_position(); | 4156 int pos = peek_position(); |
4154 Expect(Token::MOD, CHECK_OK); | 4157 Expect(Token::MOD, CHECK_OK); |
4155 // Allow "eval" or "arguments" for backward compatibility. | 4158 // Allow "eval" or "arguments" for backward compatibility. |
4156 const AstRawString* name = ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 4159 const AstRawString* name = ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); |
4157 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); | 4160 Scanner::Location spread_pos; |
4161 ZoneList<Expression*>* args = ParseArguments(&spread_pos, CHECK_OK); | |
4158 | 4162 |
4159 if (extension_ != NULL) { | 4163 if (extension_ != NULL) { |
4160 // The extension structures are only accessible while parsing the | 4164 // The extension structures are only accessible while parsing the |
4161 // very first time not when reparsing because of lazy compilation. | 4165 // very first time not when reparsing because of lazy compilation. |
4162 scope_->DeclarationScope()->ForceEagerCompilation(); | 4166 scope_->DeclarationScope()->ForceEagerCompilation(); |
4163 } | 4167 } |
4164 | 4168 |
4165 const Runtime::Function* function = Runtime::FunctionForName(name->string()); | 4169 const Runtime::Function* function = Runtime::FunctionForName(name->string()); |
4166 | 4170 |
4167 // Check for built-in IS_VAR macro. | 4171 // Check for built-in IS_VAR macro. |
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5467 running_hash, data, raw_string->length()); | 5471 running_hash, data, raw_string->length()); |
5468 } else { | 5472 } else { |
5469 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); | 5473 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); |
5470 running_hash = StringHasher::ComputeRunningHash(running_hash, data, | 5474 running_hash = StringHasher::ComputeRunningHash(running_hash, data, |
5471 raw_string->length()); | 5475 raw_string->length()); |
5472 } | 5476 } |
5473 } | 5477 } |
5474 | 5478 |
5475 return running_hash; | 5479 return running_hash; |
5476 } | 5480 } |
5481 | |
5482 | |
5483 ZoneList<v8::internal::Expression*>* Parser::PrepareSpreadCallArguments( | |
5484 Expression* function, ZoneList<v8::internal::Expression*>* list) { | |
5485 int length = list->length() + 3; | |
arv (Not doing code reviews)
2015/02/18 15:07:06
Please add a comment explaining "3 is the magic nu
| |
5486 Expression* thisArg; | |
5487 | |
5488 if (function->IsProperty()) { | |
arv (Not doing code reviews)
2015/02/18 15:07:06
TODO: IsSuperReference
| |
5489 thisArg = function->AsProperty()->obj(); | |
5490 } else { | |
5491 thisArg = factory()->NewUndefinedLiteral(RelocInfo::kNoPosition); | |
5492 } | |
5493 list->InsertAt(0, function, zone()); | |
5494 list->InsertAt(1, thisArg, zone()); | |
5495 list->InsertAt(2, factory()->NewSmiLiteral(length, RelocInfo::kNoPosition), | |
5496 zone()); | |
5497 | |
5498 for (int i = 3; i < length; ++i) { | |
5499 Expression* arg = list->at(i); | |
5500 if (arg->IsSpreadOperation()) { | |
5501 list->Add(factory()->NewSmiLiteral(i, RelocInfo::kNoPosition), zone()); | |
arv (Not doing code reviews)
2015/02/18 15:07:06
It is not clear to me what the list contains? I th
caitp (gmail)
2015/02/18 15:32:08
I tried to draw a graph of it in a comment, but it
arv (Not doing code reviews)
2015/02/18 15:36:54
I think this is a really good solution but it is n
| |
5502 } | |
5503 } | |
5504 | |
5505 return list; | |
5506 } | |
5507 | |
5508 | |
5509 ZoneList<v8::internal::Expression*>* Parser::PrepareSpreadCallNewArguments( | |
5510 Expression* function, ZoneList<v8::internal::Expression*>* list) { | |
5511 int length = list->length() + 2; | |
5512 | |
5513 list->InsertAt(0, function, zone()); | |
5514 list->InsertAt(1, factory()->NewSmiLiteral(length, RelocInfo::kNoPosition), | |
5515 zone()); | |
5516 | |
5517 for (int i = 2; i < length; ++i) { | |
5518 Expression* arg = list->at(i); | |
5519 if (arg->IsSpreadOperation()) { | |
5520 list->Add(factory()->NewSmiLiteral(i, RelocInfo::kNoPosition), zone()); | |
5521 } | |
5522 } | |
5523 | |
5524 return list; | |
5525 } | |
5477 } } // namespace v8::internal | 5526 } } // namespace v8::internal |
OLD | NEW |