OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/global-handles.h" | 5 #include "src/global-handles.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/cancelable-task.h" | 8 #include "src/cancelable-task.h" |
9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 void GlobalHandles::IterateAllRoots(ObjectVisitor* v) { | 942 void GlobalHandles::IterateAllRoots(ObjectVisitor* v) { |
943 for (NodeIterator it(this); !it.done(); it.Advance()) { | 943 for (NodeIterator it(this); !it.done(); it.Advance()) { |
944 if (it.node()->IsRetainer()) { | 944 if (it.node()->IsRetainer()) { |
945 v->VisitPointer(it.node()->location()); | 945 v->VisitPointer(it.node()->location()); |
946 } | 946 } |
947 } | 947 } |
948 } | 948 } |
949 | 949 |
950 | 950 |
951 DISABLE_CFI_PERF | 951 DISABLE_CFI_PERF |
952 void GlobalHandles::IterateAllRootsWithClassIds(ObjectVisitor* v) { | 952 void GlobalHandles::ApplyPersistentHandleVisitor( |
| 953 v8::PersistentHandleVisitor* visitor, GlobalHandles::Node* node) { |
| 954 v8::Value* value = ToApi<v8::Value>(Handle<Object>(node->location())); |
| 955 visitor->VisitPersistentHandle( |
| 956 reinterpret_cast<v8::Persistent<v8::Value>*>(&value), |
| 957 node->wrapper_class_id()); |
| 958 } |
| 959 |
| 960 DISABLE_CFI_PERF |
| 961 void GlobalHandles::IterateAllRootsWithClassIds( |
| 962 v8::PersistentHandleVisitor* visitor) { |
953 for (NodeIterator it(this); !it.done(); it.Advance()) { | 963 for (NodeIterator it(this); !it.done(); it.Advance()) { |
954 if (it.node()->IsRetainer() && it.node()->has_wrapper_class_id()) { | 964 if (it.node()->IsRetainer() && it.node()->has_wrapper_class_id()) { |
955 v->VisitEmbedderReference(it.node()->location(), | 965 ApplyPersistentHandleVisitor(visitor, it.node()); |
956 it.node()->wrapper_class_id()); | |
957 } | 966 } |
958 } | 967 } |
959 } | 968 } |
960 | 969 |
961 | 970 |
962 DISABLE_CFI_PERF | 971 DISABLE_CFI_PERF |
963 void GlobalHandles::IterateAllRootsInNewSpaceWithClassIds(ObjectVisitor* v) { | 972 void GlobalHandles::IterateAllRootsInNewSpaceWithClassIds( |
| 973 v8::PersistentHandleVisitor* visitor) { |
964 for (int i = 0; i < new_space_nodes_.length(); ++i) { | 974 for (int i = 0; i < new_space_nodes_.length(); ++i) { |
965 Node* node = new_space_nodes_[i]; | 975 Node* node = new_space_nodes_[i]; |
966 if (node->IsRetainer() && node->has_wrapper_class_id()) { | 976 if (node->IsRetainer() && node->has_wrapper_class_id()) { |
967 v->VisitEmbedderReference(node->location(), | 977 ApplyPersistentHandleVisitor(visitor, node); |
968 node->wrapper_class_id()); | |
969 } | 978 } |
970 } | 979 } |
971 } | 980 } |
972 | 981 |
973 | 982 |
974 DISABLE_CFI_PERF | 983 DISABLE_CFI_PERF |
975 void GlobalHandles::IterateWeakRootsInNewSpaceWithClassIds(ObjectVisitor* v) { | 984 void GlobalHandles::IterateWeakRootsInNewSpaceWithClassIds( |
| 985 v8::PersistentHandleVisitor* visitor) { |
976 for (int i = 0; i < new_space_nodes_.length(); ++i) { | 986 for (int i = 0; i < new_space_nodes_.length(); ++i) { |
977 Node* node = new_space_nodes_[i]; | 987 Node* node = new_space_nodes_[i]; |
978 if (node->has_wrapper_class_id() && node->IsWeak()) { | 988 if (node->has_wrapper_class_id() && node->IsWeak()) { |
979 v->VisitEmbedderReference(node->location(), node->wrapper_class_id()); | 989 ApplyPersistentHandleVisitor(visitor, node); |
980 } | 990 } |
981 } | 991 } |
982 } | 992 } |
983 | 993 |
984 | 994 |
985 int GlobalHandles::NumberOfWeakHandles() { | 995 int GlobalHandles::NumberOfWeakHandles() { |
986 int count = 0; | 996 int count = 0; |
987 for (NodeIterator it(this); !it.done(); it.Advance()) { | 997 for (NodeIterator it(this); !it.done(); it.Advance()) { |
988 if (it.node()->IsWeakRetainer()) { | 998 if (it.node()->IsWeakRetainer()) { |
989 count++; | 999 count++; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 blocks_[block][offset] = object; | 1137 blocks_[block][offset] = object; |
1128 if (isolate->heap()->InNewSpace(object)) { | 1138 if (isolate->heap()->InNewSpace(object)) { |
1129 new_space_indices_.Add(size_); | 1139 new_space_indices_.Add(size_); |
1130 } | 1140 } |
1131 *index = size_++; | 1141 *index = size_++; |
1132 } | 1142 } |
1133 | 1143 |
1134 | 1144 |
1135 } // namespace internal | 1145 } // namespace internal |
1136 } // namespace v8 | 1146 } // namespace v8 |
OLD | NEW |