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

Side by Side Diff: src/x64/codegen-x64.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 4226 matching lines...) Expand 10 before | Expand all | Expand 10 after
4237 // Spill everything, even constants, to the frame. 4237 // Spill everything, even constants, to the frame.
4238 frame_->SpillAll(); 4238 frame_->SpillAll();
4239 4239
4240 frame_->DebugBreak(); 4240 frame_->DebugBreak();
4241 // Ignore the return value. 4241 // Ignore the return value.
4242 #endif 4242 #endif
4243 } 4243 }
4244 4244
4245 4245
4246 void CodeGenerator::InstantiateFunction( 4246 void CodeGenerator::InstantiateFunction(
4247 Handle<SharedFunctionInfo> function_info) { 4247 Handle<SharedFunctionInfo> function_info,
4248 bool pretenure) {
4248 // The inevitable call will sync frame elements to memory anyway, so 4249 // The inevitable call will sync frame elements to memory anyway, so
4249 // we do it eagerly to allow us to push the arguments directly into 4250 // we do it eagerly to allow us to push the arguments directly into
4250 // place. 4251 // place.
4251 frame_->SyncRange(0, frame_->element_count() - 1); 4252 frame_->SyncRange(0, frame_->element_count() - 1);
4252 4253
4253 // Use the fast case closure allocation code that allocates in new 4254 // Use the fast case closure allocation code that allocates in new
4254 // space for nested functions that don't need literals cloning. 4255 // space for nested functions that don't need literals cloning.
4255 if (scope()->is_function_scope() && function_info->num_literals() == 0) { 4256 if (scope()->is_function_scope() &&
4257 function_info->num_literals() == 0 &&
4258 !pretenure) {
4256 FastNewClosureStub stub; 4259 FastNewClosureStub stub;
4257 frame_->Push(function_info); 4260 frame_->Push(function_info);
4258 Result answer = frame_->CallStub(&stub, 1); 4261 Result answer = frame_->CallStub(&stub, 1);
4259 frame_->Push(&answer); 4262 frame_->Push(&answer);
4260 } else { 4263 } else {
4261 // Call the runtime to instantiate the function based on the 4264 // Call the runtime to instantiate the function based on the
4262 // shared function info. 4265 // shared function info.
4263 frame_->EmitPush(rsi); 4266 frame_->EmitPush(rsi);
4264 frame_->EmitPush(function_info); 4267 frame_->EmitPush(function_info);
4265 Result result = frame_->CallRuntime(Runtime::kNewClosure, 2); 4268 frame_->EmitPush(pretenure
4269 ? Factory::true_value()
4270 : Factory::false_value());
4271 Result result = frame_->CallRuntime(Runtime::kNewClosure, 3);
4266 frame_->Push(&result); 4272 frame_->Push(&result);
4267 } 4273 }
4268 } 4274 }
4269 4275
4270 4276
4271 void CodeGenerator::VisitFunctionLiteral(FunctionLiteral* node) { 4277 void CodeGenerator::VisitFunctionLiteral(FunctionLiteral* node) {
4272 Comment cmnt(masm_, "[ FunctionLiteral"); 4278 Comment cmnt(masm_, "[ FunctionLiteral");
4273 4279
4274 // Build the function info and instantiate it. 4280 // Build the function info and instantiate it.
4275 Handle<SharedFunctionInfo> function_info = 4281 Handle<SharedFunctionInfo> function_info =
4276 Compiler::BuildFunctionInfo(node, script()); 4282 Compiler::BuildFunctionInfo(node, script());
4277 // Check for stack-overflow exception. 4283 // Check for stack-overflow exception.
4278 if (function_info.is_null()) { 4284 if (function_info.is_null()) {
4279 SetStackOverflow(); 4285 SetStackOverflow();
4280 return; 4286 return;
4281 } 4287 }
4282 InstantiateFunction(function_info); 4288 InstantiateFunction(function_info, node->pretenure());
4283 } 4289 }
4284 4290
4285 4291
4286 void CodeGenerator::VisitSharedFunctionInfoLiteral( 4292 void CodeGenerator::VisitSharedFunctionInfoLiteral(
4287 SharedFunctionInfoLiteral* node) { 4293 SharedFunctionInfoLiteral* node) {
4288 Comment cmnt(masm_, "[ SharedFunctionInfoLiteral"); 4294 Comment cmnt(masm_, "[ SharedFunctionInfoLiteral");
4289 InstantiateFunction(node->shared_function_info()); 4295 InstantiateFunction(node->shared_function_info(), false);
4290 } 4296 }
4291 4297
4292 4298
4293 void CodeGenerator::VisitConditional(Conditional* node) { 4299 void CodeGenerator::VisitConditional(Conditional* node) {
4294 Comment cmnt(masm_, "[ Conditional"); 4300 Comment cmnt(masm_, "[ Conditional");
4295 JumpTarget then; 4301 JumpTarget then;
4296 JumpTarget else_; 4302 JumpTarget else_;
4297 JumpTarget exit; 4303 JumpTarget exit;
4298 ControlDestination dest(&then, &else_, true); 4304 ControlDestination dest(&then, &else_, true);
4299 LoadCondition(node->condition(), &dest, true); 4305 LoadCondition(node->condition(), &dest, true);
(...skipping 4572 matching lines...) Expand 10 before | Expand all | Expand 10 after
8872 #undef __ 8878 #undef __
8873 8879
8874 void RecordWriteStub::Generate(MacroAssembler* masm) { 8880 void RecordWriteStub::Generate(MacroAssembler* masm) {
8875 masm->RecordWriteHelper(object_, addr_, scratch_); 8881 masm->RecordWriteHelper(object_, addr_, scratch_);
8876 masm->ret(0); 8882 masm->ret(0);
8877 } 8883 }
8878 8884
8879 } } // namespace v8::internal 8885 } } // namespace v8::internal
8880 8886
8881 #endif // V8_TARGET_ARCH_X64 8887 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/arm/codegen-arm.cc ('K') | « src/x64/codegen-x64.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698