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 5098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5109 ASSERT(IsIterating()); | 5109 ASSERT(IsIterating()); |
5110 // Attention, tricky index manipulation ahead: Two consecutive indices are | 5110 // Attention, tricky index manipulation ahead: Two consecutive indices are |
5111 // assigned to each descriptor. Most descriptors directly advance to the | 5111 // assigned to each descriptor. Most descriptors directly advance to the |
5112 // next descriptor by adding 2 to the index. The exceptions are the | 5112 // next descriptor by adding 2 to the index. The exceptions are the |
5113 // CALLBACKS entries: An even index means we look at its getter, and an odd | 5113 // CALLBACKS entries: An even index means we look at its getter, and an odd |
5114 // index means we look at its setter. | 5114 // index means we look at its setter. |
5115 int raw_index = Smi::cast(*DescriptorArrayHeader())->value(); | 5115 int raw_index = Smi::cast(*DescriptorArrayHeader())->value(); |
5116 int index = raw_index / 2; | 5116 int index = raw_index / 2; |
5117 int number_of_descriptors = descriptor_array_->number_of_descriptors(); | 5117 int number_of_descriptors = descriptor_array_->number_of_descriptors(); |
5118 while (index < number_of_descriptors) { | 5118 while (index < number_of_descriptors) { |
5119 PropertyDetails details(RawGetDetails(index)); | 5119 PropertyDetails details(descriptor_array_->GetDetails(index)); |
5120 switch (details.type()) { | 5120 switch (details.type()) { |
5121 case MAP_TRANSITION: | 5121 case MAP_TRANSITION: |
5122 case CONSTANT_TRANSITION: | 5122 case CONSTANT_TRANSITION: |
5123 case ELEMENTS_TRANSITION: | 5123 case ELEMENTS_TRANSITION: |
5124 // We definitely have a map transition. | 5124 // We definitely have a map transition. |
5125 *DescriptorArrayHeader() = Smi::FromInt(raw_index + 2); | 5125 *DescriptorArrayHeader() = Smi::FromInt(raw_index + 2); |
5126 return static_cast<Map*>(RawGetValue(index)); | 5126 return static_cast<Map*>(descriptor_array_->GetValue(index)); |
5127 case CALLBACKS: { | 5127 case CALLBACKS: { |
5128 // We might have a map transition in a getter or in a setter. | 5128 // We might have a map transition in a getter or in a setter. |
5129 AccessorPair* accessors = | 5129 AccessorPair* accessors = |
5130 static_cast<AccessorPair*>(RawGetValue(index)); | 5130 static_cast<AccessorPair*>(descriptor_array_->GetValue(index)); |
5131 Object* accessor; | 5131 Object* accessor; |
5132 if ((raw_index & 1) == 0) { | 5132 if ((raw_index & 1) == 0) { |
5133 accessor = accessors->setter(); | 5133 accessor = accessors->setter(); |
5134 } else { | 5134 } else { |
5135 ++index; | 5135 ++index; |
5136 accessor = accessors->getter(); | 5136 accessor = accessors->getter(); |
5137 } | 5137 } |
5138 ++raw_index; | 5138 ++raw_index; |
5139 if (accessor->IsMap()) { | 5139 if (accessor->IsMap()) { |
5140 *DescriptorArrayHeader() = Smi::FromInt(raw_index); | 5140 *DescriptorArrayHeader() = Smi::FromInt(raw_index); |
(...skipping 19 matching lines...) Expand all Loading... |
5160 | 5160 |
5161 private: | 5161 private: |
5162 bool HasDescriptors() { | 5162 bool HasDescriptors() { |
5163 return descriptor_array_->length() > DescriptorArray::kFirstIndex; | 5163 return descriptor_array_->length() > DescriptorArray::kFirstIndex; |
5164 } | 5164 } |
5165 | 5165 |
5166 Object** DescriptorArrayHeader() { | 5166 Object** DescriptorArrayHeader() { |
5167 return HeapObject::RawField(descriptor_array_, DescriptorArray::kMapOffset); | 5167 return HeapObject::RawField(descriptor_array_, DescriptorArray::kMapOffset); |
5168 } | 5168 } |
5169 | 5169 |
5170 FixedArray* RawGetContentArray() { | |
5171 Object* array = | |
5172 descriptor_array_->get(DescriptorArray::kContentArrayIndex); | |
5173 return static_cast<FixedArray*>(array); | |
5174 } | |
5175 | |
5176 Object* RawGetValue(int descriptor_number) { | |
5177 return RawGetContentArray()->get( | |
5178 DescriptorArray::ToValueIndex(descriptor_number)); | |
5179 } | |
5180 | |
5181 PropertyDetails RawGetDetails(int descriptor_number) { | |
5182 Object* details = RawGetContentArray()->get( | |
5183 DescriptorArray::ToDetailsIndex(descriptor_number)); | |
5184 return PropertyDetails(Smi::cast(details)); | |
5185 } | |
5186 | |
5187 | |
5188 DescriptorArray* descriptor_array_; | 5170 DescriptorArray* descriptor_array_; |
5189 }; | 5171 }; |
5190 | 5172 |
5191 | 5173 |
5192 // An iterator over all prototype transitions, reusing the map field of the | 5174 // An iterator over all prototype transitions, reusing the map field of the |
5193 // underlying array while it is running. | 5175 // underlying array while it is running. |
5194 class IntrusivePrototypeTransitionIterator { | 5176 class IntrusivePrototypeTransitionIterator { |
5195 public: | 5177 public: |
5196 explicit IntrusivePrototypeTransitionIterator(HeapObject* proto_trans) | 5178 explicit IntrusivePrototypeTransitionIterator(HeapObject* proto_trans) |
5197 : proto_trans_(proto_trans) { } | 5179 : proto_trans_(proto_trans) { } |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5876 } | 5858 } |
5877 // Allocate the array of keys. | 5859 // Allocate the array of keys. |
5878 Object* array; | 5860 Object* array; |
5879 { MaybeObject* maybe_array = | 5861 { MaybeObject* maybe_array = |
5880 heap->AllocateFixedArray(ToKeyIndex(number_of_descriptors)); | 5862 heap->AllocateFixedArray(ToKeyIndex(number_of_descriptors)); |
5881 if (!maybe_array->ToObject(&array)) return maybe_array; | 5863 if (!maybe_array->ToObject(&array)) return maybe_array; |
5882 } | 5864 } |
5883 // Do not use DescriptorArray::cast on incomplete object. | 5865 // Do not use DescriptorArray::cast on incomplete object. |
5884 FixedArray* result = FixedArray::cast(array); | 5866 FixedArray* result = FixedArray::cast(array); |
5885 | 5867 |
5886 // Allocate the content array and set it in the descriptor array. | |
5887 { MaybeObject* maybe_array = | |
5888 heap->AllocateFixedArray(number_of_descriptors << 1); | |
5889 if (!maybe_array->ToObject(&array)) return maybe_array; | |
5890 } | |
5891 result->set(kBitField3StorageIndex, Smi::FromInt(0)); | 5868 result->set(kBitField3StorageIndex, Smi::FromInt(0)); |
5892 result->set(kContentArrayIndex, array); | |
5893 result->set(kEnumerationIndexIndex, | 5869 result->set(kEnumerationIndexIndex, |
5894 Smi::FromInt(PropertyDetails::kInitialIndex)); | 5870 Smi::FromInt(PropertyDetails::kInitialIndex)); |
5895 return result; | 5871 return result; |
5896 } | 5872 } |
5897 | 5873 |
5898 | 5874 |
5899 void DescriptorArray::SetEnumCache(FixedArray* bridge_storage, | 5875 void DescriptorArray::SetEnumCache(FixedArray* bridge_storage, |
5900 FixedArray* new_cache, | 5876 FixedArray* new_cache, |
5901 Object* new_index_cache) { | 5877 Object* new_index_cache) { |
5902 ASSERT(bridge_storage->length() >= kEnumCacheBridgeLength); | 5878 ASSERT(bridge_storage->length() >= kEnumCacheBridgeLength); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6209 pretenure); | 6185 pretenure); |
6210 } | 6186 } |
6211 | 6187 |
6212 | 6188 |
6213 #ifdef DEBUG | 6189 #ifdef DEBUG |
6214 bool DescriptorArray::IsEqualTo(DescriptorArray* other) { | 6190 bool DescriptorArray::IsEqualTo(DescriptorArray* other) { |
6215 if (IsEmpty()) return other->IsEmpty(); | 6191 if (IsEmpty()) return other->IsEmpty(); |
6216 if (other->IsEmpty()) return false; | 6192 if (other->IsEmpty()) return false; |
6217 if (length() != other->length()) return false; | 6193 if (length() != other->length()) return false; |
6218 for (int i = 0; i < length(); ++i) { | 6194 for (int i = 0; i < length(); ++i) { |
6219 if (get(i) != other->get(i) && i != kContentArrayIndex) return false; | 6195 if (get(i) != other->get(i)) return false; |
6220 } | 6196 } |
6221 return GetContentArray()->IsEqualTo(other->GetContentArray()); | 6197 return true; |
6222 } | 6198 } |
6223 #endif | 6199 #endif |
6224 | 6200 |
6225 | 6201 |
6226 bool String::LooksValid() { | 6202 bool String::LooksValid() { |
6227 if (!Isolate::Current()->heap()->Contains(this)) return false; | 6203 if (!Isolate::Current()->heap()->Contains(this)) return false; |
6228 return true; | 6204 return true; |
6229 } | 6205 } |
6230 | 6206 |
6231 | 6207 |
(...skipping 7009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13241 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13217 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13242 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13218 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13243 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13219 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13244 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13220 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13245 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13221 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13246 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13222 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13247 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13223 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13248 } | 13224 } |
13249 | 13225 |
13250 } } // namespace v8::internal | 13226 } } // namespace v8::internal |
OLD | NEW |