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(indexed_handles_); i++) { | |
1023 indexed_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(Get(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(*Get(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 for (int i = 0; i < kSize; i++) { | |
Michael Starzinger
2013/08/01 13:26:11
Use MemsetPointer() instead of the loop.
| |
1073 next_block[i] = the_hole; | |
1074 } | |
1075 blocks_.Add(next_block); | |
1076 } | |
1077 ASSERT_EQ(isolate->heap()->the_hole_value(), blocks_[block][offset]); | |
1078 blocks_[block][offset] = object; | |
1079 if (isolate->heap()->InNewSpace(object)) { | |
1080 new_space_indices_.Add(size_); | |
1081 } | |
1082 return size_++; | |
1083 } | |
1084 | |
1085 | |
1021 } } // namespace v8::internal | 1086 } } // namespace v8::internal |
OLD | NEW |