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

Side by Side Diff: src/parser.cc

Issue 6240012: Optimize calls to object literal properties that are initialized with a funct... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: added x64 and arm code. Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3239 matching lines...) Expand 10 before | Expand all | Expand 10 after
3250 Expression* Parser::ParseObjectLiteral(bool* ok) { 3250 Expression* Parser::ParseObjectLiteral(bool* ok) {
3251 // ObjectLiteral :: 3251 // ObjectLiteral ::
3252 // '{' ( 3252 // '{' (
3253 // ((IdentifierName | String | Number) ':' AssignmentExpression) 3253 // ((IdentifierName | String | Number) ':' AssignmentExpression)
3254 // | (('get' | 'set') (IdentifierName | String | Number) FunctionLiteral) 3254 // | (('get' | 'set') (IdentifierName | String | Number) FunctionLiteral)
3255 // )*[','] '}' 3255 // )*[','] '}'
3256 3256
3257 ZoneList<ObjectLiteral::Property*>* properties = 3257 ZoneList<ObjectLiteral::Property*>* properties =
3258 new ZoneList<ObjectLiteral::Property*>(4); 3258 new ZoneList<ObjectLiteral::Property*>(4);
3259 int number_of_boilerplate_properties = 0; 3259 int number_of_boilerplate_properties = 0;
3260 bool has_function = false;
3260 3261
3261 ObjectLiteralPropertyChecker checker(this, temp_scope_->StrictMode()); 3262 ObjectLiteralPropertyChecker checker(this, temp_scope_->StrictMode());
3262 3263
3263 Expect(Token::LBRACE, CHECK_OK); 3264 Expect(Token::LBRACE, CHECK_OK);
3264 Scanner::Location loc = scanner().location(); 3265 Scanner::Location loc = scanner().location();
3265 3266
3266 while (peek() != Token::RBRACE) { 3267 while (peek() != Token::RBRACE) {
3267 if (fni_ != NULL) fni_->Enter(); 3268 if (fni_ != NULL) fni_->Enter();
3268 3269
3269 Literal* key = NULL; 3270 Literal* key = NULL;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
3337 return NULL; 3338 return NULL;
3338 } 3339 }
3339 } 3340 }
3340 3341
3341 Expect(Token::COLON, CHECK_OK); 3342 Expect(Token::COLON, CHECK_OK);
3342 Expression* value = ParseAssignmentExpression(true, CHECK_OK); 3343 Expression* value = ParseAssignmentExpression(true, CHECK_OK);
3343 3344
3344 ObjectLiteral::Property* property = 3345 ObjectLiteral::Property* property =
3345 new ObjectLiteral::Property(key, value); 3346 new ObjectLiteral::Property(key, value);
3346 3347
3348 // Mark object literals that contain function literals and pretenure the
3349 // literal so it can be added as a constant function property.
3350 if (value->AsFunctionLiteral() != NULL) {
3351 has_function = true;
3352 value->AsFunctionLiteral()->set_pretenure(true);
3353 }
3354
3347 // Count CONSTANT or COMPUTED properties to maintain the enumeration order. 3355 // Count CONSTANT or COMPUTED properties to maintain the enumeration order.
3348 if (IsBoilerplateProperty(property)) number_of_boilerplate_properties++; 3356 if (IsBoilerplateProperty(property)) number_of_boilerplate_properties++;
3349 // Validate the property 3357 // Validate the property
3350 checker.CheckProperty(property, loc, CHECK_OK); 3358 checker.CheckProperty(property, loc, CHECK_OK);
3351 properties->Add(property); 3359 properties->Add(property);
3352 3360
3353 // TODO(1240767): Consider allowing trailing comma. 3361 // TODO(1240767): Consider allowing trailing comma.
3354 if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK); 3362 if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK);
3355 3363
3356 if (fni_ != NULL) { 3364 if (fni_ != NULL) {
(...skipping 15 matching lines...) Expand all
3372 BuildObjectLiteralConstantProperties(properties, 3380 BuildObjectLiteralConstantProperties(properties,
3373 constant_properties, 3381 constant_properties,
3374 &is_simple, 3382 &is_simple,
3375 &fast_elements, 3383 &fast_elements,
3376 &depth); 3384 &depth);
3377 return new ObjectLiteral(constant_properties, 3385 return new ObjectLiteral(constant_properties,
3378 properties, 3386 properties,
3379 literal_index, 3387 literal_index,
3380 is_simple, 3388 is_simple,
3381 fast_elements, 3389 fast_elements,
3382 depth); 3390 depth,
3391 has_function);
3383 } 3392 }
3384 3393
3385 3394
3386 Expression* Parser::ParseRegExpLiteral(bool seen_equal, bool* ok) { 3395 Expression* Parser::ParseRegExpLiteral(bool seen_equal, bool* ok) {
3387 if (!scanner().ScanRegExpPattern(seen_equal)) { 3396 if (!scanner().ScanRegExpPattern(seen_equal)) {
3388 Next(); 3397 Next();
3389 ReportMessage("unterminated_regexp", Vector<const char*>::empty()); 3398 ReportMessage("unterminated_regexp", Vector<const char*>::empty());
3390 *ok = false; 3399 *ok = false;
3391 return NULL; 3400 return NULL;
3392 } 3401 }
(...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after
5027 Handle<String> source = Handle<String>(String::cast(script->source())); 5036 Handle<String> source = Handle<String>(String::cast(script->source()));
5028 result = parser.ParseProgram(source, info->is_global()); 5037 result = parser.ParseProgram(source, info->is_global());
5029 } 5038 }
5030 } 5039 }
5031 5040
5032 info->SetFunction(result); 5041 info->SetFunction(result);
5033 return (result != NULL); 5042 return (result != NULL);
5034 } 5043 }
5035 5044
5036 } } // namespace v8::internal 5045 } } // namespace v8::internal
OLDNEW
« src/hydrogen-instructions.h ('K') | « src/ia32/lithium-ia32.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698