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

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

Issue 227133007: Allow race-full access of map instance size when sweeping concurrently. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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
« src/objects.cc ('K') | « src/objects.cc ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3982 matching lines...) Expand 10 before | Expand all | Expand 10 after
3993 3993
3994 int Map::GetInObjectPropertyOffset(int index) { 3994 int Map::GetInObjectPropertyOffset(int index) {
3995 // Adjust for the number of properties stored in the object. 3995 // Adjust for the number of properties stored in the object.
3996 index -= inobject_properties(); 3996 index -= inobject_properties();
3997 ASSERT(index < 0); 3997 ASSERT(index < 0);
3998 return instance_size() + (index * kPointerSize); 3998 return instance_size() + (index * kPointerSize);
3999 } 3999 }
4000 4000
4001 4001
4002 int HeapObject::SizeFromMap(Map* map) { 4002 int HeapObject::SizeFromMap(Map* map) {
4003 int instance_size = map->instance_size(); 4003 int instance_size = map->nobarrier_instance_size();
4004 if (instance_size != kVariableSizeSentinel) return instance_size; 4004 if (instance_size != kVariableSizeSentinel) return instance_size;
4005 // Only inline the most frequent cases. 4005 // Only inline the most frequent cases.
4006 int instance_type = static_cast<int>(map->instance_type()); 4006 int instance_type = static_cast<int>(map->instance_type());
4007 if (instance_type == FIXED_ARRAY_TYPE) { 4007 if (instance_type == FIXED_ARRAY_TYPE) {
4008 return FixedArray::BodyDescriptor::SizeOf(map, this); 4008 return FixedArray::BodyDescriptor::SizeOf(map, this);
4009 } 4009 }
4010 if (instance_type == ASCII_STRING_TYPE || 4010 if (instance_type == ASCII_STRING_TYPE ||
4011 instance_type == ASCII_INTERNALIZED_STRING_TYPE) { 4011 instance_type == ASCII_INTERNALIZED_STRING_TYPE) {
4012 return SeqOneByteString::SizeFor( 4012 return SeqOneByteString::SizeFor(
4013 reinterpret_cast<SeqOneByteString*>(this)->length()); 4013 reinterpret_cast<SeqOneByteString*>(this)->length());
(...skipping 30 matching lines...) Expand all
4044 4044
4045 4045
4046 void Map::set_instance_size(int value) { 4046 void Map::set_instance_size(int value) {
4047 ASSERT_EQ(0, value & (kPointerSize - 1)); 4047 ASSERT_EQ(0, value & (kPointerSize - 1));
4048 value >>= kPointerSizeLog2; 4048 value >>= kPointerSizeLog2;
4049 ASSERT(0 <= value && value < 256); 4049 ASSERT(0 <= value && value < 256);
4050 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value)); 4050 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value));
4051 } 4051 }
4052 4052
4053 4053
4054 int Map::nobarrier_instance_size() {
4055 // Our atomics API does not support byte accessors. Hence, we have to manually
4056 // read out atomically the whole word and mask out the upper bytes.
4057 ASSERT(kInstanceSizeOffset % kPointerSize == 0);
Jarin 2014/04/08 20:11:11 STATIC_ASSERT?
4058 AtomicWord value = reinterpret_cast<AtomicWord>(
4059 NO_BARRIER_READ_FIELD(this, kInstanceSizeOffset));
4060 return (value & 0xff) << kPointerSizeLog2;
4061 }
4062
4063
4054 void Map::set_inobject_properties(int value) { 4064 void Map::set_inobject_properties(int value) {
4055 ASSERT(0 <= value && value < 256); 4065 ASSERT(0 <= value && value < 256);
4056 WRITE_BYTE_FIELD(this, kInObjectPropertiesOffset, static_cast<byte>(value)); 4066 WRITE_BYTE_FIELD(this, kInObjectPropertiesOffset, static_cast<byte>(value));
4057 } 4067 }
4058 4068
4059 4069
4060 void Map::set_pre_allocated_property_fields(int value) { 4070 void Map::set_pre_allocated_property_fields(int value) {
4061 ASSERT(0 <= value && value < 256); 4071 ASSERT(0 <= value && value < 256);
4062 WRITE_BYTE_FIELD(this, 4072 WRITE_BYTE_FIELD(this,
4063 kPreAllocatedPropertyFieldsOffset, 4073 kPreAllocatedPropertyFieldsOffset,
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
4282 DependentCode::kPrototypeCheckGroup); 4292 DependentCode::kPrototypeCheckGroup);
4283 } 4293 }
4284 } 4294 }
4285 4295
4286 4296
4287 bool Map::CanOmitMapChecks() { 4297 bool Map::CanOmitMapChecks() {
4288 return is_stable() && FLAG_omit_map_checks_for_leaf_maps; 4298 return is_stable() && FLAG_omit_map_checks_for_leaf_maps;
4289 } 4299 }
4290 4300
4291 4301
4302 void Map::Shrink(int slack) {
4303 ASSERT(kInstanceSizeOffset % kPointerSize == 0);
Jarin 2014/04/08 20:11:11 STATIC_ASSERT? Tiny nit - since you are using Atom
4304 ASSERT(kInstanceSizeOffset + kInObjectPropertiesByte ==
4305 kInObjectPropertiesOffset);
4306
4307 // Our atomics API does not support byte accessors. Hence, we have to manually
4308 // read out atomically the whole word, update the instance size and in object
4309 // properties byte and write back the modified word.
4310 Atomic32 first_word = NoBarrier_Load(reinterpret_cast<Atomic32*>(
4311 FIELD_ADDR(this, kInstanceSizeOffset)));
4312
4313 // The first byte contains the instance size and the second byte (8 bits left)
4314 // is the in object properties byte.
4315 int difference = (slack << 8) + slack;
Michael Starzinger 2014/04/08 11:34:22 I don't even ... OMG.
Jarin 2014/04/08 20:11:11 Replace 8 with kInObjectPropertiesByte * kBitsPer
4316 first_word -= difference;
4317
4318 ASSERT(0 <= (first_word & 0xff) && (first_word & 0xff) < 256);
4319 ASSERT(0 <= ((first_word & 0xff00) >> 8) &&
4320 ((first_word & 0xff00) >> 8) < 256);
Jarin 2014/04/08 20:11:11 The two assertions above do not seem to test any i
4321
4322 NoBarrier_Store(reinterpret_cast<Atomic32*>(
4323 FIELD_ADDR(this, kInstanceSizeOffset)), first_word);
4324
4325 set_unused_property_fields(unused_property_fields() - slack);
4326
4327 // Visitor id might depend on the instance size, recalculate it.
4328 set_visitor_id(StaticVisitorBase::GetVisitorId(this));
4329 }
4330
4331
4292 int DependentCode::number_of_entries(DependencyGroup group) { 4332 int DependentCode::number_of_entries(DependencyGroup group) {
4293 if (length() == 0) return 0; 4333 if (length() == 0) return 0;
4294 return Smi::cast(get(group))->value(); 4334 return Smi::cast(get(group))->value();
4295 } 4335 }
4296 4336
4297 4337
4298 void DependentCode::set_number_of_entries(DependencyGroup group, int value) { 4338 void DependentCode::set_number_of_entries(DependencyGroup group, int value) {
4299 set(group, Smi::FromInt(value)); 4339 set(group, Smi::FromInt(value));
4300 } 4340 }
4301 4341
(...skipping 2622 matching lines...) Expand 10 before | Expand all | Expand 10 after
6924 #undef READ_UINT32_FIELD 6964 #undef READ_UINT32_FIELD
6925 #undef WRITE_UINT32_FIELD 6965 #undef WRITE_UINT32_FIELD
6926 #undef READ_SHORT_FIELD 6966 #undef READ_SHORT_FIELD
6927 #undef WRITE_SHORT_FIELD 6967 #undef WRITE_SHORT_FIELD
6928 #undef READ_BYTE_FIELD 6968 #undef READ_BYTE_FIELD
6929 #undef WRITE_BYTE_FIELD 6969 #undef WRITE_BYTE_FIELD
6930 6970
6931 } } // namespace v8::internal 6971 } } // namespace v8::internal
6932 6972
6933 #endif // V8_OBJECTS_INL_H_ 6973 #endif // V8_OBJECTS_INL_H_
OLDNEW
« src/objects.cc ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698