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

Side by Side Diff: src/preparser.cc

Issue 1231343003: Scoping error caused crash in CallICNexus::StateFromFeedback (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix webkit tests. Created 5 years, 5 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/preparser.h ('k') | test/mjsunit/regress/regress-491536.js » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 <cmath> 5 #include <cmath>
6 6
7 #include "src/allocation.h" 7 #include "src/allocation.h"
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 PreParserExpression PreParserTraits::ParseV8Intrinsic(bool* ok) { 87 PreParserExpression PreParserTraits::ParseV8Intrinsic(bool* ok) {
88 return pre_parser_->ParseV8Intrinsic(ok); 88 return pre_parser_->ParseV8Intrinsic(ok);
89 } 89 }
90 90
91 91
92 PreParserExpression PreParserTraits::ParseFunctionLiteral( 92 PreParserExpression PreParserTraits::ParseFunctionLiteral(
93 PreParserIdentifier name, Scanner::Location function_name_location, 93 PreParserIdentifier name, Scanner::Location function_name_location,
94 FunctionNameValidity function_name_validity, FunctionKind kind, 94 FunctionNameValidity function_name_validity, FunctionKind kind,
95 int function_token_position, FunctionLiteral::FunctionType type, 95 int function_token_position, FunctionLiteral::FunctionType type,
96 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { 96 FunctionLiteral::ArityRestriction arity_restriction,
97 LanguageMode language_mode, bool* ok) {
97 return pre_parser_->ParseFunctionLiteral( 98 return pre_parser_->ParseFunctionLiteral(
98 name, function_name_location, function_name_validity, kind, 99 name, function_name_location, function_name_validity, kind,
99 function_token_position, type, arity_restriction, ok); 100 function_token_position, type, arity_restriction, language_mode, ok);
100 } 101 }
101 102
102 103
103 PreParser::PreParseResult PreParser::PreParseLazyFunction( 104 PreParser::PreParseResult PreParser::PreParseLazyFunction(
104 LanguageMode language_mode, FunctionKind kind, ParserRecorder* log, 105 LanguageMode language_mode, FunctionKind kind, ParserRecorder* log,
105 Scanner::BookmarkScope* bookmark) { 106 Scanner::BookmarkScope* bookmark) {
106 log_ = log; 107 log_ = log;
107 // Lazy functions always have trivial outer scopes (no with/catch scopes). 108 // Lazy functions always have trivial outer scopes (no with/catch scopes).
108 Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE); 109 Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE);
109 PreParserFactory top_factory(NULL); 110 PreParserFactory top_factory(NULL);
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 bool is_generator = Check(Token::MUL); 419 bool is_generator = Check(Token::MUL);
419 bool is_strict_reserved = false; 420 bool is_strict_reserved = false;
420 Identifier name = ParseIdentifierOrStrictReservedWord( 421 Identifier name = ParseIdentifierOrStrictReservedWord(
421 &is_strict_reserved, CHECK_OK); 422 &is_strict_reserved, CHECK_OK);
422 ParseFunctionLiteral(name, scanner()->location(), 423 ParseFunctionLiteral(name, scanner()->location(),
423 is_strict_reserved ? kFunctionNameIsStrictReserved 424 is_strict_reserved ? kFunctionNameIsStrictReserved
424 : kFunctionNameValidityUnknown, 425 : kFunctionNameValidityUnknown,
425 is_generator ? FunctionKind::kGeneratorFunction 426 is_generator ? FunctionKind::kGeneratorFunction
426 : FunctionKind::kNormalFunction, 427 : FunctionKind::kNormalFunction,
427 pos, FunctionLiteral::DECLARATION, 428 pos, FunctionLiteral::DECLARATION,
428 FunctionLiteral::NORMAL_ARITY, CHECK_OK); 429 FunctionLiteral::NORMAL_ARITY, language_mode(),
430 CHECK_OK);
429 return Statement::FunctionDeclaration(); 431 return Statement::FunctionDeclaration();
430 } 432 }
431 433
432 434
433 PreParser::Statement PreParser::ParseClassDeclaration(bool* ok) { 435 PreParser::Statement PreParser::ParseClassDeclaration(bool* ok) {
434 Expect(Token::CLASS, CHECK_OK); 436 Expect(Token::CLASS, CHECK_OK);
435 if (!allow_harmony_sloppy() && is_sloppy(language_mode())) { 437 if (!allow_harmony_sloppy() && is_sloppy(language_mode())) {
436 ReportMessage(MessageTemplate::kSloppyLexical); 438 ReportMessage(MessageTemplate::kSloppyLexical);
437 *ok = false; 439 *ok = false;
438 return Statement::Default(); 440 return Statement::Default();
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 if (!*ok) return Expression::Default(); \ 1027 if (!*ok) return Expression::Default(); \
1026 ((void)0 1028 ((void)0
1027 #define DUMMY ) // to make indentation work 1029 #define DUMMY ) // to make indentation work
1028 #undef DUMMY 1030 #undef DUMMY
1029 1031
1030 1032
1031 PreParser::Expression PreParser::ParseFunctionLiteral( 1033 PreParser::Expression PreParser::ParseFunctionLiteral(
1032 Identifier function_name, Scanner::Location function_name_location, 1034 Identifier function_name, Scanner::Location function_name_location,
1033 FunctionNameValidity function_name_validity, FunctionKind kind, 1035 FunctionNameValidity function_name_validity, FunctionKind kind,
1034 int function_token_pos, FunctionLiteral::FunctionType function_type, 1036 int function_token_pos, FunctionLiteral::FunctionType function_type,
1035 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { 1037 FunctionLiteral::ArityRestriction arity_restriction,
1038 LanguageMode language_mode, bool* ok) {
1036 // Function :: 1039 // Function ::
1037 // '(' FormalParameterList? ')' '{' FunctionBody '}' 1040 // '(' FormalParameterList? ')' '{' FunctionBody '}'
1038 1041
1039 // Parse function body. 1042 // Parse function body.
1040 bool outer_is_script_scope = scope_->is_script_scope(); 1043 bool outer_is_script_scope = scope_->is_script_scope();
1041 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind); 1044 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind);
1045 function_scope->SetLanguageMode(language_mode);
1042 PreParserFactory factory(NULL); 1046 PreParserFactory factory(NULL);
1043 FunctionState function_state(&function_state_, &scope_, function_scope, kind, 1047 FunctionState function_state(&function_state_, &scope_, function_scope, kind,
1044 &factory); 1048 &factory);
1045 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); 1049 DuplicateFinder duplicate_finder(scanner()->unicode_cache());
1046 ExpressionClassifier formals_classifier(&duplicate_finder); 1050 ExpressionClassifier formals_classifier(&duplicate_finder);
1047 1051
1048 Expect(Token::LPAREN, CHECK_OK); 1052 Expect(Token::LPAREN, CHECK_OK);
1049 int start_position = scanner()->location().beg_pos; 1053 int start_position = scanner()->location().beg_pos;
1050 function_scope->set_start_position(start_position); 1054 function_scope->set_start_position(start_position);
1051 PreParserFormalParameterParsingState parsing_state(nullptr); 1055 PreParserFormalParameterParsingState parsing_state(nullptr);
(...skipping 13 matching lines...) Expand all
1065 parenthesized_function_ = false; 1069 parenthesized_function_ = false;
1066 1070
1067 Expect(Token::LBRACE, CHECK_OK); 1071 Expect(Token::LBRACE, CHECK_OK);
1068 if (is_lazily_parsed) { 1072 if (is_lazily_parsed) {
1069 ParseLazyFunctionLiteralBody(CHECK_OK); 1073 ParseLazyFunctionLiteralBody(CHECK_OK);
1070 } else { 1074 } else {
1071 ParseStatementList(Token::RBRACE, CHECK_OK); 1075 ParseStatementList(Token::RBRACE, CHECK_OK);
1072 } 1076 }
1073 Expect(Token::RBRACE, CHECK_OK); 1077 Expect(Token::RBRACE, CHECK_OK);
1074 1078
1079 // Parsing the body may change the language mode in our scope.
1080 language_mode = function_scope->language_mode();
1081
1075 // Validate name and parameter names. We can do this only after parsing the 1082 // Validate name and parameter names. We can do this only after parsing the
1076 // function, since the function can declare itself strict. 1083 // function, since the function can declare itself strict.
1077 CheckFunctionName(language_mode(), function_name, function_name_validity, 1084 CheckFunctionName(language_mode, function_name, function_name_validity,
1078 function_name_location, CHECK_OK); 1085 function_name_location, CHECK_OK);
1079 const bool strict_formal_parameters = 1086 const bool strict_formal_parameters =
1080 !parsing_state.is_simple_parameter_list || IsConciseMethod(kind); 1087 !parsing_state.is_simple_parameter_list || IsConciseMethod(kind);
1081 const bool allow_duplicate_parameters = 1088 const bool allow_duplicate_parameters =
1082 is_sloppy(language_mode()) && !strict_formal_parameters; 1089 is_sloppy(language_mode) && !strict_formal_parameters;
1083 ValidateFormalParameters(&formals_classifier, language_mode(), 1090 ValidateFormalParameters(&formals_classifier, language_mode,
1084 allow_duplicate_parameters, CHECK_OK); 1091 allow_duplicate_parameters, CHECK_OK);
1085 1092
1086 if (is_strict(language_mode())) { 1093 if (is_strict(language_mode)) {
1087 int end_position = scanner()->location().end_pos; 1094 int end_position = scanner()->location().end_pos;
1088 CheckStrictOctalLiteral(start_position, end_position, CHECK_OK); 1095 CheckStrictOctalLiteral(start_position, end_position, CHECK_OK);
1089 } 1096 }
1090 1097
1091 if (is_strong(language_mode()) && IsSubclassConstructor(kind)) { 1098 if (is_strong(language_mode) && IsSubclassConstructor(kind)) {
1092 if (!function_state.super_location().IsValid()) { 1099 if (!function_state.super_location().IsValid()) {
1093 ReportMessageAt(function_name_location, 1100 ReportMessageAt(function_name_location,
1094 MessageTemplate::kStrongSuperCallMissing, 1101 MessageTemplate::kStrongSuperCallMissing,
1095 kReferenceError); 1102 kReferenceError);
1096 *ok = false; 1103 *ok = false;
1097 return Expression::Default(); 1104 return Expression::Default();
1098 } 1105 }
1099 } 1106 }
1100 1107
1101 return Expression::Default(); 1108 return Expression::Default();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 1202
1196 DCHECK(!spread_pos.IsValid()); 1203 DCHECK(!spread_pos.IsValid());
1197 1204
1198 return Expression::Default(); 1205 return Expression::Default();
1199 } 1206 }
1200 1207
1201 #undef CHECK_OK 1208 #undef CHECK_OK
1202 1209
1203 1210
1204 } } // v8::internal 1211 } } // v8::internal
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | test/mjsunit/regress/regress-491536.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698