| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_COMPILER_JS_TYPE_FEEDBACK_H_ | 5 #ifndef V8_COMPILER_JS_TYPE_FEEDBACK_H_ |
| 6 #define V8_COMPILER_JS_TYPE_FEEDBACK_H_ | 6 #define V8_COMPILER_JS_TYPE_FEEDBACK_H_ |
| 7 | 7 |
| 8 #include "src/utils.h" | 8 #include "src/utils.h" |
| 9 | 9 |
| 10 #include "src/compiler/graph-reducer.h" | 10 #include "src/compiler/graph-reducer.h" |
| 11 #include "src/compiler/js-graph.h" | 11 #include "src/compiler/js-graph.h" |
| 12 #include "src/compiler/node-aux-data.h" | 12 #include "src/compiler/node-aux-data.h" |
| 13 #include "src/compiler/simplified-operator.h" | 13 #include "src/compiler/simplified-operator.h" |
| 14 | 14 |
| 15 namespace v8 { | 15 namespace v8 { |
| 16 namespace internal { | 16 namespace internal { |
| 17 | 17 |
| 18 class TypeFeedbackOracle; | 18 class TypeFeedbackOracle; |
| 19 class SmallMapList; | 19 class SmallMapList; |
| 20 class CompilationDependencies; | 20 class CompilationDependencies; |
| 21 | 21 |
| 22 namespace compiler { | 22 namespace compiler { |
| 23 | 23 |
| 24 // Stores type feedback information for nodes in the graph in a separate | 24 // Stores type feedback information for nodes in the graph in a separate |
| 25 // data structure. | 25 // data structure. |
| 26 class JSTypeFeedbackTable : public ZoneObject { | 26 class JSTypeFeedbackTable : public ZoneObject { |
| 27 public: | 27 public: |
| 28 explicit JSTypeFeedbackTable(Zone* zone); | 28 explicit JSTypeFeedbackTable(Zone* zone); |
| 29 | 29 |
| 30 // TODO(titzer): support recording the feedback vector slot. | |
| 31 | |
| 32 void Record(Node* node, TypeFeedbackId id); | 30 void Record(Node* node, TypeFeedbackId id); |
| 31 void Record(Node* node, FeedbackVectorICSlot slot); |
| 33 | 32 |
| 34 private: | 33 private: |
| 35 friend class JSTypeFeedbackSpecializer; | 34 friend class JSTypeFeedbackSpecializer; |
| 36 typedef std::map<NodeId, TypeFeedbackId, std::less<NodeId>, | 35 typedef std::map<NodeId, TypeFeedbackId, std::less<NodeId>, |
| 37 zone_allocator<TypeFeedbackId> > TypeFeedbackIdMap; | 36 zone_allocator<TypeFeedbackId> > TypeFeedbackIdMap; |
| 37 typedef std::map<NodeId, FeedbackVectorICSlot, std::less<NodeId>, |
| 38 zone_allocator<FeedbackVectorICSlot> > |
| 39 FeedbackVectorICSlotMap; |
| 38 | 40 |
| 39 TypeFeedbackIdMap map_; | 41 TypeFeedbackIdMap type_feedback_id_map_; |
| 42 FeedbackVectorICSlotMap feedback_vector_ic_slot_map_; |
| 40 | 43 |
| 41 TypeFeedbackId find(Node* node) { | 44 TypeFeedbackId FindTypeFeedbackId(Node* node) { |
| 42 TypeFeedbackIdMap::const_iterator it = map_.find(node->id()); | 45 TypeFeedbackIdMap::const_iterator it = |
| 43 return it == map_.end() ? TypeFeedbackId::None() : it->second; | 46 type_feedback_id_map_.find(node->id()); |
| 47 return it == type_feedback_id_map_.end() ? TypeFeedbackId::None() |
| 48 : it->second; |
| 49 } |
| 50 |
| 51 FeedbackVectorICSlot FindFeedbackVectorICSlot(Node* node) { |
| 52 FeedbackVectorICSlotMap::const_iterator it = |
| 53 feedback_vector_ic_slot_map_.find(node->id()); |
| 54 return it == feedback_vector_ic_slot_map_.end() |
| 55 ? FeedbackVectorICSlot::Invalid() |
| 56 : it->second; |
| 44 } | 57 } |
| 45 }; | 58 }; |
| 46 | 59 |
| 47 | 60 |
| 48 // Specializes a graph to the type feedback recorded in the | 61 // Specializes a graph to the type feedback recorded in the |
| 49 // {js_type_feedback} provided to the constructor. | 62 // {js_type_feedback} provided to the constructor. |
| 50 class JSTypeFeedbackSpecializer : public AdvancedReducer { | 63 class JSTypeFeedbackSpecializer : public AdvancedReducer { |
| 51 public: | 64 public: |
| 52 JSTypeFeedbackSpecializer(Editor* editor, JSGraph* jsgraph, | 65 JSTypeFeedbackSpecializer(Editor* editor, JSGraph* jsgraph, |
| 53 JSTypeFeedbackTable* js_type_feedback, | 66 JSTypeFeedbackTable* js_type_feedback, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 83 | 96 |
| 84 TypeFeedbackOracle* oracle() { return oracle_; } | 97 TypeFeedbackOracle* oracle() { return oracle_; } |
| 85 Graph* graph() { return jsgraph_->graph(); } | 98 Graph* graph() { return jsgraph_->graph(); } |
| 86 JSGraph* jsgraph() { return jsgraph_; } | 99 JSGraph* jsgraph() { return jsgraph_; } |
| 87 CommonOperatorBuilder* common() { return jsgraph_->common(); } | 100 CommonOperatorBuilder* common() { return jsgraph_->common(); } |
| 88 SimplifiedOperatorBuilder* simplified() { return &simplified_; } | 101 SimplifiedOperatorBuilder* simplified() { return &simplified_; } |
| 89 | 102 |
| 90 void BuildMapCheck(Node* receiver, Handle<Map> map, bool smi_check, | 103 void BuildMapCheck(Node* receiver, Handle<Map> map, bool smi_check, |
| 91 Node* effect, Node* control, Node** success, Node** fail); | 104 Node* effect, Node* control, Node** success, Node** fail); |
| 92 | 105 |
| 93 void GatherReceiverTypes(Node* receiver, Node* effect, TypeFeedbackId id, | |
| 94 Handle<Name> property, SmallMapList* maps); | |
| 95 | |
| 96 Node* GetFrameStateBefore(Node* node); | 106 Node* GetFrameStateBefore(Node* node); |
| 97 }; | 107 }; |
| 98 | 108 |
| 99 } // namespace compiler | 109 } // namespace compiler |
| 100 } // namespace internal | 110 } // namespace internal |
| 101 } // namespace v8 | 111 } // namespace v8 |
| 102 | 112 |
| 103 #endif | 113 #endif |
| OLD | NEW |