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 6275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6286 callback); | 6286 callback); |
| 6287 } | 6287 } |
| 6288 | 6288 |
| 6289 | 6289 |
| 6290 void V8::AddCallCompletedCallback(CallCompletedCallback callback) { | 6290 void V8::AddCallCompletedCallback(CallCompletedCallback callback) { |
| 6291 if (callback == NULL) return; | 6291 if (callback == NULL) return; |
| 6292 i::V8::AddCallCompletedCallback(callback); | 6292 i::V8::AddCallCompletedCallback(callback); |
| 6293 } | 6293 } |
| 6294 | 6294 |
| 6295 | 6295 |
| 6296 void V8::RunMicrotasks(Isolate* isolate) { | |
| 6297 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | |
| 6298 i::HandleScope scope(i_isolate); | |
| 6299 i::V8::RunMicrotasks(i_isolate); | |
| 6300 } | |
| 6301 | |
| 6302 | |
| 6303 static void ExternalMicrotaskFunctionCallback( | |
| 6304 const v8::FunctionCallbackInfo<Value>& info) { | |
| 6305 STATIC_ASSERT( | |
| 6306 sizeof(ExternalMicrotaskCallback) == sizeof(v8::internal::Address)); | |
| 6307 ExternalMicrotaskCallback callback = | |
| 6308 reinterpret_cast<ExternalMicrotaskCallback>(reinterpret_cast<intptr_t>( | |
| 6309 info.Data().As<External>()->Value())); | |
| 6310 (*callback)(info.GetIsolate()); | |
| 6311 } | |
| 6312 | |
| 6313 | |
| 6314 void V8::EnqueueExternalMicrotask(Isolate* isolate, | |
| 6315 ExternalMicrotaskCallback callback) { | |
|
dcarney
2014/02/11 07:47:13
No need for a new ExternalMicrotaskCallback type:
rafaelw
2014/02/11 20:37:43
Done.
| |
| 6316 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | |
| 6317 ENTER_V8(i_isolate); | |
| 6318 i::HandleScope scope(i_isolate); | |
| 6319 STATIC_ASSERT( | |
| 6320 sizeof(ExternalMicrotaskCallback) == sizeof(v8::internal::Address)); | |
| 6321 Local<External> external_callback = | |
| 6322 External::New(isolate, | |
| 6323 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(callback))); | |
| 6324 Local<Function> local_handler = Function::New(isolate, | |
| 6325 &ExternalMicrotaskFunctionCallback, external_callback); | |
| 6326 i::Handle<i::Object> handler = Utils::OpenHandle(*local_handler); | |
| 6327 i::V8::EnqueueExternalMicrotask(i_isolate, handler); | |
| 6328 } | |
| 6329 | |
| 6330 | |
| 6331 void V8::SetAutorunMicrotasks(Isolate* isolate, bool autorun) { | |
| 6332 reinterpret_cast<i::Isolate*>(isolate)->set_autorun_microtasks(autorun); | |
| 6333 } | |
| 6334 | |
| 6335 | |
| 6296 void V8::RemoveCallCompletedCallback(CallCompletedCallback callback) { | 6336 void V8::RemoveCallCompletedCallback(CallCompletedCallback callback) { |
| 6297 i::V8::RemoveCallCompletedCallback(callback); | 6337 i::V8::RemoveCallCompletedCallback(callback); |
| 6298 } | 6338 } |
| 6299 | 6339 |
| 6300 | 6340 |
| 6301 void V8::TerminateExecution(Isolate* isolate) { | 6341 void V8::TerminateExecution(Isolate* isolate) { |
| 6302 // If no isolate is supplied, use the default isolate. | 6342 // If no isolate is supplied, use the default isolate. |
| 6303 if (isolate != NULL) { | 6343 if (isolate != NULL) { |
| 6304 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution(); | 6344 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution(); |
| 6305 } else { | 6345 } else { |
| (...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7351 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7391 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7352 Address callback_address = | 7392 Address callback_address = |
| 7353 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7393 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7354 VMState<EXTERNAL> state(isolate); | 7394 VMState<EXTERNAL> state(isolate); |
| 7355 ExternalCallbackScope call_scope(isolate, callback_address); | 7395 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7356 callback(info); | 7396 callback(info); |
| 7357 } | 7397 } |
| 7358 | 7398 |
| 7359 | 7399 |
| 7360 } } // namespace v8::internal | 7400 } } // namespace v8::internal |
| OLD | NEW |