Reviewers: jarin,
Description:
[turbofan] Use proper eager deopts for %_ThrowNotDateError().
Also adjust %_DeoptimizeNow() to use an eager deopt, for which it didn't
really matter.
[email protected]
Please review this at https://codereview.chromium.org/1210863002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+24, -15 lines):
M src/ast.h
M src/compiler/ast-graph-builder.cc
M src/compiler/js-intrinsic-lowering.h
M src/compiler/js-intrinsic-lowering.cc
M src/compiler/linkage.h
M src/compiler/linkage.cc
M src/compiler/linkage-impl.h
M src/compiler/operator-properties.cc
M src/x64/full-codegen-x64.cc
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index
4c65c7f3b83bd4cce6b6a406619a898c3ccd6477..7a847db17223a93c3c25cc9777dc2a49f04d5cb9
100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -2028,7 +2028,8 @@ class CallRuntime final : public Expression {
return callruntime_feedback_slot_;
}
- static int num_ids() { return parent_num_ids(); }
+ static int num_ids() { return parent_num_ids() + 1; }
+ BailoutId CallId() { return BailoutId(local_id(0)); }
protected:
CallRuntime(Zone* zone, const AstRawString* name,
@@ -2042,6 +2043,8 @@ class CallRuntime final : public Expression {
static int parent_num_ids() { return Expression::num_ids(); }
private:
+ int local_id(int n) const { return base_id() + parent_num_ids() + n; }
+
const AstRawString* raw_name_;
const Runtime::Function* function_;
ZoneList<Expression*>* arguments_;
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc
b/src/compiler/ast-graph-builder.cc
index
1147f85a6377c5978b39a5701438d789779b1aab..5a5fcdc47d5cbb738c8bd707b2b83159b318e735
100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -2544,8 +2544,9 @@ void AstGraphBuilder::VisitCallRuntime(CallRuntime*
expr) {
if (functionId == Runtime::kInlineGeneratorNext) SetStackOverflow();
if (functionId == Runtime::kInlineGeneratorThrow) SetStackOverflow();
const Operator* call = javascript()->CallRuntime(functionId,
args->length());
+ FrameStateBeforeAndAfter states(this, expr->CallId());
Node* value = ProcessArguments(call, args->length());
- PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
+ states.AddToNode(value, expr->id(), ast_context()->GetStateCombine());
ast_context()->ProduceValue(value);
}
Index: src/compiler/js-intrinsic-lowering.cc
diff --git a/src/compiler/js-intrinsic-lowering.cc
b/src/compiler/js-intrinsic-lowering.cc
index
f4a886f88ca41b915d5d37a562ebfac045af25be..be9e5e6786f40eeb9d1fcd499a7dece3efec0111
100644
--- a/src/compiler/js-intrinsic-lowering.cc
+++ b/src/compiler/js-intrinsic-lowering.cc
@@ -35,7 +35,7 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) {
case Runtime::kInlineDateField:
return ReduceDateField(node);
case Runtime::kInlineDeoptimizeNow:
- return ReduceDeoptimizeNow(node);
+ return ReduceDeoptimize(node);
case Runtime::kInlineDoubleHi:
return ReduceDoubleHi(node);
case Runtime::kInlineDoubleLo:
@@ -92,6 +92,8 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) {
return ReduceGetTypeFeedbackVector(node);
case Runtime::kInlineGetCallerJSFunction:
return ReduceGetCallerJSFunction(node);
+ case Runtime::kInlineThrowNotDateError:
+ return ReduceDeoptimize(node);
default:
break;
}
@@ -130,9 +132,9 @@ Reduction JSIntrinsicLowering::ReduceDateField(Node*
node) {
}
-Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) {
+Reduction JSIntrinsicLowering::ReduceDeoptimize(Node* node) {
if (mode() != kDeoptimizationEnabled) return NoChange();
- Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0);
+ Node* const frame_state = NodeProperties::GetFrameStateInput(node, 1);
Node* const effect = NodeProperties::GetEffectInput(node);
Node* const control = NodeProperties::GetControlInput(node);
Index: src/compiler/js-intrinsic-lowering.h
diff --git a/src/compiler/js-intrinsic-lowering.h
b/src/compiler/js-intrinsic-lowering.h
index
be6e536026a5fffe703729441c3b030c557228cc..93034992b954c8f04fb79f75393e688ff5492eb0
100644
--- a/src/compiler/js-intrinsic-lowering.h
+++ b/src/compiler/js-intrinsic-lowering.h
@@ -33,7 +33,7 @@ class JSIntrinsicLowering final : public AdvancedReducer {
private:
Reduction ReduceConstructDouble(Node* node);
Reduction ReduceDateField(Node* node);
- Reduction ReduceDeoptimizeNow(Node* node);
+ Reduction ReduceDeoptimize(Node* node);
Reduction ReduceDoubleHi(Node* node);
Reduction ReduceDoubleLo(Node* node);
Reduction ReduceHeapObjectGetMap(Node* node);
Index: src/compiler/linkage-impl.h
diff --git a/src/compiler/linkage-impl.h b/src/compiler/linkage-impl.h
index
0a18f6e8db21301d833ab31ed8746e745d11d40f..a648148be4b57c9f2fc9a65f64e83e04ed99e126
100644
--- a/src/compiler/linkage-impl.h
+++ b/src/compiler/linkage-impl.h
@@ -115,7 +115,7 @@ class LinkageHelper {
locations.AddParam(regloc(LinkageTraits::ContextReg()));
types.AddParam(kMachAnyTagged);
- CallDescriptor::Flags flags = Linkage::NeedsFrameState(function_id)
+ CallDescriptor::Flags flags =
Linkage::FrameStateInputCount(function_id) > 0
? CallDescriptor::kNeedsFrameState
: CallDescriptor::kNoFlags;
Index: src/compiler/linkage.cc
diff --git a/src/compiler/linkage.cc b/src/compiler/linkage.cc
index
9727639a88c8fcb7a287d51f1175203445f96f4c..9338a5bed7029d4783618b9734df6fb06bcd0a4e
100644
--- a/src/compiler/linkage.cc
+++ b/src/compiler/linkage.cc
@@ -105,7 +105,7 @@ FrameOffset Linkage::GetFrameOffset(int spill_slot,
Frame* frame,
// static
-bool Linkage::NeedsFrameState(Runtime::FunctionId function) {
+int Linkage::FrameStateInputCount(Runtime::FunctionId function) {
// Most runtime functions need a FrameState. A few chosen ones that we
know
// not to call into arbitrary JavaScript, not to throw, and not to
deoptimize
// are blacklisted here and can be called without a FrameState.
@@ -129,15 +129,16 @@ bool Linkage::NeedsFrameState(Runtime::FunctionId
function) {
case Runtime::kToFastProperties: // TODO(jarin): Is it safe?
case Runtime::kTraceEnter:
case Runtime::kTraceExit:
- return false;
+ return 0;
case Runtime::kInlineArguments:
case Runtime::kInlineCallFunction:
- case Runtime::kInlineDeoptimizeNow:
case Runtime::kInlineGetCallerJSFunction:
case Runtime::kInlineGetPrototype:
case Runtime::kInlineRegExpExec:
+ return 1;
+ case Runtime::kInlineDeoptimizeNow:
case Runtime::kInlineThrowNotDateError:
- return true;
+ return 2;
default:
break;
}
@@ -145,9 +146,9 @@ bool Linkage::NeedsFrameState(Runtime::FunctionId
function) {
// Most inlined runtime functions (except the ones listed above) can be
called
// without a FrameState or will be lowered by JSIntrinsicLowering
internally.
const Runtime::Function* const f = Runtime::FunctionForId(function);
- if (f->intrinsic_type == Runtime::IntrinsicType::INLINE) return false;
+ if (f->intrinsic_type == Runtime::IntrinsicType::INLINE) return 0;
- return true;
+ return 1;
}
Index: src/compiler/linkage.h
diff --git a/src/compiler/linkage.h b/src/compiler/linkage.h
index
0358cd28f1b054509750e1a402bb354fa909c7ee..9f01f32f4bd0d74f64d9547443dc5174e5e08a2b
100644
--- a/src/compiler/linkage.h
+++ b/src/compiler/linkage.h
@@ -251,7 +251,7 @@ class Linkage : public ZoneObject {
// the frame offset, e.g. to index into part of a double slot.
FrameOffset GetFrameOffset(int spill_slot, Frame* frame, int extra = 0)
const;
- static bool NeedsFrameState(Runtime::FunctionId function);
+ static int FrameStateInputCount(Runtime::FunctionId function);
// Get the location where an incoming OSR value is stored.
LinkageLocation GetOsrValueLocation(int index) const;
Index: src/compiler/operator-properties.cc
diff --git a/src/compiler/operator-properties.cc
b/src/compiler/operator-properties.cc
index
ac363c9773ee8eb22821153852f0eeebdb771d9a..6de6d2487cf860630e8ad8ca3ea02e0c9224942f
100644
--- a/src/compiler/operator-properties.cc
+++ b/src/compiler/operator-properties.cc
@@ -26,7 +26,7 @@ int OperatorProperties::GetFrameStateInputCount(const
Operator* op) {
return 1;
case IrOpcode::kJSCallRuntime: {
const CallRuntimeParameters& p = CallRuntimeParametersOf(op);
- return Linkage::NeedsFrameState(p.id());
+ return Linkage::FrameStateInputCount(p.id());
}
// Strict equality cannot lazily deoptimize.
Index: src/x64/full-codegen-x64.cc
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
index
b8cb3ee31a334b6ddac4888be4b359d6f69343e9..17272fc24911ecc40f4e89cb6f7c3c04af6b8d4b
100644
--- a/src/x64/full-codegen-x64.cc
+++ b/src/x64/full-codegen-x64.cc
@@ -4696,6 +4696,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime*
expr) {
VisitForStackValue(args->at(i));
}
+ PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
EmitCallJSRuntimeFunction(expr);
// Restore context register.
@@ -4720,6 +4721,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime*
expr) {
}
// Call the C runtime.
+ PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
__ CallRuntime(function, arg_count);
context()->Plug(rax);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.