[turbofan] Use proper eager deopts for %_ThrowNotDateError().
authorbmeurer <bmeurer@chromium.org>
Fri, 26 Jun 2015 05:56:00 +0000 (22:56 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 26 Jun 2015 05:56:13 +0000 (05:56 +0000)
R=jarin@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#29309}

16 files changed:
src/arm/full-codegen-arm.cc
src/arm64/full-codegen-arm64.cc
src/ast.h
src/compiler/ast-graph-builder.cc
src/compiler/js-intrinsic-lowering.cc
src/compiler/js-intrinsic-lowering.h
src/compiler/linkage-impl.h
src/compiler/linkage.cc
src/compiler/linkage.h
src/compiler/operator-properties.cc
src/ia32/full-codegen-ia32.cc
src/mips/full-codegen-mips.cc
src/mips64/full-codegen-mips64.cc
src/ppc/full-codegen-ppc.cc
src/x64/full-codegen-x64.cc
src/x87/full-codegen-x87.cc

index 582a57e6058ac55eaef85a15868628890185e9e3..b2bd6c8fc77aa8ef0057d8fcef36555a60a73269 100644 (file)
@@ -4748,6 +4748,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
       VisitForStackValue(args->at(i));
     }
 
+    PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
     EmitCallJSRuntimeFunction(expr);
 
     // Restore context register.
@@ -4773,6 +4774,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
         }
 
         // Call the C runtime function.
+        PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
         __ CallRuntime(expr->function(), arg_count);
         context()->Plug(r0);
       }
index 684f818898ead6624afce016e5229b89a0216ba4..8ccf4a1011dc0613a6ded13b05d1e9ca6cf50c7f 100644 (file)
@@ -4441,6 +4441,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
       VisitForStackValue(args->at(i));
     }
 
+    PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
     EmitCallJSRuntimeFunction(expr);
 
     // Restore context register.
@@ -4466,6 +4467,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
         }
 
         // Call the C runtime function.
+        PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
         __ CallRuntime(expr->function(), arg_count);
         context()->Plug(x0);
       }
index f3a65316402692ae1ecbcaaccab357e97d725fc9..a70b1fbfac80e4f6778d90b5b1c7402288a24b57 100644 (file)
--- a/src/ast.h
+++ b/src/ast.h
@@ -2029,7 +2029,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,
@@ -2043,6 +2044,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 1ab19771464e3a8f3f870ead25a332f1b1baa6b5..89373a37bca255dfad94d1bb0d2eae11685375d9 100644 (file)
@@ -2552,8 +2552,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 f4a886f88ca41b915d5d37a562ebfac045af25be..0039d1d4c3ee9f89ca80dc6d6be8abdc1b8eb9de 100644 (file)
@@ -92,6 +92,8 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) {
       return ReduceGetTypeFeedbackVector(node);
     case Runtime::kInlineGetCallerJSFunction:
       return ReduceGetCallerJSFunction(node);
+    case Runtime::kInlineThrowNotDateError:
+      return ReduceThrowNotDateError(node);
     default:
       break;
   }
@@ -494,6 +496,23 @@ Reduction JSIntrinsicLowering::ReduceGetCallerJSFunction(Node* node) {
 }
 
 
+Reduction JSIntrinsicLowering::ReduceThrowNotDateError(Node* node) {
+  if (mode() != kDeoptimizationEnabled) return NoChange();
+  Node* const frame_state = NodeProperties::GetFrameStateInput(node, 1);
+  Node* const effect = NodeProperties::GetEffectInput(node);
+  Node* const control = NodeProperties::GetControlInput(node);
+
+  // TODO(bmeurer): Move MergeControlToEnd() to the AdvancedReducer.
+  Node* deoptimize =
+      graph()->NewNode(common()->Deoptimize(), frame_state, effect, control);
+  NodeProperties::MergeControlToEnd(graph(), common(), deoptimize);
+
+  node->set_op(common()->Dead());
+  node->TrimInputCount(0);
+  return Changed(node);
+}
+
+
 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a,
                                       Node* b) {
   node->set_op(op);
index be6e536026a5fffe703729441c3b030c557228cc..5dd46156b3c587ed95dfc7c74b7a8b45143710b2 100644 (file)
@@ -55,6 +55,7 @@ class JSIntrinsicLowering final : public AdvancedReducer {
   Reduction ReduceFixedArraySet(Node* node);
   Reduction ReduceGetTypeFeedbackVector(Node* node);
   Reduction ReduceGetCallerJSFunction(Node* node);
+  Reduction ReduceThrowNotDateError(Node* node);
 
   Reduction Change(Node* node, const Operator* op);
   Reduction Change(Node* node, const Operator* op, Node* a, Node* b);
index 0a18f6e8db21301d833ab31ed8746e745d11d40f..a648148be4b57c9f2fc9a65f64e83e04ed99e126 100644 (file)
@@ -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 9727639a88c8fcb7a287d51f1175203445f96f4c..9338a5bed7029d4783618b9734df6fb06bcd0a4e 100644 (file)
@@ -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 0358cd28f1b054509750e1a402bb354fa909c7ee..9f01f32f4bd0d74f64d9547443dc5174e5e08a2b 100644 (file)
@@ -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 ac363c9773ee8eb22821153852f0eeebdb771d9a..6de6d2487cf860630e8ad8ca3ea02e0c9224942f 100644 (file)
@@ -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 cc166cc44553ee92f94487881cd8ce004ec36bfa..04d48bdfdfb581c57096e8502ad50ee67f8531c2 100644 (file)
@@ -4682,6 +4682,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
       VisitForStackValue(args->at(i));
     }
 
+    PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
     EmitCallJSRuntimeFunction(expr);
 
     // Restore context register.
@@ -4706,6 +4707,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
         }
 
         // Call the C runtime function.
+        PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
         __ CallRuntime(expr->function(), arg_count);
         context()->Plug(eax);
       }
index dd78c3cac90dcc1cc320533a6043f63be74b0142..08a39a1400b2a872c8fb6ef9818d6b38cdcade48 100644 (file)
@@ -4765,6 +4765,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
       VisitForStackValue(args->at(i));
     }
 
+    PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
     EmitCallJSRuntimeFunction(expr);
 
     // Restore context register.
@@ -4790,6 +4791,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
         }
 
         // Call the C runtime function.
+        PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
         __ CallRuntime(expr->function(), arg_count);
         context()->Plug(v0);
       }
index 4782f46fd70653314018cc9db4440d04d105f2ca..62991c9eaac39b7041569835f2d3bdbcc9d8aec4 100644 (file)
@@ -4768,6 +4768,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
       VisitForStackValue(args->at(i));
     }
 
+    PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
     EmitCallJSRuntimeFunction(expr);
 
     // Restore context register.
@@ -4792,6 +4793,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
         }
 
         // Call the C runtime function.
+        PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
         __ CallRuntime(expr->function(), arg_count);
         context()->Plug(v0);
       }
index fca0698d67eb9af8db83f62cfdb2853dc2a486cd..533e097fc379ebbb1453ca3a91133b0c1bf44d1b 100644 (file)
@@ -4777,6 +4777,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
       VisitForStackValue(args->at(i));
     }
 
+    PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
     EmitCallJSRuntimeFunction(expr);
 
     // Restore context register.
@@ -4802,6 +4803,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
         }
 
         // Call the C runtime function.
+        PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
         __ CallRuntime(expr->function(), arg_count);
         context()->Plug(r3);
       }
index 9f88cc398e0f6d68a6304afca69e283a0fd58c04..0b19edd683084bd92d7f67ebdff57ec6f3d43d12 100644 (file)
@@ -4706,6 +4706,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
       VisitForStackValue(args->at(i));
     }
 
+    PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
     EmitCallJSRuntimeFunction(expr);
 
     // Restore context register.
@@ -4730,6 +4731,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
         }
 
         // Call the C runtime.
+        PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
         __ CallRuntime(function, arg_count);
         context()->Plug(rax);
       }
index 794b2cc19e954e9b259d11eee58cfd5ad8d095d1..4ee27490a9bf03024839ca3bf9794791eb3e83bb 100644 (file)
@@ -4664,6 +4664,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
       VisitForStackValue(args->at(i));
     }
 
+    PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
     EmitCallJSRuntimeFunction(expr);
 
     // Restore context register.
@@ -4688,6 +4689,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
         }
 
         // Call the C runtime function.
+        PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
         __ CallRuntime(expr->function(), arg_count);
         context()->Plug(eax);
       }