OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // Order of properties is significant. | 54 // Order of properties is significant. |
55 // Must fit in the BitField PropertyDetails::TypeField. | 55 // Must fit in the BitField PropertyDetails::TypeField. |
56 // A copy of this is in mirror-debugger.js. | 56 // A copy of this is in mirror-debugger.js. |
57 enum PropertyType { | 57 enum PropertyType { |
58 NORMAL = 0, // only in slow mode | 58 NORMAL = 0, // only in slow mode |
59 FIELD = 1, // only in fast mode | 59 FIELD = 1, // only in fast mode |
60 CONSTANT_FUNCTION = 2, // only in fast mode | 60 CONSTANT_FUNCTION = 2, // only in fast mode |
61 CALLBACKS = 3, | 61 CALLBACKS = 3, |
62 HANDLER = 4, // only in lookup results, not in descriptors | 62 HANDLER = 4, // only in lookup results, not in descriptors |
63 INTERCEPTOR = 5, // only in lookup results, not in descriptors | 63 INTERCEPTOR = 5, // only in lookup results, not in descriptors |
| 64 // All properties before MAP_TRANSITION are real. |
64 MAP_TRANSITION = 6, // only in fast mode | 65 MAP_TRANSITION = 6, // only in fast mode |
65 ELEMENTS_TRANSITION = 7, | 66 ELEMENTS_TRANSITION = 7, |
66 CONSTANT_TRANSITION = 8, // only in fast mode | 67 CONSTANT_TRANSITION = 8, // only in fast mode |
67 NULL_DESCRIPTOR = 9, // only in fast mode | 68 NULL_DESCRIPTOR = 9, // only in fast mode |
68 // All properties before MAP_TRANSITION are real. | |
69 FIRST_PHANTOM_PROPERTY_TYPE = MAP_TRANSITION, | |
70 // There are no IC stubs for NULL_DESCRIPTORS. Therefore, | 69 // There are no IC stubs for NULL_DESCRIPTORS. Therefore, |
71 // NULL_DESCRIPTOR can be used as the type flag for IC stubs for | 70 // NULL_DESCRIPTOR can be used as the type flag for IC stubs for |
72 // nonexistent properties. | 71 // nonexistent properties. |
73 NONEXISTENT = NULL_DESCRIPTOR | 72 NONEXISTENT = NULL_DESCRIPTOR |
74 }; | 73 }; |
75 | 74 |
76 | 75 |
77 inline bool IsTransitionType(PropertyType type) { | 76 inline bool IsTransitionType(PropertyType type) { |
78 switch (type) { | 77 switch (type) { |
79 case MAP_TRANSITION: | 78 case MAP_TRANSITION: |
80 case CONSTANT_TRANSITION: | 79 case CONSTANT_TRANSITION: |
81 case ELEMENTS_TRANSITION: | 80 case ELEMENTS_TRANSITION: |
82 return true; | 81 return true; |
83 case NORMAL: | 82 case NORMAL: |
84 case FIELD: | 83 case FIELD: |
85 case CONSTANT_FUNCTION: | 84 case CONSTANT_FUNCTION: |
86 case CALLBACKS: | 85 case CALLBACKS: |
87 case HANDLER: | 86 case HANDLER: |
88 case INTERCEPTOR: | 87 case INTERCEPTOR: |
89 case NULL_DESCRIPTOR: | 88 case NULL_DESCRIPTOR: |
90 return false; | 89 return false; |
91 } | 90 } |
92 UNREACHABLE(); // keep the compiler happy | 91 UNREACHABLE(); // keep the compiler happy |
93 return false; | 92 return false; |
94 } | 93 } |
95 | 94 |
96 | 95 |
| 96 inline bool IsRealProperty(PropertyType type) { |
| 97 switch (type) { |
| 98 case NORMAL: |
| 99 case FIELD: |
| 100 case CONSTANT_FUNCTION: |
| 101 case CALLBACKS: |
| 102 case HANDLER: |
| 103 case INTERCEPTOR: |
| 104 return true; |
| 105 case MAP_TRANSITION: |
| 106 case ELEMENTS_TRANSITION: |
| 107 case CONSTANT_TRANSITION: |
| 108 case NULL_DESCRIPTOR: |
| 109 return false; |
| 110 } |
| 111 UNREACHABLE(); // keep the compiler happy |
| 112 return false; |
| 113 } |
| 114 |
| 115 |
97 // PropertyDetails captures type and attributes for a property. | 116 // PropertyDetails captures type and attributes for a property. |
98 // They are used both in property dictionaries and instance descriptors. | 117 // They are used both in property dictionaries and instance descriptors. |
99 class PropertyDetails BASE_EMBEDDED { | 118 class PropertyDetails BASE_EMBEDDED { |
100 public: | 119 public: |
101 PropertyDetails(PropertyAttributes attributes, | 120 PropertyDetails(PropertyAttributes attributes, |
102 PropertyType type, | 121 PropertyType type, |
103 int index = 0) { | 122 int index = 0) { |
104 ASSERT(TypeField::is_valid(type)); | 123 ASSERT(TypeField::is_valid(type)); |
105 ASSERT(AttributesField::is_valid(attributes)); | 124 ASSERT(AttributesField::is_valid(attributes)); |
106 ASSERT(StorageField::is_valid(index)); | 125 ASSERT(StorageField::is_valid(index)); |
(...skipping 13 matching lines...) Expand all Loading... |
120 | 139 |
121 PropertyType type() { return TypeField::decode(value_); } | 140 PropertyType type() { return TypeField::decode(value_); } |
122 | 141 |
123 bool IsTransition() { | 142 bool IsTransition() { |
124 PropertyType t = type(); | 143 PropertyType t = type(); |
125 ASSERT(t != INTERCEPTOR); | 144 ASSERT(t != INTERCEPTOR); |
126 return IsTransitionType(t); | 145 return IsTransitionType(t); |
127 } | 146 } |
128 | 147 |
129 bool IsProperty() { | 148 bool IsProperty() { |
130 return type() < FIRST_PHANTOM_PROPERTY_TYPE; | 149 return IsRealProperty(type()); |
131 } | 150 } |
132 | 151 |
133 PropertyAttributes attributes() { return AttributesField::decode(value_); } | 152 PropertyAttributes attributes() { return AttributesField::decode(value_); } |
134 | 153 |
135 int index() { return StorageField::decode(value_); } | 154 int index() { return StorageField::decode(value_); } |
136 | 155 |
137 inline PropertyDetails AsDeleted(); | 156 inline PropertyDetails AsDeleted(); |
138 | 157 |
139 static bool IsValidIndex(int index) { | 158 static bool IsValidIndex(int index) { |
140 return StorageField::is_valid(index); | 159 return StorageField::is_valid(index); |
(...skipping 13 matching lines...) Expand all Loading... |
154 | 173 |
155 static const int kInitialIndex = 1; | 174 static const int kInitialIndex = 1; |
156 | 175 |
157 private: | 176 private: |
158 uint32_t value_; | 177 uint32_t value_; |
159 }; | 178 }; |
160 | 179 |
161 } } // namespace v8::internal | 180 } } // namespace v8::internal |
162 | 181 |
163 #endif // V8_PROPERTY_DETAILS_H_ | 182 #endif // V8_PROPERTY_DETAILS_H_ |
OLD | NEW |