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

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

Issue 300283002: Introduce FieldIndex to unify and abstract property/field offset (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix mutable boxed double runtime function Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.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 //
11 11
12 #ifndef V8_OBJECTS_INL_H_ 12 #ifndef V8_OBJECTS_INL_H_
13 #define V8_OBJECTS_INL_H_ 13 #define V8_OBJECTS_INL_H_
14 14
15 #include "src/base/atomicops.h" 15 #include "src/base/atomicops.h"
16 #include "src/elements.h" 16 #include "src/elements.h"
17 #include "src/objects.h" 17 #include "src/objects.h"
18 #include "src/contexts.h" 18 #include "src/contexts.h"
19 #include "src/conversions-inl.h" 19 #include "src/conversions-inl.h"
20 #include "src/field-index-inl.h"
20 #include "src/heap.h" 21 #include "src/heap.h"
21 #include "src/isolate.h" 22 #include "src/isolate.h"
22 #include "src/heap-inl.h" 23 #include "src/heap-inl.h"
23 #include "src/property.h" 24 #include "src/property.h"
24 #include "src/spaces.h" 25 #include "src/spaces.h"
25 #include "src/store-buffer.h" 26 #include "src/store-buffer.h"
26 #include "src/v8memory.h" 27 #include "src/v8memory.h"
27 #include "src/factory.h" 28 #include "src/factory.h"
28 #include "src/incremental-marking.h" 29 #include "src/incremental-marking.h"
29 #include "src/transitions-inl.h" 30 #include "src/transitions-inl.h"
(...skipping 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 // properties are at the end of the object. Therefore there is no need 1939 // properties are at the end of the object. Therefore there is no need
1939 // to adjust the index here. 1940 // to adjust the index here.
1940 int offset = GetHeaderSize() + (kPointerSize * index); 1941 int offset = GetHeaderSize() + (kPointerSize * index);
1941 WRITE_FIELD(this, offset, value); 1942 WRITE_FIELD(this, offset, value);
1942 } 1943 }
1943 1944
1944 1945
1945 // Access fast-case object properties at index. The use of these routines 1946 // Access fast-case object properties at index. The use of these routines
1946 // is needed to correctly distinguish between properties stored in-object and 1947 // is needed to correctly distinguish between properties stored in-object and
1947 // properties stored in the properties array. 1948 // properties stored in the properties array.
1948 Object* JSObject::RawFastPropertyAt(int index) { 1949 Object* JSObject::RawFastPropertyAt(FieldIndex index) {
1949 // Adjust for the number of properties stored in the object. 1950 if (index.is_inobject()) {
1950 index -= map()->inobject_properties(); 1951 return READ_FIELD(this, index.offset());
1951 if (index < 0) {
1952 int offset = map()->instance_size() + (index * kPointerSize);
1953 return READ_FIELD(this, offset);
1954 } else { 1952 } else {
1955 ASSERT(index < properties()->length()); 1953 return properties()->get(index.outobject_array_index());
1956 return properties()->get(index);
1957 } 1954 }
1958 } 1955 }
1959 1956
1960 1957
1961 void JSObject::FastPropertyAtPut(int index, Object* value) { 1958 void JSObject::FastPropertyAtPut(FieldIndex index, Object* value) {
1962 // Adjust for the number of properties stored in the object. 1959 if (index.is_inobject()) {
1963 index -= map()->inobject_properties(); 1960 int offset = index.offset();
1964 if (index < 0) {
1965 int offset = map()->instance_size() + (index * kPointerSize);
1966 WRITE_FIELD(this, offset, value); 1961 WRITE_FIELD(this, offset, value);
1967 WRITE_BARRIER(GetHeap(), this, offset, value); 1962 WRITE_BARRIER(GetHeap(), this, offset, value);
1968 } else { 1963 } else {
1969 ASSERT(index < properties()->length()); 1964 properties()->set(index.outobject_array_index(), value);
1970 properties()->set(index, value);
1971 } 1965 }
1972 } 1966 }
1973 1967
1974 1968
1975 int JSObject::GetInObjectPropertyOffset(int index) { 1969 int JSObject::GetInObjectPropertyOffset(int index) {
1976 return map()->GetInObjectPropertyOffset(index); 1970 return map()->GetInObjectPropertyOffset(index);
1977 } 1971 }
1978 1972
1979 1973
1980 Object* JSObject::InObjectPropertyAt(int index) { 1974 Object* JSObject::InObjectPropertyAt(int index) {
(...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after
4069 4063
4070 4064
4071 int Map::pre_allocated_property_fields() { 4065 int Map::pre_allocated_property_fields() {
4072 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); 4066 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset);
4073 } 4067 }
4074 4068
4075 4069
4076 int Map::GetInObjectPropertyOffset(int index) { 4070 int Map::GetInObjectPropertyOffset(int index) {
4077 // Adjust for the number of properties stored in the object. 4071 // Adjust for the number of properties stored in the object.
4078 index -= inobject_properties(); 4072 index -= inobject_properties();
4079 ASSERT(index < 0); 4073 ASSERT(index <= 0);
4080 return instance_size() + (index * kPointerSize); 4074 return instance_size() + (index * kPointerSize);
4081 } 4075 }
4082 4076
4083 4077
4084 int HeapObject::SizeFromMap(Map* map) { 4078 int HeapObject::SizeFromMap(Map* map) {
4085 int instance_size = map->instance_size(); 4079 int instance_size = map->instance_size();
4086 if (instance_size != kVariableSizeSentinel) return instance_size; 4080 if (instance_size != kVariableSizeSentinel) return instance_size;
4087 // Only inline the most frequent cases. 4081 // Only inline the most frequent cases.
4088 InstanceType instance_type = map->instance_type(); 4082 InstanceType instance_type = map->instance_type();
4089 if (instance_type == FIXED_ARRAY_TYPE) { 4083 if (instance_type == FIXED_ARRAY_TYPE) {
(...skipping 2901 matching lines...) Expand 10 before | Expand all | Expand 10 after
6991 #undef READ_SHORT_FIELD 6985 #undef READ_SHORT_FIELD
6992 #undef WRITE_SHORT_FIELD 6986 #undef WRITE_SHORT_FIELD
6993 #undef READ_BYTE_FIELD 6987 #undef READ_BYTE_FIELD
6994 #undef WRITE_BYTE_FIELD 6988 #undef WRITE_BYTE_FIELD
6995 #undef NOBARRIER_READ_BYTE_FIELD 6989 #undef NOBARRIER_READ_BYTE_FIELD
6996 #undef NOBARRIER_WRITE_BYTE_FIELD 6990 #undef NOBARRIER_WRITE_BYTE_FIELD
6997 6991
6998 } } // namespace v8::internal 6992 } } // namespace v8::internal
6999 6993
7000 #endif // V8_OBJECTS_INL_H_ 6994 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698