yaar@chromium.org | 37eb477 | 2010-05-20 21:56:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #include "config.h" |
utatane.tea@gmail.com | 11098d6 | 2018-08-06 04:37:10 +0000 | [diff] [blame] | 27 | #include "JSExecState.h" |
weinig@apple.com | 440ba0d | 2015-12-03 19:06:45 +0000 | [diff] [blame] | 28 | |
rniwa@webkit.org | 212d9bf | 2019-11-21 01:47:56 +0000 | [diff] [blame] | 29 | #include "EventLoop.h" |
joepeck@webkit.org | a6dfe9c | 2017-04-28 03:33:57 +0000 | [diff] [blame] | 30 | #include "RejectedPromiseTracker.h" |
| 31 | #include "ScriptExecutionContext.h" |
utatane.tea@gmail.com | 11098d6 | 2018-08-06 04:37:10 +0000 | [diff] [blame] | 32 | #include "WorkerGlobalScope.h" |
yaar@chromium.org | 37eb477 | 2010-05-20 21:56:45 +0000 | [diff] [blame] | 33 | |
| 34 | namespace WebCore { |
| 35 | |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 36 | void JSExecState::didLeaveScriptContext(JSC::JSGlobalObject* lexicalGlobalObject) |
adamk@chromium.org | 82abc77 | 2012-02-08 00:40:31 +0000 | [diff] [blame] | 37 | { |
darin@apple.com | 356814b | 2021-12-21 21:56:30 +0000 | [diff] [blame] | 38 | auto context = executionContext(lexicalGlobalObject); |
yusukesuzuki@slowstart.org | 5047295 | 2018-08-14 17:45:09 +0000 | [diff] [blame] | 39 | if (!context) |
| 40 | return; |
rniwa@webkit.org | 212d9bf | 2019-11-21 01:47:56 +0000 | [diff] [blame] | 41 | context->eventLoop().performMicrotaskCheckpoint(); |
gnavamarino@apple.com | f4ce59c | 2022-04-12 18:08:56 +0000 | [diff] [blame] | 42 | if (auto rejectedPromiseTracker = context->ensureRejectedPromiseTracker()) |
| 43 | rejectedPromiseTracker->processQueueSoon(); |
charles.wei@torchmobile.com.cn | f3b125d | 2012-06-08 23:41:36 +0000 | [diff] [blame] | 44 | } |
| 45 | |
ross.kirsling@sony.com | 924e750 | 2020-04-27 09:09:32 +0000 | [diff] [blame] | 46 | JSC::JSValue functionCallHandlerFromAnyThread(JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSValue functionObject, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, NakedPtr<JSC::Exception>& returnedException) |
joepeck@webkit.org | a319844 | 2013-12-11 22:40:23 +0000 | [diff] [blame] | 47 | { |
ross.kirsling@sony.com | 924e750 | 2020-04-27 09:09:32 +0000 | [diff] [blame] | 48 | return JSExecState::call(lexicalGlobalObject, functionObject, callData, thisValue, args, returnedException); |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 49 | } |
| 50 | |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 51 | JSC::JSValue evaluateHandlerFromAnyThread(JSC::JSGlobalObject* lexicalGlobalObject, const JSC::SourceCode& source, JSC::JSValue thisValue, NakedPtr<JSC::Exception>& returnedException) |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 52 | { |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 53 | return JSExecState::evaluate(lexicalGlobalObject, source, thisValue, returnedException); |
joepeck@webkit.org | a319844 | 2013-12-11 22:40:23 +0000 | [diff] [blame] | 54 | } |
| 55 | |
darin@apple.com | 356814b | 2021-12-21 21:56:30 +0000 | [diff] [blame] | 56 | ScriptExecutionContext* executionContext(JSC::JSGlobalObject* globalObject) |
| 57 | { |
ysuzuki@apple.com | 984775d | 2022-04-16 00:00:35 +0000 | [diff] [blame] | 58 | if (!globalObject || !globalObject->inherits<JSDOMGlobalObject>()) |
darin@apple.com | 356814b | 2021-12-21 21:56:30 +0000 | [diff] [blame] | 59 | return nullptr; |
aperez@igalia.com | e3adaf5 | 2021-12-30 22:33:31 +0000 | [diff] [blame] | 60 | return JSC::jsCast<JSDOMGlobalObject*>(globalObject)->scriptExecutionContext(); |
darin@apple.com | 356814b | 2021-12-21 21:56:30 +0000 | [diff] [blame] | 61 | } |
| 62 | |
yaar@chromium.org | 37eb477 | 2010-05-20 21:56:45 +0000 | [diff] [blame] | 63 | } // namespace WebCore |