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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8RecursionScope.h

Issue 1743763004: Use v8::MicrotasksScope internally in V8RecursionScope. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8rs-2-endofscope
Patch Set: v8_helpers Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // Calls of type (2) should always stack-allocate a V8RecursionScope in the same 52 // Calls of type (2) should always stack-allocate a V8RecursionScope in the same
53 // block as the call into script. Calls of type (3) should stack allocate a 53 // block as the call into script. Calls of type (3) should stack allocate a
54 // V8RecursionScope::MicrotaskSuppression -- this skips work that is spec'd to 54 // V8RecursionScope::MicrotaskSuppression -- this skips work that is spec'd to
55 // happen at the end of the outer-most script stack frame of calls into page scr ipt: 55 // happen at the end of the outer-most script stack frame of calls into page scr ipt:
56 // 56 //
57 // http://www.whatwg.org/specs/web-apps/current-work/#perform-a-microtask-checkp oint 57 // http://www.whatwg.org/specs/web-apps/current-work/#perform-a-microtask-checkp oint
58 class CORE_EXPORT V8RecursionScope { 58 class CORE_EXPORT V8RecursionScope {
59 STACK_ALLOCATED(); 59 STACK_ALLOCATED();
60 public: 60 public:
61 explicit V8RecursionScope(v8::Isolate* isolate) 61 explicit V8RecursionScope(v8::Isolate* isolate)
62 : m_isolate(isolate) 62 : m_scope(isolate, v8::MicrotasksScope::kRunMicrotasks)
63 { 63 {
64 V8PerIsolateData::from(m_isolate)->incrementRecursionLevel(); 64 ASSERT(isolate->GetMicrotasksPolicy() == v8::MicrotasksPolicy::kScoped);
65 // If you want V8 to autorun microtasks, this class needs to have a
66 // v8::Isolate::SuppressMicrotaskExecutionScope member.
67 ASSERT(!isolate->WillAutorunMicrotasks());
68 } 65 }
69 66
70 ~V8RecursionScope() 67 ~V8RecursionScope()
71 { 68 {
72 if (!V8PerIsolateData::from(m_isolate)->decrementRecursionLevel())
73 didLeaveScriptContext();
74 } 69 }
75 70
76 static int recursionLevel(v8::Isolate* isolate) 71 static int recursionLevel(v8::Isolate* isolate)
77 { 72 {
78 return V8PerIsolateData::from(isolate)->recursionLevel(); 73 return v8::MicrotasksScope::GetCurrentDepth(isolate);
79 } 74 }
80 75
81 #if ENABLE(ASSERT)
82 static bool properlyUsed(v8::Isolate* isolate)
83 {
84 return recursionLevel(isolate) > 0 || V8PerIsolateData::from(isolate)->i nternalScriptRecursionLevel() > 0;
85 }
86 #endif
87
88 class MicrotaskSuppression { 76 class MicrotaskSuppression {
89 USING_FAST_MALLOC(MicrotaskSuppression); 77 USING_FAST_MALLOC(MicrotaskSuppression);
90 WTF_MAKE_NONCOPYABLE(MicrotaskSuppression); 78 WTF_MAKE_NONCOPYABLE(MicrotaskSuppression);
91 public: 79 public:
92 MicrotaskSuppression(v8::Isolate* isolate) 80 explicit MicrotaskSuppression(v8::Isolate* isolate)
93 #if ENABLE(ASSERT) 81 : m_scope(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks)
94 : m_isolate(isolate)
95 #endif
96 { 82 {
97 #if ENABLE(ASSERT)
98 V8PerIsolateData::from(m_isolate)->incrementInternalScriptRecursionL evel();
99 #endif
100 } 83 }
101 84
102 ~MicrotaskSuppression() 85 ~MicrotaskSuppression()
103 { 86 {
104 #if ENABLE(ASSERT)
105 V8PerIsolateData::from(m_isolate)->decrementInternalScriptRecursionL evel();
106 #endif
107 } 87 }
108 88
109 private: 89 private:
110 #if ENABLE(ASSERT) 90 v8::MicrotasksScope m_scope;
111 v8::Isolate* m_isolate;
112 #endif
113 }; 91 };
114 92
115 private: 93 private:
116 void didLeaveScriptContext(); 94 v8::MicrotasksScope m_scope;
117
118 v8::Isolate* m_isolate;
119 }; 95 };
120 96
121 } // namespace blink 97 } // namespace blink
122 98
123 #endif // V8RecursionScope_h 99 #endif // V8RecursionScope_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698