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_ACCESS_INFO_H_ | 5 #ifndef V8_COMPILER_ACCESS_INFO_H_ |
6 #define V8_COMPILER_ACCESS_INFO_H_ | 6 #define V8_COMPILER_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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 MapTransitionList const& transitions() const { return transitions_; } | 46 MapTransitionList const& transitions() const { return transitions_; } |
47 | 47 |
48 private: | 48 private: |
49 ElementsKind elements_kind_; | 49 ElementsKind elements_kind_; |
50 MaybeHandle<JSObject> holder_; | 50 MaybeHandle<JSObject> holder_; |
51 Type* receiver_type_; | 51 Type* receiver_type_; |
52 MapTransitionList transitions_; | 52 MapTransitionList transitions_; |
53 }; | 53 }; |
54 | 54 |
55 | 55 |
56 // Additional checks that need to be perform for data field accesses. | |
57 enum class FieldCheck : uint8_t { | |
58 // No additional checking needed. | |
59 kNone, | |
60 // Check that the [[ViewedArrayBuffer]] of {JSArrayBufferView}s | |
61 // was not neutered. | |
62 kJSArrayBufferViewBufferNotNeutered, | |
63 }; | |
64 | |
65 | |
66 // This class encapsulates all information required to access a certain | 56 // This class encapsulates all information required to access a certain |
67 // object property, either on the object itself or on the prototype chain. | 57 // object property, either on the object itself or on the prototype chain. |
68 class PropertyAccessInfo final { | 58 class PropertyAccessInfo final { |
69 public: | 59 public: |
70 enum Kind { kInvalid, kNotFound, kDataConstant, kDataField }; | 60 enum Kind { kInvalid, kNotFound, kDataConstant, kDataField }; |
71 | 61 |
72 static PropertyAccessInfo NotFound(Type* receiver_type, | 62 static PropertyAccessInfo NotFound(Type* receiver_type, |
73 MaybeHandle<JSObject> holder); | 63 MaybeHandle<JSObject> holder); |
74 static PropertyAccessInfo DataConstant(Type* receiver_type, | 64 static PropertyAccessInfo DataConstant(Type* receiver_type, |
75 Handle<Object> constant, | 65 Handle<Object> constant, |
76 MaybeHandle<JSObject> holder); | 66 MaybeHandle<JSObject> holder); |
77 static PropertyAccessInfo DataField( | 67 static PropertyAccessInfo DataField( |
78 Type* receiver_type, FieldIndex field_index, Type* field_type, | 68 Type* receiver_type, FieldIndex field_index, Type* field_type, |
79 FieldCheck field_check = FieldCheck::kNone, | |
80 MaybeHandle<JSObject> holder = MaybeHandle<JSObject>(), | 69 MaybeHandle<JSObject> holder = MaybeHandle<JSObject>(), |
81 MaybeHandle<Map> transition_map = MaybeHandle<Map>()); | 70 MaybeHandle<Map> transition_map = MaybeHandle<Map>()); |
82 | 71 |
83 PropertyAccessInfo(); | 72 PropertyAccessInfo(); |
84 | 73 |
85 bool IsNotFound() const { return kind() == kNotFound; } | 74 bool IsNotFound() const { return kind() == kNotFound; } |
86 bool IsDataConstant() const { return kind() == kDataConstant; } | 75 bool IsDataConstant() const { return kind() == kDataConstant; } |
87 bool IsDataField() const { return kind() == kDataField; } | 76 bool IsDataField() const { return kind() == kDataField; } |
88 | 77 |
89 bool HasTransitionMap() const { return !transition_map().is_null(); } | 78 bool HasTransitionMap() const { return !transition_map().is_null(); } |
90 | 79 |
91 Kind kind() const { return kind_; } | 80 Kind kind() const { return kind_; } |
92 MaybeHandle<JSObject> holder() const { return holder_; } | 81 MaybeHandle<JSObject> holder() const { return holder_; } |
93 MaybeHandle<Map> transition_map() const { return transition_map_; } | 82 MaybeHandle<Map> transition_map() const { return transition_map_; } |
94 Handle<Object> constant() const { return constant_; } | 83 Handle<Object> constant() const { return constant_; } |
95 FieldCheck field_check() const { return field_check_; } | |
96 FieldIndex field_index() const { return field_index_; } | 84 FieldIndex field_index() const { return field_index_; } |
97 Type* field_type() const { return field_type_; } | 85 Type* field_type() const { return field_type_; } |
98 Type* receiver_type() const { return receiver_type_; } | 86 Type* receiver_type() const { return receiver_type_; } |
99 | 87 |
100 private: | 88 private: |
101 PropertyAccessInfo(MaybeHandle<JSObject> holder, Type* receiver_type); | 89 PropertyAccessInfo(MaybeHandle<JSObject> holder, Type* receiver_type); |
102 PropertyAccessInfo(MaybeHandle<JSObject> holder, Handle<Object> constant, | 90 PropertyAccessInfo(MaybeHandle<JSObject> holder, Handle<Object> constant, |
103 Type* receiver_type); | 91 Type* receiver_type); |
104 PropertyAccessInfo(MaybeHandle<JSObject> holder, | 92 PropertyAccessInfo(MaybeHandle<JSObject> holder, |
105 MaybeHandle<Map> transition_map, FieldIndex field_index, | 93 MaybeHandle<Map> transition_map, FieldIndex field_index, |
106 FieldCheck field_check, Type* field_type, | 94 Type* field_type, Type* receiver_type); |
107 Type* receiver_type); | |
108 | 95 |
109 Kind kind_; | 96 Kind kind_; |
110 Type* receiver_type_; | 97 Type* receiver_type_; |
111 Handle<Object> constant_; | 98 Handle<Object> constant_; |
112 MaybeHandle<Map> transition_map_; | 99 MaybeHandle<Map> transition_map_; |
113 MaybeHandle<JSObject> holder_; | 100 MaybeHandle<JSObject> holder_; |
114 FieldIndex field_index_; | 101 FieldIndex field_index_; |
115 FieldCheck field_check_; | |
116 Type* field_type_; | 102 Type* field_type_; |
117 }; | 103 }; |
118 | 104 |
119 | 105 |
120 // Factory class for {ElementAccessInfo}s and {PropertyAccessInfo}s. | 106 // Factory class for {ElementAccessInfo}s and {PropertyAccessInfo}s. |
121 class AccessInfoFactory final { | 107 class AccessInfoFactory final { |
122 public: | 108 public: |
123 AccessInfoFactory(CompilationDependencies* dependencies, | 109 AccessInfoFactory(CompilationDependencies* dependencies, |
124 Handle<Context> native_context, Zone* zone); | 110 Handle<Context> native_context, Zone* zone); |
125 | 111 |
(...skipping 29 matching lines...) Expand all Loading... |
155 Zone* const zone_; | 141 Zone* const zone_; |
156 | 142 |
157 DISALLOW_COPY_AND_ASSIGN(AccessInfoFactory); | 143 DISALLOW_COPY_AND_ASSIGN(AccessInfoFactory); |
158 }; | 144 }; |
159 | 145 |
160 } // namespace compiler | 146 } // namespace compiler |
161 } // namespace internal | 147 } // namespace internal |
162 } // namespace v8 | 148 } // namespace v8 |
163 | 149 |
164 #endif // V8_COMPILER_ACCESS_INFO_H_ | 150 #endif // V8_COMPILER_ACCESS_INFO_H_ |
OLD | NEW |