| 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 #include "src/objects.h" | 5 #include "src/objects.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 9819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9830 | 9830 |
| 9831 | 9831 |
| 9832 void FixedArray::CopyTo(int pos, FixedArray* dest, int dest_pos, int len) { | 9832 void FixedArray::CopyTo(int pos, FixedArray* dest, int dest_pos, int len) { |
| 9833 DisallowHeapAllocation no_gc; | 9833 DisallowHeapAllocation no_gc; |
| 9834 WriteBarrierMode mode = dest->GetWriteBarrierMode(no_gc); | 9834 WriteBarrierMode mode = dest->GetWriteBarrierMode(no_gc); |
| 9835 for (int index = 0; index < len; index++) { | 9835 for (int index = 0; index < len; index++) { |
| 9836 dest->set(dest_pos+index, get(pos+index), mode); | 9836 dest->set(dest_pos+index, get(pos+index), mode); |
| 9837 } | 9837 } |
| 9838 } | 9838 } |
| 9839 | 9839 |
| 9840 Object* BoilerplateDescription::name(int index) const { | |
| 9841 // get() already checks for out of bounds access, but we do not want to allow | |
| 9842 // access to the last element, if it is the number of properties. | |
| 9843 DCHECK_NE(size(), index); | |
| 9844 return get(2 * index); | |
| 9845 } | |
| 9846 | |
| 9847 Object* BoilerplateDescription::value(int index) const { | |
| 9848 return get(2 * index + 1); | |
| 9849 } | |
| 9850 | |
| 9851 int BoilerplateDescription::size() const { | |
| 9852 DCHECK_EQ(0, (length() - (this->has_number_of_properties() ? 1 : 0)) % 2); | |
| 9853 // Rounding is intended. | |
| 9854 return length() / 2; | |
| 9855 } | |
| 9856 | |
| 9857 int BoilerplateDescription::backing_store_size() const { | |
| 9858 if (has_number_of_properties()) { | |
| 9859 // If present, the last entry contains the number of properties. | |
| 9860 return Smi::cast(this->get(length() - 1))->value(); | |
| 9861 } | |
| 9862 // If the number is not given explicitly, we assume there are no | |
| 9863 // properties with computed names. | |
| 9864 return size(); | |
| 9865 } | |
| 9866 | |
| 9867 void BoilerplateDescription::set_backing_store_size(Isolate* isolate, | |
| 9868 int backing_store_size) { | |
| 9869 DCHECK(has_number_of_properties()); | |
| 9870 DCHECK_NE(size(), backing_store_size); | |
| 9871 Handle<Object> backing_store_size_obj = | |
| 9872 isolate->factory()->NewNumberFromInt(backing_store_size); | |
| 9873 set(length() - 1, *backing_store_size_obj); | |
| 9874 } | |
| 9875 | |
| 9876 bool BoilerplateDescription::has_number_of_properties() const { | |
| 9877 return length() % 2 != 0; | |
| 9878 } | |
| 9879 | |
| 9880 #ifdef DEBUG | 9840 #ifdef DEBUG |
| 9881 bool FixedArray::IsEqualTo(FixedArray* other) { | 9841 bool FixedArray::IsEqualTo(FixedArray* other) { |
| 9882 if (length() != other->length()) return false; | 9842 if (length() != other->length()) return false; |
| 9883 for (int i = 0 ; i < length(); ++i) { | 9843 for (int i = 0 ; i < length(); ++i) { |
| 9884 if (get(i) != other->get(i)) return false; | 9844 if (get(i) != other->get(i)) return false; |
| 9885 } | 9845 } |
| 9886 return true; | 9846 return true; |
| 9887 } | 9847 } |
| 9888 #endif | 9848 #endif |
| 9889 | 9849 |
| (...skipping 10176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20066 // depend on this. | 20026 // depend on this. |
| 20067 return DICTIONARY_ELEMENTS; | 20027 return DICTIONARY_ELEMENTS; |
| 20068 } | 20028 } |
| 20069 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20029 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
| 20070 return kind; | 20030 return kind; |
| 20071 } | 20031 } |
| 20072 } | 20032 } |
| 20073 | 20033 |
| 20074 } // namespace internal | 20034 } // namespace internal |
| 20075 } // namespace v8 | 20035 } // namespace v8 |
| OLD | NEW |