Commit 71bde166 authored by Benedikt Meurer's avatar Benedikt Meurer

[turbofan] Remove obsolete JSTypeFeedbackSpecializer and JSTypeFeedbackLowering.

Both the JSTypeFeedbackSpecializer and the JSTypeFeedbackLowering is
dead code by now, since the more general JSNativeContextSpecialization
deals with the property/global load/store type feedback in a way that
also interacts properly with inlining.

BUG=v8:4470
LOG=n
R=jarin@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#31462}
parent 5449c984
......@@ -777,10 +777,6 @@ source_set("v8_base") {
"src/compiler/js-native-context-specialization.h",
"src/compiler/js-operator.cc",
"src/compiler/js-operator.h",
"src/compiler/js-type-feedback.cc",
"src/compiler/js-type-feedback.h",
"src/compiler/js-type-feedback-lowering.cc",
"src/compiler/js-type-feedback-lowering.h",
"src/compiler/js-typed-lowering.cc",
"src/compiler/js-typed-lowering.h",
"src/compiler/jump-threading.cc",
......
......@@ -443,9 +443,6 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
FLAG_native_context_specialization) {
info()->MarkAsNativeContextSpecializing();
info()->MarkAsTypingEnabled();
} else if (FLAG_turbo_type_feedback) {
info()->MarkAsTypeFeedbackEnabled();
info()->EnsureFeedbackVector();
}
if (!info()->shared_info()->asm_function() ||
FLAG_turbo_asm_deoptimization) {
......
......@@ -122,7 +122,6 @@ class CompilationInfo {
kTypingEnabled = 1 << 12,
kDisableFutureOptimization = 1 << 13,
kSplittingEnabled = 1 << 14,
kTypeFeedbackEnabled = 1 << 15,
kDeoptimizationEnabled = 1 << 16,
kSourcePositionsEnabled = 1 << 17,
kFirstCompile = 1 << 18,
......@@ -239,12 +238,6 @@ class CompilationInfo {
return GetFlag(kNativeContextSpecializing);
}
void MarkAsTypeFeedbackEnabled() { SetFlag(kTypeFeedbackEnabled); }
bool is_type_feedback_enabled() const {
return GetFlag(kTypeFeedbackEnabled);
}
void MarkAsDeoptimizationEnabled() { SetFlag(kDeoptimizationEnabled); }
bool is_deoptimization_enabled() const {
......
This diff is collapsed.
......@@ -19,7 +19,6 @@ namespace compiler {
class ControlBuilder;
class Graph;
class JSTypeFeedbackTable;
class LoopAssignmentAnalysis;
class LoopBuilder;
class Node;
......@@ -31,8 +30,7 @@ class Node;
class AstGraphBuilder : public AstVisitor {
public:
AstGraphBuilder(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph,
LoopAssignmentAnalysis* loop_assignment = NULL,
JSTypeFeedbackTable* js_type_feedback = NULL);
LoopAssignmentAnalysis* loop_assignment = NULL);
// Creates a graph by visiting the entire AST.
bool CreateGraph(bool stack_check = true);
......@@ -116,9 +114,6 @@ class AstGraphBuilder : public AstVisitor {
// Function info for frame state construction.
const FrameStateFunctionInfo* const frame_state_function_info_;
// Type feedback table.
JSTypeFeedbackTable* js_type_feedback_;
// Growth increment for the temporary buffer used to construct input lists to
// new nodes.
static const int kInputBufferSizeIncrement = 64;
......@@ -286,15 +281,15 @@ class AstGraphBuilder : public AstVisitor {
Node* BuildNamedLoad(Node* receiver, Handle<Name> name,
const VectorSlotPair& feedback);
Node* BuildKeyedStore(Node* receiver, Node* key, Node* value,
const VectorSlotPair& feedback, TypeFeedbackId id);
const VectorSlotPair& feedback);
Node* BuildNamedStore(Node* receiver, Handle<Name> name, Node* value,
const VectorSlotPair& feedback, TypeFeedbackId id);
const VectorSlotPair& feedback);
// Builders for super property loads and stores.
Node* BuildKeyedSuperStore(Node* receiver, Node* home_object, Node* key,
Node* value, TypeFeedbackId id);
Node* value);
Node* BuildNamedSuperStore(Node* receiver, Node* home_object,
Handle<Name> name, Node* value, TypeFeedbackId id);
Handle<Name> name, Node* value);
Node* BuildNamedSuperLoad(Node* receiver, Node* home_object,
Handle<Name> name, const VectorSlotPair& feedback);
Node* BuildKeyedSuperLoad(Node* receiver, Node* home_object, Node* key,
......@@ -304,7 +299,7 @@ class AstGraphBuilder : public AstVisitor {
Node* BuildGlobalLoad(Handle<Name> name, const VectorSlotPair& feedback,
TypeofMode typeof_mode);
Node* BuildGlobalStore(Handle<Name> name, Node* value,
const VectorSlotPair& feedback, TypeFeedbackId id);
const VectorSlotPair& feedback);
// Builders for accessing the function context.
Node* BuildLoadGlobalObject();
......
// Copyright 2015 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/js-type-feedback-lowering.h"
#include "src/compiler/access-builder.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/node-properties.h"
#include "src/objects-inl.h" // TODO(mstarzinger): Temporary cycle breaker!
#include "src/type-feedback-vector.h"
namespace v8 {
namespace internal {
namespace compiler {
JSTypeFeedbackLowering::JSTypeFeedbackLowering(Editor* editor, Flags flags,
JSGraph* jsgraph)
: AdvancedReducer(editor), flags_(flags), jsgraph_(jsgraph) {}
Reduction JSTypeFeedbackLowering::Reduce(Node* node) {
switch (node->opcode()) {
case IrOpcode::kJSLoadNamed:
return ReduceJSLoadNamed(node);
default:
break;
}
return NoChange();
}
Reduction JSTypeFeedbackLowering::ReduceJSLoadNamed(Node* node) {
DCHECK_EQ(IrOpcode::kJSLoadNamed, node->opcode());
Node* receiver = NodeProperties::GetValueInput(node, 0);
Type* receiver_type = NodeProperties::GetType(receiver);
Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
// We need to make optimistic assumptions to continue.
if (!(flags() & kDeoptimizationEnabled)) return NoChange();
NamedAccess const& p = NamedAccessOf(node->op());
if (!p.feedback().IsValid()) return NoChange(); // No feedback.
if (p.name().is_identical_to(factory()->length_string())) {
LoadICNexus nexus(p.feedback().vector(), p.feedback().slot());
MapHandleList maps;
if (nexus.ExtractMaps(&maps) > 0) {
for (Handle<Map> map : maps) {
if (map->instance_type() >= FIRST_NONSTRING_TYPE) return NoChange();
}
// Optimistic optimization for "length" property of strings.
if (receiver_type->Maybe(Type::TaggedSigned())) {
Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), receiver);
Node* branch = graph()->NewNode(common()->Branch(BranchHint::kFalse),
check, control);
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
Node* deoptimize = graph()->NewNode(common()->Deoptimize(), frame_state,
effect, if_true);
// TODO(bmeurer): This should be on the AdvancedReducer somehow.
NodeProperties::MergeControlToEnd(graph(), common(), deoptimize);
control = graph()->NewNode(common()->IfFalse(), branch);
}
Node* receiver_map = effect =
graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()),
receiver, effect, control);
Node* receiver_instance_type = effect = graph()->NewNode(
simplified()->LoadField(AccessBuilder::ForMapInstanceType()),
receiver_map, effect, control);
Node* check =
graph()->NewNode(machine()->Uint32LessThan(), receiver_instance_type,
jsgraph()->Uint32Constant(FIRST_NONSTRING_TYPE));
Node* branch =
graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
Node* deoptimize = graph()->NewNode(common()->Deoptimize(), frame_state,
effect, if_false);
// TODO(bmeurer): This should be on the AdvancedReducer somehow.
NodeProperties::MergeControlToEnd(graph(), common(), deoptimize);
control = graph()->NewNode(common()->IfTrue(), branch);
Node* value = effect =
graph()->NewNode(simplified()->LoadField(
AccessBuilder::ForStringLength(graph()->zone())),
receiver, effect, control);
ReplaceWithValue(node, value, effect, control);
return Replace(value);
}
}
return NoChange();
}
Factory* JSTypeFeedbackLowering::factory() const {
return isolate()->factory();
}
CommonOperatorBuilder* JSTypeFeedbackLowering::common() const {
return jsgraph()->common();
}
Graph* JSTypeFeedbackLowering::graph() const { return jsgraph()->graph(); }
Isolate* JSTypeFeedbackLowering::isolate() const {
return jsgraph()->isolate();
}
MachineOperatorBuilder* JSTypeFeedbackLowering::machine() const {
return jsgraph()->machine();
}
SimplifiedOperatorBuilder* JSTypeFeedbackLowering::simplified() const {
return jsgraph()->simplified();
}
} // namespace compiler
} // namespace internal
} // namespace v8
// Copyright 2015 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_TYPE_FEEDBACK_LOWERING_H_
#define V8_COMPILER_JS_TYPE_FEEDBACK_LOWERING_H_
#include "src/base/flags.h"
#include "src/compiler/graph-reducer.h"
namespace v8 {
namespace internal {
// Forward declarations.
class Factory;
namespace compiler {
// Forward declarations.
class CommonOperatorBuilder;
class JSGraph;
class MachineOperatorBuilder;
class SimplifiedOperatorBuilder;
// Lowers JS-level operators to simplified operators based on type feedback.
class JSTypeFeedbackLowering final : public AdvancedReducer {
public:
// Various configuration flags to control the operation of this lowering.
enum Flag {
kNoFlags = 0,
kDeoptimizationEnabled = 1 << 0,
};
typedef base::Flags<Flag> Flags;
JSTypeFeedbackLowering(Editor* editor, Flags flags, JSGraph* jsgraph);
~JSTypeFeedbackLowering() final {}
Reduction Reduce(Node* node) final;
private:
Reduction ReduceJSLoadNamed(Node* node);
Factory* factory() const;
Flags flags() const { return flags_; }
Graph* graph() const;
Isolate* isolate() const;
JSGraph* jsgraph() const { return jsgraph_; }
CommonOperatorBuilder* common() const;
MachineOperatorBuilder* machine() const;
SimplifiedOperatorBuilder* simplified() const;
Flags const flags_;
JSGraph* const jsgraph_;
DISALLOW_COPY_AND_ASSIGN(JSTypeFeedbackLowering);
};
DEFINE_OPERATORS_FOR_FLAGS(JSTypeFeedbackLowering::Flags)
} // namespace compiler
} // namespace internal
} // namespace v8
#endif // V8_COMPILER_JS_TYPE_FEEDBACK_LOWERING_H_
This diff is collapsed.
// Copyright 2015 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_TYPE_FEEDBACK_H_
#define V8_COMPILER_JS_TYPE_FEEDBACK_H_
#include "src/utils.h"
#include "src/compiler/graph-reducer.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/node-aux-data.h"
namespace v8 {
namespace internal {
class TypeFeedbackOracle;
class SmallMapList;
class CompilationDependencies;
namespace compiler {
// Stores type feedback information for nodes in the graph in a separate
// data structure.
class JSTypeFeedbackTable : public ZoneObject {
public:
explicit JSTypeFeedbackTable(Zone* zone);
void Record(Node* node, TypeFeedbackId id);
void Record(Node* node, FeedbackVectorSlot slot);
private:
friend class JSTypeFeedbackSpecializer;
typedef std::map<NodeId, TypeFeedbackId, std::less<NodeId>,
zone_allocator<TypeFeedbackId> > TypeFeedbackIdMap;
typedef std::map<NodeId, FeedbackVectorSlot, std::less<NodeId>,
zone_allocator<FeedbackVectorSlot> > FeedbackVectorSlotMap;
TypeFeedbackIdMap type_feedback_id_map_;
FeedbackVectorSlotMap feedback_vector_slot_map_;
TypeFeedbackId FindTypeFeedbackId(Node* node) {
TypeFeedbackIdMap::const_iterator it =
type_feedback_id_map_.find(node->id());
return it == type_feedback_id_map_.end() ? TypeFeedbackId::None()
: it->second;
}
FeedbackVectorSlot FindFeedbackVectorSlot(Node* node) {
FeedbackVectorSlotMap::const_iterator it =
feedback_vector_slot_map_.find(node->id());
return it == feedback_vector_slot_map_.end() ? FeedbackVectorSlot::Invalid()
: it->second;
}
};
// Specializes a graph to the type feedback recorded in the
// {js_type_feedback} provided to the constructor.
class JSTypeFeedbackSpecializer : public AdvancedReducer {
public:
enum DeoptimizationMode { kDeoptimizationEnabled, kDeoptimizationDisabled };
JSTypeFeedbackSpecializer(Editor* editor, JSGraph* jsgraph,
JSTypeFeedbackTable* js_type_feedback,
TypeFeedbackOracle* oracle,
Handle<GlobalObject> global_object,
DeoptimizationMode mode,
CompilationDependencies* dependencies)
: AdvancedReducer(editor),
jsgraph_(jsgraph),
js_type_feedback_(js_type_feedback),
oracle_(oracle),
global_object_(global_object),
mode_(mode),
dependencies_(dependencies) {
CHECK_NOT_NULL(js_type_feedback);
}
Reduction Reduce(Node* node) override;
// Visible for unit testing.
Reduction ReduceJSLoadGlobal(Node* node);
Reduction ReduceJSLoadNamed(Node* node);
Reduction ReduceJSLoadProperty(Node* node);
Reduction ReduceJSStoreNamed(Node* node);
Reduction ReduceJSStoreProperty(Node* node);
private:
JSGraph* jsgraph_;
JSTypeFeedbackTable* js_type_feedback_;
TypeFeedbackOracle* oracle_;
Handle<GlobalObject> global_object_;
DeoptimizationMode const mode_;
CompilationDependencies* dependencies_;
TypeFeedbackOracle* oracle() { return oracle_; }
Graph* graph() { return jsgraph_->graph(); }
JSGraph* jsgraph() { return jsgraph_; }
CommonOperatorBuilder* common() { return jsgraph_->common(); }
SimplifiedOperatorBuilder* simplified() { return jsgraph_->simplified(); }
DeoptimizationMode mode() const { return mode_; }
void BuildMapCheck(Node* receiver, Handle<Map> map, bool smi_check,
Node* effect, Node* control, Node** success, Node** fail);
Node* GetFrameStateBefore(Node* node);
};
} // namespace compiler
} // namespace internal
} // namespace v8
#endif
......@@ -34,8 +34,6 @@
#include "src/compiler/js-inlining-heuristic.h"
#include "src/compiler/js-intrinsic-lowering.h"
#include "src/compiler/js-native-context-specialization.h"
#include "src/compiler/js-type-feedback.h"
#include "src/compiler/js-type-feedback-lowering.h"
#include "src/compiler/js-typed-lowering.h"
#include "src/compiler/jump-threading.h"
#include "src/compiler/live-range-separator.h"
......@@ -89,7 +87,6 @@ class PipelineData {
common_(nullptr),
javascript_(nullptr),
jsgraph_(nullptr),
js_type_feedback_(nullptr),
schedule_(nullptr),
instruction_zone_scope_(zone_pool_),
instruction_zone_(instruction_zone_scope_.zone()),
......@@ -131,7 +128,6 @@ class PipelineData {
common_(nullptr),
javascript_(nullptr),
jsgraph_(nullptr),
js_type_feedback_(nullptr),
schedule_(schedule),
instruction_zone_scope_(zone_pool_),
instruction_zone_(instruction_zone_scope_.zone()),
......@@ -160,7 +156,6 @@ class PipelineData {
common_(nullptr),
javascript_(nullptr),
jsgraph_(nullptr),
js_type_feedback_(nullptr),
schedule_(nullptr),
instruction_zone_scope_(zone_pool_),
instruction_zone_(sequence->zone()),
......@@ -200,10 +195,6 @@ class PipelineData {
CommonOperatorBuilder* common() const { return common_; }
JSOperatorBuilder* javascript() const { return javascript_; }
JSGraph* jsgraph() const { return jsgraph_; }
JSTypeFeedbackTable* js_type_feedback() { return js_type_feedback_; }
void set_js_type_feedback(JSTypeFeedbackTable* js_type_feedback) {
js_type_feedback_ = js_type_feedback;
}
LoopAssignmentAnalysis* loop_assignment() const { return loop_assignment_; }
void set_loop_assignment(LoopAssignmentAnalysis* loop_assignment) {
......@@ -240,7 +231,6 @@ class PipelineData {
common_ = nullptr;
javascript_ = nullptr;
jsgraph_ = nullptr;
js_type_feedback_ = nullptr;
schedule_ = nullptr;
}
......@@ -308,7 +298,6 @@ class PipelineData {
CommonOperatorBuilder* common_;
JSOperatorBuilder* javascript_;
JSGraph* jsgraph_;
JSTypeFeedbackTable* js_type_feedback_;
Schedule* schedule_;
// All objects in the following group of fields are allocated in
......@@ -366,10 +355,8 @@ class AstGraphBuilderWithPositions final : public AstGraphBuilder {
AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info,
JSGraph* jsgraph,
LoopAssignmentAnalysis* loop_assignment,
JSTypeFeedbackTable* js_type_feedback,
SourcePositionTable* source_positions)
: AstGraphBuilder(local_zone, info, jsgraph, loop_assignment,
js_type_feedback),
: AstGraphBuilder(local_zone, info, jsgraph, loop_assignment),
source_positions_(source_positions),
start_position_(info->shared_info()->start_position()) {}
......@@ -493,7 +480,7 @@ struct GraphBuilderPhase {
} else {
AstGraphBuilderWithPositions graph_builder(
temp_zone, data->info(), data->jsgraph(), data->loop_assignment(),
data->js_type_feedback(), data->source_positions());
data->source_positions());
succeeded = graph_builder.CreateGraph(stack_check);
}
......@@ -583,34 +570,6 @@ struct OsrDeconstructionPhase {
};
struct JSTypeFeedbackPhase {
static const char* phase_name() { return "type feedback specializing"; }
void Run(PipelineData* data, Zone* temp_zone) {
Handle<Context> native_context(data->info()->context()->native_context());
TypeFeedbackOracle oracle(data->isolate(), temp_zone,
data->info()->unoptimized_code(),
data->info()->feedback_vector(), native_context);
JSGraphReducer graph_reducer(data->jsgraph(), temp_zone);
Handle<GlobalObject> global_object = Handle<GlobalObject>::null();
if (data->info()->has_global_object()) {
global_object =
Handle<GlobalObject>(data->info()->global_object(), data->isolate());
}
// TODO(titzer): introduce a specialization mode/flags enum to control
// specializing to the global object here.
JSTypeFeedbackSpecializer specializer(
&graph_reducer, data->jsgraph(), data->js_type_feedback(), &oracle,
global_object, data->info()->is_deoptimization_enabled()
? JSTypeFeedbackSpecializer::kDeoptimizationEnabled
: JSTypeFeedbackSpecializer::kDeoptimizationDisabled,
data->info()->dependencies());
AddReducer(data, &graph_reducer, &specializer);
graph_reducer.ReduceGraph();
}
};
struct TypedLoweringPhase {
static const char* phase_name() { return "typed lowering"; }
......@@ -621,11 +580,6 @@ struct TypedLoweringPhase {
LoadElimination load_elimination(&graph_reducer);
JSBuiltinReducer builtin_reducer(&graph_reducer, data->jsgraph());
JSTypedLowering typed_lowering(&graph_reducer, data->jsgraph(), temp_zone);
JSTypeFeedbackLowering type_feedback_lowering(
&graph_reducer, data->info()->is_deoptimization_enabled()
? JSTypeFeedbackLowering::kDeoptimizationEnabled
: JSTypeFeedbackLowering::kNoFlags,
data->jsgraph());
JSIntrinsicLowering intrinsic_lowering(
&graph_reducer, data->jsgraph(),
data->info()->is_deoptimization_enabled()
......@@ -637,7 +591,6 @@ struct TypedLoweringPhase {
AddReducer(data, &graph_reducer, &builtin_reducer);
AddReducer(data, &graph_reducer, &typed_lowering);
AddReducer(data, &graph_reducer, &intrinsic_lowering);
AddReducer(data, &graph_reducer, &type_feedback_lowering);
AddReducer(data, &graph_reducer, &load_elimination);
AddReducer(data, &graph_reducer, &common_reducer);
graph_reducer.ReduceGraph();
......@@ -1095,11 +1048,6 @@ Handle<Code> Pipeline::GenerateCode() {
PipelineData data(&zone_pool, info(), pipeline_statistics.get());
this->data_ = &data;
if (info()->is_type_feedback_enabled()) {
data.set_js_type_feedback(new (data.graph_zone())
JSTypeFeedbackTable(data.graph_zone()));
}
BeginPhaseKind("graph creation");
if (FLAG_trace_turbo) {
......@@ -1166,11 +1114,6 @@ Handle<Code> Pipeline::GenerateCode() {
RunPrintAndVerify("Loop peeled");
}
if (info()->is_type_feedback_enabled()) {
Run<JSTypeFeedbackPhase>();
RunPrintAndVerify("JSType feedback");
}
// Lower simplified operators and insert changes.
Run<SimplifiedLoweringPhase>();
RunPrintAndVerify("Lowered simplified");
......
......@@ -430,7 +430,6 @@ DEFINE_BOOL(turbo_verify, DEBUG_BOOL, "verify TurboFan graphs at each phase")
DEFINE_BOOL(turbo_stats, false, "print TurboFan statistics")
DEFINE_BOOL(turbo_splitting, true, "split nodes during scheduling in TurboFan")
DEFINE_BOOL(turbo_types, true, "use typed lowering in TurboFan")
DEFINE_BOOL(turbo_type_feedback, false, "use type feedback in TurboFan")
DEFINE_BOOL(turbo_source_positions, false,
"track source code positions when building TurboFan IR")
DEFINE_IMPLICATION(trace_turbo, turbo_source_positions)
......
......@@ -70,7 +70,6 @@
'compiler/js-intrinsic-lowering-unittest.cc',
'compiler/js-operator-unittest.cc',
'compiler/js-typed-lowering-unittest.cc',
'compiler/js-type-feedback-unittest.cc',
'compiler/linkage-tail-call-unittest.cc',
'compiler/liveness-analyzer-unittest.cc',
'compiler/live-range-unittest.cc',
......
......@@ -534,10 +534,6 @@
'../../src/compiler/js-native-context-specialization.h',
'../../src/compiler/js-operator.cc',
'../../src/compiler/js-operator.h',
'../../src/compiler/js-type-feedback.cc',
'../../src/compiler/js-type-feedback.h',
'../../src/compiler/js-type-feedback-lowering.cc',
'../../src/compiler/js-type-feedback-lowering.h',
'../../src/compiler/js-typed-lowering.cc',
'../../src/compiler/js-typed-lowering.h',
'../../src/compiler/jump-threading.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