| 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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 block_ = block_->next_used(); | 488 block_ = block_->next_used(); |
| 489 } | 489 } |
| 490 | 490 |
| 491 private: | 491 private: |
| 492 NodeBlock* block_; | 492 NodeBlock* block_; |
| 493 int index_; | 493 int index_; |
| 494 | 494 |
| 495 DISALLOW_COPY_AND_ASSIGN(NodeIterator); | 495 DISALLOW_COPY_AND_ASSIGN(NodeIterator); |
| 496 }; | 496 }; |
| 497 | 497 |
| 498 class GlobalHandles::PendingPhantomCallbacksSecondPassTask : public v8::Task { | 498 class GlobalHandles::PendingPhantomCallbacksSecondPassTask |
| 499 : public v8::internal::CancelableTask { |
| 499 public: | 500 public: |
| 500 // Takes ownership of the contents of pending_phantom_callbacks, leaving it in | 501 // Takes ownership of the contents of pending_phantom_callbacks, leaving it in |
| 501 // the same state it would be after a call to Clear(). | 502 // the same state it would be after a call to Clear(). |
| 502 PendingPhantomCallbacksSecondPassTask( | 503 PendingPhantomCallbacksSecondPassTask( |
| 503 List<PendingPhantomCallback>* pending_phantom_callbacks, Isolate* isolate) | 504 List<PendingPhantomCallback>* pending_phantom_callbacks, Isolate* isolate) |
| 504 : isolate_(isolate) { | 505 : CancelableTask(isolate) { |
| 505 pending_phantom_callbacks_.Swap(pending_phantom_callbacks); | 506 pending_phantom_callbacks_.Swap(pending_phantom_callbacks); |
| 506 } | 507 } |
| 507 | 508 |
| 508 ~PendingPhantomCallbacksSecondPassTask() override {} | 509 void RunInternal() override { |
| 509 | |
| 510 void Run() override { | |
| 511 InvokeSecondPassPhantomCallbacks(&pending_phantom_callbacks_, isolate_); | 510 InvokeSecondPassPhantomCallbacks(&pending_phantom_callbacks_, isolate_); |
| 512 } | 511 } |
| 513 | 512 |
| 514 private: | 513 private: |
| 515 List<PendingPhantomCallback> pending_phantom_callbacks_; | 514 List<PendingPhantomCallback> pending_phantom_callbacks_; |
| 516 Isolate* isolate_; | |
| 517 | 515 |
| 518 DISALLOW_COPY_AND_ASSIGN(PendingPhantomCallbacksSecondPassTask); | 516 DISALLOW_COPY_AND_ASSIGN(PendingPhantomCallbacksSecondPassTask); |
| 519 }; | 517 }; |
| 520 | 518 |
| 521 | 519 |
| 522 GlobalHandles::GlobalHandles(Isolate* isolate) | 520 GlobalHandles::GlobalHandles(Isolate* isolate) |
| 523 : isolate_(isolate), | 521 : isolate_(isolate), |
| 524 number_of_global_handles_(0), | 522 number_of_global_handles_(0), |
| 525 first_block_(NULL), | 523 first_block_(NULL), |
| 526 first_used_block_(NULL), | 524 first_used_block_(NULL), |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 // Skip callbacks that have already been processed once. | 836 // Skip callbacks that have already been processed once. |
| 839 if (callback->node() == nullptr) continue; | 837 if (callback->node() == nullptr) continue; |
| 840 callback->Invoke(isolate()); | 838 callback->Invoke(isolate()); |
| 841 freed_nodes++; | 839 freed_nodes++; |
| 842 } | 840 } |
| 843 } | 841 } |
| 844 if (pending_phantom_callbacks_.length() > 0) { | 842 if (pending_phantom_callbacks_.length() > 0) { |
| 845 if (synchronous_second_pass) { | 843 if (synchronous_second_pass) { |
| 846 InvokeSecondPassPhantomCallbacks(&pending_phantom_callbacks_, isolate()); | 844 InvokeSecondPassPhantomCallbacks(&pending_phantom_callbacks_, isolate()); |
| 847 } else { | 845 } else { |
| 848 auto* task = new PendingPhantomCallbacksSecondPassTask( | 846 auto task = new PendingPhantomCallbacksSecondPassTask( |
| 849 &pending_phantom_callbacks_, isolate()); | 847 &pending_phantom_callbacks_, isolate()); |
| 850 V8::GetCurrentPlatform()->CallOnForegroundThread( | 848 V8::GetCurrentPlatform()->CallOnForegroundThread( |
| 851 reinterpret_cast<v8::Isolate*>(isolate()), task); | 849 reinterpret_cast<v8::Isolate*>(isolate()), task); |
| 852 } | 850 } |
| 853 } | 851 } |
| 854 pending_phantom_callbacks_.Clear(); | 852 pending_phantom_callbacks_.Clear(); |
| 855 return freed_nodes; | 853 return freed_nodes; |
| 856 } | 854 } |
| 857 | 855 |
| 858 | 856 |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1267 blocks_[block][offset] = object; | 1265 blocks_[block][offset] = object; |
| 1268 if (isolate->heap()->InNewSpace(object)) { | 1266 if (isolate->heap()->InNewSpace(object)) { |
| 1269 new_space_indices_.Add(size_); | 1267 new_space_indices_.Add(size_); |
| 1270 } | 1268 } |
| 1271 *index = size_++; | 1269 *index = size_++; |
| 1272 } | 1270 } |
| 1273 | 1271 |
| 1274 | 1272 |
| 1275 } // namespace internal | 1273 } // namespace internal |
| 1276 } // namespace v8 | 1274 } // namespace v8 |
| OLD | NEW |