commit | fb8c73c90a4aa82c1ebffe5159aa3657a0e118a3 | [log] [tgz] |
---|---|---|
author | ysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Thu May 30 21:40:35 2019 +0000 |
committer | ysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Thu May 30 21:40:35 2019 +0000 |
tree | 77957fdad4ddea96f8b9c781b4f50a102c8503f8 | |
parent | d21f37e1bc12d55caa201871531fa05ccf9f233b [diff] |
[JSC] Implement op_wide16 / op_wide32 and introduce 16bit version bytecode https://bugs.webkit.org/show_bug.cgi?id=197979 Reviewed by Filip Pizlo. JSTests: * stress/16bit-code.js: Added. (shouldBe): * stress/32bit-code.js: Added. (shouldBe): Source/JavaScriptCore: This patch introduces 16bit bytecode size. Previously, we had two versions of bytecodes, 8bit and 32bit. However, in Gmail, we found that a lot of bytecodes get 32bit because they do not fit in 8bit. 8bit is very small and large function easily emits a lot of 32bit bytecodes because of large VirtualRegister number etc. But they almost always fit in 16bit. If we can have 16bit version of bytecode, we can make most of the current 32bit bytecodes 16bit and save memory. We rename rename op_wide to op_wide32 and introduce op_wide16. The mechanism is similar to old op_wide. When we get op_wide16, the following bytecode data is 16bit, and we execute 16bit version of bytecode in LLInt. We also disable this op_wide16 feature in Windows CLoop, which is used in AppleWin port. When the code size of CLoop::execute increases, MSVC starts generating CLoop::execute function with very large stack allocation requirement. Even before introducing this 16bit bytecode, CLoop::execute in AppleWin takes almost 100KB stack height. After introducing this, it becomes 160KB. While the semantics of the function is correctly compiled, such a large stack allocation is not essentially necessary, and this leads to stack overflow errors quite easily, and tests fail with AppleWin port because it starts throwing stack overflow range error in various places. In this patch, for now, we just disable op_wide16 feature for AppleWin so that CLoop::execute takes 100KB stack allocation because this patch is not focusing on fixing AppleWin's CLoop issue. We introduce a new backend type for LLInt, "C_LOOP_WIN". "C_LOOP_WIN" do not generate wide16 version of code to reduce the code size of CLoop::execute. In the future, we should investigate whether this MSVC issue is fixed in Visual Studio 2019. Or we should consider always enabling ASM LLInt for Windows. This patch improves Gmail by 7MB at least. * CMakeLists.txt: * bytecode/BytecodeConventions.h: * bytecode/BytecodeDumper.cpp: (JSC::BytecodeDumper<Block>::dumpBlock): * bytecode/BytecodeList.rb: * bytecode/BytecodeRewriter.h: (JSC::BytecodeRewriter::Fragment::align): * bytecode/BytecodeUseDef.h: (JSC::computeUsesForBytecodeOffset): (JSC::computeDefsForBytecodeOffset): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): * bytecode/CodeBlock.h: (JSC::CodeBlock::metadataTable const): * bytecode/Fits.h: * bytecode/Instruction.h: (JSC::Instruction::opcodeID const): (JSC::Instruction::isWide16 const): (JSC::Instruction::isWide32 const): (JSC::Instruction::hasMetadata const): (JSC::Instruction::sizeShiftAmount const): (JSC::Instruction::size const): (JSC::Instruction::wide16 const): (JSC::Instruction::wide32 const): (JSC::Instruction::isWide const): Deleted. (JSC::Instruction::wide const): Deleted. * bytecode/InstructionStream.h: (JSC::InstructionStreamWriter::write): * bytecode/Opcode.h: * bytecode/OpcodeSize.h: * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::alignWideOpcode16): (JSC::BytecodeGenerator::alignWideOpcode32): (JSC::BytecodeGenerator::emitGetByVal): Previously, we always emit 32bit op_get_by_val for bytecodes in `for-in` context because its operand can be replaced to the other VirtualRegister later. But if we know that replacing VirtualRegister can fit in 8bit / 16bit a-priori, we should not emit 32bit version. We expose OpXXX::checkWithoutMetadataID to check whether we could potentially compact the bytecode for the given operands. (JSC::BytecodeGenerator::emitYieldPoint): (JSC::StructureForInContext::finalize): (JSC::BytecodeGenerator::alignWideOpcode): Deleted. * bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::write): * dfg/DFGCapabilities.cpp: (JSC::DFG::capabilityLevel): * generator/Argument.rb: * generator/DSL.rb: * generator/Metadata.rb: * generator/Opcode.rb: A little bit weird but checkImpl's argument must be reference. We are relying on that BoundLabel is once modified in this check phase, and the modified BoundLabel will be used when emitting the code. If checkImpl copies the passed BoundLabel, this modification will be discarded in this checkImpl function and make the code generation broken. * generator/Section.rb: * jit/JITExceptions.cpp: (JSC::genericUnwind): * llint/LLIntData.cpp: (JSC::LLInt::initialize): * llint/LLIntData.h: (JSC::LLInt::opcodeMapWide16): (JSC::LLInt::opcodeMapWide32): (JSC::LLInt::getOpcodeWide16): (JSC::LLInt::getOpcodeWide32): (JSC::LLInt::getWide16CodePtr): (JSC::LLInt::getWide32CodePtr): (JSC::LLInt::opcodeMapWide): Deleted. (JSC::LLInt::getOpcodeWide): Deleted. (JSC::LLInt::getWideCodePtr): Deleted. * llint/LLIntOfflineAsmConfig.h: * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): * llint/LLIntSlowPaths.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter.cpp: (JSC::CLoop::execute): * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: * offlineasm/arm.rb: * offlineasm/arm64.rb: * offlineasm/asm.rb: * offlineasm/backends.rb: * offlineasm/cloop.rb: * offlineasm/instructions.rb: * offlineasm/mips.rb: * offlineasm/x86.rb: Load operation with sign extension should also have the extended size information. For example, loadbs should be converted to loadbsi for 32bit sign extension (and loadbsq for 64bit sign extension). And use loadbsq / loadhsq for loading VirtualRegister information in LowLevelInterpreter64 since they will be used for pointer arithmetic and they are using machine register width. * parser/ResultType.h: (JSC::OperandTypes::OperandTypes): (JSC::OperandTypes::first const): (JSC::OperandTypes::second const): (JSC::OperandTypes::bits): (JSC::OperandTypes::fromBits): (): Deleted. (JSC::OperandTypes::toInt): Deleted. (JSC::OperandTypes::fromInt): Deleted. We reduce sizeof(OperandTypes) from unsigned to uint16_t, which guarantees that OperandTypes always fit in 16bit bytecode. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@245906 268f45cc-cd09-0410-ab3c-d52691b4dbfc
WebKit is a cross-platform web browser engine. On iOS and macOS, it powers Safari, Mail, iBooks, and many other applications.
Visit WebKit Feature Status page to see which Web API has been implemented, in development, or under consideration.
On macOS, download Safari Technology Preview to test the latest version of WebKit. On Linux, download Epiphany Technology Preview. On Windows, you'll have to build it yourself.
Once your bug is filed, you will receive email when it is updated at each stage in the bug life cycle. After the bug is considered fixed, you may be asked to download the latest nightly and confirm that the fix works for you.
On Windows, follow the instructions on our website.
Run the following command to clone WebKit's Git SVN repository:
git clone git://git.webkit.org/WebKit.git WebKit
or
git clone https://git.webkit.org/git/WebKit.git WebKit
If you want to be able to commit changes to the repository, or just want to check out branches that aren’t contained in WebKit.git, you will need track WebKit's Subversion repository. You can run the following command to configure this and other options of the new Git clone for WebKit development.
Tools/Scripts/webkit-patch setup-git-clone
For information about this, and other aspects of using Git with WebKit, read the wiki page.
If you don‘t want to use Git, run the following command to check out WebKit’s Subversion repository:
svn checkout https://svn.webkit.org/repository/webkit/trunk WebKit
Install Xcode and its command line tools if you haven't done so already:
xcode-select --install
Run the following command to build a debug build with debugging symbols and assertions:
Tools/Scripts/build-webkit --debug
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.
The first time after you install a new Xcode, you will need to run the following command to enable Xcode to build command line tools for iOS Simulator:
sudo Tools/Scripts/configure-xcode-for-ios-development
Without this step, you will see the error message: “target specifies product type ‘com.apple.product-type.tool’, but there’s no such product type for the ‘iphonesimulator’ platform.
” when building target JSCLLIntOffsetsExtractor
of project JavaScriptCore
.
Run the following command to build a debug build with debugging symbols and assertions for iOS:
Tools/Scripts/build-webkit --debug --ios-simulator
For production builds:
cmake -DPORT=GTK -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja ninja sudo ninja install
For development builds:
Tools/gtk/install-dependencies Tools/Scripts/update-webkitgtk-libs Tools/Scripts/build-webkit --gtk --debug
For more information on building WebKitGTK+, see the wiki page.
For production builds:
cmake -DPORT=WPE -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja ninja sudo ninja install
For development builds:
Tools/wpe/install-dependencies Tools/Scripts/update-webkitwpe-libs Tools/Scripts/build-webkit --wpe --debug
For building WebKit on Windows, see the wiki page.
Run the following command to launch Safari with your local build of WebKit:
Tools/Scripts/run-safari --debug
The run-safari
script sets the DYLD_FRAMEWORK_PATH
environment variable to point to your build products, and then launches /Applications/Safari.app
. DYLD_FRAMEWORK_PATH
tells the system loader to prefer your build products over the frameworks installed in /System/Library/Frameworks
.
To run other applications with your local build of WebKit, run the following command:
Tools/Scripts/run-webkit-app <application-path>
Run the following command to launch iOS simulator with your local build of WebKit:
run-safari --debug --ios-simulator
In both cases, if you have built release builds instead, use --release
instead of --debug
.
If you have a development build, you can use the run-minibrowser script, e.g.:
run-minibrowser --debug --wpe
Pass one of --gtk
, --jsc-only
, or --wpe
to indicate the port to use.
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.