Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 for (int i = 0; i < call_completed_callbacks_->length(); i++) { | 141 for (int i = 0; i < call_completed_callbacks_->length(); i++) { |
| 142 if (callback == call_completed_callbacks_->at(i)) { | 142 if (callback == call_completed_callbacks_->at(i)) { |
| 143 call_completed_callbacks_->Remove(i); | 143 call_completed_callbacks_->Remove(i); |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 | 148 |
| 149 void V8::FireCallCompletedCallback(Isolate* isolate) { | 149 void V8::FireCallCompletedCallback(Isolate* isolate) { |
| 150 bool has_call_completed_callbacks = call_completed_callbacks_ != NULL; | 150 bool has_call_completed_callbacks = call_completed_callbacks_ != NULL; |
| 151 bool microtask_pending = isolate->microtask_pending(); | 151 bool run_microtasks = isolate->autorun_microtasks() && |
| 152 if (!has_call_completed_callbacks && !microtask_pending) return; | 152 isolate->microtask_pending(); |
| 153 if (!has_call_completed_callbacks && !run_microtasks) return; | |
| 153 | 154 |
| 154 HandleScopeImplementer* handle_scope_implementer = | 155 HandleScopeImplementer* handle_scope_implementer = |
| 155 isolate->handle_scope_implementer(); | 156 isolate->handle_scope_implementer(); |
| 156 if (!handle_scope_implementer->CallDepthIsZero()) return; | 157 if (!handle_scope_implementer->CallDepthIsZero()) return; |
| 157 // Fire callbacks. Increase call depth to prevent recursive callbacks. | 158 // Fire callbacks. Increase call depth to prevent recursive callbacks. |
| 158 handle_scope_implementer->IncrementCallDepth(); | 159 handle_scope_implementer->IncrementCallDepth(); |
| 159 if (microtask_pending) Execution::RunMicrotasks(isolate); | 160 if (run_microtasks) Execution::RunMicrotasks(isolate); |
| 160 if (has_call_completed_callbacks) { | 161 if (has_call_completed_callbacks) { |
| 161 for (int i = 0; i < call_completed_callbacks_->length(); i++) { | 162 for (int i = 0; i < call_completed_callbacks_->length(); i++) { |
| 162 call_completed_callbacks_->at(i)(); | 163 call_completed_callbacks_->at(i)(); |
| 163 } | 164 } |
| 164 } | 165 } |
| 165 handle_scope_implementer->DecrementCallDepth(); | 166 handle_scope_implementer->DecrementCallDepth(); |
| 166 } | 167 } |
| 167 | 168 |
| 168 | 169 |
| 170 void V8::RunMicrotasks(Isolate* isolate) { | |
| 171 if (!isolate->microtask_pending()) | |
| 172 return; | |
| 173 | |
| 174 HandleScopeImplementer* handle_scope_implementer = | |
| 175 isolate->handle_scope_implementer(); | |
| 176 ASSERT(handle_scope_implementer->CallDepthIsZero()); | |
| 177 | |
| 178 // Increase call depth to prevent recursive callbacks. | |
| 179 handle_scope_implementer->IncrementCallDepth(); | |
| 180 Execution::RunMicrotasks(isolate); | |
| 181 handle_scope_implementer->DecrementCallDepth(); | |
| 182 } | |
| 183 | |
| 184 | |
| 185 void V8::EnqueueMicrotask(Isolate* isolate, Handle<Object> microtask) { | |
|
dcarney
2014/02/12 07:17:15
this function seems kinds of pointless now, maybe
rafaelw
2014/02/12 21:25:04
Excellent point =-). Removed.
On 2014/02/12 07:17
| |
| 186 Execution::EnqueueMicrotask(isolate, microtask); | |
| 187 } | |
| 188 | |
| 189 | |
| 169 void V8::InitializeOncePerProcessImpl() { | 190 void V8::InitializeOncePerProcessImpl() { |
| 170 FlagList::EnforceFlagImplications(); | 191 FlagList::EnforceFlagImplications(); |
| 171 | 192 |
| 172 if (FLAG_predictable) { | 193 if (FLAG_predictable) { |
| 173 if (FLAG_random_seed == 0) { | 194 if (FLAG_random_seed == 0) { |
| 174 // Avoid random seeds in predictable mode. | 195 // Avoid random seeds in predictable mode. |
| 175 FLAG_random_seed = 12347; | 196 FLAG_random_seed = 12347; |
| 176 } | 197 } |
| 177 FLAG_hash_seed = 0; | 198 FLAG_hash_seed = 0; |
| 178 } | 199 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 platform_ = NULL; | 235 platform_ = NULL; |
| 215 } | 236 } |
| 216 | 237 |
| 217 | 238 |
| 218 v8::Platform* V8::GetCurrentPlatform() { | 239 v8::Platform* V8::GetCurrentPlatform() { |
| 219 ASSERT(platform_); | 240 ASSERT(platform_); |
| 220 return platform_; | 241 return platform_; |
| 221 } | 242 } |
| 222 | 243 |
| 223 } } // namespace v8::internal | 244 } } // namespace v8::internal |
| OLD | NEW |