OLD | NEW |
| (Empty) |
1 // Copyright 2015 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef V8_COMPILER_JS_TYPE_FEEDBACK_H_ | |
6 #define V8_COMPILER_JS_TYPE_FEEDBACK_H_ | |
7 | |
8 #include "src/utils.h" | |
9 | |
10 #include "src/compiler/graph-reducer.h" | |
11 #include "src/compiler/js-graph.h" | |
12 #include "src/compiler/node-aux-data.h" | |
13 | |
14 namespace v8 { | |
15 namespace internal { | |
16 | |
17 class TypeFeedbackOracle; | |
18 class SmallMapList; | |
19 class CompilationDependencies; | |
20 | |
21 namespace compiler { | |
22 | |
23 // Stores type feedback information for nodes in the graph in a separate | |
24 // data structure. | |
25 class JSTypeFeedbackTable : public ZoneObject { | |
26 public: | |
27 explicit JSTypeFeedbackTable(Zone* zone); | |
28 | |
29 void Record(Node* node, TypeFeedbackId id); | |
30 void Record(Node* node, FeedbackVectorSlot slot); | |
31 | |
32 private: | |
33 friend class JSTypeFeedbackSpecializer; | |
34 typedef std::map<NodeId, TypeFeedbackId, std::less<NodeId>, | |
35 zone_allocator<TypeFeedbackId> > TypeFeedbackIdMap; | |
36 typedef std::map<NodeId, FeedbackVectorSlot, std::less<NodeId>, | |
37 zone_allocator<FeedbackVectorSlot> > FeedbackVectorSlotMap; | |
38 | |
39 TypeFeedbackIdMap type_feedback_id_map_; | |
40 FeedbackVectorSlotMap feedback_vector_slot_map_; | |
41 | |
42 TypeFeedbackId FindTypeFeedbackId(Node* node) { | |
43 TypeFeedbackIdMap::const_iterator it = | |
44 type_feedback_id_map_.find(node->id()); | |
45 return it == type_feedback_id_map_.end() ? TypeFeedbackId::None() | |
46 : it->second; | |
47 } | |
48 | |
49 FeedbackVectorSlot FindFeedbackVectorSlot(Node* node) { | |
50 FeedbackVectorSlotMap::const_iterator it = | |
51 feedback_vector_slot_map_.find(node->id()); | |
52 return it == feedback_vector_slot_map_.end() ? FeedbackVectorSlot::Invalid() | |
53 : it->second; | |
54 } | |
55 }; | |
56 | |
57 | |
58 // Specializes a graph to the type feedback recorded in the | |
59 // {js_type_feedback} provided to the constructor. | |
60 class JSTypeFeedbackSpecializer : public AdvancedReducer { | |
61 public: | |
62 enum DeoptimizationMode { kDeoptimizationEnabled, kDeoptimizationDisabled }; | |
63 | |
64 JSTypeFeedbackSpecializer(Editor* editor, JSGraph* jsgraph, | |
65 JSTypeFeedbackTable* js_type_feedback, | |
66 TypeFeedbackOracle* oracle, | |
67 Handle<GlobalObject> global_object, | |
68 DeoptimizationMode mode, | |
69 CompilationDependencies* dependencies) | |
70 : AdvancedReducer(editor), | |
71 jsgraph_(jsgraph), | |
72 js_type_feedback_(js_type_feedback), | |
73 oracle_(oracle), | |
74 global_object_(global_object), | |
75 mode_(mode), | |
76 dependencies_(dependencies) { | |
77 CHECK_NOT_NULL(js_type_feedback); | |
78 } | |
79 | |
80 Reduction Reduce(Node* node) override; | |
81 | |
82 // Visible for unit testing. | |
83 Reduction ReduceJSLoadGlobal(Node* node); | |
84 Reduction ReduceJSLoadNamed(Node* node); | |
85 Reduction ReduceJSLoadProperty(Node* node); | |
86 Reduction ReduceJSStoreNamed(Node* node); | |
87 Reduction ReduceJSStoreProperty(Node* node); | |
88 | |
89 private: | |
90 JSGraph* jsgraph_; | |
91 JSTypeFeedbackTable* js_type_feedback_; | |
92 TypeFeedbackOracle* oracle_; | |
93 Handle<GlobalObject> global_object_; | |
94 DeoptimizationMode const mode_; | |
95 CompilationDependencies* dependencies_; | |
96 | |
97 TypeFeedbackOracle* oracle() { return oracle_; } | |
98 Graph* graph() { return jsgraph_->graph(); } | |
99 JSGraph* jsgraph() { return jsgraph_; } | |
100 CommonOperatorBuilder* common() { return jsgraph_->common(); } | |
101 SimplifiedOperatorBuilder* simplified() { return jsgraph_->simplified(); } | |
102 DeoptimizationMode mode() const { return mode_; } | |
103 | |
104 void BuildMapCheck(Node* receiver, Handle<Map> map, bool smi_check, | |
105 Node* effect, Node* control, Node** success, Node** fail); | |
106 | |
107 Node* GetFrameStateBefore(Node* node); | |
108 }; | |
109 | |
110 } // namespace compiler | |
111 } // namespace internal | |
112 } // namespace v8 | |
113 | |
114 #endif | |
OLD | NEW |