Bug 1039197 - Always build js engine with zlib. r=luke

This commit is contained in:
Mike Hommey 2014-07-17 08:42:17 +09:00
parent c82884982d
commit 90c08ab89f
8 changed files with 21 additions and 48 deletions

View File

@ -22,6 +22,9 @@ DIST_INSTALL = 1
ifdef JS_STANDALONE
SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,mfbt,$(DEPTH)/mfbt)
ifndef MOZ_NATIVE_ZLIB
SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,mozz,$(DEPTH)/modules/zlib/src)
endif
endif
ifdef JS_HAS_CTYPES
@ -219,12 +222,6 @@ endif
CFLAGS += $(MOZ_ZLIB_CFLAGS)
EXTRA_LIBS += $(MOZ_ZLIB_LIBS)
# Enable zlib usage if zlib has been located. When building the browser on
# Windows, MOZ_ZLIB_LIBS is empty because zlib is part of libmozglue. We thus
# also enable zlib if mozglue is present.
ifneq (,$(MOZ_ZLIB_LIBS)$(MOZ_GLUE_LDFLAGS))
DEFINES += -DUSE_ZLIB
endif
ifdef MOZ_SHARED_ICU
EXTRA_DSO_LDOPTS += $(MOZ_ICU_LIBS)

View File

@ -96,26 +96,16 @@ def embed(cxx, preprocessorOption, msgs, sources, c_out, js_out, env):
with open(js_out, 'w') as output:
output.write(processed)
with open(c_out, 'w') as output:
if 'USE_ZLIB' in env:
import zlib
compressed = zlib.compress(processed)
data = ToCArray(compressed)
output.write(HEADER_TEMPLATE % {
'sources_type': 'unsigned char',
'sources_data': data,
'sources_name': 'compressedSources',
'compressed_total_length': len(compressed),
'raw_total_length': len(processed)
})
else:
data = ToCAsciiArray(processed)
output.write(HEADER_TEMPLATE % {
'sources_type': 'char',
'sources_data': data,
'sources_name': 'rawSources',
'compressed_total_length': 0,
'raw_total_length': len(processed)
})
import zlib
compressed = zlib.compress(processed)
data = ToCArray(compressed)
output.write(HEADER_TEMPLATE % {
'sources_type': 'unsigned char',
'sources_data': data,
'sources_name': 'compressedSources',
'compressed_total_length': len(compressed),
'raw_total_length': len(processed)
})
def preprocess(cxx, preprocessorOption, source, args = []):
if (not os.path.exists(cxx[0])):

View File

@ -1495,7 +1495,6 @@ ScriptSource::chars(JSContext *cx, UncompressedSourceCache::AutoHoldEntry &holde
return uncompressedChars();
case DataCompressed: {
#ifdef USE_ZLIB
if (const jschar *decompressed = cx->runtime()->uncompressedSourceCache.lookup(this, holder))
return decompressed;
@ -1520,9 +1519,6 @@ ScriptSource::chars(JSContext *cx, UncompressedSourceCache::AutoHoldEntry &holde
}
return decompressed;
#else
MOZ_CRASH();
#endif
}
case DataParent:
@ -1654,7 +1650,7 @@ ScriptSource::setSourceCopy(ExclusiveContext *cx, SourceBufferHolder &srcBuf,
// thread (see HelperThreadState::canStartParseTask) which would cause a
// deadlock if there wasn't a second helper thread that could make
// progress on our compression task.
#if defined(JS_THREADSAFE) && defined(USE_ZLIB)
#if defined(JS_THREADSAFE)
bool canCompressOffThread =
HelperThreadState().cpuCount > 1 &&
HelperThreadState().threadCount >= 2;
@ -1677,7 +1673,6 @@ ScriptSource::setSourceCopy(ExclusiveContext *cx, SourceBufferHolder &srcBuf,
SourceCompressionTask::ResultType
SourceCompressionTask::work()
{
#ifdef USE_ZLIB
// Try to keep the maximum memory usage down by only allocating half the
// size of the string, first.
size_t inputBytes = ss->length() * sizeof(jschar);
@ -1723,9 +1718,6 @@ SourceCompressionTask::work()
}
compressedBytes = comp.outWritten();
compressedHash = CompressedSourceHasher::computeHash(compressed, compressedBytes);
#else
MOZ_CRASH();
#endif
// Shrink the buffer to the size of the compressed data.
if (void *newCompressed = js_realloc(compressed, compressedBytes))

View File

@ -73,6 +73,9 @@ case $cmd in
${MKDIR} -p ${tgtpath}/testing
cp -t ${tgtpath}/testing -dRp \
${SRCDIR}/../../testing/mozbase
${MKDIR} -p ${tgtpath}/modules/zlib
cp -t ${tgtpath}/modules/zlib -dRp \
${SRCDIR}/../../modules/zlib/src
# remove *.pyc and *.pyo files if any
find ${tgtpath} -type f -name "*.pyc" -o -name "*.pyo" |xargs rm -f

View File

@ -10,7 +10,6 @@
using namespace js;
#if USE_ZLIB
static void *
zlib_alloc(void *cx, uInt items, uInt size)
{
@ -127,5 +126,3 @@ js::DecompressString(const unsigned char *inp, size_t inplen, unsigned char *out
JS_ASSERT(ret == Z_OK);
return true;
}
#endif /* USE_ZLIB */

View File

@ -7,8 +7,6 @@
#ifndef vm_Compression_h
#define vm_Compression_h
#ifdef USE_ZLIB
#include <zlib.h>
#include "jstypes.h"
@ -51,5 +49,4 @@ bool DecompressString(const unsigned char *inp, size_t inplen,
} /* namespace js */
#endif /* USE_ZLIB */
#endif /* vm_Compression_h */

View File

@ -1015,7 +1015,6 @@ JSRuntime::initSelfHosting(JSContext *cx)
} else {
uint32_t srcLen = GetRawScriptsSize();
#ifdef USE_ZLIB
const unsigned char *compressed = compressedSources;
uint32_t compressedLen = GetCompressedSize();
ScopedJSFreePtr<char> src(reinterpret_cast<char *>(cx->malloc_(srcLen)));
@ -1024,9 +1023,6 @@ JSRuntime::initSelfHosting(JSContext *cx)
{
return false;
}
#else
const char *src = rawSources;
#endif
ok = Evaluate(cx, shg, options, src, srcLen, &rv);
}

View File

@ -24,6 +24,9 @@ if not CONFIG['JS_STANDALONE']:
if not CONFIG['LIBXUL_SDK']:
add_tier_dir('base', ['mfbt'])
if not CONFIG['MOZ_NATIVE_ZLIB']:
add_tier_dir('base', ['modules/zlib'])
if not CONFIG['JS_STANDALONE']:
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
add_tier_dir('base', ['other-licenses/android'])
@ -31,11 +34,9 @@ if not CONFIG['LIBXUL_SDK']:
if CONFIG['MOZ_MEMORY']:
add_tier_dir('base', ['memory'])
if not CONFIG['MOZ_NATIVE_ZLIB']:
add_tier_dir('base', ['modules/zlib'])
add_tier_dir('base', ['mozglue', 'memory/mozalloc'])
if not CONFIG['JS_STANDALONE']:
add_tier_dir('precompile', 'xpcom/xpidl')