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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 ASSERT(OFFSET_OF(Node, object_) == 0); | 64 ASSERT(OFFSET_OF(Node, object_) == 0); |
65 return reinterpret_cast<Node*>(location); | 65 return reinterpret_cast<Node*>(location); |
66 } | 66 } |
67 | 67 |
68 Node() { | 68 Node() { |
69 ASSERT(OFFSET_OF(Node, class_id_) == Internals::kNodeClassIdOffset); | 69 ASSERT(OFFSET_OF(Node, class_id_) == Internals::kNodeClassIdOffset); |
70 ASSERT(OFFSET_OF(Node, flags_) == Internals::kNodeFlagsOffset); | 70 ASSERT(OFFSET_OF(Node, flags_) == Internals::kNodeFlagsOffset); |
71 STATIC_ASSERT(static_cast<int>(NodeState::kMask) == | 71 STATIC_ASSERT(static_cast<int>(NodeState::kMask) == |
72 Internals::kNodeStateMask); | 72 Internals::kNodeStateMask); |
73 STATIC_ASSERT(WEAK == Internals::kNodeStateIsWeakValue); | 73 STATIC_ASSERT(WEAK == Internals::kNodeStateIsWeakValue); |
74 STATIC_ASSERT(PENDING == Internals::kNodeStateIsPendingValue); | |
75 STATIC_ASSERT(NEAR_DEATH == Internals::kNodeStateIsNearDeathValue); | 74 STATIC_ASSERT(NEAR_DEATH == Internals::kNodeStateIsNearDeathValue); |
76 STATIC_ASSERT(static_cast<int>(IsIndependent::kShift) == | 75 STATIC_ASSERT(static_cast<int>(IsIndependent::kShift) == |
77 Internals::kNodeIsIndependentShift); | 76 Internals::kNodeIsIndependentShift); |
78 STATIC_ASSERT(static_cast<int>(IsPartiallyDependent::kShift) == | 77 STATIC_ASSERT(static_cast<int>(IsPartiallyDependent::kShift) == |
79 Internals::kNodeIsPartiallyDependentShift); | 78 Internals::kNodeIsPartiallyDependentShift); |
80 } | 79 } |
81 | 80 |
82 #ifdef ENABLE_EXTRA_CHECKS | 81 #ifdef ENABLE_EXTRA_CHECKS |
83 ~Node() { | 82 ~Node() { |
84 // TODO(1428): if it's a weak handle we should have invoked its callback. | 83 // TODO(1428): if it's a weak handle we should have invoked its callback. |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 } | 1011 } |
1013 } | 1012 } |
1014 } | 1013 } |
1015 object_group_connections_.Clear(); | 1014 object_group_connections_.Clear(); |
1016 object_group_connections_.Initialize(kObjectGroupConnectionsCapacity); | 1015 object_group_connections_.Initialize(kObjectGroupConnectionsCapacity); |
1017 retainer_infos_.Clear(); | 1016 retainer_infos_.Clear(); |
1018 implicit_ref_connections_.Clear(); | 1017 implicit_ref_connections_.Clear(); |
1019 } | 1018 } |
1020 | 1019 |
1021 | 1020 |
1022 EternalHandles::EternalHandles() : size_(0) { | |
1023 STATIC_ASSERT(v8::kUninitializedEternalIndex == kInvalidIndex); | |
1024 for (unsigned i = 0; i < ARRAY_SIZE(singleton_handles_); i++) { | |
1025 singleton_handles_[i] = kInvalidIndex; | |
1026 } | |
1027 } | |
1028 | |
1029 | |
1030 EternalHandles::~EternalHandles() { | |
1031 for (int i = 0; i < blocks_.length(); i++) delete[] blocks_[i]; | |
1032 } | |
1033 | |
1034 | |
1035 void EternalHandles::IterateAllRoots(ObjectVisitor* visitor) { | |
1036 int limit = size_; | |
1037 for (int i = 0; i < blocks_.length(); i++) { | |
1038 ASSERT(limit > 0); | |
1039 Object** block = blocks_[i]; | |
1040 visitor->VisitPointers(block, block + Min(limit, kSize)); | |
1041 limit -= kSize; | |
1042 } | |
1043 } | |
1044 | |
1045 | |
1046 void EternalHandles::IterateNewSpaceRoots(ObjectVisitor* visitor) { | |
1047 for (int i = 0; i < new_space_indices_.length(); i++) { | |
1048 visitor->VisitPointer(GetLocation(new_space_indices_[i])); | |
1049 } | |
1050 } | |
1051 | |
1052 | |
1053 void EternalHandles::PostGarbageCollectionProcessing(Heap* heap) { | |
1054 int last = 0; | |
1055 for (int i = 0; i < new_space_indices_.length(); i++) { | |
1056 int index = new_space_indices_[i]; | |
1057 if (heap->InNewSpace(*GetLocation(index))) { | |
1058 new_space_indices_[last++] = index; | |
1059 } | |
1060 } | |
1061 new_space_indices_.Rewind(last); | |
1062 } | |
1063 | |
1064 | |
1065 int EternalHandles::Create(Isolate* isolate, Object* object) { | |
1066 if (object == NULL) return kInvalidIndex; | |
1067 ASSERT_NE(isolate->heap()->the_hole_value(), object); | |
1068 int block = size_ >> kShift; | |
1069 int offset = size_ & kMask; | |
1070 // need to resize | |
1071 if (offset == 0) { | |
1072 Object** next_block = new Object*[kSize]; | |
1073 Object* the_hole = isolate->heap()->the_hole_value(); | |
1074 MemsetPointer(next_block, the_hole, kSize); | |
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 | |
1086 } } // namespace v8::internal | 1021 } } // namespace v8::internal |
OLD | NEW |