Chromium Code Reviews| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 class CallbacksDescriptor: public Descriptor { | 125 class CallbacksDescriptor: public Descriptor { |
| 126 public: | 126 public: |
| 127 CallbacksDescriptor(String* key, | 127 CallbacksDescriptor(String* key, |
| 128 Object* foreign, | 128 Object* foreign, |
| 129 PropertyAttributes attributes, | 129 PropertyAttributes attributes, |
| 130 int index = 0) | 130 int index = 0) |
| 131 : Descriptor(key, foreign, attributes, CALLBACKS, index) {} | 131 : Descriptor(key, foreign, attributes, CALLBACKS, index) {} |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 | 134 |
| 135 // Hold a property index value distinguishing if it is a field index or an | |
|
Jakob Kummerow
2012/11/13 10:44:43
nit: s/Hold/Holds/
| |
| 136 // index inside the object header. | |
| 137 class PropertyIndex { | |
| 138 public: | |
| 139 static PropertyIndex NewFieldIndex(int index) { | |
| 140 return PropertyIndex(index, false); | |
| 141 } | |
| 142 static PropertyIndex NewHeaderIndex(int index) { | |
| 143 return PropertyIndex(index, true); | |
| 144 } | |
| 145 | |
| 146 bool IsFieldIndex() { return (index_ & kHeaderIndexBit) == 0; } | |
|
Jakob Kummerow
2012/11/13 10:44:43
nit: I think for this and the next three methods,
| |
| 147 bool IsHeaderIndex() { return (index_ & kHeaderIndexBit) != 0; } | |
| 148 | |
| 149 int FieldIndex() { | |
| 150 ASSERT(IsFieldIndex()); | |
| 151 return value(); | |
| 152 } | |
| 153 int HeaderIndex() { | |
| 154 ASSERT(IsHeaderIndex()); | |
| 155 return value(); | |
| 156 } | |
| 157 | |
| 158 int RawIndex() { return index_; } | |
|
Jakob Kummerow
2012/11/13 10:44:43
I don't see this ever getting called.
| |
| 159 | |
| 160 private: | |
| 161 static const int kHeaderIndexBit = 1 << 31; | |
| 162 static const int kIndexMask = ~kHeaderIndexBit; | |
| 163 | |
| 164 int value() { return index_ & kIndexMask; } | |
| 165 | |
| 166 int index_; | |
| 167 PropertyIndex(int index, bool isHeaderBased) : | |
|
Jakob Kummerow
2012/11/13 10:44:43
nit1: ':' should be on the second line (see e.g. t
| |
| 168 index_(index | (isHeaderBased ? kHeaderIndexBit : 0)) { | |
| 169 ASSERT(index <= kIndexMask); | |
| 170 } | |
| 171 }; | |
| 172 | |
|
Jakob Kummerow
2012/11/13 10:44:43
nit: two lines of whitespace between top-level def
| |
| 135 class LookupResult BASE_EMBEDDED { | 173 class LookupResult BASE_EMBEDDED { |
| 136 public: | 174 public: |
| 137 explicit LookupResult(Isolate* isolate) | 175 explicit LookupResult(Isolate* isolate) |
| 138 : isolate_(isolate), | 176 : isolate_(isolate), |
| 139 next_(isolate->top_lookup_result()), | 177 next_(isolate->top_lookup_result()), |
| 140 lookup_type_(NOT_FOUND), | 178 lookup_type_(NOT_FOUND), |
| 141 holder_(NULL), | 179 holder_(NULL), |
| 142 cacheable_(true), | 180 cacheable_(true), |
| 143 details_(NONE, NONEXISTENT) { | 181 details_(NONE, NONEXISTENT) { |
| 144 isolate->SetTopLookupResult(this); | 182 isolate->SetTopLookupResult(this); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 bool IsProperty() { | 309 bool IsProperty() { |
| 272 return IsFound() && !IsTransition(); | 310 return IsFound() && !IsTransition(); |
| 273 } | 311 } |
| 274 | 312 |
| 275 bool IsCacheable() { return cacheable_; } | 313 bool IsCacheable() { return cacheable_; } |
| 276 void DisallowCaching() { cacheable_ = false; } | 314 void DisallowCaching() { cacheable_ = false; } |
| 277 | 315 |
| 278 Object* GetLazyValue() { | 316 Object* GetLazyValue() { |
| 279 switch (type()) { | 317 switch (type()) { |
| 280 case FIELD: | 318 case FIELD: |
| 281 return holder()->FastPropertyAt(GetFieldIndex()); | 319 return holder()->FastPropertyAt(GetFieldIndex().FieldIndex()); |
| 282 case NORMAL: { | 320 case NORMAL: { |
| 283 Object* value; | 321 Object* value; |
| 284 value = holder()->property_dictionary()->ValueAt(GetDictionaryEntry()); | 322 value = holder()->property_dictionary()->ValueAt(GetDictionaryEntry()); |
| 285 if (holder()->IsGlobalObject()) { | 323 if (holder()->IsGlobalObject()) { |
| 286 value = JSGlobalPropertyCell::cast(value)->value(); | 324 value = JSGlobalPropertyCell::cast(value)->value(); |
| 287 } | 325 } |
| 288 return value; | 326 return value; |
| 289 } | 327 } |
| 290 case CONSTANT_FUNCTION: | 328 case CONSTANT_FUNCTION: |
| 291 return GetConstantFunction(); | 329 return GetConstantFunction(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 int GetTransitionIndex() { | 365 int GetTransitionIndex() { |
| 328 ASSERT(IsTransition()); | 366 ASSERT(IsTransition()); |
| 329 return number_; | 367 return number_; |
| 330 } | 368 } |
| 331 | 369 |
| 332 int GetDescriptorIndex() { | 370 int GetDescriptorIndex() { |
| 333 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); | 371 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); |
| 334 return number_; | 372 return number_; |
| 335 } | 373 } |
| 336 | 374 |
| 337 int GetFieldIndex() { | 375 PropertyIndex GetFieldIndex() { |
| 338 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); | 376 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); |
| 339 ASSERT(IsField()); | 377 ASSERT(IsField()); |
| 340 return Descriptor::IndexFromValue(GetValue()); | 378 return PropertyIndex::NewFieldIndex( |
| 379 Descriptor::IndexFromValue(GetValue())); | |
| 341 } | 380 } |
| 342 | 381 |
| 343 int GetLocalFieldIndexFromMap(Map* map) { | 382 int GetLocalFieldIndexFromMap(Map* map) { |
| 344 ASSERT(IsField()); | 383 ASSERT(IsField()); |
| 345 return Descriptor::IndexFromValue(GetValueFromMap(map)) - | 384 return Descriptor::IndexFromValue(GetValueFromMap(map)) - |
| 346 map->inobject_properties(); | 385 map->inobject_properties(); |
| 347 } | 386 } |
| 348 | 387 |
| 349 int GetDictionaryEntry() { | 388 int GetDictionaryEntry() { |
| 350 ASSERT(lookup_type_ == DICTIONARY_TYPE); | 389 ASSERT(lookup_type_ == DICTIONARY_TYPE); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 JSReceiver* holder_; | 447 JSReceiver* holder_; |
| 409 int number_; | 448 int number_; |
| 410 bool cacheable_; | 449 bool cacheable_; |
| 411 PropertyDetails details_; | 450 PropertyDetails details_; |
| 412 }; | 451 }; |
| 413 | 452 |
| 414 | 453 |
| 415 } } // namespace v8::internal | 454 } } // namespace v8::internal |
| 416 | 455 |
| 417 #endif // V8_PROPERTY_H_ | 456 #endif // V8_PROPERTY_H_ |
| OLD | NEW |