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 "src/isolate.h" | 5 #include "src/isolate.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 3491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3502 } | 3502 } |
3503 | 3503 |
3504 | 3504 |
3505 void Isolate::RunMicrotasksInternal() { | 3505 void Isolate::RunMicrotasksInternal() { |
3506 if (!pending_microtask_count()) return; | 3506 if (!pending_microtask_count()) return; |
3507 TRACE_EVENT0("v8.execute", "RunMicrotasks"); | 3507 TRACE_EVENT0("v8.execute", "RunMicrotasks"); |
3508 TRACE_EVENT_CALL_STATS_SCOPED(this, "v8", "V8.RunMicrotasks"); | 3508 TRACE_EVENT_CALL_STATS_SCOPED(this, "v8", "V8.RunMicrotasks"); |
3509 while (pending_microtask_count() > 0) { | 3509 while (pending_microtask_count() > 0) { |
3510 HandleScope scope(this); | 3510 HandleScope scope(this); |
3511 int num_tasks = pending_microtask_count(); | 3511 int num_tasks = pending_microtask_count(); |
| 3512 // Do not use factory()->microtask_queue() here; we need a fresh handle! |
3512 Handle<FixedArray> queue(heap()->microtask_queue(), this); | 3513 Handle<FixedArray> queue(heap()->microtask_queue(), this); |
3513 DCHECK(num_tasks <= queue->length()); | 3514 DCHECK(num_tasks <= queue->length()); |
3514 set_pending_microtask_count(0); | 3515 set_pending_microtask_count(0); |
3515 heap()->set_microtask_queue(heap()->empty_fixed_array()); | 3516 heap()->set_microtask_queue(heap()->empty_fixed_array()); |
3516 | 3517 |
3517 Isolate* isolate = this; | 3518 Isolate* isolate = this; |
3518 FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < num_tasks, i++, { | 3519 FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < num_tasks, i++, { |
3519 Handle<Object> microtask(queue->get(i), this); | 3520 Handle<Object> microtask(queue->get(i), this); |
3520 | 3521 |
3521 if (microtask->IsCallHandlerInfo()) { | 3522 if (microtask->IsCallHandlerInfo()) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3645 // deoptimize only those functions that are affected by the change of this | 3646 // deoptimize only those functions that are affected by the change of this |
3646 // flag. | 3647 // flag. |
3647 internal::Deoptimizer::DeoptimizeAll(this); | 3648 internal::Deoptimizer::DeoptimizeAll(this); |
3648 } | 3649 } |
3649 | 3650 |
3650 // Heap::detached_contexts tracks detached contexts as pairs | 3651 // Heap::detached_contexts tracks detached contexts as pairs |
3651 // (number of GC since the context was detached, the context). | 3652 // (number of GC since the context was detached, the context). |
3652 void Isolate::AddDetachedContext(Handle<Context> context) { | 3653 void Isolate::AddDetachedContext(Handle<Context> context) { |
3653 HandleScope scope(this); | 3654 HandleScope scope(this); |
3654 Handle<WeakCell> cell = factory()->NewWeakCell(context); | 3655 Handle<WeakCell> cell = factory()->NewWeakCell(context); |
3655 Handle<FixedArray> detached_contexts = factory()->detached_contexts(); | 3656 Handle<FixedArray> detached_contexts = |
3656 int length = detached_contexts->length(); | 3657 factory()->CopyFixedArrayAndGrow(factory()->detached_contexts(), 2); |
3657 detached_contexts = factory()->CopyFixedArrayAndGrow(detached_contexts, 2); | 3658 int new_length = detached_contexts->length(); |
3658 detached_contexts->set(length, Smi::kZero); | 3659 detached_contexts->set(new_length - 2, Smi::kZero); |
3659 detached_contexts->set(length + 1, *cell); | 3660 detached_contexts->set(new_length - 1, *cell); |
3660 heap()->set_detached_contexts(*detached_contexts); | 3661 heap()->set_detached_contexts(*detached_contexts); |
3661 } | 3662 } |
3662 | 3663 |
3663 | 3664 |
3664 void Isolate::CheckDetachedContextsAfterGC() { | 3665 void Isolate::CheckDetachedContextsAfterGC() { |
3665 HandleScope scope(this); | 3666 HandleScope scope(this); |
3666 Handle<FixedArray> detached_contexts = factory()->detached_contexts(); | 3667 Handle<FixedArray> detached_contexts = factory()->detached_contexts(); |
3667 int length = detached_contexts->length(); | 3668 int length = detached_contexts->length(); |
3668 if (length == 0) return; | 3669 if (length == 0) return; |
3669 int new_length = 0; | 3670 int new_length = 0; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3775 // Then check whether this scope intercepts. | 3776 // Then check whether this scope intercepts. |
3776 if ((flag & intercept_mask_)) { | 3777 if ((flag & intercept_mask_)) { |
3777 intercepted_flags_ |= flag; | 3778 intercepted_flags_ |= flag; |
3778 return true; | 3779 return true; |
3779 } | 3780 } |
3780 return false; | 3781 return false; |
3781 } | 3782 } |
3782 | 3783 |
3783 } // namespace internal | 3784 } // namespace internal |
3784 } // namespace v8 | 3785 } // namespace v8 |
OLD | NEW |