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

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

Issue 1765423004: Revert of Use v8::MicrotasksScope internally in V8RecursionScope. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8rs-2-endofscope
Patch Set: 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_scope(isolate, v8::MicrotasksScope::kRunMicrotasks) 62 : m_isolate(isolate)
63 { 63 {
64 ASSERT(isolate->GetMicrotasksPolicy() == v8::MicrotasksPolicy::kScoped); 64 V8PerIsolateData::from(m_isolate)->incrementRecursionLevel();
65 // If you want V8 to autorun microtasks, this class needs to have a
66 // v8::Isolate::SuppressMicrotaskExecutionScope member.
67 ASSERT(!isolate->WillAutorunMicrotasks());
65 } 68 }
66 69
67 ~V8RecursionScope() 70 ~V8RecursionScope()
68 { 71 {
72 if (!V8PerIsolateData::from(m_isolate)->decrementRecursionLevel())
73 didLeaveScriptContext();
69 } 74 }
70 75
71 static int recursionLevel(v8::Isolate* isolate) 76 static int recursionLevel(v8::Isolate* isolate)
72 { 77 {
73 return v8::MicrotasksScope::GetCurrentDepth(isolate); 78 return V8PerIsolateData::from(isolate)->recursionLevel();
74 } 79 }
75 80
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
76 class MicrotaskSuppression { 88 class MicrotaskSuppression {
77 USING_FAST_MALLOC(MicrotaskSuppression); 89 USING_FAST_MALLOC(MicrotaskSuppression);
78 WTF_MAKE_NONCOPYABLE(MicrotaskSuppression); 90 WTF_MAKE_NONCOPYABLE(MicrotaskSuppression);
79 public: 91 public:
80 explicit MicrotaskSuppression(v8::Isolate* isolate) 92 MicrotaskSuppression(v8::Isolate* isolate)
81 : m_scope(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks) 93 #if ENABLE(ASSERT)
94 : m_isolate(isolate)
95 #endif
82 { 96 {
97 #if ENABLE(ASSERT)
98 V8PerIsolateData::from(m_isolate)->incrementInternalScriptRecursionL evel();
99 #endif
83 } 100 }
84 101
85 ~MicrotaskSuppression() 102 ~MicrotaskSuppression()
86 { 103 {
104 #if ENABLE(ASSERT)
105 V8PerIsolateData::from(m_isolate)->decrementInternalScriptRecursionL evel();
106 #endif
87 } 107 }
88 108
89 private: 109 private:
90 v8::MicrotasksScope m_scope; 110 #if ENABLE(ASSERT)
111 v8::Isolate* m_isolate;
112 #endif
91 }; 113 };
92 114
93 private: 115 private:
94 v8::MicrotasksScope m_scope; 116 void didLeaveScriptContext();
117
118 v8::Isolate* m_isolate;
95 }; 119 };
96 120
97 } // namespace blink 121 } // namespace blink
98 122
99 #endif // V8RecursionScope_h 123 #endif // V8RecursionScope_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698