| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 <stdlib.h> | 5 #include <stdlib.h> |
| 6 | 6 |
| 7 #include <fstream> // NOLINT(readability/streams) | 7 #include <fstream> // NOLINT(readability/streams) |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "src/v8.h" | 10 #include "src/v8.h" |
| (...skipping 2625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2636 | 2636 |
| 2637 void Isolate::EnqueueMicrotask(Handle<Object> microtask) { | 2637 void Isolate::EnqueueMicrotask(Handle<Object> microtask) { |
| 2638 DCHECK(microtask->IsJSFunction() || microtask->IsCallHandlerInfo()); | 2638 DCHECK(microtask->IsJSFunction() || microtask->IsCallHandlerInfo()); |
| 2639 Handle<FixedArray> queue(heap()->microtask_queue(), this); | 2639 Handle<FixedArray> queue(heap()->microtask_queue(), this); |
| 2640 int num_tasks = pending_microtask_count(); | 2640 int num_tasks = pending_microtask_count(); |
| 2641 DCHECK(num_tasks <= queue->length()); | 2641 DCHECK(num_tasks <= queue->length()); |
| 2642 if (num_tasks == 0) { | 2642 if (num_tasks == 0) { |
| 2643 queue = factory()->NewFixedArray(8); | 2643 queue = factory()->NewFixedArray(8); |
| 2644 heap()->set_microtask_queue(*queue); | 2644 heap()->set_microtask_queue(*queue); |
| 2645 } else if (num_tasks == queue->length()) { | 2645 } else if (num_tasks == queue->length()) { |
| 2646 queue = FixedArray::CopySize(queue, num_tasks * 2); | 2646 queue = factory()->CopyFixedArrayAndGrow(queue, num_tasks); |
| 2647 heap()->set_microtask_queue(*queue); | 2647 heap()->set_microtask_queue(*queue); |
| 2648 } | 2648 } |
| 2649 DCHECK(queue->get(num_tasks)->IsUndefined()); | 2649 DCHECK(queue->get(num_tasks)->IsUndefined()); |
| 2650 queue->set(num_tasks, *microtask); | 2650 queue->set(num_tasks, *microtask); |
| 2651 set_pending_microtask_count(num_tasks + 1); | 2651 set_pending_microtask_count(num_tasks + 1); |
| 2652 } | 2652 } |
| 2653 | 2653 |
| 2654 | 2654 |
| 2655 void Isolate::RunMicrotasks() { | 2655 void Isolate::RunMicrotasks() { |
| 2656 // Increase call depth to prevent recursive callbacks. | 2656 // Increase call depth to prevent recursive callbacks. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2737 } | 2737 } |
| 2738 | 2738 |
| 2739 | 2739 |
| 2740 // Heap::detached_contexts tracks detached contexts as pairs | 2740 // Heap::detached_contexts tracks detached contexts as pairs |
| 2741 // (number of GC since the context was detached, the context). | 2741 // (number of GC since the context was detached, the context). |
| 2742 void Isolate::AddDetachedContext(Handle<Context> context) { | 2742 void Isolate::AddDetachedContext(Handle<Context> context) { |
| 2743 HandleScope scope(this); | 2743 HandleScope scope(this); |
| 2744 Handle<WeakCell> cell = factory()->NewWeakCell(context); | 2744 Handle<WeakCell> cell = factory()->NewWeakCell(context); |
| 2745 Handle<FixedArray> detached_contexts(heap()->detached_contexts()); | 2745 Handle<FixedArray> detached_contexts(heap()->detached_contexts()); |
| 2746 int length = detached_contexts->length(); | 2746 int length = detached_contexts->length(); |
| 2747 detached_contexts = FixedArray::CopySize(detached_contexts, length + 2); | 2747 detached_contexts = factory()->CopyFixedArrayAndGrow(detached_contexts, 2); |
| 2748 detached_contexts->set(length, Smi::FromInt(0)); | 2748 detached_contexts->set(length, Smi::FromInt(0)); |
| 2749 detached_contexts->set(length + 1, *cell); | 2749 detached_contexts->set(length + 1, *cell); |
| 2750 heap()->set_detached_contexts(*detached_contexts); | 2750 heap()->set_detached_contexts(*detached_contexts); |
| 2751 } | 2751 } |
| 2752 | 2752 |
| 2753 | 2753 |
| 2754 void Isolate::CheckDetachedContextsAfterGC() { | 2754 void Isolate::CheckDetachedContextsAfterGC() { |
| 2755 HandleScope scope(this); | 2755 HandleScope scope(this); |
| 2756 Handle<FixedArray> detached_contexts(heap()->detached_contexts()); | 2756 Handle<FixedArray> detached_contexts(heap()->detached_contexts()); |
| 2757 int length = detached_contexts->length(); | 2757 int length = detached_contexts->length(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2831 // Then check whether this scope intercepts. | 2831 // Then check whether this scope intercepts. |
| 2832 if ((flag & intercept_mask_)) { | 2832 if ((flag & intercept_mask_)) { |
| 2833 intercepted_flags_ |= flag; | 2833 intercepted_flags_ |= flag; |
| 2834 return true; | 2834 return true; |
| 2835 } | 2835 } |
| 2836 return false; | 2836 return false; |
| 2837 } | 2837 } |
| 2838 | 2838 |
| 2839 } // namespace internal | 2839 } // namespace internal |
| 2840 } // namespace v8 | 2840 } // namespace v8 |
| OLD | NEW |