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

Unified Diff: src/crankshaft/hydrogen.cc

Issue 1780043004: [crankshaft] Fixing ES6 tail call elimination. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebasing Created 4 years, 9 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/crankshaft/hydrogen.h ('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 bbe121704ce18641f70dd238c8daeb56d4584b5e..22e2f7b0e5c82ffb472fcd89c6b892b1fb77c8fd 100644
--- a/src/crankshaft/hydrogen.cc
+++ b/src/crankshaft/hydrogen.cc
@@ -5513,9 +5513,8 @@ void HOptimizedGraphBuilder::VisitFunctionLiteral(FunctionLiteral* expr) {
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);
+ instr = New<HCallWithDescriptor>(
+ stub_value, 0, descriptor, Vector<HValue*>(values, arraysize(values)));
} else {
Add<HPushArguments>(shared_info_value);
Runtime::FunctionId function_id =
@@ -5796,9 +5795,9 @@ void HOptimizedGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) {
context(), AddThisFunction(), Add<HConstant>(expr->literal_index()),
Add<HConstant>(expr->pattern()), Add<HConstant>(expr->flags())};
HConstant* stub_value = Add<HConstant>(callable.code());
- HInstruction* instr = New<HCallWithDescriptor>(
- stub_value, 0, callable.descriptor(),
- Vector<HValue*>(values, arraysize(values)), NORMAL_CALL);
+ HInstruction* instr =
+ New<HCallWithDescriptor>(stub_value, 0, callable.descriptor(),
+ Vector<HValue*>(values, arraysize(values)));
return ast_context()->ReturnInstruction(instr, expr->id());
}
@@ -6583,7 +6582,7 @@ HValue* HOptimizedGraphBuilder::BuildMonomorphicAccess(
info->NeedsWrappingFor(Handle<JSFunction>::cast(info->accessor()))) {
HValue* function = Add<HConstant>(info->accessor());
PushArgumentsFromEnvironment(argument_count);
- return NewCallFunction(function, argument_count,
+ return NewCallFunction(function, argument_count, TailCallMode::kDisallow,
ConvertReceiverMode::kNotNullOrUndefined,
TailCallMode::kDisallow);
} else if (FLAG_inline_accessors && can_inline_accessor) {
@@ -6600,7 +6599,8 @@ HValue* HOptimizedGraphBuilder::BuildMonomorphicAccess(
return nullptr;
}
return NewCallConstantFunction(Handle<JSFunction>::cast(info->accessor()),
- argument_count, TailCallMode::kDisallow);
+ argument_count, TailCallMode::kDisallow,
+ TailCallMode::kDisallow);
}
DCHECK(info->IsDataConstant());
@@ -7999,8 +7999,8 @@ void HOptimizedGraphBuilder::AddCheckPrototypeMaps(Handle<JSObject> holder,
}
HInstruction* HOptimizedGraphBuilder::NewCallFunction(
- HValue* function, int argument_count, ConvertReceiverMode convert_mode,
- TailCallMode tail_call_mode) {
+ HValue* function, int argument_count, TailCallMode syntactic_tail_call_mode,
+ ConvertReceiverMode convert_mode, TailCallMode tail_call_mode) {
HValue* arity = Add<HConstant>(argument_count - 1);
HValue* op_vals[] = {context(), function, arity};
@@ -8010,12 +8010,14 @@ HInstruction* HOptimizedGraphBuilder::NewCallFunction(
HConstant* stub = Add<HConstant>(callable.code());
return New<HCallWithDescriptor>(stub, argument_count, callable.descriptor(),
- Vector<HValue*>(op_vals, arraysize(op_vals)));
+ Vector<HValue*>(op_vals, arraysize(op_vals)),
+ syntactic_tail_call_mode);
}
HInstruction* HOptimizedGraphBuilder::NewCallFunctionViaIC(
- HValue* function, int argument_count, ConvertReceiverMode convert_mode,
- TailCallMode tail_call_mode, FeedbackVectorSlot slot) {
+ HValue* function, int argument_count, TailCallMode syntactic_tail_call_mode,
+ ConvertReceiverMode convert_mode, TailCallMode tail_call_mode,
+ FeedbackVectorSlot slot) {
int arity = argument_count - 1;
Handle<TypeFeedbackVector> vector(current_feedback_vector(), isolate());
HValue* index_val = Add<HConstant>(vector->GetIndex(slot));
@@ -8028,14 +8030,16 @@ HInstruction* HOptimizedGraphBuilder::NewCallFunctionViaIC(
HConstant* stub = Add<HConstant>(callable.code());
return New<HCallWithDescriptor>(stub, argument_count, callable.descriptor(),
- Vector<HValue*>(op_vals, arraysize(op_vals)));
+ Vector<HValue*>(op_vals, arraysize(op_vals)),
+ syntactic_tail_call_mode);
}
HInstruction* HOptimizedGraphBuilder::NewCallConstantFunction(
Handle<JSFunction> function, int argument_count,
- TailCallMode tail_call_mode) {
+ TailCallMode syntactic_tail_call_mode, TailCallMode tail_call_mode) {
HValue* target = Add<HConstant>(function);
- return New<HInvokeFunction>(target, function, argument_count, tail_call_mode);
+ return New<HInvokeFunction>(target, function, argument_count,
+ syntactic_tail_call_mode, tail_call_mode);
}
@@ -8186,10 +8190,12 @@ void HOptimizedGraphBuilder::HandlePolymorphicCallNamed(Call* expr,
// HWrapReceiver.
HInstruction* call =
needs_wrapping
- ? NewCallFunction(function, argument_count,
- ConvertReceiverMode::kNotNullOrUndefined,
- tail_call_mode)
- : NewCallConstantFunction(target, argument_count, tail_call_mode);
+ ? NewCallFunction(
+ function, argument_count, syntactic_tail_call_mode,
+ ConvertReceiverMode::kNotNullOrUndefined, tail_call_mode)
+ : NewCallConstantFunction(target, argument_count,
+ syntactic_tail_call_mode,
+ tail_call_mode);
PushArgumentsFromEnvironment(argument_count);
AddInstruction(call);
Drop(1); // Drop the function.
@@ -8219,8 +8225,8 @@ void HOptimizedGraphBuilder::HandlePolymorphicCallNamed(Call* expr,
CHECK_ALIVE(VisitExpressions(expr->arguments()));
HInstruction* call = NewCallFunction(
- function, argument_count, ConvertReceiverMode::kNotNullOrUndefined,
- tail_call_mode);
+ function, argument_count, syntactic_tail_call_mode,
+ ConvertReceiverMode::kNotNullOrUndefined, tail_call_mode);
PushArgumentsFromEnvironment(argument_count);
@@ -9106,8 +9112,8 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
if_inline.Else();
{
Add<HPushArguments>(receiver);
- result = AddInstruction(
- NewCallConstantFunction(function, 1, TailCallMode::kDisallow));
+ result = AddInstruction(NewCallConstantFunction(
+ function, 1, TailCallMode::kDisallow, TailCallMode::kDisallow));
if (!ast_context()->IsEffect()) Push(result);
}
if_inline.End();
@@ -9371,8 +9377,9 @@ void HOptimizedGraphBuilder::HandleIndirectCall(Call* expr, HValue* function,
function_state()->ComputeTailCallMode(syntactic_tail_call_mode);
PushArgumentsFromEnvironment(arguments_count);
- HInvokeFunction* call = New<HInvokeFunction>(function, known_function,
- arguments_count, tail_call_mode);
+ HInvokeFunction* call =
+ New<HInvokeFunction>(function, known_function, arguments_count,
+ syntactic_tail_call_mode, tail_call_mode);
Drop(1); // Function
ast_context()->ReturnInstruction(call, expr->id());
}
@@ -9769,14 +9776,15 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) {
// the receiver.
// TODO(verwaest): Support creation of value wrappers directly in
// HWrapReceiver.
- call = NewCallFunction(function, argument_count,
- ConvertReceiverMode::kNotNullOrUndefined,
- tail_call_mode);
+ call = NewCallFunction(
+ function, argument_count, syntactic_tail_call_mode,
+ ConvertReceiverMode::kNotNullOrUndefined, tail_call_mode);
} else if (TryInlineCall(expr)) {
return;
} else {
- call = NewCallConstantFunction(known_function, argument_count,
- tail_call_mode);
+ call =
+ NewCallConstantFunction(known_function, argument_count,
+ syntactic_tail_call_mode, tail_call_mode);
}
} else {
@@ -9795,7 +9803,7 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) {
Push(receiver);
CHECK_ALIVE(VisitExpressions(expr->arguments(), arguments_flag));
- call = NewCallFunction(function, argument_count,
+ call = NewCallFunction(function, argument_count, syntactic_tail_call_mode,
ConvertReceiverMode::kNotNullOrUndefined,
tail_call_mode);
}
@@ -9845,7 +9853,7 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) {
PushArgumentsFromEnvironment(argument_count);
call = NewCallConstantFunction(expr->target(), argument_count,
- tail_call_mode);
+ syntactic_tail_call_mode, tail_call_mode);
} else {
PushArgumentsFromEnvironment(argument_count);
if (expr->is_uninitialized() &&
@@ -9853,12 +9861,13 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) {
// We've never seen this call before, so let's have Crankshaft learn
// through the type vector.
call = NewCallFunctionViaIC(function, argument_count,
+ syntactic_tail_call_mode,
ConvertReceiverMode::kNullOrUndefined,
tail_call_mode, expr->CallFeedbackICSlot());
} else {
- call = NewCallFunction(function, argument_count,
- ConvertReceiverMode::kNullOrUndefined,
- tail_call_mode);
+ call = NewCallFunction(
+ function, argument_count, syntactic_tail_call_mode,
+ ConvertReceiverMode::kNullOrUndefined, tail_call_mode);
}
}
}
@@ -10500,6 +10509,7 @@ void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) {
CHECK_ALIVE(VisitExpressions(expr->arguments()));
PushArgumentsFromEnvironment(argument_count);
HInstruction* call = NewCallConstantFunction(known_function, argument_count,
+ TailCallMode::kDisallow,
TailCallMode::kDisallow);
Drop(1); // Function
return ast_context()->ReturnInstruction(call, expr->id());
« no previous file with comments | « src/crankshaft/hydrogen.h ('k') | src/crankshaft/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698