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 #include "src/compiler/simplified-operator.h" |
| 14 |
| 15 namespace v8 { |
| 16 namespace internal { |
| 17 |
| 18 class TypeFeedbackOracle; |
| 19 class SmallMapList; |
| 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 // TODO(titzer): support recording the feedback vector slot. |
| 30 |
| 31 void Record(Node* node, TypeFeedbackId id); |
| 32 |
| 33 private: |
| 34 friend class JSTypeFeedbackSpecializer; |
| 35 typedef std::map<NodeId, TypeFeedbackId, std::less<NodeId>, |
| 36 zone_allocator<TypeFeedbackId> > TypeFeedbackIdMap; |
| 37 |
| 38 TypeFeedbackIdMap map_; |
| 39 |
| 40 TypeFeedbackId find(Node* node) { |
| 41 TypeFeedbackIdMap::const_iterator it = map_.find(node->id()); |
| 42 return it == map_.end() ? TypeFeedbackId::None() : it->second; |
| 43 } |
| 44 }; |
| 45 |
| 46 |
| 47 // Specializes a graph to the type feedback recorded in the |
| 48 // {js_type_feedback} provided to the constructor. |
| 49 class JSTypeFeedbackSpecializer : public Reducer { |
| 50 public: |
| 51 JSTypeFeedbackSpecializer(JSGraph* jsgraph, |
| 52 JSTypeFeedbackTable* js_type_feedback, |
| 53 TypeFeedbackOracle* oracle) |
| 54 : jsgraph_(jsgraph), |
| 55 simplified_(jsgraph->graph()->zone()), |
| 56 js_type_feedback_(js_type_feedback), |
| 57 oracle_(oracle) { |
| 58 CHECK(js_type_feedback); |
| 59 } |
| 60 |
| 61 Reduction Reduce(Node* node) OVERRIDE; |
| 62 |
| 63 // Visible for unit testing. |
| 64 Reduction ReduceJSLoadNamed(Node* node); |
| 65 Reduction ReduceJSLoadProperty(Node* node); |
| 66 Reduction ReduceJSStoreNamed(Node* node); |
| 67 Reduction ReduceJSStoreProperty(Node* node); |
| 68 |
| 69 private: |
| 70 JSGraph* jsgraph_; |
| 71 SimplifiedOperatorBuilder simplified_; |
| 72 JSTypeFeedbackTable* js_type_feedback_; |
| 73 TypeFeedbackOracle* oracle_; |
| 74 |
| 75 TypeFeedbackOracle* oracle() { return oracle_; } |
| 76 Graph* graph() { return jsgraph_->graph(); } |
| 77 CommonOperatorBuilder* common() { return jsgraph_->common(); } |
| 78 SimplifiedOperatorBuilder* simplified() { return &simplified_; } |
| 79 |
| 80 void BuildMapCheck(Node* receiver, Handle<Map> map, bool smi_check, |
| 81 Node* effect, Node* control, Node** success, Node** fail); |
| 82 |
| 83 void GatherReceiverTypes(Node* receiver, Node* effect, TypeFeedbackId id, |
| 84 Handle<Name> property, SmallMapList* maps); |
| 85 }; |
| 86 |
| 87 } // namespace compiler |
| 88 } // namespace internal |
| 89 } // namespace v8 |
| 90 |
| 91 #endif |
OLD | NEW |