Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(705)

Side by Side Diff: src/isolate.cc

Issue 2289593005: Introduce v8.execute tracing category with RunMicrotasks event. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2939 matching lines...) Expand 10 before | Expand all | Expand 10 after
2950 queue = factory()->CopyFixedArrayAndGrow(queue, num_tasks); 2950 queue = factory()->CopyFixedArrayAndGrow(queue, num_tasks);
2951 heap()->set_microtask_queue(*queue); 2951 heap()->set_microtask_queue(*queue);
2952 } 2952 }
2953 DCHECK(queue->get(num_tasks)->IsUndefined(this)); 2953 DCHECK(queue->get(num_tasks)->IsUndefined(this));
2954 queue->set(num_tasks, *microtask); 2954 queue->set(num_tasks, *microtask);
2955 set_pending_microtask_count(num_tasks + 1); 2955 set_pending_microtask_count(num_tasks + 1);
2956 } 2956 }
2957 2957
2958 2958
2959 void Isolate::RunMicrotasks() { 2959 void Isolate::RunMicrotasks() {
2960 // Increase call depth to prevent recursive callbacks. 2960 if (pending_microtask_count()) {
2961 v8::Isolate::SuppressMicrotaskExecutionScope suppress( 2961 TRACE_EVENT0("v8.execute", "RunMicrotasks");
caseq 2016/08/30 16:16:14 let's move down to RunMicrotasksInternal?
alph 2016/08/30 17:06:04 Done. Also I noticed that originally FireMicrotask
2962 reinterpret_cast<v8::Isolate*>(this)); 2962 // Increase call depth to prevent recursive callbacks.
2963 is_running_microtasks_ = true; 2963 v8::Isolate::SuppressMicrotaskExecutionScope suppress(
2964 RunMicrotasksInternal(); 2964 reinterpret_cast<v8::Isolate*>(this));
2965 is_running_microtasks_ = false; 2965 is_running_microtasks_ = true;
2966 RunMicrotasksInternal();
2967 is_running_microtasks_ = false;
2968 }
2966 FireMicrotasksCompletedCallback(); 2969 FireMicrotasksCompletedCallback();
2967 } 2970 }
2968 2971
2969 2972
2970 void Isolate::RunMicrotasksInternal() { 2973 void Isolate::RunMicrotasksInternal() {
2974 DCHECK(pending_microtask_count() > 0);
2971 while (pending_microtask_count() > 0) { 2975 while (pending_microtask_count() > 0) {
2972 HandleScope scope(this); 2976 HandleScope scope(this);
2973 int num_tasks = pending_microtask_count(); 2977 int num_tasks = pending_microtask_count();
2974 Handle<FixedArray> queue(heap()->microtask_queue(), this); 2978 Handle<FixedArray> queue(heap()->microtask_queue(), this);
2975 DCHECK(num_tasks <= queue->length()); 2979 DCHECK(num_tasks <= queue->length());
2976 set_pending_microtask_count(0); 2980 set_pending_microtask_count(0);
2977 heap()->set_microtask_queue(heap()->empty_fixed_array()); 2981 heap()->set_microtask_queue(heap()->empty_fixed_array());
2978 2982
2979 Isolate* isolate = this; 2983 Isolate* isolate = this;
2980 FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < num_tasks, i++, { 2984 FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < num_tasks, i++, {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
3175 // Then check whether this scope intercepts. 3179 // Then check whether this scope intercepts.
3176 if ((flag & intercept_mask_)) { 3180 if ((flag & intercept_mask_)) {
3177 intercepted_flags_ |= flag; 3181 intercepted_flags_ |= flag;
3178 return true; 3182 return true;
3179 } 3183 }
3180 return false; 3184 return false;
3181 } 3185 }
3182 3186
3183 } // namespace internal 3187 } // namespace internal
3184 } // namespace v8 3188 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698