Index: src/full-codegen/full-codegen.cc |
diff --git a/src/full-codegen/full-codegen.cc b/src/full-codegen/full-codegen.cc |
index 1cfa016564011bcec52cd454187a8cea3dec2057..ee5687175b5c9c98f0b03959e72aba04f8856e7e 100644 |
--- a/src/full-codegen/full-codegen.cc |
+++ b/src/full-codegen/full-codegen.cc |
@@ -1007,6 +1007,30 @@ void FullCodeGenerator::EmitUnwindAndReturn() { |
EmitReturnSequence(); |
} |
+void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, |
+ bool pretenure) { |
+ // Use the fast case closure allocation code that allocates in new |
+ // space for nested functions that don't need literals cloning. If |
+ // we're running with the --always-opt or the --prepare-always-opt |
+ // flag, we need to use the runtime function so that the new function |
+ // we are creating here gets a chance to have its code optimized and |
+ // doesn't just get a copy of the existing unoptimized code. |
+ if (!FLAG_always_opt && |
+ !FLAG_prepare_always_opt && |
+ !pretenure && |
+ scope()->is_function_scope() && |
+ info->num_literals() == 0) { |
+ FastNewClosureStub stub(isolate(), info->language_mode(), info->kind()); |
+ __ Move(stub.GetCallInterfaceDescriptor().GetRegisterParameter(0), info); |
+ __ CallStub(&stub); |
+ } else { |
+ __ Push(info); |
+ __ CallRuntime(pretenure ? Runtime::kNewClosure_Tenured |
+ : Runtime::kNewClosure); |
+ } |
+ context()->Plug(result_register()); |
+} |
+ |
void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
SetExpressionPosition(prop); |
Literal* key = prop->key()->AsLiteral(); |