JSC: Pack unlinked instructions harder.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Jan 2014 05:45:30 +0000 (05:45 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Jan 2014 05:45:30 +0000 (05:45 +0000)
commitdbd98c410910f1452f4dd67a7d64baa40de0fb9d
treeebdfd97b667da93c12b6a8624b94cad2f6783ccf
parent999f11451bd6eebfafc6e68d8be94bf418db0531
JSC: Pack unlinked instructions harder.
<https://webkit.org/b/127660>

Store UnlinkedCodeBlock's instructions in a variable-length stream
to reduce memory usage. Compression rate ends up around 60-61%.

The format is very simple. Every instruction starts with a 1 byte
opcode. It's followed by an opcode-dependent number of argument
values, each encoded separately for maximum packing. There are
7 packed value formats:

    5-bit positive integer
    5-bit negative integer
    13-bit positive integer
    13-bit positive integer
    5-bit constant register index
    13-bit constant register index
    32-bit value (fallback)

27.5 MB progression on Membuster3. (~2% of total memory.)

Reviewed by Filip Pizlo.

* JavaScriptCore.xcodeproj/project.pbxproj:
* bytecode/UnlinkedInstructionStream.h: Added.
(JSC::UnlinkedInstructionStream::count):
(JSC::UnlinkedInstructionStream::Reader::atEnd):
* bytecode/UnlinkedInstructionStream.cpp: Added.
(JSC::UnlinkedInstructionStream::Reader::Reader):
(JSC::UnlinkedInstructionStream::Reader::read8):
(JSC::UnlinkedInstructionStream::Reader::read32):
(JSC::UnlinkedInstructionStream::Reader::next):
(JSC::append8):
(JSC::append32):
(JSC::UnlinkedInstructionStream::UnlinkedInstructionStream):
(JSC::UnlinkedInstructionStream::unpackForDebugging):
* bytecompiler/BytecodeGenerator.cpp:
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock):
* bytecode/UnlinkedCodeBlock.cpp:
(JSC::UnlinkedCodeBlock::lineNumberForBytecodeOffset):
(JSC::dumpLineColumnEntry):
(JSC::UnlinkedCodeBlock::expressionRangeForBytecodeOffset):
(JSC::UnlinkedCodeBlock::setInstructions):
(JSC::UnlinkedCodeBlock::instructions):
* bytecode/UnlinkedCodeBlock.h:
(JSC::BytecodeGenerator::generate):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162825 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/GNUmakefile.list.am
Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/bytecode/CodeBlock.cpp
Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
Source/JavaScriptCore/bytecode/UnlinkedInstructionStream.cpp [new file with mode: 0644]
Source/JavaScriptCore/bytecode/UnlinkedInstructionStream.h [new file with mode: 0644]
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp