OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 void requestInterrupt() override | 45 void requestInterrupt() override |
46 { | 46 { |
47 // GCTask has an empty run() method. Its only purpose is to guarantee | 47 // GCTask has an empty run() method. Its only purpose is to guarantee |
48 // that MessageLoop will have a task to process which will result | 48 // that MessageLoop will have a task to process which will result |
49 // in GCTaskRunner::didProcessTask being executed. | 49 // in GCTaskRunner::didProcessTask being executed. |
50 m_taskRunner->postTask(BLINK_FROM_HERE, new GCTask); | 50 m_taskRunner->postTask(BLINK_FROM_HERE, new GCTask); |
51 } | 51 } |
52 | 52 |
53 private: | 53 private: |
54 class GCTask : public WebTaskRunner::Task { | 54 class GCTask final : public WebTaskRunner::Task { |
| 55 USING_FAST_MALLOC(GCTask); |
55 public: | 56 public: |
56 virtual ~GCTask() { } | 57 virtual ~GCTask() { } |
57 | 58 |
58 void run() override | 59 void run() override |
59 { | 60 { |
60 // Don't do anything here because we don't know if this is | 61 // Don't do anything here because we don't know if this is |
61 // a nested event loop or not. GCTaskRunner::didProcessTask | 62 // a nested event loop or not. GCTaskRunner::didProcessTask |
62 // will enter correct safepoint for us. | 63 // will enter correct safepoint for us. |
63 // We are not calling onInterrupted() because that always | 64 // We are not calling onInterrupted() because that always |
64 // conservatively enters safepoint with pointers on stack. | 65 // conservatively enters safepoint with pointers on stack. |
65 } | 66 } |
66 }; | 67 }; |
67 | 68 |
68 WebTaskRunner* m_taskRunner; | 69 WebTaskRunner* m_taskRunner; |
69 }; | 70 }; |
70 | 71 |
71 class GCTaskObserver final : public WebThread::TaskObserver { | 72 class GCTaskObserver final : public WebThread::TaskObserver { |
| 73 USING_FAST_MALLOC(GCTaskObserver); |
72 public: | 74 public: |
73 GCTaskObserver() : m_nesting(0) { } | 75 GCTaskObserver() : m_nesting(0) { } |
74 | 76 |
75 ~GCTaskObserver() | 77 ~GCTaskObserver() |
76 { | 78 { |
77 // m_nesting can be 1 if this was unregistered in a task and | 79 // m_nesting can be 1 if this was unregistered in a task and |
78 // didProcessTask was not called. | 80 // didProcessTask was not called. |
79 ASSERT(!m_nesting || m_nesting == 1); | 81 ASSERT(!m_nesting || m_nesting == 1); |
80 } | 82 } |
81 | 83 |
(...skipping 11 matching lines...) Expand all Loading... |
93 m_nesting--; | 95 m_nesting--; |
94 | 96 |
95 ThreadState::current()->safePoint(m_nesting ? BlinkGC::HeapPointersOnSta
ck : BlinkGC::NoHeapPointersOnStack); | 97 ThreadState::current()->safePoint(m_nesting ? BlinkGC::HeapPointersOnSta
ck : BlinkGC::NoHeapPointersOnStack); |
96 } | 98 } |
97 | 99 |
98 private: | 100 private: |
99 int m_nesting; | 101 int m_nesting; |
100 }; | 102 }; |
101 | 103 |
102 class GCTaskRunner final { | 104 class GCTaskRunner final { |
| 105 USING_FAST_MALLOC(GCTaskRunner); |
103 public: | 106 public: |
104 explicit GCTaskRunner(WebThread* thread) | 107 explicit GCTaskRunner(WebThread* thread) |
105 : m_gcTaskObserver(adoptPtr(new GCTaskObserver)) | 108 : m_gcTaskObserver(adoptPtr(new GCTaskObserver)) |
106 , m_thread(thread) | 109 , m_thread(thread) |
107 { | 110 { |
108 m_thread->addTaskObserver(m_gcTaskObserver.get()); | 111 m_thread->addTaskObserver(m_gcTaskObserver.get()); |
109 ThreadState::current()->addInterruptor(adoptPtr(new MessageLoopInterrupt
or(thread->taskRunner()))); | 112 ThreadState::current()->addInterruptor(adoptPtr(new MessageLoopInterrupt
or(thread->taskRunner()))); |
110 } | 113 } |
111 | 114 |
112 ~GCTaskRunner() | 115 ~GCTaskRunner() |
113 { | 116 { |
114 m_thread->removeTaskObserver(m_gcTaskObserver.get()); | 117 m_thread->removeTaskObserver(m_gcTaskObserver.get()); |
115 } | 118 } |
116 | 119 |
117 private: | 120 private: |
118 OwnPtr<GCTaskObserver> m_gcTaskObserver; | 121 OwnPtr<GCTaskObserver> m_gcTaskObserver; |
119 WebThread* m_thread; | 122 WebThread* m_thread; |
120 }; | 123 }; |
121 | 124 |
122 } // namespace blink | 125 } // namespace blink |
123 | 126 |
124 #endif | 127 #endif |
OLD | NEW |