fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 1 | /* |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 2 | * Copyright (C) 2013-2019 Apple Inc. All rights reserved. |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 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. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #include "config.h" |
ossy@webkit.org | beb0de4 | 2014-02-17 19:00:03 +0000 | [diff] [blame] | 27 | #include "DFGToFTLForOSREntryDeferredCompilationCallback.h" |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 28 | |
| 29 | #if ENABLE(FTL_JIT) |
| 30 | |
| 31 | #include "CodeBlock.h" |
| 32 | #include "DFGJITCode.h" |
benjamin@webkit.org | 31527f5 | 2016-03-09 17:51:38 +0000 | [diff] [blame] | 33 | #include "FTLForOSREntryJITCode.h" |
fpizlo@apple.com | fb7eff2 | 2014-02-11 01:45:50 +0000 | [diff] [blame] | 34 | #include "JSCInlines.h" |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 35 | |
| 36 | namespace JSC { namespace DFG { |
| 37 | |
jfbastien@apple.com | e551457 | 2017-02-04 01:17:38 +0000 | [diff] [blame] | 38 | ToFTLForOSREntryDeferredCompilationCallback::ToFTLForOSREntryDeferredCompilationCallback(JITCode::TriggerReason* forcedOSREntryTrigger) |
benjamin@webkit.org | 31527f5 | 2016-03-09 17:51:38 +0000 | [diff] [blame] | 39 | : m_forcedOSREntryTrigger(forcedOSREntryTrigger) |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 40 | { |
| 41 | } |
| 42 | |
| 43 | ToFTLForOSREntryDeferredCompilationCallback::~ToFTLForOSREntryDeferredCompilationCallback() |
| 44 | { |
| 45 | } |
| 46 | |
jfbastien@apple.com | e551457 | 2017-02-04 01:17:38 +0000 | [diff] [blame] | 47 | Ref<ToFTLForOSREntryDeferredCompilationCallback>ToFTLForOSREntryDeferredCompilationCallback::create(JITCode::TriggerReason* forcedOSREntryTrigger) |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 48 | { |
benjamin@webkit.org | 31527f5 | 2016-03-09 17:51:38 +0000 | [diff] [blame] | 49 | return adoptRef(*new ToFTLForOSREntryDeferredCompilationCallback(forcedOSREntryTrigger)); |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | void ToFTLForOSREntryDeferredCompilationCallback::compilationDidBecomeReadyAsynchronously( |
ggaren@apple.com | 81def5f | 2015-10-09 23:10:16 +0000 | [diff] [blame] | 53 | CodeBlock* codeBlock, CodeBlock* profiledDFGCodeBlock) |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 54 | { |
| 55 | if (Options::verboseOSR()) { |
| 56 | dataLog( |
ggaren@apple.com | 81def5f | 2015-10-09 23:10:16 +0000 | [diff] [blame] | 57 | "Optimizing compilation of ", *codeBlock, " (for ", *profiledDFGCodeBlock, |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 58 | ") did become ready.\n"); |
| 59 | } |
benjamin@webkit.org | 31527f5 | 2016-03-09 17:51:38 +0000 | [diff] [blame] | 60 | |
jfbastien@apple.com | e551457 | 2017-02-04 01:17:38 +0000 | [diff] [blame] | 61 | *m_forcedOSREntryTrigger = JITCode::TriggerReason::CompilationDone; |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | void ToFTLForOSREntryDeferredCompilationCallback::compilationDidComplete( |
ggaren@apple.com | 81def5f | 2015-10-09 23:10:16 +0000 | [diff] [blame] | 65 | CodeBlock* codeBlock, CodeBlock* profiledDFGCodeBlock, CompilationResult result) |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 66 | { |
| 67 | if (Options::verboseOSR()) { |
| 68 | dataLog( |
ggaren@apple.com | 81def5f | 2015-10-09 23:10:16 +0000 | [diff] [blame] | 69 | "Optimizing compilation of ", *codeBlock, " (for ", *profiledDFGCodeBlock, |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 70 | ") result: ", result, "\n"); |
| 71 | } |
| 72 | |
ggaren@apple.com | 81def5f | 2015-10-09 23:10:16 +0000 | [diff] [blame] | 73 | JITCode* jitCode = profiledDFGCodeBlock->jitCode()->dfg(); |
fpizlo@apple.com | 0c60670 | 2014-02-06 07:11:48 +0000 | [diff] [blame] | 74 | |
| 75 | switch (result) { |
benjamin@webkit.org | 31527f5 | 2016-03-09 17:51:38 +0000 | [diff] [blame] | 76 | case CompilationSuccessful: { |
mark.lam@apple.com | 5ba0779 | 2019-08-27 22:14:52 +0000 | [diff] [blame] | 77 | jitCode->setOSREntryBlock(codeBlock->vm(), profiledDFGCodeBlock, codeBlock); |
benjamin@webkit.org | 31527f5 | 2016-03-09 17:51:38 +0000 | [diff] [blame] | 78 | unsigned osrEntryBytecode = codeBlock->jitCode()->ftlForOSREntry()->bytecodeIndex(); |
jfbastien@apple.com | e551457 | 2017-02-04 01:17:38 +0000 | [diff] [blame] | 79 | jitCode->tierUpEntryTriggers.set(osrEntryBytecode, JITCode::TriggerReason::CompilationDone); |
mark.lam@apple.com | aebf685 | 2014-03-03 21:39:21 +0000 | [diff] [blame] | 80 | break; |
benjamin@webkit.org | 31527f5 | 2016-03-09 17:51:38 +0000 | [diff] [blame] | 81 | } |
fpizlo@apple.com | 0c60670 | 2014-02-06 07:11:48 +0000 | [diff] [blame] | 82 | case CompilationFailed: |
| 83 | jitCode->osrEntryRetry = 0; |
| 84 | jitCode->abandonOSREntry = true; |
benjamin@webkit.org | 31527f5 | 2016-03-09 17:51:38 +0000 | [diff] [blame] | 85 | profiledDFGCodeBlock->jitCode()->dfg()->setOptimizationThresholdBasedOnCompilationResult( |
| 86 | profiledDFGCodeBlock, result); |
mark.lam@apple.com | aebf685 | 2014-03-03 21:39:21 +0000 | [diff] [blame] | 87 | break; |
fpizlo@apple.com | 0c60670 | 2014-02-06 07:11:48 +0000 | [diff] [blame] | 88 | case CompilationDeferred: |
mark.lam@apple.com | aebf685 | 2014-03-03 21:39:21 +0000 | [diff] [blame] | 89 | RELEASE_ASSERT_NOT_REACHED(); |
fpizlo@apple.com | 0c60670 | 2014-02-06 07:11:48 +0000 | [diff] [blame] | 90 | case CompilationInvalidated: |
| 91 | jitCode->osrEntryRetry = 0; |
mark.lam@apple.com | aebf685 | 2014-03-03 21:39:21 +0000 | [diff] [blame] | 92 | break; |
fpizlo@apple.com | 0c60670 | 2014-02-06 07:11:48 +0000 | [diff] [blame] | 93 | } |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 94 | |
ggaren@apple.com | 81def5f | 2015-10-09 23:10:16 +0000 | [diff] [blame] | 95 | DeferredCompilationCallback::compilationDidComplete(codeBlock, profiledDFGCodeBlock, result); |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | } } // JSC::DFG |
| 99 | |
| 100 | #endif // ENABLE(FTL_JIT) |