Skip to content

Commit

Permalink
Rest of the changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner committed Jun 11, 2022
1 parent ff1f8e2 commit 8c70a89
Show file tree
Hide file tree
Showing 16 changed files with 440 additions and 18 deletions.
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
node_modules
**/node_modules
LayoutTests
zig-out
zig-build
**/*.o
**/*.a
**/.next
.git
**/CMakeCache.txt
CMakeCache.txt
WebKitBuild
ManualTests
Websites
WebDriverTests
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ __cmake_systeminformation/

# Local overrides configuration files
LocalOverrides.xcconfig

DerivedData
94 changes: 94 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# BuildKit is required to build this
# Enable via DOCKER_BUILDKIT=1
FROM ubuntu:20.04

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install --no-install-recommends -y wget gnupg2 curl lsb-release wget software-properties-common

RUN wget https://apt.llvm.org/llvm.sh --no-check-certificate
RUN chmod +x llvm.sh
RUN ./llvm.sh 13

# Use the same version of LLVM/clang used to build Zig
# This prevents the allocation failure
RUN apt-get update && apt-get install --no-install-recommends -y \
bc \
build-essential \
ca-certificates \
clang-13 \
clang-format-13 \
cmake \
cpio \
curl \
file \
g++ \
gcc \
git \
gnupg2 \
libicu66 \
libc++-13-dev \
libc++abi-13-dev \
libclang-13-dev \
liblld-13-dev \
libssl-dev \
lld-13 \
make \
ninja-build \
perl \
python2 \
rsync \
ruby \
software-properties-common \
unzip \
wget

RUN update-alternatives --install /usr/bin/ld ld /usr/bin/lld-13 90 && \
update-alternatives --install /usr/bin/cc cc /usr/bin/clang-13 90 && \
update-alternatives --install /usr/bin/cpp cpp /usr/bin/clang++-13 90 && \
update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-13 90


ENV WEBKIT_OUT_DIR=/webkitbuild

ENV CC=clang-13
ENV CXX=clang++-13

COPY . /webkit
WORKDIR /webkit

RUN mkdir -p /output/lib /output/include /output/include/JavaScriptCore /output/include/wtf /output/include/bmalloc

ARG WEBKIT_RELEASE_TYPE=Release

# | Explanation | Flag
# -----------------------------------------------------------------------------------------------------------------------------------------------------
# | Use the "JSCOnly" WebKit port | -DPORT="JSCOnly" |
# | Build JavaScriptCore as a static library | -DENABLE_STATIC_JSC=ON |
# | Build for release mode but include debug symbols | -DCMAKE_BUILD_TYPE=relwithdebuginfo |
# | The .a files shouldn't be symlinks to UnifiedSource.cpp files or else you can't move the files | -DUSE_THIN_ARCHIVES=OFF |
# | Enable the FTL Just-In-Time Compiler | -DENABLE_FTL_JIT=ON |
# -----------------------------------------------------------------------------------------------------------------------------------------------------

# Using tmpfs this way makes it compile 2x faster
# But means everything has to be one "RUN" statement
RUN --mount=type=tmpfs,target=/webkitbuild \
cd /webkitbuild && \
cmake \
-DPORT="JSCOnly" \
-DENABLE_STATIC_JSC=ON \
-DCMAKE_BUILD_TYPE=$WEBKIT_RELEASE_TYPE \
-DUSE_THIN_ARCHIVES=OFF \
-DENABLE_FTL_JIT=ON \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-G Ninja \
-DCMAKE_CXX_COMPILER=$(which clang++-13) \
-DCMAKE_C_COMPILER=$(which clang-13) \
/webkit && \
cd /webkitbuild && \
CFLAGS="$CFLAGS -ffat-lto-objects" CXXFLAGS="$CXXFLAGS -ffat-lto-objects" cmake --build /webkitbuild --config $WEBKIT_RELEASE_TYPE -- "jsc" -j$(nproc) && \
cp -r $WEBKIT_OUT_DIR/lib/*.a /output/lib && \
cp $WEBKIT_OUT_DIR/*.h /output/include && \
find $WEBKIT_OUT_DIR/JavaScriptCore/Headers/JavaScriptCore/ -name "*.h" -exec cp {} /output/include/JavaScriptCore/ \; && \
find $WEBKIT_OUT_DIR/JavaScriptCore/PrivateHeaders/JavaScriptCore/ -name "*.h" -exec cp {} /output/include/JavaScriptCore/ \; && \
cp -r $WEBKIT_OUT_DIR/WTF/Headers/wtf/ /output/include && \
cp -r $WEBKIT_OUT_DIR/bmalloc/Headers/bmalloc/ /output/include; echo "";
66 changes: 66 additions & 0 deletions Dockerfile.musl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
FROM alpine:3.15 as base

RUN apk update
RUN apk add --no-cache cmake make clang clang-static clang-dev llvm12-dev llvm12-static musl-dev git lld libgcc gcc g++ libstdc++ build-base lld-dev lld-static llvm12-libs libc-dev xz zlib zlib-dev libxml2 libxml2-dev

ENV CXX=clang++
ENV CC=clang
ENV LDFLAGS='-L/usr/include -L/usr/include/llvm12'
ENV CXXFLAGS="-I/usr/include -I/usr/include/llvm12"
ENV PATH="/usr/bin:/usr/local/bin:/zig/bin:$PATH"

FROM base as build_webkit

RUN apk add --no-cache cpio curl file gnupg icu-dev ninja ruby unzip rsync perl python2 openssl-dev openssl linux-headers

ENV WEBKIT_OUT_DIR=/webkit
# These are unnecessary on musl
# ENV CFLAGS="$CFLAGS -ffat-lto-objects"
# ENV CXXFLAGS="$CXXFLAGS -ffat-lto-objects"

WORKDIR /webkit-build

COPY . /webkit-src

RUN --mount=type=tmpfs,target=/webkit-build; \
cmake \
-DPORT="JSCOnly" \
-DENABLE_STATIC_JSC=ON \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_THIN_ARCHIVES=OFF \
-DENABLE_FTL_JIT=ON \
-G Ninja \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang \
/webkit-src && \
cd /webkit-build && \
cmake --build /webkit-build --config release -- "jsc" && \
mkdir -p ${WEBKIT_OUT_DIR}/lib ${WEBKIT_OUT_DIR}/include/JavaScriptCore && \
cp -r /webkit-build/lib/*.a $WEBKIT_OUT_DIR/lib && \
cp /webkit-build/*.h $WEBKIT_OUT_DIR/include && \
find /webkit-build/JavaScriptCore/Headers/JavaScriptCore/ -name "*.h" -exec cp {} $WEBKIT_OUT_DIR/include/JavaScriptCore/ \; && \
find /webkit-build/JavaScriptCore/PrivateHeaders/JavaScriptCore/ -name "*.h" -exec cp {} $WEBKIT_OUT_DIR/include/JavaScriptCore/ \; && \
cp -r /webkit-build/WTF/Headers/wtf/ $WEBKIT_OUT_DIR/include && \
cp -r /webkit-build/bmalloc/Headers/bmalloc/ $WEBKIT_OUT_DIR/include && echo "Done";


FROM base as build_icu

RUN apk add --no-cache cpio curl icu-dev tar


WORKDIR /icu-src
RUN --mount=type=tmpfs,target=/icu-src; curl -L https://github.com/unicode-org/icu/releases/download/release-66-1/icu4c-66_1-src.tgz > icu4c-66_1-src.tgz && \
tar -xzf icu4c-66_1-src.tgz && \
rm icu4c-66_1-src.tgz && \
cd icu/source && \
./configure --enable-static --disable-shared && \
make -j$(nproc) && \
mkdir -p /icu && \
cp -r lib/*.a /icu


FROM alpine:3.15 as webkit

COPY --from=build_webkit /webkit /webkit
COPY --from=build_icu /icu/*.a /webkit/lib
20 changes: 18 additions & 2 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# WebKit with patches

This is a fork of WebKit used by a new JavaScript bundler. It's not designed for usage outside the bundler.

The changes to WebKit are as follows:

- Many of the locks in the C API are removed. Locking is handled internally by the bundler.
- `JSString` iterator that exposes the pointer of each nested `JSRopeString`'s underlying buffer to a callback without flattening/allocating an entirely new string. This is useful for native code piping strings from JavaScript to elsewhere, or manually allocating strings outside of `WTF::String`. `console.log` or server-side rendering (when not using streams) are examples.
- `ExternalStringImpl` now supports static strings. This is somewhat of a hack; the better solution for this case is a script that generates all the static strings at compile time using `NeverDestroyed<StaticStringImpl>`, however need to figure out a way to do that well from Zig.
- Several additional methods exposed in the C API, such as a fast path for checking string equality from UTF8. In a future version, all the changes to the C API should be removed in place of a new API that looks more like WebCore but with C bindings.
- `OptionsJSC.cmake` changes to always build with debug symbols, amongst other things.

Still need to figure out how to get the remote inspector to work.

---

# WebKit

WebKit is a cross-platform web browser engine. On iOS and macOS, it powers Safari, Mail, iBooks, and many other applications.
Expand Down Expand Up @@ -59,7 +75,7 @@ For performance testing, and other purposes, use `--release` instead.

You can open `WebKit.xcworkspace` to build and debug WebKit within Xcode.

If you don't use a custom build location in Xcode preferences, you have to update the workspace settings to use `WebKitBuild` directory. In menu bar, choose File > Workspace Settings, then click the Advanced button, select "Custom", "Relative to Workspace", and enter `WebKitBuild` for both Products and Intermediates.
If you don't use a custom build location in Xcode preferences, you have to update the workspace settings to use `WebKitBuild` directory. In menu bar, choose File > Workspace Settings, then click the Advanced button, select "Custom", "Relative to Workspace", and enter `WebKitBuild` for both Products and Intermediates.

### Embedded Builds

Expand All @@ -78,6 +94,7 @@ Tools/Scripts/build-webkit --debug --<platform>-simulator
```

or embedded devices:

```
Tools/Scripts/build-webkit --debug --<platform>-device
```
Expand Down Expand Up @@ -167,4 +184,3 @@ Pass one of `--gtk`, `--jsc-only`, or `--wpe` to indicate the port to use.
## Contribute

Congratulations! You’re up and running. Now you can begin coding in WebKit and contribute your fixes and new features to the project. For details on submitting your code to the project, read [Contributing Code](https://webkit.org/contributing-code/).

58 changes: 58 additions & 0 deletions Source/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"cmake.configureOnOpen": false,
"files.exclude": {
"ThirdParty/": true,
"WebDriver": true,
"WebInspectorUI/": true,
"WebKit": true,
"WebKitBuild": true,
"WebKitLegacy": true
},
"files.associations": {
"memory": "cpp",
"__functional_base": "cpp",
"__functional_base_03": "cpp",
"__hash_table": "cpp",
"__tree": "cpp",
"__tuple": "cpp",
"algorithm": "cpp",
"array": "cpp",
"chrono": "cpp",
"cstddef": "cpp",
"type_traits": "cpp",
"filesystem": "cpp",
"functional": "cpp",
"iterator": "cpp",
"limits": "cpp",
"random": "cpp",
"ratio": "cpp",
"tuple": "cpp",
"utility": "cpp",
"*.idl": "cpp",
"__mutex_base": "cpp",
"__locale": "cpp",
"__config": "cpp",
"__threading_support": "cpp",
"thread": "cpp",
"__split_buffer": "cpp",
"atomic": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"ios": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"system_error": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"__bit_reference": "cpp",
"__node_handle": "cpp",
"bitset": "cpp",
"__memory": "cpp",
"locale": "cpp",
"optional": "cpp",
"regex": "cpp"
}
}
60 changes: 60 additions & 0 deletions Source/JavaScriptCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -885,19 +885,33 @@ set(JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS

llint/LLIntOpcode.h


bytecode/UnlinkedFunctionCodeBlock.h
bytecode/UnlinkedModuleProgramCodeBlock.h
bytecode/UnlinkedProgramCodeBlock.h
bytecode/ParseHash.h
bytecompiler/Label.h

parser/ExecutableInfo.h
parser/Lexer.h
parser/ModuleScopeData.h
parser/Nodes.h
parser/Parser.h
parser/ParserArena.h
parser/ParserError.h
parser/ParserFunctionInfo.h
parser/ParserModes.h
parser/ParserTokens.h
parser/ResultType.h
parser/SourceCode.h
parser/SourceCodeKey.h
parser/SourceProvider.h
parser/SourceProviderCache.h
parser/SourceProviderCacheItem.h
parser/UnlinkedSourceCode.h
parser/VariableEnvironment.h


profiler/ProfilerBytecode.h
profiler/ProfilerBytecodeSequence.h
profiler/ProfilerBytecodes.h
Expand All @@ -915,6 +929,8 @@ set(JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS
profiler/ProfilerProfiledBytecodes.h
profiler/ProfilerUID.h

runtime/AggregateError.h

runtime/AbstractModuleRecord.h
runtime/ArgList.h
runtime/ArityCheckMode.h
Expand Down Expand Up @@ -952,6 +968,7 @@ set(JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS
runtime/CatchScope.h
runtime/CellSize.h
runtime/ClassInfo.h
runtime/CodeCache.h
runtime/CodeSpecializationKind.h
runtime/CommonIdentifiers.h
runtime/CompilationResult.h
Expand Down Expand Up @@ -985,6 +1002,7 @@ set(JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS
runtime/EnsureStillAliveHere.h
runtime/EnumerationMode.h
runtime/Error.h
runtime/ErrorConstructor.h
runtime/ErrorHandlingScope.h
runtime/ErrorInstance.h
runtime/ErrorPrototype.h
Expand Down Expand Up @@ -1272,8 +1290,50 @@ set(JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS
yarr/YarrParser.h
yarr/YarrPattern.h
yarr/YarrUnicodeProperties.h

bytecode/Opcode.h
llint/LLIntOpcode.h

runtime/LazyClassStructureInlines.h
runtime/LazyPropertyInlines.h
runtime/JSTypedArrayViewPrototype.h
runtime/JSTypedArrayPrototypes.h
API/JSWeakValue.h

jit/JIT.h
bytecode/StructureStubInfo.h
bytecode/PolymorphicAccess.h
bytecode/AccessCase.h
bytecode/ObjectPropertyConditionSet.h
bytecode/PolyProtoAccessChain.h
bytecode/PutKind.h
bytecode/StructureStubClearingWatchpoint.h
bytecode/AdaptiveInferredPropertyValueWatchpointBase.h
bytecode/StubInfoSummary.h
runtime/CommonSlowPaths.h
runtime/DirectArguments.h
runtime/GenericArguments.h
runtime/ScopedArguments.h
runtime/JSLexicalEnvironment.h
jit/JITDisassembler.h
jit/JITInlineCacheGenerator.h
jit/JITMathIC.h
jit/JITAddGenerator.h
jit/JITMathICInlineResult.h
jit/SnippetOperand.h
jit/JITMulGenerator.h
jit/JITNegGenerator.h
jit/JITSubGenerator.h
bytecode/Repatch.h
jit/JITRightShiftGenerator.h
jit/JITBitBinaryOpGenerator.h
jit/JSInterfaceJIT.h
llint/LLIntData.h
bytecode/FunctionCodeBlock.h
)



if (USE_INSPECTOR_SOCKET_SERVER)
list(APPEND JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS
API/JSRemoteInspectorServer.h
Expand Down
Loading

0 comments on commit 8c70a89

Please sign in to comment.