Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
pyodide
Commits
7f578a81
Commit
7f578a81
authored
Sep 18, 2018
by
Michael Droettboom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix library_lz4.js
parent
0d4b22ba
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
15 deletions
+16
-15
emsdk/Makefile
emsdk/Makefile
+1
-0
emsdk/patches/lz4_c.patch
emsdk/patches/lz4_c.patch
+15
-15
No files found.
emsdk/Makefile
View file @
7f578a81
...
...
@@ -4,6 +4,7 @@ all: emsdk/.complete
# run out of memory
emsdk/.complete
:
if
[
-d
emsdk
]
;
then
rm
-rf
emsdk
;
fi
git clone https://github.com/juj/emsdk.git
...
...
emsdk/patches/lz4_c.patch
View file @
7f578a81
diff --git a/src/library_lz4.js b/src/library_lz4.js
index 4c3f583b7..
bca230fe
b 100644
--- a/
emsdk/emscripten/tag-1.38.10/
src/library_lz4.js
+++ b/
emsdk/emscripten/tag-1.38.10/
src/library_lz4.js
index 4c3f583b7..
9540a64f
b 100644
--- a/src/library_lz4.js
+++ b/src/library_lz4.js
@@ -5,26 +5,15 @@
mergeInto(LibraryManager.library, {
DIR_MODE: {{{ cDefine('S_IFDIR') }}} | 511 /* 0777 */,
FILE_MODE: {{{ cDefine('S_IFREG') }}} | 511 /* 0777 */,
CHUNK_SIZE: -1,
- codec: null,
+ buf: null,
init: function() {
- if (LZ4.codec) return;
- LZ4.codec = (function() {
...
...
@@ -29,27 +28,29 @@ index 4c3f583b7..bca230feb 100644
- compressedData.cachedOffset + (i+1)*LZ4.CHUNK_SIZE);
- assert(compressedData.cachedChunks[i].length === LZ4.CHUNK_SIZE);
- }
+ compressedData.buf = null;
pack['metadata'].files.forEach(function(file) {
var dir = PATH.dirname(file.filename);
var name = PATH.basename(file.filename);
@@ -112,8 +101,1
6
@@
mergeInto(LibraryManager.library, {
@@ -112,8 +101,1
7
@@
mergeInto(LibraryManager.library, {
//console.log('LZ4 read ' + [offset, length, position]);
length = Math.min(length, stream.node.size - position);
if (length <= 0) return 0;
+
var contents = stream.node.contents;
var compressedData = contents.compressedData;
+ if (
LZ4
.buf === null) {
+
LZ4.buf = Module['_malloc'](LZ4.CHUNK_SIZE
);
+ if (
compressedData
.buf === null) {
+
compressedData.buf = Module['_malloc'](LZ4.CHUNK_SIZE * 2
);
+ for (var i = 0; i < compressedData.cachedIndexes.length; i++) {
+ compressedData.cachedIndexes[i] = -1;
+ compressedData.cachedChunks[i] = Module['_malloc'](LZ4.CHUNK_SIZE);
+ compressedData.cachedChunks[i] = Module['_malloc'](LZ4.CHUNK_SIZE * 2);
+ assert(compressedData.cachedChunks[i] !== null)
+ }
+ }
var written = 0;
while (written < length) {
var start = contents.start + position + written; // start index in uncompressed data
@@ -138,18 +13
5,24
@@
mergeInto(LibraryManager.library, {
@@ -138,18 +13
6,23
@@
mergeInto(LibraryManager.library, {
Module['decompressedChunks'] = (Module['decompressedChunks'] || 0) + 1;
}
var compressed = compressedData.data.subarray(compressedStart, compressedStart + compressedSize);
...
...
@@ -58,8 +59,8 @@ index 4c3f583b7..bca230feb 100644
- //console.log('decompress time: ' + (Date.now() - t));
+ // var t = Date.now();
+ // var originalSize = LZ4.codec.uncompress(compressed, currChunk);
+ Module.HEAPU8.set(compressed,
LZ4
.buf);
+ var originalSize = Module['_LZ4_decompress_safe'](
LZ4
.buf, currChunk, compressedSize, LZ4.CHUNK_SIZE);
+ Module.HEAPU8.set(compressed,
compressedData
.buf);
+ var originalSize = Module['_LZ4_decompress_safe'](
compressedData
.buf, currChunk, compressedSize, LZ4.CHUNK_SIZE);
+ // console.log('decompress time: ' + (Date.now() - t));
if (chunkIndex < compressedData.successes.length-1) assert(originalSize === LZ4.CHUNK_SIZE); // all but the last chunk must be full-size
}
...
...
@@ -68,10 +69,9 @@ index 4c3f583b7..bca230feb 100644
+ else {
// uncompressed
- currChunk = compressedData.data.subarray(compressedStart, compressedStart + LZ4.CHUNK_SIZE);
+ var compressed = compressedData.data.subarray(compressedStart, compressedStart + compressedSize);
+ // var originalSize = LZ4.codec.uncompress(compressed, currChunk);
+ Module.HEAPU8.set(compressed, LZ4.buf);
+ currChunk = LZ4.buf;
+ var compressed = compressedData.data.subarray(compressedStart, compressedStart + LZ4.CHUNK_SIZE);
+ Module.HEAPU8.set(compressed, compressedData.buf);
+ currChunk = compressedData.buf;
}
var startInChunk = start % LZ4.CHUNK_SIZE;
var endInChunk = Math.min(startInChunk + desired, LZ4.CHUNK_SIZE);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment