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 4106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4117 // it is no proxy, has no interceptors and needs no access checks). | 4117 // it is no proxy, has no interceptors and needs no access checks). |
4118 // - This object has no elements. | 4118 // - This object has no elements. |
4119 // - No prototype has enumerable properties/elements. | 4119 // - No prototype has enumerable properties/elements. |
4120 bool JSReceiver::IsSimpleEnum() { | 4120 bool JSReceiver::IsSimpleEnum() { |
4121 Heap* heap = GetHeap(); | 4121 Heap* heap = GetHeap(); |
4122 for (Object* o = this; | 4122 for (Object* o = this; |
4123 o != heap->null_value(); | 4123 o != heap->null_value(); |
4124 o = JSObject::cast(o)->GetPrototype()) { | 4124 o = JSObject::cast(o)->GetPrototype()) { |
4125 if (!o->IsJSObject()) return false; | 4125 if (!o->IsJSObject()) return false; |
4126 JSObject* curr = JSObject::cast(o); | 4126 JSObject* curr = JSObject::cast(o); |
4127 if (!curr->map()->instance_descriptors()->HasEnumCache()) return false; | 4127 int enum_length = curr->map()->EnumLength(); |
| 4128 if (enum_length == Map::kInvalidEnumCache) return false; |
4128 ASSERT(!curr->HasNamedInterceptor()); | 4129 ASSERT(!curr->HasNamedInterceptor()); |
4129 ASSERT(!curr->HasIndexedInterceptor()); | 4130 ASSERT(!curr->HasIndexedInterceptor()); |
4130 ASSERT(!curr->IsAccessCheckNeeded()); | 4131 ASSERT(!curr->IsAccessCheckNeeded()); |
4131 if (curr->NumberOfEnumElements() > 0) return false; | 4132 if (curr->NumberOfEnumElements() > 0) return false; |
4132 if (curr != this) { | 4133 if (curr != this && enum_length != 0) return false; |
4133 FixedArray* curr_fixed_array = | |
4134 FixedArray::cast(curr->map()->instance_descriptors()->GetEnumCache()); | |
4135 if (curr_fixed_array->length() > 0) return false; | |
4136 } | |
4137 } | 4134 } |
4138 return true; | 4135 return true; |
4139 } | 4136 } |
4140 | 4137 |
4141 | 4138 |
4142 int Map::NumberOfDescribedProperties(PropertyAttributes filter) { | 4139 int Map::NumberOfDescribedProperties(PropertyAttributes filter) { |
4143 int result = 0; | 4140 int result = 0; |
4144 DescriptorArray* descs = instance_descriptors(); | 4141 DescriptorArray* descs = instance_descriptors(); |
4145 for (int i = 0; i < descs->number_of_descriptors(); i++) { | 4142 for (int i = 0; i < descs->number_of_descriptors(); i++) { |
4146 PropertyDetails details = descs->GetDetails(i); | 4143 PropertyDetails details = descs->GetDetails(i); |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4809 MaybeObject* maybe_result = | 4806 MaybeObject* maybe_result = |
4810 GetHeap()->AllocateMap(instance_type(), instance_size); | 4807 GetHeap()->AllocateMap(instance_type(), instance_size); |
4811 if (!maybe_result->To(&result)) return maybe_result; | 4808 if (!maybe_result->To(&result)) return maybe_result; |
4812 | 4809 |
4813 result->set_prototype(prototype()); | 4810 result->set_prototype(prototype()); |
4814 result->set_constructor(constructor()); | 4811 result->set_constructor(constructor()); |
4815 result->set_bit_field(bit_field()); | 4812 result->set_bit_field(bit_field()); |
4816 result->set_bit_field2(bit_field2()); | 4813 result->set_bit_field2(bit_field2()); |
4817 result->set_bit_field3(bit_field3()); | 4814 result->set_bit_field3(bit_field3()); |
4818 result->SetLastAdded(kNoneAdded); | 4815 result->SetLastAdded(kNoneAdded); |
| 4816 result->SetEnumLength(kInvalidEnumCache); |
4819 return result; | 4817 return result; |
4820 } | 4818 } |
4821 | 4819 |
4822 | 4820 |
4823 MaybeObject* Map::CopyNormalized(PropertyNormalizationMode mode, | 4821 MaybeObject* Map::CopyNormalized(PropertyNormalizationMode mode, |
4824 NormalizedMapSharingMode sharing) { | 4822 NormalizedMapSharingMode sharing) { |
4825 int new_instance_size = instance_size(); | 4823 int new_instance_size = instance_size(); |
4826 if (mode == CLEAR_INOBJECT_PROPERTIES) { | 4824 if (mode == CLEAR_INOBJECT_PROPERTIES) { |
4827 new_instance_size -= inobject_properties() * kPointerSize; | 4825 new_instance_size -= inobject_properties() * kPointerSize; |
4828 } | 4826 } |
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5757 #endif | 5755 #endif |
5758 return result; | 5756 return result; |
5759 } | 5757 } |
5760 | 5758 |
5761 | 5759 |
5762 MaybeObject* FixedArray::UnionOfKeys(FixedArray* other) { | 5760 MaybeObject* FixedArray::UnionOfKeys(FixedArray* other) { |
5763 ElementsAccessor* accessor = ElementsAccessor::ForArray(other); | 5761 ElementsAccessor* accessor = ElementsAccessor::ForArray(other); |
5764 MaybeObject* maybe_result = | 5762 MaybeObject* maybe_result = |
5765 accessor->AddElementsToFixedArray(NULL, NULL, this, other); | 5763 accessor->AddElementsToFixedArray(NULL, NULL, this, other); |
5766 FixedArray* result; | 5764 FixedArray* result; |
5767 if (!maybe_result->To<FixedArray>(&result)) return maybe_result; | 5765 if (!maybe_result->To(&result)) return maybe_result; |
5768 #ifdef DEBUG | 5766 #ifdef DEBUG |
5769 if (FLAG_enable_slow_asserts) { | 5767 if (FLAG_enable_slow_asserts) { |
5770 for (int i = 0; i < result->length(); i++) { | 5768 for (int i = 0; i < result->length(); i++) { |
5771 Object* current = result->get(i); | 5769 Object* current = result->get(i); |
5772 ASSERT(current->IsNumber() || current->IsString()); | 5770 ASSERT(current->IsNumber() || current->IsString()); |
5773 } | 5771 } |
5774 } | 5772 } |
5775 #endif | 5773 #endif |
5776 return result; | 5774 return result; |
5777 } | 5775 } |
(...skipping 7318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13096 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13094 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13097 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13095 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13098 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13096 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13099 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13097 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13100 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13098 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13101 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13099 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13102 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13100 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13103 } | 13101 } |
13104 | 13102 |
13105 } } // namespace v8::internal | 13103 } } // namespace v8::internal |
OLD | NEW |