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

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

Issue 203583007: Support weak heap references in the ConstantPool to support IsWeakObjectInOptimizedCode objects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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
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 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2196 int offset = kHeaderSize + index * kDoubleSize; 2196 int offset = kHeaderSize + index * kDoubleSize;
2197 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset)); 2197 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset));
2198 } 2198 }
2199 2199
2200 2200
2201 SMI_ACCESSORS( 2201 SMI_ACCESSORS(
2202 ConstantPoolArray, first_code_ptr_index, kFirstCodePointerIndexOffset) 2202 ConstantPoolArray, first_code_ptr_index, kFirstCodePointerIndexOffset)
2203 SMI_ACCESSORS( 2203 SMI_ACCESSORS(
2204 ConstantPoolArray, first_heap_ptr_index, kFirstHeapPointerIndexOffset) 2204 ConstantPoolArray, first_heap_ptr_index, kFirstHeapPointerIndexOffset)
2205 SMI_ACCESSORS( 2205 SMI_ACCESSORS(
2206 ConstantPoolArray, first_weak_ptr_index, kFirstWeakPointerIndexOffset)
2207 SMI_ACCESSORS(
2206 ConstantPoolArray, first_int32_index, kFirstInt32IndexOffset) 2208 ConstantPoolArray, first_int32_index, kFirstInt32IndexOffset)
2207 2209
2208 2210
2209 int ConstantPoolArray::first_int64_index() { 2211 int ConstantPoolArray::first_int64_index() {
2210 return 0; 2212 return 0;
2211 } 2213 }
2212 2214
2213 2215
2216 int ConstantPoolArray::first_ptr_index() {
2217 return first_code_ptr_index();
2218 }
2219
2220
2214 int ConstantPoolArray::count_of_int64_entries() { 2221 int ConstantPoolArray::count_of_int64_entries() {
2215 return first_code_ptr_index(); 2222 return first_code_ptr_index();
2216 } 2223 }
2217 2224
2218 2225
2219 int ConstantPoolArray::count_of_code_ptr_entries() { 2226 int ConstantPoolArray::count_of_code_ptr_entries() {
2220 return first_heap_ptr_index() - first_code_ptr_index(); 2227 return first_heap_ptr_index() - first_code_ptr_index();
2221 } 2228 }
2222 2229
2223 2230
2224 int ConstantPoolArray::count_of_heap_ptr_entries() { 2231 int ConstantPoolArray::count_of_heap_ptr_entries() {
2225 return first_int32_index() - first_heap_ptr_index(); 2232 return first_weak_ptr_index() - first_heap_ptr_index();
2226 } 2233 }
2227 2234
2228 2235
2236 int ConstantPoolArray::count_of_weak_ptr_entries() {
2237 return first_int32_index() - first_weak_ptr_index();
2238 }
2239
2240
2229 int ConstantPoolArray::count_of_int32_entries() { 2241 int ConstantPoolArray::count_of_int32_entries() {
2230 return length() - first_int32_index(); 2242 return length() - first_int32_index();
2231 } 2243 }
2232 2244
2233 2245
2246 int ConstantPoolArray::count_of_ptr_entries() {
2247 return count_of_code_ptr_entries() + count_of_heap_ptr_entries() +
2248 count_of_weak_ptr_entries();
2249 }
2250
2251
2234 void ConstantPoolArray::SetEntryCounts(int number_of_int64_entries, 2252 void ConstantPoolArray::SetEntryCounts(int number_of_int64_entries,
2235 int number_of_code_ptr_entries, 2253 int number_of_code_ptr_entries,
2236 int number_of_heap_ptr_entries, 2254 int number_of_heap_ptr_entries,
2255 int number_of_weak_ptr_entries,
2237 int number_of_int32_entries) { 2256 int number_of_int32_entries) {
2238 int current_index = number_of_int64_entries; 2257 int current_index = number_of_int64_entries;
2239 set_first_code_ptr_index(current_index); 2258 set_first_code_ptr_index(current_index);
2240 current_index += number_of_code_ptr_entries; 2259 current_index += number_of_code_ptr_entries;
2241 set_first_heap_ptr_index(current_index); 2260 set_first_heap_ptr_index(current_index);
2242 current_index += number_of_heap_ptr_entries; 2261 current_index += number_of_heap_ptr_entries;
2262 set_first_weak_ptr_index(current_index);
2263 current_index += number_of_weak_ptr_entries;
2243 set_first_int32_index(current_index); 2264 set_first_int32_index(current_index);
2244 current_index += number_of_int32_entries; 2265 current_index += number_of_int32_entries;
2245 set_length(current_index); 2266 set_length(current_index);
2246 } 2267 }
2247 2268
2248 2269
2249 int64_t ConstantPoolArray::get_int64_entry(int index) { 2270 int64_t ConstantPoolArray::get_int64_entry(int index) {
2250 ASSERT(map() == GetHeap()->constant_pool_array_map()); 2271 ASSERT(map() == GetHeap()->constant_pool_array_map());
2251 ASSERT(index >= 0 && index < first_code_ptr_index()); 2272 ASSERT(index >= 0 && index < first_code_ptr_index());
2252 return READ_INT64_FIELD(this, OffsetOfElementAt(index)); 2273 return READ_INT64_FIELD(this, OffsetOfElementAt(index));
2253 } 2274 }
2254 2275
2255 double ConstantPoolArray::get_int64_entry_as_double(int index) { 2276 double ConstantPoolArray::get_int64_entry_as_double(int index) {
2256 STATIC_ASSERT(kDoubleSize == kInt64Size); 2277 STATIC_ASSERT(kDoubleSize == kInt64Size);
2257 ASSERT(map() == GetHeap()->constant_pool_array_map()); 2278 ASSERT(map() == GetHeap()->constant_pool_array_map());
2258 ASSERT(index >= 0 && index < first_code_ptr_index()); 2279 ASSERT(index >= 0 && index < first_code_ptr_index());
2259 return READ_DOUBLE_FIELD(this, OffsetOfElementAt(index)); 2280 return READ_DOUBLE_FIELD(this, OffsetOfElementAt(index));
2260 } 2281 }
2261 2282
2262 2283
2263 Address ConstantPoolArray::get_code_ptr_entry(int index) { 2284 Address ConstantPoolArray::get_code_ptr_entry(int index) {
2264 ASSERT(map() == GetHeap()->constant_pool_array_map()); 2285 ASSERT(map() == GetHeap()->constant_pool_array_map());
2265 ASSERT(index >= first_code_ptr_index() && index < first_heap_ptr_index()); 2286 ASSERT(index >= first_code_ptr_index() && index < first_heap_ptr_index());
2266 return reinterpret_cast<Address>(READ_FIELD(this, OffsetOfElementAt(index))); 2287 return reinterpret_cast<Address>(READ_FIELD(this, OffsetOfElementAt(index)));
2267 } 2288 }
2268 2289
2269 2290
2270 Object* ConstantPoolArray::get_heap_ptr_entry(int index) { 2291 Object* ConstantPoolArray::get_heap_ptr_entry(int index) {
2271 ASSERT(map() == GetHeap()->constant_pool_array_map()); 2292 ASSERT(map() == GetHeap()->constant_pool_array_map());
2272 ASSERT(index >= first_heap_ptr_index() && index < first_int32_index()); 2293 ASSERT(index >= first_heap_ptr_index() && index < first_weak_ptr_index());
2273 return READ_FIELD(this, OffsetOfElementAt(index)); 2294 return READ_FIELD(this, OffsetOfElementAt(index));
2274 } 2295 }
2275 2296
2297
2298 Object* ConstantPoolArray::get_weak_ptr_entry(int index) {
2299 ASSERT(map() == GetHeap()->constant_pool_array_map());
2300 ASSERT(index >= first_weak_ptr_index() && index < first_int32_index());
2301 return READ_FIELD(this, OffsetOfElementAt(index));
2302 }
2303
2276 2304
2277 int32_t ConstantPoolArray::get_int32_entry(int index) { 2305 int32_t ConstantPoolArray::get_int32_entry(int index) {
2278 ASSERT(map() == GetHeap()->constant_pool_array_map()); 2306 ASSERT(map() == GetHeap()->constant_pool_array_map());
2279 ASSERT(index >= first_int32_index() && index < length()); 2307 ASSERT(index >= first_int32_index() && index < length());
2280 return READ_INT32_FIELD(this, OffsetOfElementAt(index)); 2308 return READ_INT32_FIELD(this, OffsetOfElementAt(index));
2281 } 2309 }
2282 2310
2283 2311
2284 void ConstantPoolArray::set(int index, Address value) { 2312 void ConstantPoolArray::set(int index, Address value) {
2285 ASSERT(map() == GetHeap()->constant_pool_array_map()); 2313 ASSERT(map() == GetHeap()->constant_pool_array_map());
2286 ASSERT(index >= first_code_ptr_index() && index < first_heap_ptr_index()); 2314 ASSERT(index >= first_code_ptr_index() && index < first_heap_ptr_index());
2287 WRITE_FIELD(this, OffsetOfElementAt(index), reinterpret_cast<Object*>(value)); 2315 WRITE_FIELD(this, OffsetOfElementAt(index), reinterpret_cast<Object*>(value));
2288 } 2316 }
2289 2317
2290 2318
2291 void ConstantPoolArray::set(int index, Object* value) { 2319 void ConstantPoolArray::set(int index, Object* value) {
2292 ASSERT(map() == GetHeap()->constant_pool_array_map()); 2320 ASSERT(map() == GetHeap()->constant_pool_array_map());
2293 ASSERT(index >= first_code_ptr_index() && index < first_int32_index()); 2321 ASSERT(index >= first_heap_ptr_index() && index < first_int32_index());
2294 WRITE_FIELD(this, OffsetOfElementAt(index), value); 2322 WRITE_FIELD(this, OffsetOfElementAt(index), value);
2295 WRITE_BARRIER(GetHeap(), this, OffsetOfElementAt(index), value); 2323 WRITE_BARRIER(GetHeap(), this, OffsetOfElementAt(index), value);
2296 } 2324 }
2297 2325
2298 2326
2299 void ConstantPoolArray::set(int index, int64_t value) { 2327 void ConstantPoolArray::set(int index, int64_t value) {
2300 ASSERT(map() == GetHeap()->constant_pool_array_map()); 2328 ASSERT(map() == GetHeap()->constant_pool_array_map());
2301 ASSERT(index >= first_int64_index() && index < first_code_ptr_index()); 2329 ASSERT(index >= first_int64_index() && index < first_code_ptr_index());
2302 WRITE_INT64_FIELD(this, OffsetOfElementAt(index), value); 2330 WRITE_INT64_FIELD(this, OffsetOfElementAt(index), value);
2303 } 2331 }
(...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after
3867 return SeqTwoByteString::SizeFor( 3895 return SeqTwoByteString::SizeFor(
3868 reinterpret_cast<SeqTwoByteString*>(this)->length()); 3896 reinterpret_cast<SeqTwoByteString*>(this)->length());
3869 } 3897 }
3870 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { 3898 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) {
3871 return FixedDoubleArray::SizeFor( 3899 return FixedDoubleArray::SizeFor(
3872 reinterpret_cast<FixedDoubleArray*>(this)->length()); 3900 reinterpret_cast<FixedDoubleArray*>(this)->length());
3873 } 3901 }
3874 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { 3902 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) {
3875 return ConstantPoolArray::SizeFor( 3903 return ConstantPoolArray::SizeFor(
3876 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int64_entries(), 3904 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int64_entries(),
3877 reinterpret_cast<ConstantPoolArray*>(this)->count_of_code_ptr_entries(), 3905 reinterpret_cast<ConstantPoolArray*>(this)->count_of_ptr_entries(),
3878 reinterpret_cast<ConstantPoolArray*>(this)->count_of_heap_ptr_entries(),
3879 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int32_entries()); 3906 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int32_entries());
3880 } 3907 }
3881 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && 3908 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE &&
3882 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { 3909 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) {
3883 return reinterpret_cast<FixedTypedArrayBase*>(this)->size(); 3910 return reinterpret_cast<FixedTypedArrayBase*>(this)->size();
3884 } 3911 }
3885 ASSERT(instance_type == CODE_TYPE); 3912 ASSERT(instance_type == CODE_TYPE);
3886 return reinterpret_cast<Code*>(this)->CodeSize(); 3913 return reinterpret_cast<Code*>(this)->CodeSize();
3887 } 3914 }
3888 3915
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
4570 } 4597 }
4571 4598
4572 4599
4573 Object* Code::GetObjectFromEntryAddress(Address location_of_address) { 4600 Object* Code::GetObjectFromEntryAddress(Address location_of_address) {
4574 return HeapObject:: 4601 return HeapObject::
4575 FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize); 4602 FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize);
4576 } 4603 }
4577 4604
4578 4605
4579 bool Code::IsWeakObjectInOptimizedCode(Object* object) { 4606 bool Code::IsWeakObjectInOptimizedCode(Object* object) {
4580 ASSERT(is_optimized_code());
4581 if (object->IsMap()) { 4607 if (object->IsMap()) {
4582 return Map::cast(object)->CanTransition() && 4608 return Map::cast(object)->CanTransition() &&
4583 FLAG_collect_maps && 4609 FLAG_collect_maps &&
4584 FLAG_weak_embedded_maps_in_optimized_code; 4610 FLAG_weak_embedded_maps_in_optimized_code;
4585 } 4611 }
4586 if (object->IsJSObject() || 4612 if (object->IsJSObject() ||
4587 (object->IsCell() && Cell::cast(object)->value()->IsJSObject())) { 4613 (object->IsCell() && Cell::cast(object)->value()->IsJSObject())) {
4588 return FLAG_weak_embedded_objects_in_optimized_code; 4614 return FLAG_weak_embedded_objects_in_optimized_code;
4589 } 4615 }
4590 return false; 4616 return false;
(...skipping 2169 matching lines...) Expand 10 before | Expand all | Expand 10 after
6760 #undef READ_UINT32_FIELD 6786 #undef READ_UINT32_FIELD
6761 #undef WRITE_UINT32_FIELD 6787 #undef WRITE_UINT32_FIELD
6762 #undef READ_SHORT_FIELD 6788 #undef READ_SHORT_FIELD
6763 #undef WRITE_SHORT_FIELD 6789 #undef WRITE_SHORT_FIELD
6764 #undef READ_BYTE_FIELD 6790 #undef READ_BYTE_FIELD
6765 #undef WRITE_BYTE_FIELD 6791 #undef WRITE_BYTE_FIELD
6766 6792
6767 } } // namespace v8::internal 6793 } } // namespace v8::internal
6768 6794
6769 #endif // V8_OBJECTS_INL_H_ 6795 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/objects-printer.cc » ('j') | src/objects-visiting-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698