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

Side by Side Diff: src/parser.cc

Issue 1227093005: Fix uses of eval() with non-string arguments under nosnap/--use-strict (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Undo reordering 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/parser.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/ast-literal-reindexer.h" 9 #include "src/ast-literal-reindexer.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 } 864 }
865 865
866 866
867 Expression* ParserTraits::ParseV8Intrinsic(bool* ok) { 867 Expression* ParserTraits::ParseV8Intrinsic(bool* ok) {
868 return parser_->ParseV8Intrinsic(ok); 868 return parser_->ParseV8Intrinsic(ok);
869 } 869 }
870 870
871 871
872 FunctionLiteral* ParserTraits::ParseFunctionLiteral( 872 FunctionLiteral* ParserTraits::ParseFunctionLiteral(
873 const AstRawString* name, Scanner::Location function_name_location, 873 const AstRawString* name, Scanner::Location function_name_location,
874 bool name_is_strict_reserved, FunctionKind kind, 874 FunctionNameValidity function_name_validity, FunctionKind kind,
875 int function_token_position, FunctionLiteral::FunctionType type, 875 int function_token_position, FunctionLiteral::FunctionType type,
876 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { 876 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) {
877 return parser_->ParseFunctionLiteral( 877 return parser_->ParseFunctionLiteral(
878 name, function_name_location, name_is_strict_reserved, kind, 878 name, function_name_location, function_name_validity, kind,
879 function_token_position, type, arity_restriction, ok); 879 function_token_position, type, arity_restriction, ok);
880 } 880 }
881 881
882 882
883 ClassLiteral* ParserTraits::ParseClassLiteral( 883 ClassLiteral* ParserTraits::ParseClassLiteral(
884 const AstRawString* name, Scanner::Location class_name_location, 884 const AstRawString* name, Scanner::Location class_name_location,
885 bool name_is_strict_reserved, int pos, bool* ok) { 885 bool name_is_strict_reserved, int pos, bool* ok) {
886 return parser_->ParseClassLiteral(name, class_name_location, 886 return parser_->ParseClassLiteral(name, class_name_location,
887 name_is_strict_reserved, pos, ok); 887 name_is_strict_reserved, pos, ok);
888 } 888 }
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 ok = false; 1220 ok = false;
1221 } 1221 }
1222 } 1222 }
1223 } 1223 }
1224 } else if (shared_info->is_default_constructor()) { 1224 } else if (shared_info->is_default_constructor()) {
1225 result = DefaultConstructor(IsSubclassConstructor(shared_info->kind()), 1225 result = DefaultConstructor(IsSubclassConstructor(shared_info->kind()),
1226 scope, shared_info->start_position(), 1226 scope, shared_info->start_position(),
1227 shared_info->end_position()); 1227 shared_info->end_position());
1228 } else { 1228 } else {
1229 result = ParseFunctionLiteral(raw_name, Scanner::Location::invalid(), 1229 result = ParseFunctionLiteral(raw_name, Scanner::Location::invalid(),
1230 false, // Strict mode name already checked. 1230 kSkipFunctionNameCheck, shared_info->kind(),
1231 shared_info->kind(), RelocInfo::kNoPosition, 1231 RelocInfo::kNoPosition, function_type,
1232 function_type,
1233 FunctionLiteral::NORMAL_ARITY, &ok); 1232 FunctionLiteral::NORMAL_ARITY, &ok);
1234 } 1233 }
1235 // Make sure the results agree. 1234 // Make sure the results agree.
1236 DCHECK(ok == (result != NULL)); 1235 DCHECK(ok == (result != NULL));
1237 } 1236 }
1238 1237
1239 // Make sure the target stack is empty. 1238 // Make sure the target stack is empty.
1240 DCHECK(target_stack_ == NULL); 1239 DCHECK(target_stack_ == NULL);
1241 1240
1242 if (result != NULL) { 1241 if (result != NULL) {
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
2187 // GeneratorDeclaration :: 2186 // GeneratorDeclaration ::
2188 // 'function' '*' Identifier '(' FormalParameterListopt ')' 2187 // 'function' '*' Identifier '(' FormalParameterListopt ')'
2189 // '{' FunctionBody '}' 2188 // '{' FunctionBody '}'
2190 Expect(Token::FUNCTION, CHECK_OK); 2189 Expect(Token::FUNCTION, CHECK_OK);
2191 int pos = position(); 2190 int pos = position();
2192 bool is_generator = Check(Token::MUL); 2191 bool is_generator = Check(Token::MUL);
2193 bool is_strict_reserved = false; 2192 bool is_strict_reserved = false;
2194 const AstRawString* name = ParseIdentifierOrStrictReservedWord( 2193 const AstRawString* name = ParseIdentifierOrStrictReservedWord(
2195 &is_strict_reserved, CHECK_OK); 2194 &is_strict_reserved, CHECK_OK);
2196 FunctionLiteral* fun = 2195 FunctionLiteral* fun =
2197 ParseFunctionLiteral(name, scanner()->location(), is_strict_reserved, 2196 ParseFunctionLiteral(name, scanner()->location(),
2197 is_strict_reserved ? kFunctionNameIsStrictReserved
2198 : kFunctionNameValidityUnknown,
2198 is_generator ? FunctionKind::kGeneratorFunction 2199 is_generator ? FunctionKind::kGeneratorFunction
2199 : FunctionKind::kNormalFunction, 2200 : FunctionKind::kNormalFunction,
2200 pos, FunctionLiteral::DECLARATION, 2201 pos, FunctionLiteral::DECLARATION,
2201 FunctionLiteral::NORMAL_ARITY, CHECK_OK); 2202 FunctionLiteral::NORMAL_ARITY, CHECK_OK);
2202 // Even if we're not at the top-level of the global or a function 2203 // Even if we're not at the top-level of the global or a function
2203 // scope, we treat it as such and introduce the function with its 2204 // scope, we treat it as such and introduce the function with its
2204 // initial value upon entering the corresponding scope. 2205 // initial value upon entering the corresponding scope.
2205 // In ES6, a function behaves as a lexical binding, except in 2206 // In ES6, a function behaves as a lexical binding, except in
2206 // a script scope, or the initial scope of eval or another function. 2207 // a script scope, or the initial scope of eval or another function.
2207 VariableMode mode = 2208 VariableMode mode =
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after
3907 if (p.pattern != nullptr) reindexer.Reindex(p.pattern); 3908 if (p.pattern != nullptr) reindexer.Reindex(p.pattern);
3908 } 3909 }
3909 DCHECK(reindexer.count() <= 3910 DCHECK(reindexer.count() <=
3910 parser_->function_state_->materialized_literal_count()); 3911 parser_->function_state_->materialized_literal_count());
3911 } 3912 }
3912 } 3913 }
3913 3914
3914 3915
3915 FunctionLiteral* Parser::ParseFunctionLiteral( 3916 FunctionLiteral* Parser::ParseFunctionLiteral(
3916 const AstRawString* function_name, Scanner::Location function_name_location, 3917 const AstRawString* function_name, Scanner::Location function_name_location,
3917 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, 3918 FunctionNameValidity function_name_validity, FunctionKind kind,
3918 FunctionLiteral::FunctionType function_type, 3919 int function_token_pos, FunctionLiteral::FunctionType function_type,
3919 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { 3920 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) {
3920 // Function :: 3921 // Function ::
3921 // '(' FormalParameterList? ')' '{' FunctionBody '}' 3922 // '(' FormalParameterList? ')' '{' FunctionBody '}'
3922 // 3923 //
3923 // Getter :: 3924 // Getter ::
3924 // '(' ')' '{' FunctionBody '}' 3925 // '(' ')' '{' FunctionBody '}'
3925 // 3926 //
3926 // Setter :: 3927 // Setter ::
3927 // '(' PropertySetParameterList ')' '{' FunctionBody '}' 3928 // '(' PropertySetParameterList ')' '{' FunctionBody '}'
3928 3929
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
4121 MessageTemplate::kStrongSuperCallMissing, 4122 MessageTemplate::kStrongSuperCallMissing,
4122 kReferenceError); 4123 kReferenceError);
4123 *ok = false; 4124 *ok = false;
4124 return nullptr; 4125 return nullptr;
4125 } 4126 }
4126 } 4127 }
4127 } 4128 }
4128 4129
4129 // Validate name and parameter names. We can do this only after parsing the 4130 // Validate name and parameter names. We can do this only after parsing the
4130 // function, since the function can declare itself strict. 4131 // function, since the function can declare itself strict.
4131 CheckFunctionName(language_mode(), kind, function_name, 4132 CheckFunctionName(language_mode(), function_name, function_name_validity,
4132 name_is_strict_reserved, function_name_location, 4133 function_name_location, CHECK_OK);
4133 CHECK_OK);
4134 const bool use_strict_params = 4134 const bool use_strict_params =
4135 !parsing_state.is_simple_parameter_list || IsConciseMethod(kind); 4135 !parsing_state.is_simple_parameter_list || IsConciseMethod(kind);
4136 const bool allow_duplicate_parameters = 4136 const bool allow_duplicate_parameters =
4137 is_sloppy(language_mode()) && !use_strict_params; 4137 is_sloppy(language_mode()) && !use_strict_params;
4138 ValidateFormalParameters(&formals_classifier, language_mode(), 4138 ValidateFormalParameters(&formals_classifier, language_mode(),
4139 allow_duplicate_parameters, CHECK_OK); 4139 allow_duplicate_parameters, CHECK_OK);
4140 4140
4141 if (is_strict(language_mode())) { 4141 if (is_strict(language_mode())) {
4142 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), 4142 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(),
4143 CHECK_OK); 4143 CHECK_OK);
(...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after
5944 Expression* Parser::SpreadCallNew(Expression* function, 5944 Expression* Parser::SpreadCallNew(Expression* function,
5945 ZoneList<v8::internal::Expression*>* args, 5945 ZoneList<v8::internal::Expression*>* args,
5946 int pos) { 5946 int pos) {
5947 args->InsertAt(0, function, zone()); 5947 args->InsertAt(0, function, zone());
5948 5948
5949 return factory()->NewCallRuntime( 5949 return factory()->NewCallRuntime(
5950 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 5950 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
5951 } 5951 }
5952 } // namespace internal 5952 } // namespace internal
5953 } // namespace v8 5953 } // namespace v8
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698