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

Side by Side Diff: src/parser.cc

Issue 952243002: Implement experimental exponentiation operator via desugaring (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Simplify scanner, inline getting ast_value_factory in parser Created 5 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
« no previous file with comments | « src/ic/ic-state.h ('k') | src/preparser.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 // 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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 uint32_t value = DoubleToUint32(x_val) >> shift; 504 uint32_t value = DoubleToUint32(x_val) >> shift;
505 *x = factory->NewNumberLiteral(value, pos); 505 *x = factory->NewNumberLiteral(value, pos);
506 return true; 506 return true;
507 } 507 }
508 case Token::SAR: { 508 case Token::SAR: {
509 uint32_t shift = DoubleToInt32(y_val) & 0x1f; 509 uint32_t shift = DoubleToInt32(y_val) & 0x1f;
510 int value = ArithmeticShiftRight(DoubleToInt32(x_val), shift); 510 int value = ArithmeticShiftRight(DoubleToInt32(x_val), shift);
511 *x = factory->NewNumberLiteral(value, pos); 511 *x = factory->NewNumberLiteral(value, pos);
512 return true; 512 return true;
513 } 513 }
514 case Token::EXP: {
515 double value = power_helper(x_val, y_val);
516 *x = factory->NewNumberLiteral(value, pos);
517 return true;
518 }
514 default: 519 default:
515 break; 520 break;
516 } 521 }
522 } else if (op == Token::EXP) {
523 Zone* zone = parser_->zone();
524
525 // Desugar exponentiation to runtime call
526 ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(2, zone);
527 args->Add(*x, zone);
528 args->Add(y, zone);
529 *x = factory->NewCallRuntime(
530 parser_->ast_value_factory()->math_pow_string(), NULL, args, pos);
531 return true;
517 } 532 }
518 return false; 533 return false;
519 } 534 }
520 535
521 536
522 Expression* ParserTraits::BuildUnaryExpression(Expression* expression, 537 Expression* ParserTraits::BuildUnaryExpression(Expression* expression,
523 Token::Value op, int pos, 538 Token::Value op, int pos,
524 AstNodeFactory* factory) { 539 AstNodeFactory* factory) {
525 DCHECK(expression != NULL); 540 DCHECK(expression != NULL);
526 if (expression->IsLiteral()) { 541 if (expression->IsLiteral()) {
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions); 823 set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions);
809 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); 824 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals);
810 set_allow_harmony_classes(FLAG_harmony_classes); 825 set_allow_harmony_classes(FLAG_harmony_classes);
811 set_allow_harmony_object_literals(FLAG_harmony_object_literals); 826 set_allow_harmony_object_literals(FLAG_harmony_object_literals);
812 set_allow_harmony_templates(FLAG_harmony_templates); 827 set_allow_harmony_templates(FLAG_harmony_templates);
813 set_allow_harmony_sloppy(FLAG_harmony_sloppy); 828 set_allow_harmony_sloppy(FLAG_harmony_sloppy);
814 set_allow_harmony_unicode(FLAG_harmony_unicode); 829 set_allow_harmony_unicode(FLAG_harmony_unicode);
815 set_allow_harmony_computed_property_names( 830 set_allow_harmony_computed_property_names(
816 FLAG_harmony_computed_property_names); 831 FLAG_harmony_computed_property_names);
817 set_allow_harmony_rest_params(FLAG_harmony_rest_parameters); 832 set_allow_harmony_rest_params(FLAG_harmony_rest_parameters);
833 set_allow_harmony_exponentiation(FLAG_harmony_exponentiation);
818 set_allow_strong_mode(FLAG_strong_mode); 834 set_allow_strong_mode(FLAG_strong_mode);
819 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; 835 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount;
820 ++feature) { 836 ++feature) {
821 use_counts_[feature] = 0; 837 use_counts_[feature] = 0;
822 } 838 }
823 if (info->ast_value_factory() == NULL) { 839 if (info->ast_value_factory() == NULL) {
824 // info takes ownership of AstValueFactory. 840 // info takes ownership of AstValueFactory.
825 info->SetAstValueFactory(new AstValueFactory(zone(), hash_seed)); 841 info->SetAstValueFactory(new AstValueFactory(zone(), hash_seed));
826 ast_value_factory_ = info->ast_value_factory(); 842 ast_value_factory_ = info->ast_value_factory();
827 } 843 }
(...skipping 3224 matching lines...) Expand 10 before | Expand all | Expand 10 after
4052 reusable_preparser_->set_allow_harmony_classes(allow_harmony_classes()); 4068 reusable_preparser_->set_allow_harmony_classes(allow_harmony_classes());
4053 reusable_preparser_->set_allow_harmony_object_literals( 4069 reusable_preparser_->set_allow_harmony_object_literals(
4054 allow_harmony_object_literals()); 4070 allow_harmony_object_literals());
4055 reusable_preparser_->set_allow_harmony_templates(allow_harmony_templates()); 4071 reusable_preparser_->set_allow_harmony_templates(allow_harmony_templates());
4056 reusable_preparser_->set_allow_harmony_sloppy(allow_harmony_sloppy()); 4072 reusable_preparser_->set_allow_harmony_sloppy(allow_harmony_sloppy());
4057 reusable_preparser_->set_allow_harmony_unicode(allow_harmony_unicode()); 4073 reusable_preparser_->set_allow_harmony_unicode(allow_harmony_unicode());
4058 reusable_preparser_->set_allow_harmony_computed_property_names( 4074 reusable_preparser_->set_allow_harmony_computed_property_names(
4059 allow_harmony_computed_property_names()); 4075 allow_harmony_computed_property_names());
4060 reusable_preparser_->set_allow_harmony_rest_params( 4076 reusable_preparser_->set_allow_harmony_rest_params(
4061 allow_harmony_rest_params()); 4077 allow_harmony_rest_params());
4078 reusable_preparser_->set_allow_harmony_exponentiation(
4079 allow_harmony_exponentiation());
4062 reusable_preparser_->set_allow_strong_mode(allow_strong_mode()); 4080 reusable_preparser_->set_allow_strong_mode(allow_strong_mode());
4063 } 4081 }
4064 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( 4082 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction(
4065 language_mode(), function_state_->kind(), logger); 4083 language_mode(), function_state_->kind(), logger);
4066 if (pre_parse_timer_ != NULL) { 4084 if (pre_parse_timer_ != NULL) {
4067 pre_parse_timer_->Stop(); 4085 pre_parse_timer_->Stop();
4068 } 4086 }
4069 return result; 4087 return result;
4070 } 4088 }
4071 4089
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
5485 } else { 5503 } else {
5486 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); 5504 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data());
5487 running_hash = StringHasher::ComputeRunningHash(running_hash, data, 5505 running_hash = StringHasher::ComputeRunningHash(running_hash, data,
5488 raw_string->length()); 5506 raw_string->length());
5489 } 5507 }
5490 } 5508 }
5491 5509
5492 return running_hash; 5510 return running_hash;
5493 } 5511 }
5494 } } // namespace v8::internal 5512 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic/ic-state.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698