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

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

Issue 1276533003: [runtime] Store constructor function index on primitive maps. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arm failures Created 5 years, 4 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-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 //
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 #undef SIMD128_TYPE_CHECKER 179 #undef SIMD128_TYPE_CHECKER
180 180
181 181
182 bool Object::IsString() const { 182 bool Object::IsString() const {
183 return Object::IsHeapObject() 183 return Object::IsHeapObject()
184 && HeapObject::cast(this)->map()->instance_type() < FIRST_NONSTRING_TYPE; 184 && HeapObject::cast(this)->map()->instance_type() < FIRST_NONSTRING_TYPE;
185 } 185 }
186 186
187 187
188 bool Object::IsName() const { 188 bool Object::IsName() const {
189 return IsString() || IsSymbol(); 189 STATIC_ASSERT(FIRST_NAME_TYPE == FIRST_TYPE);
190 return Object::IsHeapObject() &&
191 HeapObject::cast(this)->map()->instance_type() <= LAST_NAME_TYPE;
190 } 192 }
191 193
192 194
193 bool Object::IsUniqueName() const { 195 bool Object::IsUniqueName() const {
194 return IsInternalizedString() || IsSymbol(); 196 return IsInternalizedString() || IsSymbol();
195 } 197 }
196 198
197 199
198 bool Object::IsSpecObject() const { 200 bool Object::IsSpecObject() const {
199 return Object::IsHeapObject() 201 return Object::IsHeapObject()
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 return IsOrderedHashTable(); 980 return IsOrderedHashTable();
979 } 981 }
980 982
981 983
982 bool Object::IsOrderedHashMap() const { 984 bool Object::IsOrderedHashMap() const {
983 return IsOrderedHashTable(); 985 return IsOrderedHashTable();
984 } 986 }
985 987
986 988
987 bool Object::IsPrimitive() const { 989 bool Object::IsPrimitive() const {
988 return IsOddball() || IsNumber() || IsString(); 990 return IsSmi() || HeapObject::cast(this)->map()->IsPrimitiveMap();
989 } 991 }
990 992
991 993
992 bool Object::IsJSGlobalProxy() const { 994 bool Object::IsJSGlobalProxy() const {
993 bool result = IsHeapObject() && 995 bool result = IsHeapObject() &&
994 (HeapObject::cast(this)->map()->instance_type() == 996 (HeapObject::cast(this)->map()->instance_type() ==
995 JS_GLOBAL_PROXY_TYPE); 997 JS_GLOBAL_PROXY_TYPE);
996 DCHECK(!result || 998 DCHECK(!result ||
997 HeapObject::cast(this)->map()->is_access_check_needed()); 999 HeapObject::cast(this)->map()->is_access_check_needed());
998 return result; 1000 return result;
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 return 0; 2112 return 0;
2111 } 2113 }
2112 } 2114 }
2113 2115
2114 2116
2115 int JSObject::GetInternalFieldCount() { 2117 int JSObject::GetInternalFieldCount() {
2116 DCHECK(1 << kPointerSizeLog2 == kPointerSize); 2118 DCHECK(1 << kPointerSizeLog2 == kPointerSize);
2117 // Make sure to adjust for the number of in-object properties. These 2119 // Make sure to adjust for the number of in-object properties. These
2118 // properties do contribute to the size, but are not internal fields. 2120 // properties do contribute to the size, but are not internal fields.
2119 return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) - 2121 return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) -
2120 map()->inobject_properties(); 2122 map()->GetInObjectProperties();
2121 } 2123 }
2122 2124
2123 2125
2124 int JSObject::GetInternalFieldOffset(int index) { 2126 int JSObject::GetInternalFieldOffset(int index) {
2125 DCHECK(index < GetInternalFieldCount() && index >= 0); 2127 DCHECK(index < GetInternalFieldCount() && index >= 0);
2126 return GetHeaderSize() + (kPointerSize * index); 2128 return GetHeaderSize() + (kPointerSize * index);
2127 } 2129 }
2128 2130
2129 2131
2130 Object* JSObject::GetInternalField(int index) { 2132 Object* JSObject::GetInternalField(int index) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 Object* pre_allocated_value, 2269 Object* pre_allocated_value,
2268 Object* filler_value) { 2270 Object* filler_value) {
2269 DCHECK(!filler_value->IsHeapObject() || 2271 DCHECK(!filler_value->IsHeapObject() ||
2270 !GetHeap()->InNewSpace(filler_value)); 2272 !GetHeap()->InNewSpace(filler_value));
2271 DCHECK(!pre_allocated_value->IsHeapObject() || 2273 DCHECK(!pre_allocated_value->IsHeapObject() ||
2272 !GetHeap()->InNewSpace(pre_allocated_value)); 2274 !GetHeap()->InNewSpace(pre_allocated_value));
2273 int size = map->instance_size(); 2275 int size = map->instance_size();
2274 int offset = kHeaderSize; 2276 int offset = kHeaderSize;
2275 if (filler_value != pre_allocated_value) { 2277 if (filler_value != pre_allocated_value) {
2276 int pre_allocated = 2278 int pre_allocated =
2277 map->inobject_properties() - map->unused_property_fields(); 2279 map->GetInObjectProperties() - map->unused_property_fields();
2278 DCHECK(pre_allocated * kPointerSize + kHeaderSize <= size); 2280 DCHECK(pre_allocated * kPointerSize + kHeaderSize <= size);
2279 for (int i = 0; i < pre_allocated; i++) { 2281 for (int i = 0; i < pre_allocated; i++) {
2280 WRITE_FIELD(this, offset, pre_allocated_value); 2282 WRITE_FIELD(this, offset, pre_allocated_value);
2281 offset += kPointerSize; 2283 offset += kPointerSize;
2282 } 2284 }
2283 } 2285 }
2284 while (offset < size) { 2286 while (offset < size) {
2285 WRITE_FIELD(this, offset, filler_value); 2287 WRITE_FIELD(this, offset, filler_value);
2286 offset += kPointerSize; 2288 offset += kPointerSize;
2287 } 2289 }
2288 } 2290 }
2289 2291
2290 2292
2291 bool JSObject::HasFastProperties() { 2293 bool JSObject::HasFastProperties() {
2292 DCHECK(properties()->IsDictionary() == map()->is_dictionary_map()); 2294 DCHECK(properties()->IsDictionary() == map()->is_dictionary_map());
2293 return !properties()->IsDictionary(); 2295 return !properties()->IsDictionary();
2294 } 2296 }
2295 2297
2296 2298
2297 bool Map::TooManyFastProperties(StoreFromKeyed store_mode) { 2299 bool Map::TooManyFastProperties(StoreFromKeyed store_mode) {
2298 if (unused_property_fields() != 0) return false; 2300 if (unused_property_fields() != 0) return false;
2299 if (is_prototype_map()) return false; 2301 if (is_prototype_map()) return false;
2300 int minimum = store_mode == CERTAINLY_NOT_STORE_FROM_KEYED ? 128 : 12; 2302 int minimum = store_mode == CERTAINLY_NOT_STORE_FROM_KEYED ? 128 : 12;
2301 int limit = Max(minimum, inobject_properties()); 2303 int limit = Max(minimum, GetInObjectProperties());
2302 int external = NumberOfFields() - inobject_properties(); 2304 int external = NumberOfFields() - GetInObjectProperties();
2303 return external > limit; 2305 return external > limit;
2304 } 2306 }
2305 2307
2306 2308
2307 void Struct::InitializeBody(int object_size) { 2309 void Struct::InitializeBody(int object_size) {
2308 Object* value = GetHeap()->undefined_value(); 2310 Object* value = GetHeap()->undefined_value();
2309 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { 2311 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) {
2310 WRITE_FIELD(this, offset, value); 2312 WRITE_FIELD(this, offset, value);
2311 } 2313 }
2312 } 2314 }
(...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after
3979 WRITE_BYTE_FIELD(this, kVisitorIdOffset, static_cast<byte>(id)); 3981 WRITE_BYTE_FIELD(this, kVisitorIdOffset, static_cast<byte>(id));
3980 } 3982 }
3981 3983
3982 3984
3983 int Map::instance_size() { 3985 int Map::instance_size() {
3984 return NOBARRIER_READ_BYTE_FIELD( 3986 return NOBARRIER_READ_BYTE_FIELD(
3985 this, kInstanceSizeOffset) << kPointerSizeLog2; 3987 this, kInstanceSizeOffset) << kPointerSizeLog2;
3986 } 3988 }
3987 3989
3988 3990
3989 int Map::inobject_properties() { 3991 int Map::inobject_properties_or_constructor_function_index() {
3990 return READ_BYTE_FIELD(this, kInObjectPropertiesOffset); 3992 return READ_BYTE_FIELD(this,
3993 kInObjectPropertiesOrConstructorFunctionIndexOffset);
3994 }
3995
3996
3997 void Map::set_inobject_properties_or_constructor_function_index(int value) {
3998 DCHECK(0 <= value && value < 256);
3999 WRITE_BYTE_FIELD(this, kInObjectPropertiesOrConstructorFunctionIndexOffset,
4000 static_cast<byte>(value));
4001 }
4002
4003
4004 int Map::GetInObjectProperties() {
4005 DCHECK(IsJSObjectMap());
4006 return inobject_properties_or_constructor_function_index();
4007 }
4008
4009
4010 void Map::SetInObjectProperties(int value) {
4011 DCHECK(IsJSObjectMap());
4012 set_inobject_properties_or_constructor_function_index(value);
4013 }
4014
4015
4016 int Map::GetConstructorFunctionIndex() {
4017 DCHECK(IsPrimitiveMap());
4018 return inobject_properties_or_constructor_function_index();
4019 }
4020
4021
4022 void Map::SetConstructorFunctionIndex(int value) {
4023 DCHECK(IsPrimitiveMap());
4024 set_inobject_properties_or_constructor_function_index(value);
3991 } 4025 }
3992 4026
3993 4027
3994 int Map::GetInObjectPropertyOffset(int index) { 4028 int Map::GetInObjectPropertyOffset(int index) {
3995 // Adjust for the number of properties stored in the object. 4029 // Adjust for the number of properties stored in the object.
3996 index -= inobject_properties(); 4030 index -= GetInObjectProperties();
3997 DCHECK(index <= 0); 4031 DCHECK(index <= 0);
3998 return instance_size() + (index * kPointerSize); 4032 return instance_size() + (index * kPointerSize);
3999 } 4033 }
4000 4034
4001 4035
4002 Handle<Map> Map::CopyInstallDescriptorsForTesting( 4036 Handle<Map> Map::CopyInstallDescriptorsForTesting(
4003 Handle<Map> map, int new_descriptor, Handle<DescriptorArray> descriptors, 4037 Handle<Map> map, int new_descriptor, Handle<DescriptorArray> descriptors,
4004 Handle<LayoutDescriptor> layout_descriptor) { 4038 Handle<LayoutDescriptor> layout_descriptor) {
4005 return CopyInstallDescriptors(map, new_descriptor, descriptors, 4039 return CopyInstallDescriptors(map, new_descriptor, descriptors,
4006 layout_descriptor); 4040 layout_descriptor);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4054 4088
4055 void Map::set_instance_size(int value) { 4089 void Map::set_instance_size(int value) {
4056 DCHECK_EQ(0, value & (kPointerSize - 1)); 4090 DCHECK_EQ(0, value & (kPointerSize - 1));
4057 value >>= kPointerSizeLog2; 4091 value >>= kPointerSizeLog2;
4058 DCHECK(0 <= value && value < 256); 4092 DCHECK(0 <= value && value < 256);
4059 NOBARRIER_WRITE_BYTE_FIELD( 4093 NOBARRIER_WRITE_BYTE_FIELD(
4060 this, kInstanceSizeOffset, static_cast<byte>(value)); 4094 this, kInstanceSizeOffset, static_cast<byte>(value));
4061 } 4095 }
4062 4096
4063 4097
4064 void Map::set_inobject_properties(int value) {
4065 DCHECK(0 <= value && value < 256);
4066 WRITE_BYTE_FIELD(this, kInObjectPropertiesOffset, static_cast<byte>(value));
4067 }
4068
4069
4070 void Map::clear_unused() { WRITE_BYTE_FIELD(this, kUnusedOffset, 0); } 4098 void Map::clear_unused() { WRITE_BYTE_FIELD(this, kUnusedOffset, 0); }
4071 4099
4072 4100
4073 InstanceType Map::instance_type() { 4101 InstanceType Map::instance_type() {
4074 return static_cast<InstanceType>(READ_BYTE_FIELD(this, kInstanceTypeOffset)); 4102 return static_cast<InstanceType>(READ_BYTE_FIELD(this, kInstanceTypeOffset));
4075 } 4103 }
4076 4104
4077 4105
4078 void Map::set_instance_type(InstanceType value) { 4106 void Map::set_instance_type(InstanceType value) {
4079 WRITE_BYTE_FIELD(this, kInstanceTypeOffset, value); 4107 WRITE_BYTE_FIELD(this, kInstanceTypeOffset, value);
(...skipping 3135 matching lines...) Expand 10 before | Expand all | Expand 10 after
7215 #undef READ_INT64_FIELD 7243 #undef READ_INT64_FIELD
7216 #undef WRITE_INT64_FIELD 7244 #undef WRITE_INT64_FIELD
7217 #undef READ_BYTE_FIELD 7245 #undef READ_BYTE_FIELD
7218 #undef WRITE_BYTE_FIELD 7246 #undef WRITE_BYTE_FIELD
7219 #undef NOBARRIER_READ_BYTE_FIELD 7247 #undef NOBARRIER_READ_BYTE_FIELD
7220 #undef NOBARRIER_WRITE_BYTE_FIELD 7248 #undef NOBARRIER_WRITE_BYTE_FIELD
7221 7249
7222 } } // namespace v8::internal 7250 } } // namespace v8::internal
7223 7251
7224 #endif // V8_OBJECTS_INL_H_ 7252 #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