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

Unified Diff: src/hydrogen.cc

Issue 1329293003: [runtime] Sanitize %NewClosure runtime entries. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Ports Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 902e507258c6c722c829c244df0c1e17be632620..337c35b87b76e897e131848e58a0a191e2ec739f 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -5473,8 +5473,25 @@ void HOptimizedGraphBuilder::VisitFunctionLiteral(FunctionLiteral* expr) {
expr, current_info()->script(), top_info());
// We also have a stack overflow if the recursive compilation did.
if (HasStackOverflow()) return;
- HFunctionLiteral* instr =
- New<HFunctionLiteral>(shared_info, expr->pretenure());
+ // Use the fast case closure allocation code that allocates in new
+ // space for nested functions that don't need literals cloning.
+ HConstant* shared_info_value = Add<HConstant>(shared_info);
+ HInstruction* instr;
+ if (!expr->pretenure() && shared_info->num_literals() == 0) {
+ FastNewClosureStub stub(isolate(), shared_info->language_mode(),
+ shared_info->kind());
+ FastNewClosureDescriptor descriptor(isolate());
+ HValue* values[] = {context(), shared_info_value};
+ HConstant* stub_value = Add<HConstant>(stub.GetCode());
+ instr = New<HCallWithDescriptor>(stub_value, 0, descriptor,
+ Vector<HValue*>(values, arraysize(values)),
+ NORMAL_CALL);
+ } else {
+ Add<HPushArguments>(shared_info_value);
+ Runtime::FunctionId function_id =
+ expr->pretenure() ? Runtime::kNewClosure_Tenured : Runtime::kNewClosure;
+ instr = New<HCallRuntime>(Runtime::FunctionForId(function_id), 1);
+ }
return ast_context()->ReturnInstruction(instr, expr->id());
}
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698