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

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
« 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 // 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);
4058 AtomicWord value = reinterpret_cast<AtomicWord>(
4059 NO_BARRIER_READ_FIELD(this, kInstanceSizeOffset));
4060 return (value & 0xff) << kPointerSizeLog2;
4061 }
4062
4063
4064 void Map::nobarrier_set_instance_size(int value) {
4065 ASSERT_EQ(0, value & (kPointerSize - 1));
4066 value >>= kPointerSizeLog2;
4067 ASSERT(0 <= value && value < 256);
4068
4069 // Our atomics API does not support byte accessors. Hence, we have to manually
4070 // read out atomically the whole word, update the last byte and write back the
4071 // modified word.
4072 ASSERT(kInstanceSizeOffset % kPointerSize == 0);
4073 AtomicWord size_field = reinterpret_cast<AtomicWord>(
4074 NO_BARRIER_READ_FIELD(this, kInstanceSizeOffset));
4075 size_field >>= 8;
Hannes Payer (out of office) 2014/04/07 12:31:13 Do you prefer masking ifdef style?
4076 size_field <<= 8;
4077 size_field |= value;
4078 NO_BARRIER_WRITE_FIELD(
4079 this, kInstanceSizeOffset, reinterpret_cast<Object*>(size_field));
4080 }
4081
4082
4054 void Map::set_inobject_properties(int value) { 4083 void Map::set_inobject_properties(int value) {
4055 ASSERT(0 <= value && value < 256); 4084 ASSERT(0 <= value && value < 256);
4056 WRITE_BYTE_FIELD(this, kInObjectPropertiesOffset, static_cast<byte>(value)); 4085 WRITE_BYTE_FIELD(this, kInObjectPropertiesOffset, static_cast<byte>(value));
4057 } 4086 }
4058 4087
4059 4088
4060 void Map::set_pre_allocated_property_fields(int value) { 4089 void Map::set_pre_allocated_property_fields(int value) {
4061 ASSERT(0 <= value && value < 256); 4090 ASSERT(0 <= value && value < 256);
4062 WRITE_BYTE_FIELD(this, 4091 WRITE_BYTE_FIELD(this,
4063 kPreAllocatedPropertyFieldsOffset, 4092 kPreAllocatedPropertyFieldsOffset,
(...skipping 2860 matching lines...) Expand 10 before | Expand all | Expand 10 after
6924 #undef READ_UINT32_FIELD 6953 #undef READ_UINT32_FIELD
6925 #undef WRITE_UINT32_FIELD 6954 #undef WRITE_UINT32_FIELD
6926 #undef READ_SHORT_FIELD 6955 #undef READ_SHORT_FIELD
6927 #undef WRITE_SHORT_FIELD 6956 #undef WRITE_SHORT_FIELD
6928 #undef READ_BYTE_FIELD 6957 #undef READ_BYTE_FIELD
6929 #undef WRITE_BYTE_FIELD 6958 #undef WRITE_BYTE_FIELD
6930 6959
6931 } } // namespace v8::internal 6960 } } // namespace v8::internal
6932 6961
6933 #endif // V8_OBJECTS_INL_H_ 6962 #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