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

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

Issue 11085070: Enable --verify-heap in release mode (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: A couple of verification functions weren't behind the new #define. Created 8 years, 2 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 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 667
668 bool Object::IsJSFunctionResultCache() { 668 bool Object::IsJSFunctionResultCache() {
669 if (!IsFixedArray()) return false; 669 if (!IsFixedArray()) return false;
670 FixedArray* self = FixedArray::cast(this); 670 FixedArray* self = FixedArray::cast(this);
671 int length = self->length(); 671 int length = self->length();
672 if (length < JSFunctionResultCache::kEntriesIndex) return false; 672 if (length < JSFunctionResultCache::kEntriesIndex) return false;
673 if ((length - JSFunctionResultCache::kEntriesIndex) 673 if ((length - JSFunctionResultCache::kEntriesIndex)
674 % JSFunctionResultCache::kEntrySize != 0) { 674 % JSFunctionResultCache::kEntrySize != 0) {
675 return false; 675 return false;
676 } 676 }
677 #ifdef DEBUG 677 #ifdef VERIFY_HEAP
678 if (FLAG_verify_heap) { 678 if (FLAG_verify_heap) {
679 reinterpret_cast<JSFunctionResultCache*>(this)-> 679 reinterpret_cast<JSFunctionResultCache*>(this)->
680 JSFunctionResultCacheVerify(); 680 JSFunctionResultCacheVerify();
681 } 681 }
682 #endif 682 #endif
683 return true; 683 return true;
684 } 684 }
685 685
686 686
687 bool Object::IsNormalizedMapCache() { 687 bool Object::IsNormalizedMapCache() {
688 if (!IsFixedArray()) return false; 688 if (!IsFixedArray()) return false;
689 if (FixedArray::cast(this)->length() != NormalizedMapCache::kEntries) { 689 if (FixedArray::cast(this)->length() != NormalizedMapCache::kEntries) {
690 return false; 690 return false;
691 } 691 }
692 #ifdef DEBUG 692 #ifdef VERIFY_HEAP
693 if (FLAG_verify_heap) { 693 if (FLAG_verify_heap) {
694 reinterpret_cast<NormalizedMapCache*>(this)->NormalizedMapCacheVerify(); 694 reinterpret_cast<NormalizedMapCache*>(this)->NormalizedMapCacheVerify();
695 } 695 }
696 #endif 696 #endif
697 return true; 697 return true;
698 } 698 }
699 699
700 700
701 bool Object::IsCompilationCacheTable() { 701 bool Object::IsCompilationCacheTable() {
702 return IsHashTable(); 702 return IsHashTable();
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 return MapWord(reinterpret_cast<uintptr_t>(raw)); 1103 return MapWord(reinterpret_cast<uintptr_t>(raw));
1104 } 1104 }
1105 1105
1106 1106
1107 HeapObject* MapWord::ToForwardingAddress() { 1107 HeapObject* MapWord::ToForwardingAddress() {
1108 ASSERT(IsForwardingAddress()); 1108 ASSERT(IsForwardingAddress());
1109 return HeapObject::FromAddress(reinterpret_cast<Address>(value_)); 1109 return HeapObject::FromAddress(reinterpret_cast<Address>(value_));
1110 } 1110 }
1111 1111
1112 1112
1113 #ifdef DEBUG 1113 #ifdef VERIFY_HEAP
1114 void HeapObject::VerifyObjectField(int offset) { 1114 void HeapObject::VerifyObjectField(int offset) {
1115 VerifyPointer(READ_FIELD(this, offset)); 1115 VerifyPointer(READ_FIELD(this, offset));
1116 } 1116 }
1117 1117
1118 void HeapObject::VerifySmiField(int offset) { 1118 void HeapObject::VerifySmiField(int offset) {
1119 ASSERT(READ_FIELD(this, offset)->IsSmi()); 1119 CHECK(READ_FIELD(this, offset)->IsSmi());
1120 } 1120 }
1121 #endif 1121 #endif
1122 1122
1123 1123
1124 Heap* HeapObject::GetHeap() { 1124 Heap* HeapObject::GetHeap() {
1125 Heap* heap = 1125 Heap* heap =
1126 MemoryChunk::FromAddress(reinterpret_cast<Address>(this))->heap(); 1126 MemoryChunk::FromAddress(reinterpret_cast<Address>(this))->heap();
1127 ASSERT(heap != NULL); 1127 ASSERT(heap != NULL);
1128 ASSERT(heap->isolate() == Isolate::Current()); 1128 ASSERT(heap->isolate() == Isolate::Current());
1129 return heap; 1129 return heap;
(...skipping 2491 matching lines...) Expand 10 before | Expand all | Expand 10 after
3621 SetNumberOfOwnDescriptors(len); 3621 SetNumberOfOwnDescriptors(len);
3622 return this; 3622 return this;
3623 } 3623 }
3624 3624
3625 3625
3626 SMI_ACCESSORS(Map, bit_field3, kBitField3Offset) 3626 SMI_ACCESSORS(Map, bit_field3, kBitField3Offset)
3627 3627
3628 3628
3629 void Map::ClearTransitions(Heap* heap, WriteBarrierMode mode) { 3629 void Map::ClearTransitions(Heap* heap, WriteBarrierMode mode) {
3630 Object* back_pointer = GetBackPointer(); 3630 Object* back_pointer = GetBackPointer();
3631 #ifdef DEBUG 3631
3632 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); 3632 if (Heap::ShouldZapGarbage()) {
Michael Starzinger 2012/10/12 10:53:16 Let's also use the following here, it's equivalent
mvstanton1 2012/10/12 11:16:27 Done.
3633 if (object->IsTransitionArray()) { 3633 Object* transitions = READ_FIELD(this, kTransitionsOrBackPointerOffset);
3634 ZapTransitions(); 3634 if (transitions->IsTransitionArray()) {
3635 } else { 3635 ZapTransitions();
3636 ASSERT(object->IsMap() || object->IsUndefined()); 3636 }
3637 } 3637 }
3638 #endif 3638
3639 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, back_pointer); 3639 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, back_pointer);
3640 CONDITIONAL_WRITE_BARRIER( 3640 CONDITIONAL_WRITE_BARRIER(
3641 heap, this, kTransitionsOrBackPointerOffset, back_pointer, mode); 3641 heap, this, kTransitionsOrBackPointerOffset, back_pointer, mode);
3642 } 3642 }
3643 3643
3644 3644
3645 void Map::AppendDescriptor(Descriptor* desc, 3645 void Map::AppendDescriptor(Descriptor* desc,
3646 const DescriptorArray::WhitenessWitness& witness) { 3646 const DescriptorArray::WhitenessWitness& witness) {
3647 DescriptorArray* descriptors = instance_descriptors(); 3647 DescriptorArray* descriptors = instance_descriptors();
3648 int number_of_own_descriptors = NumberOfOwnDescriptors(); 3648 int number_of_own_descriptors = NumberOfOwnDescriptors();
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
3750 3750
3751 TransitionArray* Map::transitions() { 3751 TransitionArray* Map::transitions() {
3752 ASSERT(HasTransitionArray()); 3752 ASSERT(HasTransitionArray());
3753 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); 3753 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset);
3754 return TransitionArray::cast(object); 3754 return TransitionArray::cast(object);
3755 } 3755 }
3756 3756
3757 3757
3758 void Map::set_transitions(TransitionArray* transition_array, 3758 void Map::set_transitions(TransitionArray* transition_array,
3759 WriteBarrierMode mode) { 3759 WriteBarrierMode mode) {
3760 #ifdef DEBUG 3760 // In release mode, only run this code if verify_heap is on.
3761 if (HasTransitionArray()) { 3761 if (Heap::ShouldZapGarbage() && HasTransitionArray()) {
3762 ASSERT(transitions() != transition_array); 3762 CHECK(transitions() != transition_array);
3763 ZapTransitions(); 3763 ZapTransitions();
3764 } 3764 }
3765 #endif
3766 3765
3767 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, transition_array); 3766 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, transition_array);
3768 CONDITIONAL_WRITE_BARRIER( 3767 CONDITIONAL_WRITE_BARRIER(
3769 GetHeap(), this, kTransitionsOrBackPointerOffset, transition_array, mode); 3768 GetHeap(), this, kTransitionsOrBackPointerOffset, transition_array, mode);
3770 } 3769 }
3771 3770
3772 3771
3773 void Map::init_back_pointer(Object* undefined) { 3772 void Map::init_back_pointer(Object* undefined) {
3774 ASSERT(undefined->IsUndefined()); 3773 ASSERT(undefined->IsUndefined());
3775 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, undefined); 3774 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, undefined);
(...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after
5544 #undef WRITE_UINT32_FIELD 5543 #undef WRITE_UINT32_FIELD
5545 #undef READ_SHORT_FIELD 5544 #undef READ_SHORT_FIELD
5546 #undef WRITE_SHORT_FIELD 5545 #undef WRITE_SHORT_FIELD
5547 #undef READ_BYTE_FIELD 5546 #undef READ_BYTE_FIELD
5548 #undef WRITE_BYTE_FIELD 5547 #undef WRITE_BYTE_FIELD
5549 5548
5550 5549
5551 } } // namespace v8::internal 5550 } } // namespace v8::internal
5552 5551
5553 #endif // V8_OBJECTS_INL_H_ 5552 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698