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

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

Issue 1717603002: [LookupIterator] Optimize the path that writes to fields. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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.h ('k') | no next file » | 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 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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_
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698