Commit 479a2df3 authored by bmeurer's avatar bmeurer Committed by Commit bot

[crankshaft] Specialize JS runtime calls to the native context.

Since Crankshaft specializes to the native context anyways, we don't
need the indirection of loading from the native context and calling the
JS runtime function indirectly, but we can just specialize to the JS
runtime function from the native context and emit a direct (constant)
function call.

BUG=chromium:592692,chromium:595265
R=ishell@chromium.org
LOG=n

Review URL: https://codereview.chromium.org/1807003002

Cr-Commit-Position: refs/heads/master@{#34842}
parent 46fabc1e
...@@ -10481,18 +10481,25 @@ void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) { ...@@ -10481,18 +10481,25 @@ void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) {
DCHECK(current_block() != NULL); DCHECK(current_block() != NULL);
DCHECK(current_block()->HasPredecessor()); DCHECK(current_block()->HasPredecessor());
if (expr->is_jsruntime()) { if (expr->is_jsruntime()) {
// Crankshaft always specializes to the native context, so we can just grab
// the constant function from the current native context and embed that into
// the code object.
Handle<JSFunction> known_function(
JSFunction::cast(
current_info()->native_context()->get(expr->context_index())),
isolate());
// The callee and the receiver both have to be pushed onto the operand stack // The callee and the receiver both have to be pushed onto the operand stack
// before arguments are being evaluated. // before arguments are being evaluated.
HValue* function = AddLoadJSBuiltin(expr->context_index()); HConstant* function = Add<HConstant>(known_function);
HValue* receiver = graph()->GetConstantUndefined(); HValue* receiver = ImplicitReceiverFor(function, known_function);
Push(function); Push(function);
Push(receiver); Push(receiver);
int argument_count = expr->arguments()->length() + 1; // Count receiver. int argument_count = expr->arguments()->length() + 1; // Count receiver.
CHECK_ALIVE(VisitExpressions(expr->arguments())); CHECK_ALIVE(VisitExpressions(expr->arguments()));
PushArgumentsFromEnvironment(argument_count); PushArgumentsFromEnvironment(argument_count);
HInstruction* call = NewCallFunction(function, argument_count, HInstruction* call = NewCallConstantFunction(known_function, argument_count,
ConvertReceiverMode::kNullOrUndefined,
TailCallMode::kDisallow); TailCallMode::kDisallow);
Drop(1); // Function Drop(1); // Function
return ast_context()->ReturnInstruction(call, expr->id()); return ast_context()->ReturnInstruction(call, expr->id());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment