From 8236bfbae38afd589182b90904ffd191c3723567 Mon Sep 17 00:00:00 2001 From: bmeurer Date: Wed, 20 May 2015 06:11:41 -0700 Subject: [PATCH] [turbofan] Pass deoptimization mode to intrinsic lowering. R=jarin@chromium.org Review URL: https://codereview.chromium.org/1148033002 Cr-Commit-Position: refs/heads/master@{#28515} --- src/compiler/js-intrinsic-lowering.cc | 8 ++++---- src/compiler/js-intrinsic-lowering.h | 9 +++++++-- src/compiler/pipeline.cc | 6 +++++- test/unittests/compiler/js-intrinsic-lowering-unittest.cc | 3 ++- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/compiler/js-intrinsic-lowering.cc b/src/compiler/js-intrinsic-lowering.cc index 5e063a7..2a3bdf8 100644 --- a/src/compiler/js-intrinsic-lowering.cc +++ b/src/compiler/js-intrinsic-lowering.cc @@ -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); diff --git a/src/compiler/js-intrinsic-lowering.h b/src/compiler/js-intrinsic-lowering.h index 339000b..75a8892 100644 --- a/src/compiler/js-intrinsic-lowering.h +++ b/src/compiler/js-intrinsic-lowering.h @@ -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_; }; diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc index d05b55a..4118e1d 100644 --- a/src/compiler/pipeline.cc +++ b/src/compiler/pipeline.cc @@ -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); diff --git a/test/unittests/compiler/js-intrinsic-lowering-unittest.cc b/test/unittests/compiler/js-intrinsic-lowering-unittest.cc index 7c56131..92b59d2 100644 --- a/test/unittests/compiler/js-intrinsic-lowering-unittest.cc +++ b/test/unittests/compiler/js-intrinsic-lowering-unittest.cc @@ -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); } -- 2.7.4