Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/objects-inl.h

Issue 2633553002: [runtime] Cleanup DescriptorArray interface, remove more PropertyType usages. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.cc ('k') | src/property-descriptor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3100 matching lines...) Expand 10 before | Expand all | Expand 10 after
3111 } 3111 }
3112 3112
3113 3113
3114 PropertyDetails DescriptorArray::GetDetails(int descriptor_number) { 3114 PropertyDetails DescriptorArray::GetDetails(int descriptor_number) {
3115 DCHECK(descriptor_number < number_of_descriptors()); 3115 DCHECK(descriptor_number < number_of_descriptors());
3116 Object* details = get(ToDetailsIndex(descriptor_number)); 3116 Object* details = get(ToDetailsIndex(descriptor_number));
3117 return PropertyDetails(Smi::cast(details)); 3117 return PropertyDetails(Smi::cast(details));
3118 } 3118 }
3119 3119
3120 3120
3121 PropertyType DescriptorArray::GetType(int descriptor_number) {
3122 return GetDetails(descriptor_number).type();
3123 }
3124
3125
3126 int DescriptorArray::GetFieldIndex(int descriptor_number) { 3121 int DescriptorArray::GetFieldIndex(int descriptor_number) {
3127 DCHECK(GetDetails(descriptor_number).location() == kField); 3122 DCHECK(GetDetails(descriptor_number).location() == kField);
3128 return GetDetails(descriptor_number).field_index(); 3123 return GetDetails(descriptor_number).field_index();
3129 } 3124 }
3130 3125
3131 FieldType* DescriptorArray::GetFieldType(int descriptor_number) { 3126 FieldType* DescriptorArray::GetFieldType(int descriptor_number) {
3132 DCHECK(GetDetails(descriptor_number).location() == kField); 3127 DCHECK(GetDetails(descriptor_number).location() == kField);
3133 Object* wrapped_type = GetValue(descriptor_number); 3128 Object* wrapped_type = GetValue(descriptor_number);
3134 return Map::UnwrapFieldType(wrapped_type); 3129 return Map::UnwrapFieldType(wrapped_type);
3135 } 3130 }
3136 3131
3137 Object* DescriptorArray::GetConstant(int descriptor_number) {
3138 return GetValue(descriptor_number);
3139 }
3140
3141
3142 Object* DescriptorArray::GetCallbacksObject(int descriptor_number) {
3143 DCHECK(GetType(descriptor_number) == ACCESSOR_CONSTANT);
3144 return GetValue(descriptor_number);
3145 }
3146
3147
3148 AccessorDescriptor* DescriptorArray::GetCallbacks(int descriptor_number) {
3149 DCHECK(GetType(descriptor_number) == ACCESSOR_CONSTANT);
3150 Foreign* p = Foreign::cast(GetCallbacksObject(descriptor_number));
3151 return reinterpret_cast<AccessorDescriptor*>(p->foreign_address());
3152 }
3153
3154
3155 void DescriptorArray::Get(int descriptor_number, Descriptor* desc) { 3132 void DescriptorArray::Get(int descriptor_number, Descriptor* desc) {
3156 desc->Init(handle(GetKey(descriptor_number), GetIsolate()), 3133 desc->Init(handle(GetKey(descriptor_number), GetIsolate()),
3157 handle(GetValue(descriptor_number), GetIsolate()), 3134 handle(GetValue(descriptor_number), GetIsolate()),
3158 GetDetails(descriptor_number)); 3135 GetDetails(descriptor_number));
3159 } 3136 }
3160 3137
3161 3138 void DescriptorArray::Set(int descriptor_number, Name* key, Object* value,
3162 void DescriptorArray::SetDescriptor(int descriptor_number, Descriptor* desc) { 3139 PropertyDetails details) {
3163 // Range check. 3140 // Range check.
3164 DCHECK(descriptor_number < number_of_descriptors()); 3141 DCHECK(descriptor_number < number_of_descriptors());
3165 set(ToKeyIndex(descriptor_number), *desc->GetKey()); 3142 set(ToKeyIndex(descriptor_number), key);
3166 set(ToValueIndex(descriptor_number), *desc->GetValue()); 3143 set(ToValueIndex(descriptor_number), value);
3167 set(ToDetailsIndex(descriptor_number), desc->GetDetails().AsSmi()); 3144 set(ToDetailsIndex(descriptor_number), details.AsSmi());
3145 }
3146
3147 void DescriptorArray::Set(int descriptor_number, Descriptor* desc) {
3148 Name* key = *desc->GetKey();
3149 Object* value = *desc->GetValue();
3150 Set(descriptor_number, key, value, desc->GetDetails());
3168 } 3151 }
3169 3152
3170 3153
3171 void DescriptorArray::Set(int descriptor_number, Descriptor* desc) {
3172 // Range check.
3173 DCHECK(descriptor_number < number_of_descriptors());
3174
3175 set(ToKeyIndex(descriptor_number), *desc->GetKey());
3176 set(ToValueIndex(descriptor_number), *desc->GetValue());
3177 set(ToDetailsIndex(descriptor_number), desc->GetDetails().AsSmi());
3178 }
3179
3180
3181 void DescriptorArray::Append(Descriptor* desc) { 3154 void DescriptorArray::Append(Descriptor* desc) {
3182 DisallowHeapAllocation no_gc; 3155 DisallowHeapAllocation no_gc;
3183 int descriptor_number = number_of_descriptors(); 3156 int descriptor_number = number_of_descriptors();
3184 SetNumberOfDescriptors(descriptor_number + 1); 3157 SetNumberOfDescriptors(descriptor_number + 1);
3185 Set(descriptor_number, desc); 3158 Set(descriptor_number, desc);
3186 3159
3187 uint32_t hash = desc->GetKey()->Hash(); 3160 uint32_t hash = desc->GetKey()->Hash();
3188 3161
3189 int insertion; 3162 int insertion;
3190 3163
(...skipping 5247 matching lines...) Expand 10 before | Expand all | Expand 10 after
8438 #undef WRITE_INT64_FIELD 8411 #undef WRITE_INT64_FIELD
8439 #undef READ_BYTE_FIELD 8412 #undef READ_BYTE_FIELD
8440 #undef WRITE_BYTE_FIELD 8413 #undef WRITE_BYTE_FIELD
8441 #undef NOBARRIER_READ_BYTE_FIELD 8414 #undef NOBARRIER_READ_BYTE_FIELD
8442 #undef NOBARRIER_WRITE_BYTE_FIELD 8415 #undef NOBARRIER_WRITE_BYTE_FIELD
8443 8416
8444 } // namespace internal 8417 } // namespace internal
8445 } // namespace v8 8418 } // namespace v8
8446 8419
8447 #endif // V8_OBJECTS_INL_H_ 8420 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/property-descriptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698