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

Side by Side Diff: src/heap.cc

Issue 183883011: Differentate between code target pointers and heap pointers in constant pools. (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
« no previous file with comments | « src/heap.h ('k') | src/mark-compact.h » ('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 // 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 5111 matching lines...) Expand 10 before | Expand all | Expand 10 after
5122 dst->address() + FixedDoubleArray::kLengthOffset, 5122 dst->address() + FixedDoubleArray::kLengthOffset,
5123 src->address() + FixedDoubleArray::kLengthOffset, 5123 src->address() + FixedDoubleArray::kLengthOffset,
5124 FixedDoubleArray::SizeFor(len) - FixedDoubleArray::kLengthOffset); 5124 FixedDoubleArray::SizeFor(len) - FixedDoubleArray::kLengthOffset);
5125 return obj; 5125 return obj;
5126 } 5126 }
5127 5127
5128 5128
5129 MaybeObject* Heap::CopyConstantPoolArrayWithMap(ConstantPoolArray* src, 5129 MaybeObject* Heap::CopyConstantPoolArrayWithMap(ConstantPoolArray* src,
5130 Map* map) { 5130 Map* map) {
5131 int int64_entries = src->count_of_int64_entries(); 5131 int int64_entries = src->count_of_int64_entries();
5132 int ptr_entries = src->count_of_ptr_entries(); 5132 int code_ptr_entries = src->count_of_code_ptr_entries();
5133 int heap_ptr_entries = src->count_of_heap_ptr_entries();
5133 int int32_entries = src->count_of_int32_entries(); 5134 int int32_entries = src->count_of_int32_entries();
5134 Object* obj; 5135 Object* obj;
5135 { MaybeObject* maybe_obj = 5136 { MaybeObject* maybe_obj =
5136 AllocateConstantPoolArray(int64_entries, ptr_entries, int32_entries); 5137 AllocateConstantPoolArray(int64_entries, code_ptr_entries,
5138 heap_ptr_entries, int32_entries);
5137 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 5139 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
5138 } 5140 }
5139 HeapObject* dst = HeapObject::cast(obj); 5141 HeapObject* dst = HeapObject::cast(obj);
5140 dst->set_map_no_write_barrier(map); 5142 dst->set_map_no_write_barrier(map);
5143 int size = ConstantPoolArray::SizeFor(
5144 int64_entries, code_ptr_entries, heap_ptr_entries, int32_entries);
5141 CopyBlock( 5145 CopyBlock(
5142 dst->address() + ConstantPoolArray::kLengthOffset, 5146 dst->address() + ConstantPoolArray::kLengthOffset,
5143 src->address() + ConstantPoolArray::kLengthOffset, 5147 src->address() + ConstantPoolArray::kLengthOffset,
5144 ConstantPoolArray::SizeFor(int64_entries, ptr_entries, int32_entries) 5148 size - ConstantPoolArray::kLengthOffset);
5145 - ConstantPoolArray::kLengthOffset);
5146 return obj; 5149 return obj;
5147 } 5150 }
5148 5151
5149 5152
5150 MaybeObject* Heap::AllocateRawFixedArray(int length, PretenureFlag pretenure) { 5153 MaybeObject* Heap::AllocateRawFixedArray(int length, PretenureFlag pretenure) {
5151 if (length < 0 || length > FixedArray::kMaxLength) { 5154 if (length < 0 || length > FixedArray::kMaxLength) {
5152 return Failure::OutOfMemoryException(0xe); 5155 return Failure::OutOfMemoryException(0xe);
5153 } 5156 }
5154 int size = FixedArray::SizeFor(length); 5157 int size = FixedArray::SizeFor(length);
5155 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, pretenure); 5158 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, pretenure);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
5272 HeapObject* object; 5275 HeapObject* object;
5273 { MaybeObject* maybe_object = AllocateRaw(size, space, OLD_DATA_SPACE); 5276 { MaybeObject* maybe_object = AllocateRaw(size, space, OLD_DATA_SPACE);
5274 if (!maybe_object->To<HeapObject>(&object)) return maybe_object; 5277 if (!maybe_object->To<HeapObject>(&object)) return maybe_object;
5275 } 5278 }
5276 5279
5277 return EnsureDoubleAligned(this, object, size); 5280 return EnsureDoubleAligned(this, object, size);
5278 } 5281 }
5279 5282
5280 5283
5281 MaybeObject* Heap::AllocateConstantPoolArray(int number_of_int64_entries, 5284 MaybeObject* Heap::AllocateConstantPoolArray(int number_of_int64_entries,
5282 int number_of_ptr_entries, 5285 int number_of_code_ptr_entries,
5286 int number_of_heap_ptr_entries,
5283 int number_of_int32_entries) { 5287 int number_of_int32_entries) {
5284 ASSERT(number_of_int64_entries > 0 || number_of_ptr_entries > 0 || 5288 ASSERT(number_of_int64_entries > 0 || number_of_code_ptr_entries > 0 ||
5285 number_of_int32_entries > 0); 5289 number_of_heap_ptr_entries > 0 || number_of_int32_entries > 0);
5286 int size = ConstantPoolArray::SizeFor(number_of_int64_entries, 5290 int size = ConstantPoolArray::SizeFor(number_of_int64_entries,
5287 number_of_ptr_entries, 5291 number_of_code_ptr_entries,
5292 number_of_heap_ptr_entries,
5288 number_of_int32_entries); 5293 number_of_int32_entries);
5289 #ifndef V8_HOST_ARCH_64_BIT 5294 #ifndef V8_HOST_ARCH_64_BIT
5290 size += kPointerSize; 5295 size += kPointerSize;
5291 #endif 5296 #endif
5292 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED); 5297 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED);
5293 5298
5294 HeapObject* object; 5299 HeapObject* object;
5295 { MaybeObject* maybe_object = AllocateRaw(size, space, OLD_POINTER_SPACE); 5300 { MaybeObject* maybe_object = AllocateRaw(size, space, OLD_POINTER_SPACE);
5296 if (!maybe_object->To<HeapObject>(&object)) return maybe_object; 5301 if (!maybe_object->To<HeapObject>(&object)) return maybe_object;
5297 } 5302 }
5298 object = EnsureDoubleAligned(this, object, size); 5303 object = EnsureDoubleAligned(this, object, size);
5299 HeapObject::cast(object)->set_map_no_write_barrier(constant_pool_array_map()); 5304 HeapObject::cast(object)->set_map_no_write_barrier(constant_pool_array_map());
5300 5305
5301 ConstantPoolArray* constant_pool = 5306 ConstantPoolArray* constant_pool =
5302 reinterpret_cast<ConstantPoolArray*>(object); 5307 reinterpret_cast<ConstantPoolArray*>(object);
5303 constant_pool->SetEntryCounts(number_of_int64_entries, 5308 constant_pool->SetEntryCounts(number_of_int64_entries,
5304 number_of_ptr_entries, 5309 number_of_code_ptr_entries,
5310 number_of_heap_ptr_entries,
5305 number_of_int32_entries); 5311 number_of_int32_entries);
5306 if (number_of_ptr_entries > 0) { 5312 if (number_of_code_ptr_entries > 0) {
5313 int offset =
5314 constant_pool->OffsetOfElementAt(constant_pool->first_code_ptr_index());
5307 MemsetPointer( 5315 MemsetPointer(
5308 HeapObject::RawField( 5316 reinterpret_cast<Address*>(HeapObject::RawField(constant_pool, offset)),
5309 constant_pool, 5317 isolate()->builtins()->builtin(Builtins::kIllegal)->entry(),
5310 constant_pool->OffsetOfElementAt(constant_pool->first_ptr_index())), 5318 number_of_code_ptr_entries);
5319 }
5320 if (number_of_heap_ptr_entries > 0) {
5321 int offset =
5322 constant_pool->OffsetOfElementAt(constant_pool->first_code_ptr_index());
5323 MemsetPointer(
5324 HeapObject::RawField(constant_pool, offset),
5311 undefined_value(), 5325 undefined_value(),
5312 number_of_ptr_entries); 5326 number_of_heap_ptr_entries);
5313 } 5327 }
5314 return constant_pool; 5328 return constant_pool;
5315 } 5329 }
5316 5330
5317 5331
5318 MaybeObject* Heap::AllocateEmptyConstantPoolArray() { 5332 MaybeObject* Heap::AllocateEmptyConstantPoolArray() {
5319 int size = ConstantPoolArray::SizeFor(0, 0, 0); 5333 int size = ConstantPoolArray::SizeFor(0, 0, 0, 0);
5320 Object* result; 5334 Object* result;
5321 { MaybeObject* maybe_result = 5335 { MaybeObject* maybe_result =
5322 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); 5336 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE);
5323 if (!maybe_result->ToObject(&result)) return maybe_result; 5337 if (!maybe_result->ToObject(&result)) return maybe_result;
5324 } 5338 }
5325 HeapObject::cast(result)->set_map_no_write_barrier(constant_pool_array_map()); 5339 HeapObject::cast(result)->set_map_no_write_barrier(constant_pool_array_map());
5326 ConstantPoolArray::cast(result)->SetEntryCounts(0, 0, 0); 5340 ConstantPoolArray::cast(result)->SetEntryCounts(0, 0, 0, 0);
5327 return result; 5341 return result;
5328 } 5342 }
5329 5343
5330 5344
5331 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) { 5345 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) {
5332 Object* result; 5346 Object* result;
5333 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure); 5347 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure);
5334 if (!maybe_result->ToObject(&result)) return maybe_result; 5348 if (!maybe_result->ToObject(&result)) return maybe_result;
5335 } 5349 }
5336 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier( 5350 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier(
(...skipping 2406 matching lines...) Expand 10 before | Expand all | Expand 10 after
7743 static_cast<int>(object_sizes_last_time_[index])); 7757 static_cast<int>(object_sizes_last_time_[index]));
7744 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 7758 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
7745 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7759 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7746 7760
7747 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7761 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7748 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7762 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7749 ClearObjectStats(); 7763 ClearObjectStats();
7750 } 7764 }
7751 7765
7752 } } // namespace v8::internal 7766 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/mark-compact.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698