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

Unified Diff: src/crankshaft/hydrogen.cc

Issue 1469793002: [builtins] Sanitize the machinery around Construct calls. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mips64 fix. Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/crankshaft/arm64/lithium-codegen-arm64.cc ('k') | src/crankshaft/hydrogen-instructions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/crankshaft/hydrogen.cc
diff --git a/src/crankshaft/hydrogen.cc b/src/crankshaft/hydrogen.cc
index d0a079d4057defd1af60886dacb2124d414d08d0..95a334a9a66a0215625cff256e5f2ed9505152f0 100644
--- a/src/crankshaft/hydrogen.cc
+++ b/src/crankshaft/hydrogen.cc
@@ -9993,18 +9993,21 @@ void HOptimizedGraphBuilder::VisitCallNew(CallNew* expr) {
instr = prev_instr;
} while (instr != check);
environment()->SetExpressionStackAt(receiver_index, function);
- HInstruction* call =
- PreProcessCall(New<HCallNew>(function, argument_count));
- return ast_context()->ReturnInstruction(call, expr->id());
} else {
// The constructor function is both an operand to the instruction and an
// argument to the construct call.
if (TryHandleArrayCallNew(expr, function)) return;
-
- HInstruction* call =
- PreProcessCall(New<HCallNew>(function, argument_count));
- return ast_context()->ReturnInstruction(call, expr->id());
}
+
+ HValue* arity = Add<HConstant>(argument_count - 1);
+ HValue* op_vals[] = {context(), function, function, arity};
+ Callable callable = CodeFactory::Construct(isolate());
+ HConstant* stub = Add<HConstant>(callable.code());
+ PushArgumentsFromEnvironment(argument_count);
+ HInstruction* construct =
+ New<HCallWithDescriptor>(stub, argument_count, callable.descriptor(),
+ Vector<HValue*>(op_vals, arraysize(op_vals)));
+ return ast_context()->ReturnInstruction(construct, expr->id());
}
« no previous file with comments | « src/crankshaft/arm64/lithium-codegen-arm64.cc ('k') | src/crankshaft/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698