| 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 |
| 169 void V8::InitializeOncePerProcessImpl() { | 185 void V8::InitializeOncePerProcessImpl() { |
| 170 FlagList::EnforceFlagImplications(); | 186 FlagList::EnforceFlagImplications(); |
| 171 | 187 |
| 172 if (FLAG_predictable) { | 188 if (FLAG_predictable) { |
| 173 if (FLAG_random_seed == 0) { | 189 if (FLAG_random_seed == 0) { |
| 174 // Avoid random seeds in predictable mode. | 190 // Avoid random seeds in predictable mode. |
| 175 FLAG_random_seed = 12347; | 191 FLAG_random_seed = 12347; |
| 176 } | 192 } |
| 177 FLAG_hash_seed = 0; | 193 FLAG_hash_seed = 0; |
| 178 } | 194 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 platform_ = NULL; | 230 platform_ = NULL; |
| 215 } | 231 } |
| 216 | 232 |
| 217 | 233 |
| 218 v8::Platform* V8::GetCurrentPlatform() { | 234 v8::Platform* V8::GetCurrentPlatform() { |
| 219 ASSERT(platform_); | 235 ASSERT(platform_); |
| 220 return platform_; | 236 return platform_; |
| 221 } | 237 } |
| 222 | 238 |
| 223 } } // namespace v8::internal | 239 } } // namespace v8::internal |
| OLD | NEW |