Chromium Code Reviews| 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/v8.h" | 8 #include "src/v8.h" |
| 9 #include "src/vm-state-inl.h" | 9 #include "src/vm-state-inl.h" |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 } else { | 71 } else { |
| 72 set_partially_dependent(false); | 72 set_partially_dependent(false); |
| 73 } | 73 } |
| 74 set_in_new_space_list(false); | 74 set_in_new_space_list(false); |
| 75 parameter_or_next_free_.next_free = NULL; | 75 parameter_or_next_free_.next_free = NULL; |
| 76 weak_callback_ = NULL; | 76 weak_callback_ = NULL; |
| 77 } | 77 } |
| 78 #endif | 78 #endif |
| 79 | 79 |
| 80 void Initialize(int index, Node** first_free) { | 80 void Initialize(int index, Node** first_free) { |
| 81 object_ = reinterpret_cast<Object*>(kGlobalHandleZapValue); | |
|
vogelheim
2016/01/25 12:00:19
nitpick: Wouldn't it be better for debugging to di
jochen (gone - plz use gerrit)
2016/01/25 13:05:48
since we recycle handles, they're expected to cons
| |
| 81 index_ = static_cast<uint8_t>(index); | 82 index_ = static_cast<uint8_t>(index); |
| 82 DCHECK(static_cast<int>(index_) == index); | 83 DCHECK(static_cast<int>(index_) == index); |
| 83 set_state(FREE); | 84 set_state(FREE); |
| 84 set_weakness_type(NORMAL_WEAK); | 85 set_weakness_type(NORMAL_WEAK); |
| 85 set_in_new_space_list(false); | 86 set_in_new_space_list(false); |
| 86 parameter_or_next_free_.next_free = *first_free; | 87 parameter_or_next_free_.next_free = *first_free; |
| 87 *first_free = this; | 88 *first_free = this; |
| 88 } | 89 } |
| 89 | 90 |
| 90 void Acquire(Object* object) { | 91 void Acquire(Object* object) { |
| 91 DCHECK(state() == FREE); | 92 DCHECK(state() == FREE); |
| 92 object_ = object; | 93 object_ = object; |
|
vogelheim
2016/01/25 12:00:19
Maybe DCHECK(object != nullptr)?
jochen (gone - plz use gerrit)
2016/01/25 13:05:48
nullptr is valid here (since that's Smi::FromInt(0
| |
| 93 class_id_ = v8::HeapProfiler::kPersistentHandleNoClassId; | 94 class_id_ = v8::HeapProfiler::kPersistentHandleNoClassId; |
| 94 set_independent(false); | 95 set_independent(false); |
| 95 if (FLAG_scavenge_reclaim_unmodified_objects) { | 96 if (FLAG_scavenge_reclaim_unmodified_objects) { |
| 96 set_active(false); | 97 set_active(false); |
| 97 } else { | 98 } else { |
| 98 set_partially_dependent(false); | 99 set_partially_dependent(false); |
| 99 } | 100 } |
| 100 set_state(NORMAL); | 101 set_state(NORMAL); |
| 101 parameter_or_next_free_.parameter = NULL; | 102 parameter_or_next_free_.parameter = NULL; |
| 102 weak_callback_ = NULL; | 103 weak_callback_ = NULL; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 Node* next_free() { | 244 Node* next_free() { |
| 244 DCHECK(state() == FREE); | 245 DCHECK(state() == FREE); |
| 245 return parameter_or_next_free_.next_free; | 246 return parameter_or_next_free_.next_free; |
| 246 } | 247 } |
| 247 void set_next_free(Node* value) { | 248 void set_next_free(Node* value) { |
| 248 DCHECK(state() == FREE); | 249 DCHECK(state() == FREE); |
| 249 parameter_or_next_free_.next_free = value; | 250 parameter_or_next_free_.next_free = value; |
| 250 } | 251 } |
| 251 | 252 |
| 252 void MakeWeak(void* parameter, WeakCallback weak_callback) { | 253 void MakeWeak(void* parameter, WeakCallback weak_callback) { |
| 253 DCHECK(weak_callback != NULL); | 254 DCHECK(weak_callback != nullptr); |
| 254 DCHECK(IsInUse()); | 255 DCHECK(IsInUse()); |
| 255 CHECK(object_ != NULL); | 256 CHECK_NE(object_, reinterpret_cast<Object*>(kGlobalHandleZapValue)); |
| 256 set_state(WEAK); | 257 set_state(WEAK); |
| 257 set_weakness_type(NORMAL_WEAK); | 258 set_weakness_type(NORMAL_WEAK); |
| 258 set_parameter(parameter); | 259 set_parameter(parameter); |
| 259 weak_callback_ = weak_callback; | 260 weak_callback_ = weak_callback; |
| 260 } | 261 } |
| 261 | 262 |
| 262 void MakeWeak(void* parameter, | 263 void MakeWeak(void* parameter, |
| 263 WeakCallbackInfo<void>::Callback phantom_callback, | 264 WeakCallbackInfo<void>::Callback phantom_callback, |
| 264 v8::WeakCallbackType type) { | 265 v8::WeakCallbackType type) { |
| 265 DCHECK(phantom_callback != nullptr); | 266 DCHECK(phantom_callback != nullptr); |
| 266 DCHECK(IsInUse()); | 267 DCHECK(IsInUse()); |
| 267 CHECK(object_ != nullptr); | 268 CHECK_NE(object_, reinterpret_cast<Object*>(kGlobalHandleZapValue)); |
| 268 set_state(WEAK); | 269 set_state(WEAK); |
| 269 switch (type) { | 270 switch (type) { |
| 270 case v8::WeakCallbackType::kParameter: | 271 case v8::WeakCallbackType::kParameter: |
| 271 set_weakness_type(PHANTOM_WEAK); | 272 set_weakness_type(PHANTOM_WEAK); |
| 272 break; | 273 break; |
| 273 case v8::WeakCallbackType::kInternalFields: | 274 case v8::WeakCallbackType::kInternalFields: |
| 274 set_weakness_type(PHANTOM_WEAK_2_INTERNAL_FIELDS); | 275 set_weakness_type(PHANTOM_WEAK_2_INTERNAL_FIELDS); |
| 275 break; | 276 break; |
| 276 } | 277 } |
| 277 set_parameter(parameter); | 278 set_parameter(parameter); |
| (...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1376 blocks_[block][offset] = object; | 1377 blocks_[block][offset] = object; |
| 1377 if (isolate->heap()->InNewSpace(object)) { | 1378 if (isolate->heap()->InNewSpace(object)) { |
| 1378 new_space_indices_.Add(size_); | 1379 new_space_indices_.Add(size_); |
| 1379 } | 1380 } |
| 1380 *index = size_++; | 1381 *index = size_++; |
| 1381 } | 1382 } |
| 1382 | 1383 |
| 1383 | 1384 |
| 1384 } // namespace internal | 1385 } // namespace internal |
| 1385 } // namespace v8 | 1386 } // namespace v8 |
| OLD | NEW |