Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Disable the JS JIT when running in a translated process
https://bugs.webkit.org/show_bug.cgi?id=213478

Reviewed by Saam Barati.

Source/JavaScriptCore:

* runtime/Options.cpp:
(JSC::Options::recomputeDependentOptions):
Based on our performance experiements, disable the JavaScript JIT
(but not the regular expression, DOM, or Wasm JIT) when running
in a translated process.

Source/WTF:

* wtf/PlatformHave.h:
* wtf/TranslatedProcess.h: Added.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
Add a helper function that can be used to determine that the current process
is being translated; currently the only case is an x86_64 process running on arm64e.


Canonical link: https://commits.webkit.org/226271@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263365 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
hortont424 committed Jun 22, 2020
1 parent c09a1e3 commit d2f7f3f
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,16 @@
2020-06-22 Tim Horton <timothy_horton@apple.com>

Disable the JS JIT when running in a translated process
https://bugs.webkit.org/show_bug.cgi?id=213478

Reviewed by Saam Barati.

* runtime/Options.cpp:
(JSC::Options::recomputeDependentOptions):
Based on our performance experiements, disable the JavaScript JIT
(but not the regular expression, DOM, or Wasm JIT) when running
in a translated process.

2020-06-22 Tim Horton <timothy_horton@apple.com>

Update macOS version macros
Expand Down
7 changes: 7 additions & 0 deletions Source/JavaScriptCore/runtime/Options.cpp
Expand Up @@ -42,6 +42,7 @@
#include <wtf/Optional.h>
#include <wtf/OSLogPrintStream.h>
#include <wtf/StdLibExtras.h>
#include <wtf/TranslatedProcess.h>
#include <wtf/text/StringBuilder.h>
#include <wtf/threads/Signals.h>

Expand Down Expand Up @@ -428,6 +429,12 @@ void Options::recomputeDependentOptions()
if (!jitEnabledByDefault() && !Options::useJIT())
Options::useLLInt() = true;

if (WTF::isX86BinaryRunningOnARM() && Options::useJIT()) {
Options::useBaselineJIT() = false;
Options::useDFGJIT() = false;
Options::useFTLJIT() = false;
}

if (!Options::useWebAssembly())
Options::useFastTLSForWasmContext() = false;

Expand Down
14 changes: 14 additions & 0 deletions Source/WTF/ChangeLog
@@ -1,3 +1,17 @@
2020-06-22 Tim Horton <timothy_horton@apple.com>

Disable the JS JIT when running in a translated process
https://bugs.webkit.org/show_bug.cgi?id=213478

Reviewed by Saam Barati.

* wtf/PlatformHave.h:
* wtf/TranslatedProcess.h: Added.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
Add a helper function that can be used to determine that the current process
is being translated; currently the only case is an x86_64 process running on arm64e.

2020-06-22 Tim Horton <timothy_horton@apple.com>

Update macOS version macros
Expand Down
2 changes: 2 additions & 0 deletions Source/WTF/WTF.xcodeproj/project.pbxproj
Expand Up @@ -361,6 +361,7 @@
2CDED0EE18115C38004DBA70 /* RunLoopCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoopCF.cpp; sourceTree = "<group>"; };
2CDED0F118115C85004DBA70 /* RunLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoop.cpp; sourceTree = "<group>"; };
2CDED0F218115C85004DBA70 /* RunLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RunLoop.h; sourceTree = "<group>"; };
2D1F2F462498F73300C63A83 /* TranslatedProcess.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TranslatedProcess.h; sourceTree = "<group>"; };
2DA442FC24904CA000C9C59D /* OSLogSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OSLogSPI.h; sourceTree = "<group>"; };
304CA4E41375437EBE931D03 /* Markable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Markable.h; sourceTree = "<group>"; };
3137E1D7DBD84AC38FAE4D34 /* IndexSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IndexSet.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1269,6 +1270,7 @@
0F7075F31FBF537A00489AF0 /* TimingScope.h */,
553071C91C40427200384898 /* TinyLRUCache.h */,
0FED67B51B22D4D80066CE15 /* TinyPtrSet.h */,
2D1F2F462498F73300C63A83 /* TranslatedProcess.h */,
149EF16216BBFE0D000A4331 /* TriState.h */,
83FBA93119DF459700F30ADB /* TypeCasts.h */,
E360C7642127B85B00C90F0E /* UnalignedAccess.h */,
Expand Down
1 change: 1 addition & 0 deletions Source/WTF/wtf/CMakeLists.txt
Expand Up @@ -265,6 +265,7 @@ set(WTF_PUBLIC_HEADERS
TimingScope.h
TinyLRUCache.h
TinyPtrSet.h
TranslatedProcess.h
TriState.h
TypeCasts.h
URL.h
Expand Down
4 changes: 4 additions & 0 deletions Source/WTF/wtf/PlatformHave.h
Expand Up @@ -649,3 +649,7 @@
#if PLATFORM(IOS_FAMILY) && !PLATFORM(MACCATALYST)
#define HAVE_FRONTBOARD_SYSTEM_APP_SERVICES 1
#endif

#if OS(DARWIN) && CPU(X86_64) && ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101600) || (PLATFORM(MACCATALYST) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000))
#define HAVE_CPU_TRANSLATION_CAPABILITY 1
#endif
43 changes: 43 additions & 0 deletions Source/WTF/wtf/TranslatedProcess.h
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

#if HAVE(CPU_TRANSLATION_CAPABILITY)
#include <System/i386/cpu_capabilities.h>
#endif

namespace WTF {

inline bool isX86BinaryRunningOnARM()
{
#if HAVE(CPU_TRANSLATION_CAPABILITY)
return (*(uint64_t*)_COMM_PAGE_CPU_CAPABILITIES64) & kIsTranslated;
#else
return false;
#endif
}

}

0 comments on commit d2f7f3f

Please sign in to comment.