[turbofan] Pass deoptimization mode to intrinsic lowering.
authorbmeurer <bmeurer@chromium.org>
Wed, 20 May 2015 13:11:41 +0000 (06:11 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 20 May 2015 13:11:24 +0000 (13:11 +0000)
R=jarin@chromium.org

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

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

src/compiler/js-intrinsic-lowering.cc
src/compiler/js-intrinsic-lowering.h
src/compiler/pipeline.cc
test/unittests/compiler/js-intrinsic-lowering-unittest.cc

index 5e063a7..2a3bdf8 100644 (file)
@@ -16,9 +16,11 @@ namespace v8 {
 namespace internal {
 namespace compiler {
 
-JSIntrinsicLowering::JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph)
+JSIntrinsicLowering::JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph,
+                                         DeoptimizationMode mode)
     : AdvancedReducer(editor),
       jsgraph_(jsgraph),
+      mode_(mode),
       simplified_(jsgraph->zone()) {}
 
 
@@ -103,9 +105,7 @@ Reduction JSIntrinsicLowering::ReduceConstructDouble(Node* node) {
 
 
 Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) {
-  // TODO(jarin): This should not depend on the global flag.
-  if (!FLAG_turbo_deoptimization) return NoChange();
-
+  if (mode() != kDeoptimizationEnabled) return NoChange();
   Node* frame_state = NodeProperties::GetFrameStateInput(node, 0);
   DCHECK_EQ(frame_state->opcode(), IrOpcode::kFrameState);
 
index 339000b..75a8892 100644 (file)
@@ -22,7 +22,10 @@ class MachineOperatorBuilder;
 // Lowers certain JS-level runtime calls.
 class JSIntrinsicLowering final : public AdvancedReducer {
  public:
-  JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph);
+  enum DeoptimizationMode { kDeoptimizationEnabled, kDeoptimizationDisabled };
+
+  JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph,
+                      DeoptimizationMode mode);
   ~JSIntrinsicLowering() final {}
 
   Reduction Reduce(Node* node) final;
@@ -60,9 +63,11 @@ class JSIntrinsicLowering final : public AdvancedReducer {
   JSGraph* jsgraph() const { return jsgraph_; }
   CommonOperatorBuilder* common() const;
   MachineOperatorBuilder* machine() const;
+  DeoptimizationMode mode() const { return mode_; }
   SimplifiedOperatorBuilder* simplified() { return &simplified_; }
 
-  JSGraph* jsgraph_;
+  JSGraph* const jsgraph_;
+  DeoptimizationMode const mode_;
   SimplifiedOperatorBuilder simplified_;
 };
 
index d05b55a..4118e1d 100644 (file)
@@ -561,7 +561,11 @@ struct TypedLoweringPhase {
     LoadElimination load_elimination;
     JSBuiltinReducer builtin_reducer(data->jsgraph());
     JSTypedLowering typed_lowering(&graph_reducer, data->jsgraph(), temp_zone);
-    JSIntrinsicLowering intrinsic_lowering(&graph_reducer, data->jsgraph());
+    JSIntrinsicLowering intrinsic_lowering(
+        &graph_reducer, data->jsgraph(),
+        data->info()->is_deoptimization_enabled()
+            ? JSIntrinsicLowering::kDeoptimizationEnabled
+            : JSIntrinsicLowering::kDeoptimizationDisabled);
     SimplifiedOperatorReducer simple_reducer(data->jsgraph());
     CommonOperatorReducer common_reducer(data->jsgraph());
     AddReducer(data, &graph_reducer, &builtin_reducer);
index 7c56131..92b59d2 100644 (file)
@@ -35,7 +35,8 @@ class JSIntrinsicLoweringTest : public GraphTest {
     JSGraph jsgraph(isolate(), graph(), common(), javascript(), &machine);
     // TODO(titzer): mock the GraphReducer here for better unit testing.
     GraphReducer graph_reducer(graph(), zone());
-    JSIntrinsicLowering reducer(&graph_reducer, &jsgraph);
+    JSIntrinsicLowering reducer(&graph_reducer, &jsgraph,
+                                JSIntrinsicLowering::kDeoptimizationEnabled);
     return reducer.Reduce(node);
   }