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 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 | 984 |
985 | 985 |
986 ElementsKind Object::OptimalElementsKind() { | 986 ElementsKind Object::OptimalElementsKind() { |
987 if (IsSmi()) return FAST_SMI_ELEMENTS; | 987 if (IsSmi()) return FAST_SMI_ELEMENTS; |
988 if (IsNumber()) return FAST_DOUBLE_ELEMENTS; | 988 if (IsNumber()) return FAST_DOUBLE_ELEMENTS; |
989 return FAST_ELEMENTS; | 989 return FAST_ELEMENTS; |
990 } | 990 } |
991 | 991 |
992 | 992 |
993 bool Object::FitsRepresentation(Representation representation) { | 993 bool Object::FitsRepresentation(Representation representation) { |
994 if (FLAG_track_fields && representation.IsNone()) { | 994 if (FLAG_track_fields && representation.IsSmi()) { |
995 return false; | |
996 } else if (FLAG_track_fields && representation.IsSmi()) { | |
997 return IsSmi(); | 995 return IsSmi(); |
998 } else if (FLAG_track_double_fields && representation.IsDouble()) { | 996 } else if (FLAG_track_double_fields && representation.IsDouble()) { |
999 return IsMutableHeapNumber() || IsNumber(); | 997 return IsMutableHeapNumber() || IsNumber(); |
1000 } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { | 998 } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { |
1001 return IsHeapObject(); | 999 return IsHeapObject(); |
| 1000 } else if (FLAG_track_fields && representation.IsNone()) { |
| 1001 return false; |
1002 } | 1002 } |
1003 return true; | 1003 return true; |
1004 } | 1004 } |
1005 | 1005 |
1006 | 1006 |
1007 // static | 1007 // static |
1008 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate, | 1008 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate, |
1009 Handle<Object> object) { | 1009 Handle<Object> object) { |
1010 if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object); | 1010 if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object); |
1011 return ToObject(isolate, object, isolate->native_context()); | 1011 return ToObject(isolate, object, isolate->native_context()); |
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2081 | 2081 |
2082 void JSObject::FastPropertyAtPut(FieldIndex index, Object* value) { | 2082 void JSObject::FastPropertyAtPut(FieldIndex index, Object* value) { |
2083 if (IsUnboxedDoubleField(index)) { | 2083 if (IsUnboxedDoubleField(index)) { |
2084 DCHECK(value->IsMutableHeapNumber()); | 2084 DCHECK(value->IsMutableHeapNumber()); |
2085 RawFastDoublePropertyAtPut(index, HeapNumber::cast(value)->value()); | 2085 RawFastDoublePropertyAtPut(index, HeapNumber::cast(value)->value()); |
2086 } else { | 2086 } else { |
2087 RawFastPropertyAtPut(index, value); | 2087 RawFastPropertyAtPut(index, value); |
2088 } | 2088 } |
2089 } | 2089 } |
2090 | 2090 |
2091 | 2091 void JSObject::WriteToField(int descriptor, PropertyDetails details, |
2092 void JSObject::WriteToField(int descriptor, Object* value) { | 2092 Object* value) { |
| 2093 DCHECK(details.type() == DATA); |
2093 DisallowHeapAllocation no_gc; | 2094 DisallowHeapAllocation no_gc; |
2094 | |
2095 DescriptorArray* desc = map()->instance_descriptors(); | |
2096 PropertyDetails details = desc->GetDetails(descriptor); | |
2097 | |
2098 DCHECK(details.type() == DATA); | |
2099 | |
2100 FieldIndex index = FieldIndex::ForDescriptor(map(), descriptor); | 2095 FieldIndex index = FieldIndex::ForDescriptor(map(), descriptor); |
2101 if (details.representation().IsDouble()) { | 2096 if (details.representation().IsDouble()) { |
2102 // Nothing more to be done. | 2097 // Nothing more to be done. |
2103 if (value->IsUninitialized()) return; | 2098 if (value->IsUninitialized()) return; |
2104 if (IsUnboxedDoubleField(index)) { | 2099 if (IsUnboxedDoubleField(index)) { |
2105 RawFastDoublePropertyAtPut(index, value->Number()); | 2100 RawFastDoublePropertyAtPut(index, value->Number()); |
2106 } else { | 2101 } else { |
2107 HeapNumber* box = HeapNumber::cast(RawFastPropertyAt(index)); | 2102 HeapNumber* box = HeapNumber::cast(RawFastPropertyAt(index)); |
2108 DCHECK(box->IsMutableHeapNumber()); | 2103 DCHECK(box->IsMutableHeapNumber()); |
2109 box->set_value(value->Number()); | 2104 box->set_value(value->Number()); |
2110 } | 2105 } |
2111 } else { | 2106 } else { |
2112 RawFastPropertyAtPut(index, value); | 2107 RawFastPropertyAtPut(index, value); |
2113 } | 2108 } |
2114 } | 2109 } |
2115 | 2110 |
| 2111 void JSObject::WriteToField(int descriptor, Object* value) { |
| 2112 DescriptorArray* desc = map()->instance_descriptors(); |
| 2113 PropertyDetails details = desc->GetDetails(descriptor); |
| 2114 WriteToField(descriptor, details, value); |
| 2115 } |
2116 | 2116 |
2117 int JSObject::GetInObjectPropertyOffset(int index) { | 2117 int JSObject::GetInObjectPropertyOffset(int index) { |
2118 return map()->GetInObjectPropertyOffset(index); | 2118 return map()->GetInObjectPropertyOffset(index); |
2119 } | 2119 } |
2120 | 2120 |
2121 | 2121 |
2122 Object* JSObject::InObjectPropertyAt(int index) { | 2122 Object* JSObject::InObjectPropertyAt(int index) { |
2123 int offset = GetInObjectPropertyOffset(index); | 2123 int offset = GetInObjectPropertyOffset(index); |
2124 return READ_FIELD(this, offset); | 2124 return READ_FIELD(this, offset); |
2125 } | 2125 } |
(...skipping 5547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7673 #undef WRITE_INT64_FIELD | 7673 #undef WRITE_INT64_FIELD |
7674 #undef READ_BYTE_FIELD | 7674 #undef READ_BYTE_FIELD |
7675 #undef WRITE_BYTE_FIELD | 7675 #undef WRITE_BYTE_FIELD |
7676 #undef NOBARRIER_READ_BYTE_FIELD | 7676 #undef NOBARRIER_READ_BYTE_FIELD |
7677 #undef NOBARRIER_WRITE_BYTE_FIELD | 7677 #undef NOBARRIER_WRITE_BYTE_FIELD |
7678 | 7678 |
7679 } // namespace internal | 7679 } // namespace internal |
7680 } // namespace v8 | 7680 } // namespace v8 |
7681 | 7681 |
7682 #endif // V8_OBJECTS_INL_H_ | 7682 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |