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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 } | 51 } |
52 | 52 |
53 | 53 |
54 PropertyDetails PropertyDetails::AsDeleted() const { | 54 PropertyDetails PropertyDetails::AsDeleted() const { |
55 Smi* smi = Smi::FromInt(value_ | DeletedField::encode(1)); | 55 Smi* smi = Smi::FromInt(value_ | DeletedField::encode(1)); |
56 return PropertyDetails(smi); | 56 return PropertyDetails(smi); |
57 } | 57 } |
58 | 58 |
59 | 59 |
60 int PropertyDetails::field_width_in_words() const { | 60 int PropertyDetails::field_width_in_words() const { |
61 DCHECK(type() == FIELD); | 61 DCHECK(type() == DATA); |
62 if (!FLAG_unbox_double_fields) return 1; | 62 if (!FLAG_unbox_double_fields) return 1; |
63 if (kDoubleSize == kPointerSize) return 1; | 63 if (kDoubleSize == kPointerSize) return 1; |
64 return representation().IsDouble() ? kDoubleSize / kPointerSize : 1; | 64 return representation().IsDouble() ? kDoubleSize / kPointerSize : 1; |
65 } | 65 } |
66 | 66 |
67 | 67 |
68 #define TYPE_CHECKER(type, instancetype) \ | 68 #define TYPE_CHECKER(type, instancetype) \ |
69 bool Object::Is##type() const { \ | 69 bool Object::Is##type() const { \ |
70 return Object::IsHeapObject() && \ | 70 return Object::IsHeapObject() && \ |
71 HeapObject::cast(this)->map()->instance_type() == instancetype; \ | 71 HeapObject::cast(this)->map()->instance_type() == instancetype; \ |
(...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1872 | 1872 |
1873 | 1873 |
1874 Handle<String> Map::ExpectedTransitionKey(Handle<Map> map) { | 1874 Handle<String> Map::ExpectedTransitionKey(Handle<Map> map) { |
1875 DisallowHeapAllocation no_gc; | 1875 DisallowHeapAllocation no_gc; |
1876 if (!map->HasTransitionArray()) return Handle<String>::null(); | 1876 if (!map->HasTransitionArray()) return Handle<String>::null(); |
1877 TransitionArray* transitions = map->transitions(); | 1877 TransitionArray* transitions = map->transitions(); |
1878 if (!transitions->IsSimpleTransition()) return Handle<String>::null(); | 1878 if (!transitions->IsSimpleTransition()) return Handle<String>::null(); |
1879 int transition = TransitionArray::kSimpleTransitionIndex; | 1879 int transition = TransitionArray::kSimpleTransitionIndex; |
1880 PropertyDetails details = transitions->GetTargetDetails(transition); | 1880 PropertyDetails details = transitions->GetTargetDetails(transition); |
1881 Name* name = transitions->GetKey(transition); | 1881 Name* name = transitions->GetKey(transition); |
1882 if (details.type() != FIELD) return Handle<String>::null(); | 1882 if (details.type() != DATA) return Handle<String>::null(); |
1883 if (details.attributes() != NONE) return Handle<String>::null(); | 1883 if (details.attributes() != NONE) return Handle<String>::null(); |
1884 if (!name->IsString()) return Handle<String>::null(); | 1884 if (!name->IsString()) return Handle<String>::null(); |
1885 return Handle<String>(String::cast(name)); | 1885 return Handle<String>(String::cast(name)); |
1886 } | 1886 } |
1887 | 1887 |
1888 | 1888 |
1889 Handle<Map> Map::ExpectedTransitionTarget(Handle<Map> map) { | 1889 Handle<Map> Map::ExpectedTransitionTarget(Handle<Map> map) { |
1890 DCHECK(!ExpectedTransitionKey(map).is_null()); | 1890 DCHECK(!ExpectedTransitionKey(map).is_null()); |
1891 return Handle<Map>(map->transitions()->GetTarget( | 1891 return Handle<Map>(map->transitions()->GetTarget( |
1892 TransitionArray::kSimpleTransitionIndex)); | 1892 TransitionArray::kSimpleTransitionIndex)); |
1893 } | 1893 } |
1894 | 1894 |
1895 | 1895 |
1896 Handle<Map> Map::FindTransitionToField(Handle<Map> map, Handle<Name> key) { | 1896 Handle<Map> Map::FindTransitionToField(Handle<Map> map, Handle<Name> key) { |
1897 DisallowHeapAllocation no_allocation; | 1897 DisallowHeapAllocation no_allocation; |
1898 if (!map->HasTransitionArray()) return Handle<Map>::null(); | 1898 if (!map->HasTransitionArray()) return Handle<Map>::null(); |
1899 TransitionArray* transitions = map->transitions(); | 1899 TransitionArray* transitions = map->transitions(); |
1900 int transition = transitions->Search(DATA, *key, NONE); | 1900 int transition = transitions->Search(kData, *key, NONE); |
1901 if (transition == TransitionArray::kNotFound) return Handle<Map>::null(); | 1901 if (transition == TransitionArray::kNotFound) return Handle<Map>::null(); |
1902 PropertyDetails details = transitions->GetTargetDetails(transition); | 1902 PropertyDetails details = transitions->GetTargetDetails(transition); |
1903 if (details.type() != FIELD) return Handle<Map>::null(); | 1903 if (details.type() != DATA) return Handle<Map>::null(); |
1904 DCHECK_EQ(NONE, details.attributes()); | 1904 DCHECK_EQ(NONE, details.attributes()); |
1905 return Handle<Map>(transitions->GetTarget(transition)); | 1905 return Handle<Map>(transitions->GetTarget(transition)); |
1906 } | 1906 } |
1907 | 1907 |
1908 | 1908 |
1909 ACCESSORS(Oddball, to_string, String, kToStringOffset) | 1909 ACCESSORS(Oddball, to_string, String, kToStringOffset) |
1910 ACCESSORS(Oddball, to_number, Object, kToNumberOffset) | 1910 ACCESSORS(Oddball, to_number, Object, kToNumberOffset) |
1911 | 1911 |
1912 | 1912 |
1913 byte Oddball::kind() const { | 1913 byte Oddball::kind() const { |
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3031 DescriptorArray* descriptors = this->instance_descriptors(); | 3031 DescriptorArray* descriptors = this->instance_descriptors(); |
3032 int number = descriptors->SearchWithCache(name, this); | 3032 int number = descriptors->SearchWithCache(name, this); |
3033 if (number == DescriptorArray::kNotFound) return result->NotFound(); | 3033 if (number == DescriptorArray::kNotFound) return result->NotFound(); |
3034 result->DescriptorResult(holder, descriptors->GetDetails(number), number); | 3034 result->DescriptorResult(holder, descriptors->GetDetails(number), number); |
3035 } | 3035 } |
3036 | 3036 |
3037 | 3037 |
3038 void Map::LookupTransition(JSObject* holder, Name* name, | 3038 void Map::LookupTransition(JSObject* holder, Name* name, |
3039 PropertyAttributes attributes, | 3039 PropertyAttributes attributes, |
3040 LookupResult* result) { | 3040 LookupResult* result) { |
3041 int transition_index = this->SearchTransition(DATA, name, attributes); | 3041 int transition_index = this->SearchTransition(kData, name, attributes); |
3042 if (transition_index == TransitionArray::kNotFound) return result->NotFound(); | 3042 if (transition_index == TransitionArray::kNotFound) return result->NotFound(); |
3043 result->TransitionResult(holder, this->GetTransition(transition_index)); | 3043 result->TransitionResult(holder, this->GetTransition(transition_index)); |
3044 } | 3044 } |
3045 | 3045 |
3046 | 3046 |
3047 FixedArrayBase* Map::GetInitialElements() { | 3047 FixedArrayBase* Map::GetInitialElements() { |
3048 if (has_fast_smi_or_object_elements() || | 3048 if (has_fast_smi_or_object_elements() || |
3049 has_fast_double_elements()) { | 3049 has_fast_double_elements()) { |
3050 DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); | 3050 DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); |
3051 return GetHeap()->empty_fixed_array(); | 3051 return GetHeap()->empty_fixed_array(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3140 return PropertyDetails(Smi::cast(details)); | 3140 return PropertyDetails(Smi::cast(details)); |
3141 } | 3141 } |
3142 | 3142 |
3143 | 3143 |
3144 PropertyType DescriptorArray::GetType(int descriptor_number) { | 3144 PropertyType DescriptorArray::GetType(int descriptor_number) { |
3145 return GetDetails(descriptor_number).type(); | 3145 return GetDetails(descriptor_number).type(); |
3146 } | 3146 } |
3147 | 3147 |
3148 | 3148 |
3149 int DescriptorArray::GetFieldIndex(int descriptor_number) { | 3149 int DescriptorArray::GetFieldIndex(int descriptor_number) { |
3150 DCHECK(GetDetails(descriptor_number).type() == FIELD); | 3150 DCHECK(GetDetails(descriptor_number).type() == DATA); |
3151 return GetDetails(descriptor_number).field_index(); | 3151 return GetDetails(descriptor_number).field_index(); |
3152 } | 3152 } |
3153 | 3153 |
3154 | 3154 |
3155 HeapType* DescriptorArray::GetFieldType(int descriptor_number) { | 3155 HeapType* DescriptorArray::GetFieldType(int descriptor_number) { |
3156 DCHECK(GetDetails(descriptor_number).type() == FIELD); | 3156 DCHECK(GetDetails(descriptor_number).type() == DATA); |
3157 return HeapType::cast(GetValue(descriptor_number)); | 3157 return HeapType::cast(GetValue(descriptor_number)); |
3158 } | 3158 } |
3159 | 3159 |
3160 | 3160 |
3161 Object* DescriptorArray::GetConstant(int descriptor_number) { | 3161 Object* DescriptorArray::GetConstant(int descriptor_number) { |
3162 return GetValue(descriptor_number); | 3162 return GetValue(descriptor_number); |
3163 } | 3163 } |
3164 | 3164 |
3165 | 3165 |
3166 Object* DescriptorArray::GetCallbacksObject(int descriptor_number) { | 3166 Object* DescriptorArray::GetCallbacksObject(int descriptor_number) { |
3167 DCHECK(GetType(descriptor_number) == CALLBACKS); | 3167 DCHECK(GetType(descriptor_number) == ACCESSOR_CONSTANT); |
3168 return GetValue(descriptor_number); | 3168 return GetValue(descriptor_number); |
3169 } | 3169 } |
3170 | 3170 |
3171 | 3171 |
3172 AccessorDescriptor* DescriptorArray::GetCallbacks(int descriptor_number) { | 3172 AccessorDescriptor* DescriptorArray::GetCallbacks(int descriptor_number) { |
3173 DCHECK(GetType(descriptor_number) == CALLBACKS); | 3173 DCHECK(GetType(descriptor_number) == ACCESSOR_CONSTANT); |
3174 Foreign* p = Foreign::cast(GetCallbacksObject(descriptor_number)); | 3174 Foreign* p = Foreign::cast(GetCallbacksObject(descriptor_number)); |
3175 return reinterpret_cast<AccessorDescriptor*>(p->foreign_address()); | 3175 return reinterpret_cast<AccessorDescriptor*>(p->foreign_address()); |
3176 } | 3176 } |
3177 | 3177 |
3178 | 3178 |
3179 void DescriptorArray::Get(int descriptor_number, Descriptor* desc) { | 3179 void DescriptorArray::Get(int descriptor_number, Descriptor* desc) { |
3180 desc->Init(handle(GetKey(descriptor_number), GetIsolate()), | 3180 desc->Init(handle(GetKey(descriptor_number), GetIsolate()), |
3181 handle(GetValue(descriptor_number), GetIsolate()), | 3181 handle(GetValue(descriptor_number), GetIsolate()), |
3182 GetDetails(descriptor_number)); | 3182 GetDetails(descriptor_number)); |
3183 } | 3183 } |
(...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4686 | 4686 |
4687 | 4687 |
4688 bool Map::CanBeDeprecated() { | 4688 bool Map::CanBeDeprecated() { |
4689 int descriptor = LastAdded(); | 4689 int descriptor = LastAdded(); |
4690 for (int i = 0; i <= descriptor; i++) { | 4690 for (int i = 0; i <= descriptor; i++) { |
4691 PropertyDetails details = instance_descriptors()->GetDetails(i); | 4691 PropertyDetails details = instance_descriptors()->GetDetails(i); |
4692 if (details.representation().IsNone()) return true; | 4692 if (details.representation().IsNone()) return true; |
4693 if (details.representation().IsSmi()) return true; | 4693 if (details.representation().IsSmi()) return true; |
4694 if (details.representation().IsDouble()) return true; | 4694 if (details.representation().IsDouble()) return true; |
4695 if (details.representation().IsHeapObject()) return true; | 4695 if (details.representation().IsHeapObject()) return true; |
4696 if (details.type() == CONSTANT) return true; | 4696 if (details.type() == DATA_CONSTANT) return true; |
4697 } | 4697 } |
4698 return false; | 4698 return false; |
4699 } | 4699 } |
4700 | 4700 |
4701 | 4701 |
4702 void Map::NotifyLeafMapLayoutChange() { | 4702 void Map::NotifyLeafMapLayoutChange() { |
4703 if (is_stable()) { | 4703 if (is_stable()) { |
4704 mark_unstable(); | 4704 mark_unstable(); |
4705 dependent_code()->DeoptimizeDependentCodeGroup( | 4705 dependent_code()->DeoptimizeDependentCodeGroup( |
4706 GetIsolate(), | 4706 GetIsolate(), |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5306 DescriptorArray* descriptors = instance_descriptors(); | 5306 DescriptorArray* descriptors = instance_descriptors(); |
5307 int number_of_own_descriptors = NumberOfOwnDescriptors(); | 5307 int number_of_own_descriptors = NumberOfOwnDescriptors(); |
5308 DCHECK(descriptors->number_of_descriptors() == number_of_own_descriptors); | 5308 DCHECK(descriptors->number_of_descriptors() == number_of_own_descriptors); |
5309 descriptors->Append(desc); | 5309 descriptors->Append(desc); |
5310 SetNumberOfOwnDescriptors(number_of_own_descriptors + 1); | 5310 SetNumberOfOwnDescriptors(number_of_own_descriptors + 1); |
5311 | 5311 |
5312 // This function does not support appending double field descriptors and | 5312 // This function does not support appending double field descriptors and |
5313 // it should never try to (otherwise, layout descriptor must be updated too). | 5313 // it should never try to (otherwise, layout descriptor must be updated too). |
5314 #ifdef DEBUG | 5314 #ifdef DEBUG |
5315 PropertyDetails details = desc->GetDetails(); | 5315 PropertyDetails details = desc->GetDetails(); |
5316 CHECK(details.type() != FIELD || !details.representation().IsDouble()); | 5316 CHECK(details.type() != DATA || !details.representation().IsDouble()); |
5317 #endif | 5317 #endif |
5318 } | 5318 } |
5319 | 5319 |
5320 | 5320 |
5321 Object* Map::GetBackPointer() { | 5321 Object* Map::GetBackPointer() { |
5322 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); | 5322 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); |
5323 if (object->IsTransitionArray()) { | 5323 if (object->IsTransitionArray()) { |
5324 return TransitionArray::cast(object)->back_pointer_storage(); | 5324 return TransitionArray::cast(object)->back_pointer_storage(); |
5325 } else { | 5325 } else { |
5326 DCHECK(object->IsMap() || object->IsUndefined()); | 5326 DCHECK(object->IsMap() || object->IsUndefined()); |
(...skipping 2183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7510 #undef READ_SHORT_FIELD | 7510 #undef READ_SHORT_FIELD |
7511 #undef WRITE_SHORT_FIELD | 7511 #undef WRITE_SHORT_FIELD |
7512 #undef READ_BYTE_FIELD | 7512 #undef READ_BYTE_FIELD |
7513 #undef WRITE_BYTE_FIELD | 7513 #undef WRITE_BYTE_FIELD |
7514 #undef NOBARRIER_READ_BYTE_FIELD | 7514 #undef NOBARRIER_READ_BYTE_FIELD |
7515 #undef NOBARRIER_WRITE_BYTE_FIELD | 7515 #undef NOBARRIER_WRITE_BYTE_FIELD |
7516 | 7516 |
7517 } } // namespace v8::internal | 7517 } } // namespace v8::internal |
7518 | 7518 |
7519 #endif // V8_OBJECTS_INL_H_ | 7519 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |