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 6754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6765 | 6765 |
6766 | 6766 |
6767 void V8::RemoveCallCompletedCallback(CallCompletedCallback callback) { | 6767 void V8::RemoveCallCompletedCallback(CallCompletedCallback callback) { |
6768 i::Isolate::EnsureDefaultIsolate(); | 6768 i::Isolate::EnsureDefaultIsolate(); |
6769 i::Isolate* isolate = i::Isolate::Current(); | 6769 i::Isolate* isolate = i::Isolate::Current(); |
6770 if (IsDeadCheck(isolate, "v8::V8::RemoveLeaveScriptCallback()")) return; | 6770 if (IsDeadCheck(isolate, "v8::V8::RemoveLeaveScriptCallback()")) return; |
6771 i::V8::RemoveCallCompletedCallback(callback); | 6771 i::V8::RemoveCallCompletedCallback(callback); |
6772 } | 6772 } |
6773 | 6773 |
6774 | 6774 |
6775 int V8::GetCurrentThreadId() { | |
6776 i::Isolate* isolate = i::Isolate::Current(); | |
6777 EnsureInitializedForIsolate(isolate, "V8::GetCurrentThreadId()"); | |
6778 return isolate->thread_id().ToInteger(); | |
6779 } | |
6780 | |
6781 | |
6782 void V8::TerminateExecution(int thread_id) { | |
6783 i::Isolate* isolate = i::Isolate::Current(); | |
6784 if (!isolate->IsInitialized()) return; | |
6785 API_ENTRY_CHECK(isolate, "V8::TerminateExecution()"); | |
6786 // If the thread_id identifies the current thread just terminate | |
6787 // execution right away. Otherwise, ask the thread manager to | |
6788 // terminate the thread with the given id if any. | |
6789 i::ThreadId internal_tid = i::ThreadId::FromInteger(thread_id); | |
6790 if (isolate->thread_id().Equals(internal_tid)) { | |
6791 isolate->stack_guard()->TerminateExecution(); | |
6792 } else { | |
6793 isolate->thread_manager()->TerminateExecution(internal_tid); | |
6794 } | |
6795 } | |
6796 | |
6797 | |
6798 void V8::TerminateExecution(Isolate* isolate) { | 6775 void V8::TerminateExecution(Isolate* isolate) { |
6799 // If no isolate is supplied, use the default isolate. | 6776 // If no isolate is supplied, use the default isolate. |
6800 if (isolate != NULL) { | 6777 if (isolate != NULL) { |
6801 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution(); | 6778 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution(); |
6802 } else { | 6779 } else { |
6803 i::Isolate::GetDefaultIsolateStackGuard()->TerminateExecution(); | 6780 i::Isolate::GetDefaultIsolateStackGuard()->TerminateExecution(); |
6804 } | 6781 } |
6805 } | 6782 } |
6806 | 6783 |
6807 | 6784 |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7897 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7874 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7898 Address callback_address = | 7875 Address callback_address = |
7899 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7876 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7900 VMState<EXTERNAL> state(isolate); | 7877 VMState<EXTERNAL> state(isolate); |
7901 ExternalCallbackScope call_scope(isolate, callback_address); | 7878 ExternalCallbackScope call_scope(isolate, callback_address); |
7902 return callback(info); | 7879 return callback(info); |
7903 } | 7880 } |
7904 | 7881 |
7905 | 7882 |
7906 } } // namespace v8::internal | 7883 } } // namespace v8::internal |
OLD | NEW |