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

Side by Side Diff: src/heap.cc

Issue 209473006: Ensure that we don't mark weak heap references in the constant pool array. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix typo 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 | « no previous file | src/lithium-codegen.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 // 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 5280 matching lines...) Expand 10 before | Expand all | Expand 10 after
5291 return EnsureDoubleAligned(this, object, size); 5291 return EnsureDoubleAligned(this, object, size);
5292 } 5292 }
5293 5293
5294 5294
5295 MaybeObject* Heap::AllocateConstantPoolArray(int number_of_int64_entries, 5295 MaybeObject* Heap::AllocateConstantPoolArray(int number_of_int64_entries,
5296 int number_of_code_ptr_entries, 5296 int number_of_code_ptr_entries,
5297 int number_of_heap_ptr_entries, 5297 int number_of_heap_ptr_entries,
5298 int number_of_int32_entries) { 5298 int number_of_int32_entries) {
5299 ASSERT(number_of_int64_entries > 0 || number_of_code_ptr_entries > 0 || 5299 ASSERT(number_of_int64_entries > 0 || number_of_code_ptr_entries > 0 ||
5300 number_of_heap_ptr_entries > 0 || number_of_int32_entries > 0); 5300 number_of_heap_ptr_entries > 0 || number_of_int32_entries > 0);
5301
5302 if (number_of_int64_entries < 0 ||
5303 number_of_int64_entries > ConstantPoolArray::kMaxEntriesPerType ||
5304 number_of_code_ptr_entries < 0 ||
5305 number_of_code_ptr_entries > ConstantPoolArray::kMaxEntriesPerType ||
5306 number_of_heap_ptr_entries < 0 ||
5307 number_of_heap_ptr_entries > ConstantPoolArray::kMaxEntriesPerType ||
5308 number_of_int32_entries < 0 ||
5309 number_of_int32_entries > ConstantPoolArray::kMaxEntriesPerType) {
5310 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true);
ulan 2014/04/07 14:14:40 Let's use ASSERT or CHECK instead of FatalProcessO
rmcilroy 2014/04/07 14:23:12 I was following what AllocateRawFixedArray does wi
ulan 2014/04/07 14:52:01 I would use CHECK in AllocateRawFixedArray too, bu
rmcilroy 2014/04/07 20:19:17 Sounds good - done.
5311 }
5301 int size = ConstantPoolArray::SizeFor(number_of_int64_entries, 5312 int size = ConstantPoolArray::SizeFor(number_of_int64_entries,
5302 number_of_code_ptr_entries, 5313 number_of_code_ptr_entries,
5303 number_of_heap_ptr_entries, 5314 number_of_heap_ptr_entries,
5304 number_of_int32_entries); 5315 number_of_int32_entries);
5305 #ifndef V8_HOST_ARCH_64_BIT 5316 #ifndef V8_HOST_ARCH_64_BIT
5306 size += kPointerSize; 5317 size += kPointerSize;
5307 #endif 5318 #endif
5308 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED); 5319 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED);
5309 5320
5310 HeapObject* object; 5321 HeapObject* object;
5311 { MaybeObject* maybe_object = AllocateRaw(size, space, OLD_POINTER_SPACE); 5322 { MaybeObject* maybe_object = AllocateRaw(size, space, OLD_POINTER_SPACE);
5312 if (!maybe_object->To<HeapObject>(&object)) return maybe_object; 5323 if (!maybe_object->To<HeapObject>(&object)) return maybe_object;
5313 } 5324 }
5314 object = EnsureDoubleAligned(this, object, size); 5325 object = EnsureDoubleAligned(this, object, size);
5315 HeapObject::cast(object)->set_map_no_write_barrier(constant_pool_array_map()); 5326 HeapObject::cast(object)->set_map_no_write_barrier(constant_pool_array_map());
5316 5327
5317 ConstantPoolArray* constant_pool = 5328 ConstantPoolArray* constant_pool =
5318 reinterpret_cast<ConstantPoolArray*>(object); 5329 reinterpret_cast<ConstantPoolArray*>(object);
5319 constant_pool->SetEntryCounts(number_of_int64_entries, 5330 constant_pool->Init(number_of_int64_entries,
5320 number_of_code_ptr_entries, 5331 number_of_code_ptr_entries,
5321 number_of_heap_ptr_entries, 5332 number_of_heap_ptr_entries,
5322 number_of_int32_entries); 5333 number_of_int32_entries);
5323 if (number_of_code_ptr_entries > 0) { 5334 if (number_of_code_ptr_entries > 0) {
5324 int offset = 5335 int offset =
5325 constant_pool->OffsetOfElementAt(constant_pool->first_code_ptr_index()); 5336 constant_pool->OffsetOfElementAt(constant_pool->first_code_ptr_index());
5326 MemsetPointer( 5337 MemsetPointer(
5327 reinterpret_cast<Address*>(HeapObject::RawField(constant_pool, offset)), 5338 reinterpret_cast<Address*>(HeapObject::RawField(constant_pool, offset)),
5328 isolate()->builtins()->builtin(Builtins::kIllegal)->entry(), 5339 isolate()->builtins()->builtin(Builtins::kIllegal)->entry(),
5329 number_of_code_ptr_entries); 5340 number_of_code_ptr_entries);
5330 } 5341 }
5331 if (number_of_heap_ptr_entries > 0) { 5342 if (number_of_heap_ptr_entries > 0) {
5332 int offset = 5343 int offset =
5333 constant_pool->OffsetOfElementAt(constant_pool->first_heap_ptr_index()); 5344 constant_pool->OffsetOfElementAt(constant_pool->first_heap_ptr_index());
5334 MemsetPointer( 5345 MemsetPointer(
5335 HeapObject::RawField(constant_pool, offset), 5346 HeapObject::RawField(constant_pool, offset),
5336 undefined_value(), 5347 undefined_value(),
5337 number_of_heap_ptr_entries); 5348 number_of_heap_ptr_entries);
5338 } 5349 }
5339 return constant_pool; 5350 return constant_pool;
5340 } 5351 }
5341 5352
5342 5353
5343 MaybeObject* Heap::AllocateEmptyConstantPoolArray() { 5354 MaybeObject* Heap::AllocateEmptyConstantPoolArray() {
5344 int size = ConstantPoolArray::SizeFor(0, 0, 0, 0); 5355 int size = ConstantPoolArray::SizeFor(0, 0, 0, 0);
5345 Object* result; 5356 Object* result;
5346 { MaybeObject* maybe_result = 5357 { MaybeObject* maybe_result =
5347 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); 5358 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE);
5348 if (!maybe_result->ToObject(&result)) return maybe_result; 5359 if (!maybe_result->ToObject(&result)) return maybe_result;
5349 } 5360 }
5350 HeapObject::cast(result)->set_map_no_write_barrier(constant_pool_array_map()); 5361 HeapObject::cast(result)->set_map_no_write_barrier(constant_pool_array_map());
5351 ConstantPoolArray::cast(result)->SetEntryCounts(0, 0, 0, 0); 5362 ConstantPoolArray::cast(result)->Init(0, 0, 0, 0);
5352 return result; 5363 return result;
5353 } 5364 }
5354 5365
5355 5366
5356 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) { 5367 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) {
5357 Object* result; 5368 Object* result;
5358 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure); 5369 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure);
5359 if (!maybe_result->ToObject(&result)) return maybe_result; 5370 if (!maybe_result->ToObject(&result)) return maybe_result;
5360 } 5371 }
5361 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier( 5372 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier(
(...skipping 2352 matching lines...) Expand 10 before | Expand all | Expand 10 after
7714 static_cast<int>(object_sizes_last_time_[index])); 7725 static_cast<int>(object_sizes_last_time_[index]));
7715 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 7726 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
7716 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7727 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7717 7728
7718 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7729 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7719 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7730 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7720 ClearObjectStats(); 7731 ClearObjectStats();
7721 } 7732 }
7722 7733
7723 } } // namespace v8::internal 7734 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/lithium-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698