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

Side by Side Diff: src/parser.cc

Issue 5220007: Force pretenuring of closures that are immediately assigned to... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 1 month 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 2258 matching lines...) Expand 10 before | Expand all | Expand 10 after
2269 // properties if we haven't seen them before. Otherwise we'll 2269 // properties if we haven't seen them before. Otherwise we'll
2270 // probably overestimate the number of properties. 2270 // probably overestimate the number of properties.
2271 Property* property = expression ? expression->AsProperty() : NULL; 2271 Property* property = expression ? expression->AsProperty() : NULL;
2272 if (op == Token::ASSIGN && 2272 if (op == Token::ASSIGN &&
2273 property != NULL && 2273 property != NULL &&
2274 property->obj()->AsVariableProxy() != NULL && 2274 property->obj()->AsVariableProxy() != NULL &&
2275 property->obj()->AsVariableProxy()->is_this()) { 2275 property->obj()->AsVariableProxy()->is_this()) {
2276 temp_scope_->AddProperty(); 2276 temp_scope_->AddProperty();
2277 } 2277 }
2278 2278
2279 // If we assign a function literal to a property we pretenure the
2280 // literal so it can be added as a constant function property.
2281 if (property != NULL && right->AsFunctionLiteral() != NULL) {
2282 right->AsFunctionLiteral()->set_pretenure(true);
2283 }
2284
2279 if (fni_ != NULL) { 2285 if (fni_ != NULL) {
2280 // Check if the right hand side is a call to avoid inferring a 2286 // Check if the right hand side is a call to avoid inferring a
2281 // name if we're dealing with "a = function(){...}();"-like 2287 // name if we're dealing with "a = function(){...}();"-like
2282 // expression. 2288 // expression.
2283 if ((op == Token::INIT_VAR 2289 if ((op == Token::INIT_VAR
2284 || op == Token::INIT_CONST 2290 || op == Token::INIT_CONST
2285 || op == Token::ASSIGN) 2291 || op == Token::ASSIGN)
2286 && (right->AsCall() == NULL)) { 2292 && (right->AsCall() == NULL)) {
2287 fni_->Infer(); 2293 fni_->Infer();
2288 } 2294 }
(...skipping 2448 matching lines...) Expand 10 before | Expand all | Expand 10 after
4737 Handle<String> source = Handle<String>(String::cast(script->source())); 4743 Handle<String> source = Handle<String>(String::cast(script->source()));
4738 result = parser.ParseProgram(source, info->is_global()); 4744 result = parser.ParseProgram(source, info->is_global());
4739 } 4745 }
4740 } 4746 }
4741 4747
4742 info->SetFunction(result); 4748 info->SetFunction(result);
4743 return (result != NULL); 4749 return (result != NULL);
4744 } 4750 }
4745 4751
4746 } } // namespace v8::internal 4752 } } // namespace v8::internal
OLDNEW
« src/arm/codegen-arm.cc ('K') | « src/ia32/full-codegen-ia32.cc ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698