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_PROPERTY_ACCESS_INFO_H_ | 5 #ifndef V8_COMPILER_PROPERTY_ACCESS_INFO_H_ |
6 #define V8_COMPILER_PROPERTY_ACCESS_INFO_H_ | 6 #define V8_COMPILER_PROPERTY_ACCESS_INFO_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/field-index.h" | 10 #include "src/field-index.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // Whether we are loading a property or storing to a property. | 25 // Whether we are loading a property or storing to a property. |
26 enum class PropertyAccessMode { kLoad, kStore }; | 26 enum class PropertyAccessMode { kLoad, kStore }; |
27 | 27 |
28 std::ostream& operator<<(std::ostream&, PropertyAccessMode); | 28 std::ostream& operator<<(std::ostream&, PropertyAccessMode); |
29 | 29 |
30 | 30 |
31 // This class encapsulates all information required to access a certain | 31 // This class encapsulates all information required to access a certain |
32 // object property, either on the object itself or on the prototype chain. | 32 // object property, either on the object itself or on the prototype chain. |
33 class PropertyAccessInfo final { | 33 class PropertyAccessInfo final { |
34 public: | 34 public: |
35 enum Kind { kInvalid, kDataConstant, kDataField }; | 35 enum Kind { kInvalid, kNotFound, kDataConstant, kDataField }; |
36 | 36 |
| 37 static PropertyAccessInfo NotFound(Type* receiver_type, |
| 38 MaybeHandle<JSObject> holder); |
37 static PropertyAccessInfo DataConstant(Type* receiver_type, | 39 static PropertyAccessInfo DataConstant(Type* receiver_type, |
38 Handle<Object> constant, | 40 Handle<Object> constant, |
39 MaybeHandle<JSObject> holder) { | 41 MaybeHandle<JSObject> holder); |
40 return PropertyAccessInfo(holder, constant, receiver_type); | |
41 } | |
42 static PropertyAccessInfo DataField( | 42 static PropertyAccessInfo DataField( |
43 Type* receiver_type, FieldIndex field_index, Type* field_type, | 43 Type* receiver_type, FieldIndex field_index, Type* field_type, |
44 MaybeHandle<JSObject> holder = MaybeHandle<JSObject>(), | 44 MaybeHandle<JSObject> holder = MaybeHandle<JSObject>(), |
45 MaybeHandle<Map> transition_map = MaybeHandle<Map>()) { | 45 MaybeHandle<Map> transition_map = MaybeHandle<Map>()); |
46 return PropertyAccessInfo(holder, transition_map, field_index, field_type, | |
47 receiver_type); | |
48 } | |
49 | 46 |
50 PropertyAccessInfo(); | 47 PropertyAccessInfo(); |
51 | 48 |
| 49 bool IsNotFound() const { return kind() == kNotFound; } |
52 bool IsDataConstant() const { return kind() == kDataConstant; } | 50 bool IsDataConstant() const { return kind() == kDataConstant; } |
53 bool IsDataField() const { return kind() == kDataField; } | 51 bool IsDataField() const { return kind() == kDataField; } |
54 | 52 |
| 53 bool HasTransitionMap() const { return !transition_map().is_null(); } |
| 54 |
55 Kind kind() const { return kind_; } | 55 Kind kind() const { return kind_; } |
56 MaybeHandle<JSObject> holder() const { return holder_; } | 56 MaybeHandle<JSObject> holder() const { return holder_; } |
57 MaybeHandle<Map> transition_map() const { return transition_map_; } | 57 MaybeHandle<Map> transition_map() const { return transition_map_; } |
58 Handle<Object> constant() const { return constant_; } | 58 Handle<Object> constant() const { return constant_; } |
59 FieldIndex field_index() const { return field_index_; } | 59 FieldIndex field_index() const { return field_index_; } |
60 Type* field_type() const { return field_type_; } | 60 Type* field_type() const { return field_type_; } |
61 Type* receiver_type() const { return receiver_type_; } | 61 Type* receiver_type() const { return receiver_type_; } |
62 | 62 |
63 bool HasTransitionMap() const { return !transition_map().is_null(); } | |
64 | |
65 private: | 63 private: |
| 64 PropertyAccessInfo(MaybeHandle<JSObject> holder, Type* receiver_type); |
66 PropertyAccessInfo(MaybeHandle<JSObject> holder, Handle<Object> constant, | 65 PropertyAccessInfo(MaybeHandle<JSObject> holder, Handle<Object> constant, |
67 Type* receiver_type); | 66 Type* receiver_type); |
68 PropertyAccessInfo(MaybeHandle<JSObject> holder, | 67 PropertyAccessInfo(MaybeHandle<JSObject> holder, |
69 MaybeHandle<Map> transition_map, FieldIndex field_index, | 68 MaybeHandle<Map> transition_map, FieldIndex field_index, |
70 Type* field_type, Type* receiver_type); | 69 Type* field_type, Type* receiver_type); |
71 | 70 |
72 Kind kind_; | 71 Kind kind_; |
73 Type* receiver_type_; | 72 Type* receiver_type_; |
74 Handle<Object> constant_; | 73 Handle<Object> constant_; |
75 MaybeHandle<Map> transition_map_; | 74 MaybeHandle<Map> transition_map_; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 Zone* const zone_; | 111 Zone* const zone_; |
113 | 112 |
114 DISALLOW_COPY_AND_ASSIGN(PropertyAccessInfoFactory); | 113 DISALLOW_COPY_AND_ASSIGN(PropertyAccessInfoFactory); |
115 }; | 114 }; |
116 | 115 |
117 } // namespace compiler | 116 } // namespace compiler |
118 } // namespace internal | 117 } // namespace internal |
119 } // namespace v8 | 118 } // namespace v8 |
120 | 119 |
121 #endif // V8_COMPILER_PROPERTY_ACCESS_INFO_H_ | 120 #endif // V8_COMPILER_PROPERTY_ACCESS_INFO_H_ |
OLD | NEW |