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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/global-handles.h" | 8 #include "src/global-handles.h" |
9 | 9 |
10 #include "src/vm-state-inl.h" | 10 #include "src/vm-state-inl.h" |
(...skipping 15 matching lines...) Loading... | |
26 | 26 |
27 class GlobalHandles::Node { | 27 class GlobalHandles::Node { |
28 public: | 28 public: |
29 // State transition diagram: | 29 // State transition diagram: |
30 // FREE -> NORMAL <-> WEAK -> PENDING -> NEAR_DEATH -> { NORMAL, WEAK, FREE } | 30 // FREE -> NORMAL <-> WEAK -> PENDING -> NEAR_DEATH -> { NORMAL, WEAK, FREE } |
31 enum State { | 31 enum State { |
32 FREE = 0, | 32 FREE = 0, |
33 NORMAL, // Normal global handle. | 33 NORMAL, // Normal global handle. |
34 WEAK, // Flagged as weak but not yet finalized. | 34 WEAK, // Flagged as weak but not yet finalized. |
35 PENDING, // Has been recognized as only reachable by weak handles. | 35 PENDING, // Has been recognized as only reachable by weak handles. |
36 NEAR_DEATH // Callback has informed the handle is near death. | 36 NEAR_DEATH, // Callback has informed the handle is near death. |
37 NUMBER_OF_NODE_STATES | |
38 }; | |
39 | |
40 enum WeaknessType { | |
41 NORMAL_WEAK, // Embedder gets a handle to the dying object. | |
42 PHANTOM_WEAK, // Embedder gets the parameter they passed in earlier. | |
43 INTERNAL_FIELDS_WEAK // Embedded gets 1 or 2 internal fields from dying obj ect. | |
37 }; | 44 }; |
38 | 45 |
39 // Maps handle location (slot) to the containing node. | 46 // Maps handle location (slot) to the containing node. |
40 static Node* FromLocation(Object** location) { | 47 static Node* FromLocation(Object** location) { |
41 DCHECK(OFFSET_OF(Node, object_) == 0); | 48 DCHECK(OFFSET_OF(Node, object_) == 0); |
42 return reinterpret_cast<Node*>(location); | 49 return reinterpret_cast<Node*>(location); |
43 } | 50 } |
44 | 51 |
45 Node() { | 52 Node() { |
46 DCHECK(OFFSET_OF(Node, class_id_) == Internals::kNodeClassIdOffset); | 53 DCHECK(OFFSET_OF(Node, class_id_) == Internals::kNodeClassIdOffset); |
(...skipping 38 matching lines...) Loading... | |
85 object_ = object; | 92 object_ = object; |
86 class_id_ = v8::HeapProfiler::kPersistentHandleNoClassId; | 93 class_id_ = v8::HeapProfiler::kPersistentHandleNoClassId; |
87 set_independent(false); | 94 set_independent(false); |
88 set_partially_dependent(false); | 95 set_partially_dependent(false); |
89 set_state(NORMAL); | 96 set_state(NORMAL); |
90 parameter_or_next_free_.parameter = NULL; | 97 parameter_or_next_free_.parameter = NULL; |
91 weak_callback_ = NULL; | 98 weak_callback_ = NULL; |
92 IncreaseBlockUses(); | 99 IncreaseBlockUses(); |
93 } | 100 } |
94 | 101 |
102 void Zap() { | |
103 DCHECK(state() != FREE); | |
104 // Zap the values for eager trapping. | |
105 object_ = reinterpret_cast<Object*>(kGlobalHandleZapValue); | |
106 } | |
107 | |
95 void Release() { | 108 void Release() { |
96 DCHECK(state() != FREE); | 109 DCHECK(state() != FREE); |
97 set_state(FREE); | 110 set_state(FREE); |
98 // Zap the values for eager trapping. | 111 // Zap the values for eager trapping. |
99 object_ = reinterpret_cast<Object*>(kGlobalHandleZapValue); | 112 object_ = reinterpret_cast<Object*>(kGlobalHandleZapValue); |
100 class_id_ = v8::HeapProfiler::kPersistentHandleNoClassId; | 113 class_id_ = v8::HeapProfiler::kPersistentHandleNoClassId; |
101 set_independent(false); | 114 set_independent(false); |
102 set_partially_dependent(false); | 115 set_partially_dependent(false); |
103 weak_callback_ = NULL; | 116 weak_callback_ = NULL; |
104 DecreaseBlockUses(); | 117 DecreaseBlockUses(); |
(...skipping 34 matching lines...) Loading... | |
139 flags_ = IsPartiallyDependent::update(flags_, v); | 152 flags_ = IsPartiallyDependent::update(flags_, v); |
140 } | 153 } |
141 | 154 |
142 bool is_in_new_space_list() { | 155 bool is_in_new_space_list() { |
143 return IsInNewSpaceList::decode(flags_); | 156 return IsInNewSpaceList::decode(flags_); |
144 } | 157 } |
145 void set_in_new_space_list(bool v) { | 158 void set_in_new_space_list(bool v) { |
146 flags_ = IsInNewSpaceList::update(flags_, v); | 159 flags_ = IsInNewSpaceList::update(flags_, v); |
147 } | 160 } |
148 | 161 |
149 bool is_zapped_during_weak_callback() { | 162 WeaknessType weakness_type() const { |
150 return IsZappedDuringWeakCallback::decode(flags_); | 163 return NodeWeaknessType::decode(flags_); |
151 } | 164 } |
152 void set_is_zapped_during_weak_callback(bool v) { | 165 void set_weakness_type(WeaknessType t) { |
153 flags_ = IsZappedDuringWeakCallback::update(flags_, v); | 166 flags_ = NodeWeaknessType::update(flags_, t); |
154 } | 167 } |
155 | 168 |
156 bool IsNearDeath() const { | 169 bool IsNearDeath() const { |
157 // Check for PENDING to ensure correct answer when processing callbacks. | 170 // Check for PENDING to ensure correct answer when processing callbacks. |
158 return state() == PENDING || state() == NEAR_DEATH; | 171 return state() == PENDING || state() == NEAR_DEATH; |
159 } | 172 } |
160 | 173 |
161 bool IsWeak() const { return state() == WEAK; } | 174 bool IsWeak() const { return state() == WEAK; } |
162 | 175 |
163 bool IsRetainer() const { return state() != FREE; } | 176 bool IsRetainer() const { return state() != FREE; } |
(...skipping 23 matching lines...) Loading... | |
187 } | 200 } |
188 void clear_partially_dependent() { set_partially_dependent(false); } | 201 void clear_partially_dependent() { set_partially_dependent(false); } |
189 | 202 |
190 // Callback accessor. | 203 // Callback accessor. |
191 // TODO(svenpanne) Re-enable or nuke later. | 204 // TODO(svenpanne) Re-enable or nuke later. |
192 // WeakReferenceCallback callback() { return callback_; } | 205 // WeakReferenceCallback callback() { return callback_; } |
193 | 206 |
194 // Callback parameter accessors. | 207 // Callback parameter accessors. |
195 void set_parameter(void* parameter) { | 208 void set_parameter(void* parameter) { |
196 DCHECK(state() != FREE); | 209 DCHECK(state() != FREE); |
210 DCHECK(weakness_type() == NORMAL_WEAK || weakness_type() == PHANTOM_WEAK); | |
197 parameter_or_next_free_.parameter = parameter; | 211 parameter_or_next_free_.parameter = parameter; |
198 } | 212 } |
199 void* parameter() const { | 213 void* parameter() const { |
200 DCHECK(state() != FREE); | 214 DCHECK(state() != FREE); |
201 return parameter_or_next_free_.parameter; | 215 return parameter_or_next_free_.parameter; |
202 } | 216 } |
203 | 217 |
218 void set_internal_fields(int internal_field_index1, int internal_field_index2) { | |
219 DCHECK(weakness_type() == INTERNAL_FIELDS_WEAK); | |
220 parameter_or_next_free_.internal_field_indeces.internal_field1 = internal_fi eld_index1; | |
221 parameter_or_next_free_.internal_field_indeces.internal_field2 = internal_fi eld_index2; | |
222 } | |
223 | |
224 int internal_field1() const { | |
225 DCHECK(weakness_type() == INTERNAL_FIELDS_WEAK); | |
226 return parameter_or_next_free_.internal_field_indeces.internal_field1; | |
227 } | |
228 | |
229 int internal_field2() const { | |
230 DCHECK(weakness_type() == INTERNAL_FIELDS_WEAK); | |
231 return parameter_or_next_free_.internal_field_indeces.internal_field2; | |
232 } | |
233 | |
204 // Accessors for next free node in the free list. | 234 // Accessors for next free node in the free list. |
205 Node* next_free() { | 235 Node* next_free() { |
206 DCHECK(state() == FREE); | 236 DCHECK(state() == FREE); |
207 return parameter_or_next_free_.next_free; | 237 return parameter_or_next_free_.next_free; |
208 } | 238 } |
209 void set_next_free(Node* value) { | 239 void set_next_free(Node* value) { |
210 DCHECK(state() == FREE); | 240 DCHECK(state() == FREE); |
211 parameter_or_next_free_.next_free = value; | 241 parameter_or_next_free_.next_free = value; |
212 } | 242 } |
213 | 243 |
214 void MakeWeak(void* parameter, WeakCallback weak_callback, | 244 void MakeWeak(void* parameter, WeakCallback weak_callback) { |
215 bool is_zapped_during_weak_callback = false) { | |
216 DCHECK(weak_callback != NULL); | 245 DCHECK(weak_callback != NULL); |
217 DCHECK(state() != FREE); | 246 DCHECK(state() != FREE); |
218 CHECK(object_ != NULL); | 247 CHECK(object_ != NULL); |
219 set_state(WEAK); | 248 set_state(WEAK); |
249 set_weakness_type(Node::NORMAL_WEAK); | |
220 set_parameter(parameter); | 250 set_parameter(parameter); |
221 set_is_zapped_during_weak_callback(is_zapped_during_weak_callback); | |
222 weak_callback_ = weak_callback; | 251 weak_callback_ = weak_callback; |
223 } | 252 } |
224 | 253 |
254 void MakePhantom(void* parameter, PhantomCallback phantom_callback, | |
255 int internal_field_index1, int internal_field_index2) { | |
256 //FIXME: Where to put the indeces... | |
257 DCHECK(phantom_callback != NULL); | |
258 DCHECK(state() != FREE); | |
259 CHECK(object_ != NULL); | |
260 set_state(WEAK); | |
261 if (parameter != NULL) { | |
262 DCHECK(internal_field_index1 == v8::Object::kNoInternalFieldIndex); | |
263 DCHECK(internal_field_index2 == v8::Object::kNoInternalFieldIndex); | |
264 set_weakness_type(Node::PHANTOM_WEAK); | |
265 set_parameter(parameter); | |
266 } else { | |
267 set_weakness_type(Node::INTERNAL_FIELDS_WEAK); | |
268 set_internal_fields(internal_field_index1, internal_field_index2); | |
269 } | |
270 weak_callback_ = reinterpret_cast<WeakCallback>(phantom_callback); | |
271 } | |
272 | |
225 void* ClearWeakness() { | 273 void* ClearWeakness() { |
226 DCHECK(state() != FREE); | 274 DCHECK(state() != FREE); |
227 void* p = parameter(); | 275 void* p = parameter(); |
228 set_state(NORMAL); | 276 set_state(NORMAL); |
229 set_parameter(NULL); | 277 set_parameter(NULL); |
230 return p; | 278 return p; |
231 } | 279 } |
232 | 280 |
233 bool PostGarbageCollectionProcessing(Isolate* isolate) { | 281 bool PostGarbageCollectionProcessing(Isolate* isolate) { |
234 if (state() != Node::PENDING) return false; | 282 if (state() != Node::PENDING) return false; |
235 if (weak_callback_ == NULL) { | 283 if (weak_callback_ == NULL) { |
236 Release(); | 284 Release(); |
237 return false; | 285 return false; |
238 } | 286 } |
239 void* param = parameter(); | |
240 set_state(NEAR_DEATH); | 287 set_state(NEAR_DEATH); |
241 set_parameter(NULL); | |
242 | 288 |
243 Object** object = location(); | |
244 { | 289 { |
245 // Check that we are not passing a finalized external string to | 290 // Check that we are not passing a finalized external string to |
246 // the callback. | 291 // the callback. |
247 DCHECK(!object_->IsExternalOneByteString() || | 292 DCHECK(!object_->IsExternalOneByteString() || |
248 ExternalOneByteString::cast(object_)->resource() != NULL); | 293 ExternalOneByteString::cast(object_)->resource() != NULL); |
249 DCHECK(!object_->IsExternalTwoByteString() || | 294 DCHECK(!object_->IsExternalTwoByteString() || |
250 ExternalTwoByteString::cast(object_)->resource() != NULL); | 295 ExternalTwoByteString::cast(object_)->resource() != NULL); |
251 // Leaving V8. | 296 // Leaving V8. |
252 VMState<EXTERNAL> vmstate(isolate); | 297 VMState<EXTERNAL> vmstate(isolate); |
253 HandleScope handle_scope(isolate); | 298 HandleScope handle_scope(isolate); |
254 if (is_zapped_during_weak_callback()) { | 299 if (weakness_type() == Node::NORMAL_WEAK) { |
255 // Phantom weak pointer case. | 300 Object** object = location(); |
256 DCHECK(*object == Smi::FromInt(kPhantomReferenceZap)); | |
257 // Make data with a null handle. | |
258 v8::WeakCallbackData<v8::Value, void> data( | |
259 reinterpret_cast<v8::Isolate*>(isolate), v8::Local<v8::Object>(), | |
260 param); | |
261 weak_callback_(data); | |
262 if (state() != FREE) { | |
263 // Callback does not have to clear the global handle if it is a | |
264 // phantom handle. | |
265 Release(); | |
266 } | |
267 } else { | |
268 Handle<Object> handle(*object, isolate); | 301 Handle<Object> handle(*object, isolate); |
269 v8::WeakCallbackData<v8::Value, void> data( | 302 v8::WeakCallbackData<v8::Value, void> data( |
270 reinterpret_cast<v8::Isolate*>(isolate), v8::Utils::ToLocal(handle), | 303 reinterpret_cast<v8::Isolate*>(isolate), v8::Utils::ToLocal(handle), |
271 param); | 304 parameter()); |
305 set_parameter(NULL); | |
272 weak_callback_(data); | 306 weak_callback_(data); |
307 } else { | |
308 v8::PhantomCallbackData<void>::Callback callback = | |
309 reinterpret_cast<v8::PhantomCallbackData<void>::Callback>(weak_callb ack_); | |
310 if (weakness_type() == Node::PHANTOM_WEAK) { | |
311 // Phantom weak pointer case. | |
312 DCHECK(*location() == Smi::FromInt(kPhantomReferenceZap)); | |
313 // Make data with a null handle. | |
314 v8::PhantomCallbackData<void> data( | |
315 reinterpret_cast<v8::Isolate*>(isolate), parameter()); | |
316 callback(data); | |
317 if (state() != FREE) { | |
318 // Callback does not have to clear the global handle if it is a | |
319 // phantom handle. | |
320 Release(); | |
321 } | |
322 set_parameter(NULL); | |
323 } else { | |
324 DCHECK(weakness_type() == Node::INTERNAL_FIELDS_WEAK); | |
325 // Phantom weak pointer case, passing internal fields instead of param eter. | |
326 Handle<Object> handle(object(), isolate); | |
327 Handle<JSObject> jsobject = Handle<JSObject>::cast(handle); | |
328 v8::PhantomCallbackData<void> data( | |
329 reinterpret_cast<v8::Isolate*>(isolate), | |
330 jsobject->GetInternalField(internal_field1()), | |
331 jsobject->GetInternalField(internal_field2())); | |
332 // In the future, we want to delay the callback. In that case we will zap | |
333 // when we queue up, to stop the C++ side accessing the dead V8 object , | |
334 // but we will call Release only after the callback (allowing the node | |
335 // to be reused). | |
336 Zap(); | |
337 callback(data); | |
338 Release(); | |
339 set_internal_fields(v8::Object::kNoInternalFieldIndex, v8::Object::kNo InternalFieldIndex); | |
340 } | |
273 } | 341 } |
274 } | 342 } |
275 // Absence of explicit cleanup or revival of weak handle | 343 // Absence of explicit cleanup or revival of weak handle |
276 // in most of the cases would lead to memory leak. | 344 // in most of the cases would lead to memory leak. |
277 CHECK(state() != NEAR_DEATH); | 345 CHECK(state() != NEAR_DEATH); |
278 return true; | 346 return true; |
279 } | 347 } |
280 | 348 |
281 inline GlobalHandles* GetGlobalHandles(); | 349 inline GlobalHandles* GetGlobalHandles(); |
282 | 350 |
(...skipping 10 matching lines...) Loading... | |
293 // Note: the most aligned fields should go first. | 361 // Note: the most aligned fields should go first. |
294 | 362 |
295 // Wrapper class ID. | 363 // Wrapper class ID. |
296 uint16_t class_id_; | 364 uint16_t class_id_; |
297 | 365 |
298 // Index in the containing handle block. | 366 // Index in the containing handle block. |
299 uint8_t index_; | 367 uint8_t index_; |
300 | 368 |
301 // This stores three flags (independent, partially_dependent and | 369 // This stores three flags (independent, partially_dependent and |
302 // in_new_space_list) and a State. | 370 // in_new_space_list) and a State. |
303 class NodeState : public BitField<State, 0, 4> {}; | 371 class NodeState : public BitField<State, 0, 3> {}; |
304 class IsIndependent : public BitField<bool, 4, 1> {}; | 372 class IsIndependent : public BitField<bool, 3, 1> {}; |
305 class IsPartiallyDependent : public BitField<bool, 5, 1> {}; | 373 class IsPartiallyDependent : public BitField<bool, 4, 1> {}; |
306 class IsInNewSpaceList : public BitField<bool, 6, 1> {}; | 374 class IsInNewSpaceList : public BitField<bool, 5, 1> {}; |
307 class IsZappedDuringWeakCallback : public BitField<bool, 7, 1> {}; | 375 class NodeWeaknessType : public BitField<WeaknessType, 6, 2> {}; |
308 | 376 |
309 uint8_t flags_; | 377 uint8_t flags_; |
310 | 378 |
311 // Handle specific callback - might be a weak reference in disguise. | 379 // Handle specific callback - might be a weak reference in disguise. |
312 WeakCallback weak_callback_; | 380 WeakCallback weak_callback_; |
313 | 381 |
314 // Provided data for callback. In FREE state, this is used for | 382 // Provided data for callback. In FREE state, this is used for |
315 // the free list link. | 383 // the free list link. |
316 union { | 384 union { |
317 void* parameter; | 385 void* parameter; |
386 struct { | |
387 uint16_t internal_field1; | |
388 uint16_t internal_field2; | |
389 } internal_field_indeces; | |
318 Node* next_free; | 390 Node* next_free; |
319 } parameter_or_next_free_; | 391 } parameter_or_next_free_; |
320 | 392 |
321 DISALLOW_COPY_AND_ASSIGN(Node); | 393 DISALLOW_COPY_AND_ASSIGN(Node); |
322 }; | 394 }; |
323 | 395 |
324 | 396 |
325 class GlobalHandles::NodeBlock { | 397 class GlobalHandles::NodeBlock { |
326 public: | 398 public: |
327 static const int kSize = 256; | 399 static const int kSize = 256; |
(...skipping 165 matching lines...) Loading... | |
493 return Node::FromLocation(location)->GetGlobalHandles()->Create(*location); | 565 return Node::FromLocation(location)->GetGlobalHandles()->Create(*location); |
494 } | 566 } |
495 | 567 |
496 | 568 |
497 void GlobalHandles::Destroy(Object** location) { | 569 void GlobalHandles::Destroy(Object** location) { |
498 if (location != NULL) Node::FromLocation(location)->Release(); | 570 if (location != NULL) Node::FromLocation(location)->Release(); |
499 } | 571 } |
500 | 572 |
501 | 573 |
502 void GlobalHandles::MakeWeak(Object** location, void* parameter, | 574 void GlobalHandles::MakeWeak(Object** location, void* parameter, |
503 WeakCallback weak_callback, PhantomState phantom) { | 575 WeakCallback weak_callback) { |
504 Node::FromLocation(location) | 576 Node::FromLocation(location)->MakeWeak(parameter, weak_callback); |
505 ->MakeWeak(parameter, weak_callback, phantom == Phantom); | |
506 } | 577 } |
507 | 578 |
508 | 579 |
580 void GlobalHandles::MakePhantom(Object** location, void* parameter, | |
581 PhantomCallback phantom_callback, | |
582 int internal_field_index1, | |
583 int internal_field_index2) { | |
584 Node::FromLocation(location) | |
585 ->MakePhantom(parameter, phantom_callback, internal_field_index1, internal _field_index2); | |
586 } | |
587 | |
588 | |
509 void* GlobalHandles::ClearWeakness(Object** location) { | 589 void* GlobalHandles::ClearWeakness(Object** location) { |
510 return Node::FromLocation(location)->ClearWeakness(); | 590 return Node::FromLocation(location)->ClearWeakness(); |
511 } | 591 } |
512 | 592 |
513 | 593 |
514 void GlobalHandles::MarkIndependent(Object** location) { | 594 void GlobalHandles::MarkIndependent(Object** location) { |
515 Node::FromLocation(location)->MarkIndependent(); | 595 Node::FromLocation(location)->MarkIndependent(); |
516 } | 596 } |
517 | 597 |
518 | 598 |
(...skipping 14 matching lines...) Loading... | |
533 | 613 |
534 bool GlobalHandles::IsWeak(Object** location) { | 614 bool GlobalHandles::IsWeak(Object** location) { |
535 return Node::FromLocation(location)->IsWeak(); | 615 return Node::FromLocation(location)->IsWeak(); |
536 } | 616 } |
537 | 617 |
538 | 618 |
539 void GlobalHandles::IterateWeakRoots(ObjectVisitor* v) { | 619 void GlobalHandles::IterateWeakRoots(ObjectVisitor* v) { |
540 for (NodeIterator it(this); !it.done(); it.Advance()) { | 620 for (NodeIterator it(this); !it.done(); it.Advance()) { |
541 Node* node = it.node(); | 621 Node* node = it.node(); |
542 if (node->IsWeakRetainer()) { | 622 if (node->IsWeakRetainer()) { |
543 if (node->state() == Node::PENDING && | 623 // Weakness type can be normal, phantom or internal fields. |
544 node->is_zapped_during_weak_callback()) { | 624 // For normal weakness we mark through the handle so that |
545 *(node->location()) = Smi::FromInt(kPhantomReferenceZap); | 625 // the object and things reachable from it are available |
626 // to the callback. | |
627 // In the case of phantom we can zap the object handle now | |
628 // and we won't need it, so we don't need to mark through it. | |
629 // In the internal fields case we will need the internal | |
630 // fields, so we can't zap the handle, but we don't need to | |
631 // mark through it, because it will die in this GC round. | |
632 v->VisitPointer(node->location()); | |
633 if (node->state() == Node::PENDING) { | |
634 if (node->weakness_type() == Node::PHANTOM_WEAK) { | |
635 *(node->location()) = Smi::FromInt(kPhantomReferenceZap); | |
jochen (gone - plz use gerrit)
2014/11/24 12:27:53
if you zap the handle here, how can you get to obj
Erik Corry
2014/11/24 12:38:26
For the INTERNAL_FIELDS case we don't zap here.
| |
636 } else if (node->weakness_type() == Node::NORMAL_WEAK) { | |
637 v->VisitPointer(node->location()); | |
638 } | |
546 } else { | 639 } else { |
547 v->VisitPointer(node->location()); | 640 v->VisitPointer(node->location()); |
548 } | 641 } |
549 } | 642 } |
550 } | 643 } |
551 } | 644 } |
552 | 645 |
553 | 646 |
554 void GlobalHandles::IdentifyWeakHandles(WeakSlotCallback f) { | 647 void GlobalHandles::IdentifyWeakHandles(WeakSlotCallback f) { |
555 for (NodeIterator it(this); !it.done(); it.Advance()) { | 648 for (NodeIterator it(this); !it.done(); it.Advance()) { |
(...skipping 28 matching lines...) Loading... | |
584 } | 677 } |
585 } | 678 } |
586 | 679 |
587 | 680 |
588 void GlobalHandles::IterateNewSpaceWeakIndependentRoots(ObjectVisitor* v) { | 681 void GlobalHandles::IterateNewSpaceWeakIndependentRoots(ObjectVisitor* v) { |
589 for (int i = 0; i < new_space_nodes_.length(); ++i) { | 682 for (int i = 0; i < new_space_nodes_.length(); ++i) { |
590 Node* node = new_space_nodes_[i]; | 683 Node* node = new_space_nodes_[i]; |
591 DCHECK(node->is_in_new_space_list()); | 684 DCHECK(node->is_in_new_space_list()); |
592 if ((node->is_independent() || node->is_partially_dependent()) && | 685 if ((node->is_independent() || node->is_partially_dependent()) && |
593 node->IsWeakRetainer()) { | 686 node->IsWeakRetainer()) { |
594 if (node->is_zapped_during_weak_callback()) { | 687 if (node->weakness_type() == Node::PHANTOM_WEAK) { |
595 *(node->location()) = Smi::FromInt(kPhantomReferenceZap); | 688 *(node->location()) = Smi::FromInt(kPhantomReferenceZap); |
689 } else if (node->weakness_type() == Node::NORMAL_WEAK) { | |
690 v->VisitPointer(node->location()); | |
596 } else { | 691 } else { |
597 v->VisitPointer(node->location()); | 692 // For this case we don't need to trace through, but we don't |
693 // zap yet. | |
694 DCHECK(node->weakness_type() == Node::INTERNAL_FIELDS_WEAK); | |
598 } | 695 } |
599 } | 696 } |
600 } | 697 } |
601 } | 698 } |
602 | 699 |
603 | 700 |
604 bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v, | 701 bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v, |
605 WeakSlotCallbackWithHeap can_skip) { | 702 WeakSlotCallbackWithHeap can_skip) { |
606 ComputeObjectGroupsAndImplicitReferences(); | 703 ComputeObjectGroupsAndImplicitReferences(); |
607 int last = 0; | 704 int last = 0; |
(...skipping 475 matching lines...) Loading... | |
1083 DCHECK_EQ(isolate->heap()->the_hole_value(), blocks_[block][offset]); | 1180 DCHECK_EQ(isolate->heap()->the_hole_value(), blocks_[block][offset]); |
1084 blocks_[block][offset] = object; | 1181 blocks_[block][offset] = object; |
1085 if (isolate->heap()->InNewSpace(object)) { | 1182 if (isolate->heap()->InNewSpace(object)) { |
1086 new_space_indices_.Add(size_); | 1183 new_space_indices_.Add(size_); |
1087 } | 1184 } |
1088 *index = size_++; | 1185 *index = size_++; |
1089 } | 1186 } |
1090 | 1187 |
1091 | 1188 |
1092 } } // namespace v8::internal | 1189 } } // namespace v8::internal |
OLD | NEW |