OLD | NEW |
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // | 49 // |
50 // Calls of type (1) should generally go through ScriptController, as inspector | 50 // Calls of type (1) should generally go through ScriptController, as inspector |
51 // instrumentation is needed. ScriptController allocates V8RecursionScope for yo
u. | 51 // instrumentation is needed. ScriptController allocates V8RecursionScope for yo
u. |
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 V8RecursionScope { | 58 class V8RecursionScope { |
59 WTF_MAKE_NONCOPYABLE(V8RecursionScope); | 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_isolate(isolate) |
63 { | 63 { |
64 RELEASE_ASSERT(!ScriptForbiddenScope::isScriptForbidden()); | 64 RELEASE_ASSERT(!ScriptForbiddenScope::isScriptForbidden()); |
65 V8PerIsolateData::from(m_isolate)->incrementRecursionLevel(); | 65 V8PerIsolateData::from(m_isolate)->incrementRecursionLevel(); |
66 // If you want V8 to autorun microtasks, this class needs to have a | 66 // If you want V8 to autorun microtasks, this class needs to have a |
67 // v8::Isolate::SuppressMicrotaskExecutionScope member. | 67 // v8::Isolate::SuppressMicrotaskExecutionScope member. |
68 ASSERT(!isolate->WillAutorunMicrotasks()); | 68 ASSERT(!isolate->WillAutorunMicrotasks()); |
69 } | 69 } |
(...skipping 10 matching lines...) Expand all Loading... |
80 } | 80 } |
81 | 81 |
82 #if ENABLE(ASSERT) | 82 #if ENABLE(ASSERT) |
83 static bool properlyUsed(v8::Isolate* isolate) | 83 static bool properlyUsed(v8::Isolate* isolate) |
84 { | 84 { |
85 return recursionLevel(isolate) > 0 || V8PerIsolateData::from(isolate)->i
nternalScriptRecursionLevel() > 0; | 85 return recursionLevel(isolate) > 0 || V8PerIsolateData::from(isolate)->i
nternalScriptRecursionLevel() > 0; |
86 } | 86 } |
87 #endif | 87 #endif |
88 | 88 |
89 class MicrotaskSuppression { | 89 class MicrotaskSuppression { |
| 90 WTF_MAKE_FAST_ALLOCATED(MicrotaskSuppression); |
| 91 WTF_MAKE_NONCOPYABLE(MicrotaskSuppression); |
90 public: | 92 public: |
91 MicrotaskSuppression(v8::Isolate* isolate) | 93 MicrotaskSuppression(v8::Isolate* isolate) |
92 #if ENABLE(ASSERT) | 94 #if ENABLE(ASSERT) |
93 : m_isolate(isolate) | 95 : m_isolate(isolate) |
94 #endif | 96 #endif |
95 { | 97 { |
96 ASSERT(!ScriptForbiddenScope::isScriptForbidden()); | 98 ASSERT(!ScriptForbiddenScope::isScriptForbidden()); |
97 #if ENABLE(ASSERT) | 99 #if ENABLE(ASSERT) |
98 V8PerIsolateData::from(m_isolate)->incrementInternalScriptRecursionL
evel(); | 100 V8PerIsolateData::from(m_isolate)->incrementInternalScriptRecursionL
evel(); |
99 #endif | 101 #endif |
(...skipping 14 matching lines...) Expand all Loading... |
114 | 116 |
115 private: | 117 private: |
116 void didLeaveScriptContext(); | 118 void didLeaveScriptContext(); |
117 | 119 |
118 v8::Isolate* m_isolate; | 120 v8::Isolate* m_isolate; |
119 }; | 121 }; |
120 | 122 |
121 } // namespace blink | 123 } // namespace blink |
122 | 124 |
123 #endif // V8RecursionScope_h | 125 #endif // V8RecursionScope_h |
OLD | NEW |