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