OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 int field_index() { | 149 int field_index() { |
150 ASSERT(is_field_index()); | 150 ASSERT(is_field_index()); |
151 return value(); | 151 return value(); |
152 } | 152 } |
153 int header_index() { | 153 int header_index() { |
154 ASSERT(is_header_index()); | 154 ASSERT(is_header_index()); |
155 return value(); | 155 return value(); |
156 } | 156 } |
157 | 157 |
| 158 bool is_inobject(Handle<JSObject> holder) { |
| 159 if (is_header_index()) return true; |
| 160 return field_index() < holder->map()->inobject_properties(); |
| 161 } |
| 162 |
| 163 int translate(Handle<JSObject> holder) { |
| 164 if (is_header_index()) return header_index(); |
| 165 int index = field_index() - holder->map()->inobject_properties(); |
| 166 if (index >= 0) return index; |
| 167 return index + holder->map()->instance_size() / kPointerSize; |
| 168 } |
| 169 |
158 private: | 170 private: |
159 static const int kHeaderIndexBit = 1 << 31; | 171 static const int kHeaderIndexBit = 1 << 31; |
160 static const int kIndexMask = ~kHeaderIndexBit; | 172 static const int kIndexMask = ~kHeaderIndexBit; |
161 | 173 |
162 int value() { return index_ & kIndexMask; } | 174 int value() { return index_ & kIndexMask; } |
163 | 175 |
164 PropertyIndex(int index, bool is_header_based) | 176 PropertyIndex(int index, bool is_header_based) |
165 : index_(index | (is_header_based ? kHeaderIndexBit : 0)) { | 177 : index_(index | (is_header_based ? kHeaderIndexBit : 0)) { |
166 ASSERT(index <= kIndexMask); | 178 ASSERT(index <= kIndexMask); |
167 } | 179 } |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 JSReceiver* holder_; | 473 JSReceiver* holder_; |
462 int number_; | 474 int number_; |
463 bool cacheable_; | 475 bool cacheable_; |
464 PropertyDetails details_; | 476 PropertyDetails details_; |
465 }; | 477 }; |
466 | 478 |
467 | 479 |
468 } } // namespace v8::internal | 480 } } // namespace v8::internal |
469 | 481 |
470 #endif // V8_PROPERTY_H_ | 482 #endif // V8_PROPERTY_H_ |
OLD | NEW |