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

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

Issue 5736008: Provide baseline for experimental GC implementation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 10 years 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
« src/globals.h ('K') | « src/objects.h ('k') | src/spaces.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 #define READ_FIELD(p, offset) \ 788 #define READ_FIELD(p, offset) \
789 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset))) 789 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)))
790 790
791 #define WRITE_FIELD(p, offset, value) \ 791 #define WRITE_FIELD(p, offset, value) \
792 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)) = value) 792 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)) = value)
793 793
794 794
795 #define WRITE_BARRIER(object, offset) \ 795 #define WRITE_BARRIER(object, offset) \
796 Heap::RecordWrite(object->address(), offset); 796 Heap::RecordWrite(object->address(), offset);
797 797
798 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER
798 // CONDITIONAL_WRITE_BARRIER must be issued after the actual 799 // CONDITIONAL_WRITE_BARRIER must be issued after the actual
799 // write due to the assert validating the written value. 800 // write due to the assert validating the written value.
800 #define CONDITIONAL_WRITE_BARRIER(object, offset, mode) \ 801 #define CONDITIONAL_WRITE_BARRIER(object, offset, mode) \
801 if (mode == UPDATE_WRITE_BARRIER) { \ 802 if (mode == UPDATE_WRITE_BARRIER) { \
802 Heap::RecordWrite(object->address(), offset); \ 803 Heap::RecordWrite(object->address(), offset); \
803 } else { \ 804 } else { \
804 ASSERT(mode == SKIP_WRITE_BARRIER); \ 805 ASSERT(mode == SKIP_WRITE_BARRIER); \
805 ASSERT(Heap::InNewSpace(object) || \ 806 ASSERT(Heap::InNewSpace(object) || \
806 !Heap::InNewSpace(READ_FIELD(object, offset)) || \ 807 !Heap::InNewSpace(READ_FIELD(object, offset)) || \
807 Page::FromAddress(object->address())-> \ 808 Page::FromAddress(object->address())-> \
808 IsRegionDirty(object->address() + offset)); \ 809 IsRegionDirty(object->address() + offset)); \
809 } 810 }
811 #else
812 #define CONDITIONAL_WRITE_BARRIER(object, offset, mode)
813 #endif
810 814
811 #define READ_DOUBLE_FIELD(p, offset) \ 815 #define READ_DOUBLE_FIELD(p, offset) \
812 (*reinterpret_cast<double*>(FIELD_ADDR(p, offset))) 816 (*reinterpret_cast<double*>(FIELD_ADDR(p, offset)))
813 817
814 #define WRITE_DOUBLE_FIELD(p, offset, value) \ 818 #define WRITE_DOUBLE_FIELD(p, offset, value) \
815 (*reinterpret_cast<double*>(FIELD_ADDR(p, offset)) = value) 819 (*reinterpret_cast<double*>(FIELD_ADDR(p, offset)) = value)
816 820
817 #define READ_INT_FIELD(p, offset) \ 821 #define READ_INT_FIELD(p, offset) \
818 (*reinterpret_cast<int*>(FIELD_ADDR(p, offset))) 822 (*reinterpret_cast<int*>(FIELD_ADDR(p, offset)))
819 823
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 void MapWord::SetOverflow() { 1014 void MapWord::SetOverflow() {
1011 value_ |= kOverflowMask; 1015 value_ |= kOverflowMask;
1012 } 1016 }
1013 1017
1014 1018
1015 void MapWord::ClearOverflow() { 1019 void MapWord::ClearOverflow() {
1016 value_ &= ~kOverflowMask; 1020 value_ &= ~kOverflowMask;
1017 } 1021 }
1018 1022
1019 1023
1020 MapWord MapWord::EncodeAddress(Address map_address, int offset) {
1021 // Offset is the distance in live bytes from the first live object in the
1022 // same page. The offset between two objects in the same page should not
1023 // exceed the object area size of a page.
1024 ASSERT(0 <= offset && offset < Page::kObjectAreaSize);
1025
1026 uintptr_t compact_offset = offset >> kObjectAlignmentBits;
1027 ASSERT(compact_offset < (1 << kForwardingOffsetBits));
1028
1029 Page* map_page = Page::FromAddress(map_address);
1030 ASSERT_MAP_PAGE_INDEX(map_page->mc_page_index);
1031
1032 uintptr_t map_page_offset =
1033 map_page->Offset(map_address) >> kMapAlignmentBits;
1034
1035 uintptr_t encoding =
1036 (compact_offset << kForwardingOffsetShift) |
1037 (map_page_offset << kMapPageOffsetShift) |
1038 (map_page->mc_page_index << kMapPageIndexShift);
1039 return MapWord(encoding);
1040 }
1041
1042
1043 Address MapWord::DecodeMapAddress(MapSpace* map_space) {
1044 int map_page_index =
1045 static_cast<int>((value_ & kMapPageIndexMask) >> kMapPageIndexShift);
1046 ASSERT_MAP_PAGE_INDEX(map_page_index);
1047
1048 int map_page_offset = static_cast<int>(
1049 ((value_ & kMapPageOffsetMask) >> kMapPageOffsetShift) <<
1050 kMapAlignmentBits);
1051
1052 return (map_space->PageAddress(map_page_index) + map_page_offset);
1053 }
1054
1055
1056 int MapWord::DecodeOffset() {
1057 // The offset field is represented in the kForwardingOffsetBits
1058 // most-significant bits.
1059 uintptr_t offset = (value_ >> kForwardingOffsetShift) << kObjectAlignmentBits;
1060 ASSERT(offset < static_cast<uintptr_t>(Page::kObjectAreaSize));
1061 return static_cast<int>(offset);
1062 }
1063
1064
1065 MapWord MapWord::FromEncodedAddress(Address address) {
1066 return MapWord(reinterpret_cast<uintptr_t>(address));
1067 }
1068
1069
1070 Address MapWord::ToEncodedAddress() {
1071 return reinterpret_cast<Address>(value_);
1072 }
1073
1074
1075 #ifdef DEBUG 1024 #ifdef DEBUG
1076 void HeapObject::VerifyObjectField(int offset) { 1025 void HeapObject::VerifyObjectField(int offset) {
1077 VerifyPointer(READ_FIELD(this, offset)); 1026 VerifyPointer(READ_FIELD(this, offset));
1078 } 1027 }
1079 1028
1080 void HeapObject::VerifySmiField(int offset) { 1029 void HeapObject::VerifySmiField(int offset) {
1081 ASSERT(READ_FIELD(this, offset)->IsSmi()); 1030 ASSERT(READ_FIELD(this, offset)->IsSmi());
1082 } 1031 }
1083 #endif 1032 #endif
1084 1033
(...skipping 2767 matching lines...) Expand 10 before | Expand all | Expand 10 after
3852 #undef WRITE_INT_FIELD 3801 #undef WRITE_INT_FIELD
3853 #undef READ_SHORT_FIELD 3802 #undef READ_SHORT_FIELD
3854 #undef WRITE_SHORT_FIELD 3803 #undef WRITE_SHORT_FIELD
3855 #undef READ_BYTE_FIELD 3804 #undef READ_BYTE_FIELD
3856 #undef WRITE_BYTE_FIELD 3805 #undef WRITE_BYTE_FIELD
3857 3806
3858 3807
3859 } } // namespace v8::internal 3808 } } // namespace v8::internal
3860 3809
3861 #endif // V8_OBJECTS_INL_H_ 3810 #endif // V8_OBJECTS_INL_H_
OLDNEW
« src/globals.h ('K') | « src/objects.h ('k') | src/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698