OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 } | 1011 } |
1012 } | 1012 } |
1013 } | 1013 } |
1014 object_group_connections_.Clear(); | 1014 object_group_connections_.Clear(); |
1015 object_group_connections_.Initialize(kObjectGroupConnectionsCapacity); | 1015 object_group_connections_.Initialize(kObjectGroupConnectionsCapacity); |
1016 retainer_infos_.Clear(); | 1016 retainer_infos_.Clear(); |
1017 implicit_ref_connections_.Clear(); | 1017 implicit_ref_connections_.Clear(); |
1018 } | 1018 } |
1019 | 1019 |
1020 | 1020 |
| 1021 EternalHandles::EternalHandles() : size_(0) { |
| 1022 for (unsigned i = 0; i < ARRAY_SIZE(singleton_handles_); i++) { |
| 1023 singleton_handles_[i] = kInvalidIndex; |
| 1024 } |
| 1025 } |
| 1026 |
| 1027 |
| 1028 EternalHandles::~EternalHandles() { |
| 1029 for (int i = 0; i < blocks_.length(); i++) delete blocks_[i]; |
| 1030 } |
| 1031 |
| 1032 |
| 1033 void EternalHandles::IterateAllRoots(ObjectVisitor* visitor) { |
| 1034 int limit = size_; |
| 1035 for (int i = 0; i < blocks_.length(); i++) { |
| 1036 ASSERT(limit > 0); |
| 1037 Object** block = blocks_[i]; |
| 1038 visitor->VisitPointers(block, block + Min(limit, kSize)); |
| 1039 limit -= kSize; |
| 1040 } |
| 1041 } |
| 1042 |
| 1043 |
| 1044 void EternalHandles::IterateNewSpaceRoots(ObjectVisitor* visitor) { |
| 1045 for (int i = 0; i < new_space_indices_.length(); i++) { |
| 1046 visitor->VisitPointer(GetLocation(new_space_indices_[i])); |
| 1047 } |
| 1048 } |
| 1049 |
| 1050 |
| 1051 void EternalHandles::PostGarbageCollectionProcessing(Heap* heap) { |
| 1052 int last = 0; |
| 1053 for (int i = 0; i < new_space_indices_.length(); i++) { |
| 1054 int index = new_space_indices_[i]; |
| 1055 if (heap->InNewSpace(*GetLocation(index))) { |
| 1056 new_space_indices_[last++] = index; |
| 1057 } |
| 1058 } |
| 1059 new_space_indices_.Rewind(last); |
| 1060 } |
| 1061 |
| 1062 |
| 1063 int EternalHandles::Create(Isolate* isolate, Object* object) { |
| 1064 if (object == NULL) return kInvalidIndex; |
| 1065 ASSERT_NE(isolate->heap()->the_hole_value(), object); |
| 1066 int block = size_ >> kShift; |
| 1067 int offset = size_ & kMask; |
| 1068 // need to resize |
| 1069 if (offset == 0) { |
| 1070 Object** next_block = new Object*[kSize]; |
| 1071 Object* the_hole = isolate->heap()->the_hole_value(); |
| 1072 MemsetPointer(next_block, the_hole, kSize); |
| 1073 blocks_.Add(next_block); |
| 1074 } |
| 1075 ASSERT_EQ(isolate->heap()->the_hole_value(), blocks_[block][offset]); |
| 1076 blocks_[block][offset] = object; |
| 1077 if (isolate->heap()->InNewSpace(object)) { |
| 1078 new_space_indices_.Add(size_); |
| 1079 } |
| 1080 return size_++; |
| 1081 } |
| 1082 |
| 1083 |
1021 } } // namespace v8::internal | 1084 } } // namespace v8::internal |
OLD | NEW |