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 // 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 // Review notes: | 5 // Review notes: |
| 6 // | 6 // |
| 7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
| 8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
| 9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
| 10 // | 10 // |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 712 bool Object::IsJSWeakCollection() const { | 712 bool Object::IsJSWeakCollection() const { |
| 713 return IsJSWeakMap() || IsJSWeakSet(); | 713 return IsJSWeakMap() || IsJSWeakSet(); |
| 714 } | 714 } |
| 715 | 715 |
| 716 | 716 |
| 717 bool Object::IsDescriptorArray() const { | 717 bool Object::IsDescriptorArray() const { |
| 718 return IsFixedArray(); | 718 return IsFixedArray(); |
| 719 } | 719 } |
| 720 | 720 |
| 721 | 721 |
| 722 bool Object::IsArrayList() const { return IsFixedArray(); } | |
| 723 | |
| 724 | |
| 722 bool Object::IsLayoutDescriptor() const { | 725 bool Object::IsLayoutDescriptor() const { |
| 723 return IsSmi() || IsFixedTypedArrayBase(); | 726 return IsSmi() || IsFixedTypedArrayBase(); |
| 724 } | 727 } |
| 725 | 728 |
| 726 | 729 |
| 727 bool Object::IsTransitionArray() const { | 730 bool Object::IsTransitionArray() const { |
| 728 return IsFixedArray(); | 731 return IsFixedArray(); |
| 729 } | 732 } |
| 730 | 733 |
| 731 | 734 |
| (...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2393 | 2396 |
| 2394 int WeakFixedArray::last_used_index() const { | 2397 int WeakFixedArray::last_used_index() const { |
| 2395 return Smi::cast(FixedArray::cast(this)->get(kLastUsedIndexIndex))->value(); | 2398 return Smi::cast(FixedArray::cast(this)->get(kLastUsedIndexIndex))->value(); |
| 2396 } | 2399 } |
| 2397 | 2400 |
| 2398 | 2401 |
| 2399 void WeakFixedArray::set_last_used_index(int index) { | 2402 void WeakFixedArray::set_last_used_index(int index) { |
| 2400 FixedArray::cast(this)->set(kLastUsedIndexIndex, Smi::FromInt(index)); | 2403 FixedArray::cast(this)->set(kLastUsedIndexIndex, Smi::FromInt(index)); |
| 2401 } | 2404 } |
| 2402 | 2405 |
| 2403 | 2406 |
|
Hannes Payer (out of office)
2015/03/05 21:12:28
Should we DCHECK for wrong input values? Negative
ulan
2015/03/06 10:16:34
Fixed array getters and setters check the index.
| |
| 2407 int ArrayList::Length() { | |
| 2408 if (FixedArray::cast(this)->length() == 0) return 0; | |
| 2409 return Smi::cast(FixedArray::cast(this)->get(kLengthIndex))->value(); | |
| 2410 } | |
| 2411 | |
| 2412 | |
| 2413 void ArrayList::SetLength(int length) { | |
| 2414 return FixedArray::cast(this)->set(kLengthIndex, Smi::FromInt(length)); | |
| 2415 } | |
| 2416 | |
| 2417 | |
| 2418 Object* ArrayList::Get(int index) { | |
| 2419 return FixedArray::cast(this)->get(kFirstIndex + index); | |
| 2420 } | |
| 2421 | |
| 2422 | |
| 2423 Object** ArrayList::Slot(int index) { | |
| 2424 return data_start() + kFirstIndex + index; | |
| 2425 } | |
| 2426 | |
| 2427 | |
| 2428 void ArrayList::Set(int index, Object* obj) { | |
| 2429 FixedArray::cast(this)->set(kFirstIndex + index, obj); | |
| 2430 } | |
| 2431 | |
| 2432 | |
| 2433 void ArrayList::Clear(int index, Object* undefined) { | |
| 2434 DCHECK(undefined->IsUndefined()); | |
| 2435 FixedArray::cast(this) | |
| 2436 ->set(kFirstIndex + index, undefined, SKIP_WRITE_BARRIER); | |
| 2437 } | |
| 2438 | |
| 2439 | |
| 2404 void ConstantPoolArray::NumberOfEntries::increment(Type type) { | 2440 void ConstantPoolArray::NumberOfEntries::increment(Type type) { |
| 2405 DCHECK(type < NUMBER_OF_TYPES); | 2441 DCHECK(type < NUMBER_OF_TYPES); |
| 2406 element_counts_[type]++; | 2442 element_counts_[type]++; |
| 2407 } | 2443 } |
| 2408 | 2444 |
| 2409 | 2445 |
| 2410 int ConstantPoolArray::NumberOfEntries::equals( | 2446 int ConstantPoolArray::NumberOfEntries::equals( |
| 2411 const ConstantPoolArray::NumberOfEntries& other) const { | 2447 const ConstantPoolArray::NumberOfEntries& other) const { |
| 2412 for (int i = 0; i < NUMBER_OF_TYPES; i++) { | 2448 for (int i = 0; i < NUMBER_OF_TYPES; i++) { |
| 2413 if (element_counts_[i] != other.element_counts_[i]) return false; | 2449 if (element_counts_[i] != other.element_counts_[i]) return false; |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3292 void SeededNumberDictionary::set_requires_slow_elements() { | 3328 void SeededNumberDictionary::set_requires_slow_elements() { |
| 3293 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); | 3329 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); |
| 3294 } | 3330 } |
| 3295 | 3331 |
| 3296 | 3332 |
| 3297 // ------------------------------------ | 3333 // ------------------------------------ |
| 3298 // Cast operations | 3334 // Cast operations |
| 3299 | 3335 |
| 3300 | 3336 |
| 3301 CAST_ACCESSOR(AccessorInfo) | 3337 CAST_ACCESSOR(AccessorInfo) |
| 3338 CAST_ACCESSOR(ArrayList) | |
| 3302 CAST_ACCESSOR(ByteArray) | 3339 CAST_ACCESSOR(ByteArray) |
| 3303 CAST_ACCESSOR(Cell) | 3340 CAST_ACCESSOR(Cell) |
| 3304 CAST_ACCESSOR(Code) | 3341 CAST_ACCESSOR(Code) |
| 3305 CAST_ACCESSOR(CodeCacheHashTable) | 3342 CAST_ACCESSOR(CodeCacheHashTable) |
| 3306 CAST_ACCESSOR(CompilationCacheTable) | 3343 CAST_ACCESSOR(CompilationCacheTable) |
| 3307 CAST_ACCESSOR(ConsString) | 3344 CAST_ACCESSOR(ConsString) |
| 3308 CAST_ACCESSOR(ConstantPoolArray) | 3345 CAST_ACCESSOR(ConstantPoolArray) |
| 3309 CAST_ACCESSOR(DeoptimizationInputData) | 3346 CAST_ACCESSOR(DeoptimizationInputData) |
| 3310 CAST_ACCESSOR(DeoptimizationOutputData) | 3347 CAST_ACCESSOR(DeoptimizationOutputData) |
| 3311 CAST_ACCESSOR(DependentCode) | 3348 CAST_ACCESSOR(DependentCode) |
| (...skipping 4318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7630 #undef READ_SHORT_FIELD | 7667 #undef READ_SHORT_FIELD |
| 7631 #undef WRITE_SHORT_FIELD | 7668 #undef WRITE_SHORT_FIELD |
| 7632 #undef READ_BYTE_FIELD | 7669 #undef READ_BYTE_FIELD |
| 7633 #undef WRITE_BYTE_FIELD | 7670 #undef WRITE_BYTE_FIELD |
| 7634 #undef NOBARRIER_READ_BYTE_FIELD | 7671 #undef NOBARRIER_READ_BYTE_FIELD |
| 7635 #undef NOBARRIER_WRITE_BYTE_FIELD | 7672 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7636 | 7673 |
| 7637 } } // namespace v8::internal | 7674 } } // namespace v8::internal |
| 7638 | 7675 |
| 7639 #endif // V8_OBJECTS_INL_H_ | 7676 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |