Commit 8a7186b8 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Remove the JSContextRelaxation reducer.

This reducer doesn't really add value, because:

 (a) it is only concerned with JSCallFunction and JSToNumber, but when
     we get to it, all JSCallFunction nodes will have been replaced by
     Call nodes, and in the not so far future, we will also have
     replaced almost all JSToNumber nodes with better code,
 (b) and the reducer tries to be smart and use one of the outermost
     contexts, but that might not be beneficial always; actually it
     might even create longer live ranges and lead to more spilling
     in some cases.

But most importantly, the JSContextRelaxation currently blocks inlining
based on SharedFunctionInfo, because it requires the inliner to check
the native context, which in turn requires JSFunction knowledge. So I'm
removing this reducer for now to unblock the more important inliner
changes.

R=jarin@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#34139}
parent 24c8f0b0
......@@ -789,8 +789,6 @@ source_set("v8_base") {
"src/compiler/js-builtin-reducer.h",
"src/compiler/js-call-reducer.cc",
"src/compiler/js-call-reducer.h",
"src/compiler/js-context-relaxation.cc",
"src/compiler/js-context-relaxation.h",
"src/compiler/js-context-specialization.cc",
"src/compiler/js-context-specialization.h",
"src/compiler/js-create-lowering.cc",
......
......@@ -480,8 +480,7 @@ AstGraphBuilder::AstGraphBuilder(Zone* local_zone, CompilationInfo* info,
local_zone),
frame_state_function_info_(common()->CreateFrameStateFunctionInfo(
FrameStateType::kJavaScriptFunction, info->num_parameters() + 1,
info->scope()->num_stack_slots(), info->shared_info(),
CALL_MAINTAINS_NATIVE_CONTEXT)) {
info->scope()->num_stack_slots(), info->shared_info())) {
InitializeAstVisitor(info->isolate());
}
......
......@@ -448,8 +448,7 @@ BytecodeGraphBuilder::BytecodeGraphBuilder(Zone* local_zone,
frame_state_function_info_(common()->CreateFrameStateFunctionInfo(
FrameStateType::kInterpretedFunction,
bytecode_array()->parameter_count(),
bytecode_array()->register_count(), info->shared_info(),
CALL_MAINTAINS_NATIVE_CONTEXT)),
bytecode_array()->register_count(), info->shared_info())),
deoptimization_enabled_(info->is_deoptimization_enabled()),
merge_environments_(local_zone),
exception_handlers_(local_zone),
......
......@@ -861,11 +861,9 @@ const Operator* CommonOperatorBuilder::ResizeMergeOrPhi(const Operator* op,
const FrameStateFunctionInfo*
CommonOperatorBuilder::CreateFrameStateFunctionInfo(
FrameStateType type, int parameter_count, int local_count,
Handle<SharedFunctionInfo> shared_info,
ContextCallingMode context_calling_mode) {
Handle<SharedFunctionInfo> shared_info) {
return new (zone()->New(sizeof(FrameStateFunctionInfo)))
FrameStateFunctionInfo(type, parameter_count, local_count, shared_info,
context_calling_mode);
FrameStateFunctionInfo(type, parameter_count, local_count, shared_info);
}
} // namespace compiler
......
......@@ -178,8 +178,7 @@ class CommonOperatorBuilder final : public ZoneObject {
// Constructs function info for frame state construction.
const FrameStateFunctionInfo* CreateFrameStateFunctionInfo(
FrameStateType type, int parameter_count, int local_count,
Handle<SharedFunctionInfo> shared_info,
ContextCallingMode context_calling_mode);
Handle<SharedFunctionInfo> shared_info);
private:
Zone* zone() const { return zone_; }
......
......@@ -83,31 +83,20 @@ enum class FrameStateType {
};
enum ContextCallingMode {
CALL_MAINTAINS_NATIVE_CONTEXT,
CALL_CHANGES_NATIVE_CONTEXT
};
class FrameStateFunctionInfo {
public:
FrameStateFunctionInfo(FrameStateType type, int parameter_count,
int local_count,
Handle<SharedFunctionInfo> shared_info,
ContextCallingMode context_calling_mode)
Handle<SharedFunctionInfo> shared_info)
: type_(type),
parameter_count_(parameter_count),
local_count_(local_count),
shared_info_(shared_info),
context_calling_mode_(context_calling_mode) {}
shared_info_(shared_info) {}
int local_count() const { return local_count_; }
int parameter_count() const { return parameter_count_; }
Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
FrameStateType type() const { return type_; }
ContextCallingMode context_calling_mode() const {
return context_calling_mode_;
}
static bool IsJSFunctionType(FrameStateType type) {
return type == FrameStateType::kJavaScriptFunction ||
......@@ -119,7 +108,6 @@ class FrameStateFunctionInfo {
int const parameter_count_;
int const local_count_;
Handle<SharedFunctionInfo> const shared_info_;
ContextCallingMode context_calling_mode_;
};
......
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/compiler/frame-states.h"
#include "src/compiler/js-context-relaxation.h"
#include "src/compiler/js-operator.h"
#include "src/compiler/node.h"
#include "src/compiler/node-properties.h"
namespace v8 {
namespace internal {
namespace compiler {
Reduction JSContextRelaxation::Reduce(Node* node) {
switch (node->opcode()) {
case IrOpcode::kJSCallFunction:
case IrOpcode::kJSToNumber: {
Node* frame_state = NodeProperties::GetFrameStateInput(node, 0);
Node* outer_frame = frame_state;
Node* original_context = NodeProperties::GetContextInput(node);
Node* candidate_new_context = original_context;
do {
FrameStateInfo frame_state_info(
OpParameter<FrameStateInfo>(outer_frame->op()));
const FrameStateFunctionInfo* function_info =
frame_state_info.function_info();
if (function_info == nullptr ||
(function_info->context_calling_mode() ==
CALL_CHANGES_NATIVE_CONTEXT)) {
break;
}
candidate_new_context = outer_frame->InputAt(kFrameStateContextInput);
outer_frame = outer_frame->InputAt(kFrameStateOuterStateInput);
} while (outer_frame->opcode() == IrOpcode::kFrameState);
while (true) {
switch (candidate_new_context->opcode()) {
case IrOpcode::kParameter:
case IrOpcode::kJSCreateModuleContext:
case IrOpcode::kJSCreateScriptContext:
if (candidate_new_context != original_context) {
NodeProperties::ReplaceContextInput(node, candidate_new_context);
return Changed(node);
} else {
return NoChange();
}
case IrOpcode::kJSCreateCatchContext:
case IrOpcode::kJSCreateWithContext:
case IrOpcode::kJSCreateBlockContext:
candidate_new_context =
NodeProperties::GetContextInput(candidate_new_context);
break;
default:
return NoChange();
}
}
}
default:
break;
}
return NoChange();
}
} // namespace compiler
} // namespace internal
} // namespace v8
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_COMPILER_JS_CONTEXT_RELAXATION_H_
#define V8_COMPILER_JS_CONTEXT_RELAXATION_H_
#include "src/compiler/graph-reducer.h"
namespace v8 {
namespace internal {
namespace compiler {
// Ensures that operations that only need to access the native context use the
// outer-most context rather than the specific context given by the AST graph
// builder. This makes it possible to use these operations with context
// specialization (e.g. for generating stubs) without forcing inner contexts to
// be embedded in generated code thus causing leaks and potentially using the
// wrong native context (i.e. stubs are shared between native contexts).
class JSContextRelaxation final : public Reducer {
public:
JSContextRelaxation() {}
~JSContextRelaxation() final {}
Reduction Reduce(Node* node) final;
};
} // namespace compiler
} // namespace internal
} // namespace v8
#endif // V8_COMPILER_JS_CONTEXT_RELAXATION_H_
......@@ -244,8 +244,7 @@ Node* JSInliner::CreateArtificialFrameState(Node* node, Node* outer_frame_state,
Handle<SharedFunctionInfo> shared) {
const FrameStateFunctionInfo* state_info =
jsgraph_->common()->CreateFrameStateFunctionInfo(
frame_state_type, parameter_count + 1, 0, shared,
CALL_MAINTAINS_NATIVE_CONTEXT);
frame_state_type, parameter_count + 1, 0, shared);
const Operator* op = jsgraph_->common()->FrameState(
BailoutId(-1), OutputFrameStateCombine::Ignore(), state_info);
......
......@@ -30,7 +30,6 @@
#include "src/compiler/instruction-selector.h"
#include "src/compiler/js-builtin-reducer.h"
#include "src/compiler/js-call-reducer.h"
#include "src/compiler/js-context-relaxation.h"
#include "src/compiler/js-context-specialization.h"
#include "src/compiler/js-create-lowering.h"
#include "src/compiler/js-frame-specialization.h"
......@@ -788,7 +787,6 @@ struct GenericLoweringPhase {
void Run(PipelineData* data, Zone* temp_zone) {
JSGraphReducer graph_reducer(data->jsgraph(), temp_zone);
JSContextRelaxation context_relaxing;
DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(),
data->common());
CommonOperatorReducer common_reducer(&graph_reducer, data->graph(),
......@@ -798,7 +796,6 @@ struct GenericLoweringPhase {
SelectLowering select_lowering(data->jsgraph()->graph(),
data->jsgraph()->common());
TailCallOptimization tco(data->common(), data->graph());
AddReducer(data, &graph_reducer, &context_relaxing);
AddReducer(data, &graph_reducer, &dead_code_elimination);
AddReducer(data, &graph_reducer, &common_reducer);
AddReducer(data, &graph_reducer, &generic_lowering);
......
......@@ -148,7 +148,7 @@ InstructionSelectorTest::StreamBuilder::GetFrameStateFunctionInfo(
int parameter_count, int local_count) {
return common()->CreateFrameStateFunctionInfo(
FrameStateType::kJavaScriptFunction, parameter_count, local_count,
Handle<SharedFunctionInfo>(), CALL_MAINTAINS_NATIVE_CONTEXT);
Handle<SharedFunctionInfo>());
}
......
......@@ -46,11 +46,10 @@ class JSCreateLoweringTest : public TypedGraphTest {
Node* FrameState(Handle<SharedFunctionInfo> shared, Node* outer_frame_state) {
Node* state_values = graph()->NewNode(common()->StateValues(0));
return graph()->NewNode(
common()->FrameState(BailoutId::None(),
OutputFrameStateCombine::Ignore(),
common()->CreateFrameStateFunctionInfo(
FrameStateType::kJavaScriptFunction, 1, 0,
shared, CALL_MAINTAINS_NATIVE_CONTEXT)),
common()->FrameState(
BailoutId::None(), OutputFrameStateCombine::Ignore(),
common()->CreateFrameStateFunctionInfo(
FrameStateType::kJavaScriptFunction, 1, 0, shared)),
state_values, state_values, state_values, NumberConstant(0),
UndefinedConstant(), outer_frame_state);
}
......
......@@ -61,7 +61,7 @@ class LivenessAnalysisTest : public GraphTest {
const FrameStateFunctionInfo* state_info =
common()->CreateFrameStateFunctionInfo(
FrameStateType::kJavaScriptFunction, 0, locals_count_,
Handle<SharedFunctionInfo>(), CALL_MAINTAINS_NATIVE_CONTEXT);
Handle<SharedFunctionInfo>());
const Operator* op = common()->FrameState(
BailoutId(ast_num), OutputFrameStateCombine::Ignore(), state_info);
......
......@@ -61,7 +61,6 @@
'compiler/instruction-sequence-unittest.cc',
'compiler/instruction-sequence-unittest.h',
'compiler/js-builtin-reducer-unittest.cc',
'compiler/js-context-relaxation-unittest.cc',
'compiler/js-create-lowering-unittest.cc',
'compiler/js-intrinsic-lowering-unittest.cc',
'compiler/js-operator-unittest.cc',
......
......@@ -610,8 +610,6 @@
'../../src/compiler/js-builtin-reducer.h',
'../../src/compiler/js-call-reducer.cc',
'../../src/compiler/js-call-reducer.h',
'../../src/compiler/js-context-relaxation.cc',
'../../src/compiler/js-context-relaxation.h',
'../../src/compiler/js-context-specialization.cc',
'../../src/compiler/js-context-specialization.h',
'../../src/compiler/js-create-lowering.cc',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment