Commit 80779dc7 authored by ishell's avatar ishell Committed by Commit bot

[crankshaft] Support calling JS runtime functions.

This should recover regression caused by 7f11fba7 (https://codereview.chromium.org/1739233002).

TBR=bmeurer@chromium.org
BUG=chromium:592692, chromium:595265
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#34824}
parent 648c2c12
......@@ -266,10 +266,6 @@ void AstNumberingVisitor::VisitFunctionDeclaration(FunctionDeclaration* node) {
void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) {
IncrementNodeCount();
ReserveFeedbackSlots(node);
if (node->is_jsruntime()) {
// Don't try to optimize JS runtime calls because we bailout on them.
DisableCrankshaft(kCallToAJavaScriptRuntimeFunction);
}
node->set_base_id(ReserveIdRange(CallRuntime::num_ids()));
VisitArguments(node->arguments());
}
......
......@@ -36,8 +36,6 @@ namespace internal {
V(kBailoutWasNotPrepared, "Bailout was not prepared") \
V(kBothRegistersWereSmisInSelectNonSmi, \
"Both registers were smis in SelectNonSmi") \
V(kCallToAJavaScriptRuntimeFunction, \
"Call to a JavaScript runtime function") \
V(kClassLiteral, "Class literal") \
V(kCodeGenerationFailed, "Code generation failed") \
V(kCodeObjectNotProperlyPatched, "Code object not properly patched") \
......
......@@ -10481,7 +10481,21 @@ void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) {
DCHECK(current_block() != NULL);
DCHECK(current_block()->HasPredecessor());
if (expr->is_jsruntime()) {
return Bailout(kCallToAJavaScriptRuntimeFunction);
// The callee and the receiver both have to be pushed onto the operand stack
// before arguments are being evaluated.
HValue* function = AddLoadJSBuiltin(expr->context_index());
HValue* receiver = graph()->GetConstantUndefined();
Push(function);
Push(receiver);
int argument_count = expr->arguments()->length() + 1; // Count receiver.
CHECK_ALIVE(VisitExpressions(expr->arguments()));
PushArgumentsFromEnvironment(argument_count);
HInstruction* call = NewCallFunction(function, argument_count,
ConvertReceiverMode::kNullOrUndefined,
TailCallMode::kDisallow);
Drop(1); // Function
return ast_context()->ReturnInstruction(call, expr->id());
}
const Runtime::Function* function = expr->function();
......
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