Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: emscripten-core/emscripten
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.5.2
Choose a base ref
...
head repository: emscripten-core/emscripten
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.5.3
Choose a head ref

Commits on Jun 26, 2013

  1. Remove old code.

    int3 committed Jun 26, 2013
    Copy the full SHA
    e4afb5d View commit details

Commits on Jun 27, 2013

  1. update tests

    kripken committed Jun 27, 2013
    Copy the full SHA
    54098d3 View commit details
  2. Copy the full SHA
    1acf958 View commit details
  3. Copy the full SHA
    9e7ca3e View commit details
  4. update tests

    kripken committed Jun 27, 2013
    Copy the full SHA
    9c746ac View commit details
  5. Copy the full SHA
    317f89f View commit details
  6. Copy the full SHA
    068f916 View commit details
  7. Remove unused macro.

    int3 committed Jun 27, 2013
    Copy the full SHA
    b3309c3 View commit details
  8. A little preprocessor trick.

    Fake method lookups, in a way.
    int3 committed Jun 27, 2013
    Copy the full SHA
    84e1197 View commit details
  9. Copy the full SHA
    4dd1e47 View commit details
  10. Use distutils where possible.

    int3 committed Jun 27, 2013
    Copy the full SHA
    691454a View commit details
  11. remove old comment

    kripken committed Jun 27, 2013
    Copy the full SHA
    0e8ff1b View commit details
  12. Copy the full SHA
    74671cd View commit details
  13. --llvm-lto 2 option

    kripken committed Jun 27, 2013
    Copy the full SHA
    6fe62c1 View commit details
  14. Copy the full SHA
    91920dc View commit details
  15. Copy the full SHA
    681ab3e View commit details
  16. add option for -O3 style LTO without normal LLVM LTO, because java-nb…

    …ody hits an LTO bug but benefits from -O3 on all the code
    kripken committed Jun 27, 2013
    Copy the full SHA
    0432f1c View commit details
  17. Copy the full SHA
    606d610 View commit details
  18. Copy the full SHA
    21bc61d View commit details
  19. Copy the full SHA
    ff96c4c View commit details
  20. fix test_openjpeg

    kripken committed Jun 27, 2013
    Copy the full SHA
    d103edb View commit details
  21. fix test_indirectbr

    kripken committed Jun 27, 2013
    Copy the full SHA
    33021c2 View commit details
  22. fix test_stack

    kripken committed Jun 27, 2013
    Copy the full SHA
    46d3849 View commit details
  23. Copy the full SHA
    4cdbf34 View commit details
  24. improve sourcemapper comment

    kripken committed Jun 27, 2013
    Copy the full SHA
    baeffc2 View commit details
  25. now that we serialize the settings in the test runner's call to emcc …

    …on source to bitcode, we don't need COMPILER_TEST_OPTS to contain everything
    kripken committed Jun 27, 2013
    Copy the full SHA
    7a218fe View commit details
  26. fix test_autodebug

    kripken committed Jun 27, 2013
    Copy the full SHA
    4a1c420 View commit details

Commits on Jun 28, 2013

  1. fix test_asm_pgo

    kripken committed Jun 28, 2013
    Copy the full SHA
    91df7b5 View commit details
  2. Copy the full SHA
    c600d4a View commit details
  3. Bump version number.

    int3 committed Jun 28, 2013
    Copy the full SHA
    2845fa9 View commit details
  4. Merge pull request #1331 from int3/incoming

    Remove old code.
    kripken committed Jun 28, 2013
    Copy the full SHA
    f4114f4 View commit details
  5. Merge pull request #1332 from int3/use-distutils

    Use distutils.
    kripken committed Jun 28, 2013
    Copy the full SHA
    fc4b0cb View commit details
  6. Copy the full SHA
    6a65e3f View commit details
  7. fix tests

    kripken committed Jun 28, 2013
    Copy the full SHA
    3bb61dc View commit details
  8. disable test_zlib in s_0_x

    kripken committed Jun 28, 2013
    Copy the full SHA
    41577ac View commit details
  9. Copy the full SHA
    9674b76 View commit details
  10. Copy the full SHA
    57bac5c View commit details
  11. fixed comment typos

    inolen authored and kripken committed Jun 28, 2013
    Copy the full SHA
    e3074dc View commit details
  12. Copy the full SHA
    4f6ffd4 View commit details
Showing with 203 additions and 145 deletions.
  1. +34 −15 emcc
  2. +49 −31 src/jsifier.js
  3. +15 −1 src/parseTools.js
  4. +33 −41 src/relooper/Relooper.cpp
  5. +0 −2 src/relooper/Relooper.h
  6. +5 −0 src/settings.js
  7. +52 −31 tests/runner.py
  8. +4 −4 tools/js-optimizer.js
  9. +8 −19 tools/shared.py
  10. +1 −1 tools/source-maps/sourcemapper.js
  11. +1 −0 tools/test-js-optimizer-asm-pre-output.js
  12. +1 −0 tools/test-js-optimizer-asm-pre.js
49 changes: 34 additions & 15 deletions emcc
Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ Options that are modified or new in %s include:
-s DOUBLE_MODE=0
-s PRECISE_I64_MATH=0
--closure 1
--llvm-lto 1
--llvm-lto 3
This is not recommended at all. A better idea
is to try each of these separately on top of
@@ -215,10 +215,15 @@ Options that are modified or new in %s include:
2: -O2 LLVM optimizations
3: -O3 LLVM optimizations (default in -O2+)
--llvm-lto <level> 0: No LLVM LTO (default in -O2 and below)
1: LLVM LTO (default in -O3)
--llvm-lto <level> 0: No LLVM LTO (default)
1: LLVM LTO is performed
2: We combine all the bitcode and run LLVM opt -O3
on that (which optimizes across modules, but is
not the same as normal LTO), but do not do normal
LTO
3: We do both 2 and then 1
Note: If LLVM optimizations are not run
(see --llvm-opts), setting this to 1 has no
(see --llvm-opts), setting this has no
effect.
--closure <on> 0: No closure compiler (default in -O2 and below)
@@ -879,10 +884,14 @@ try:
newargs = newargs + [default_cxx_std]

if llvm_opts is None: llvm_opts = LLVM_OPT_LEVEL[opt_level]
if llvm_lto is None: llvm_lto = opt_level >= 3
if llvm_lto is None and opt_level >= 3: llvm_lto = 3
if opt_level == 0: debug_level = 4
if closure is None and opt_level == 3: closure = True

if llvm_lto is None and bind:
logging.debug('running lto for embind') # XXX this is a workaround for a pointer issue
llvm_lto = 1

# TODO: support source maps with js_transform
if js_transform and debug_level >= 4:
logging.warning('disabling source maps because a js transform is being done')
@@ -1096,14 +1105,17 @@ try:
shared.Building.llvm_as(input_file, temp_file)
temp_files.append(temp_file)

if not LEAVE_INPUTS_RAW: assert len(temp_files) == len(input_files)
if not LEAVE_INPUTS_RAW:
assert len(temp_files) == len(input_files)

# Optimize source files
if llvm_opts > 0:
for input_file in input_files:
if input_file.endswith(SOURCE_SUFFIXES):
logging.debug('optimizing %s with -O%d' % (input_file, llvm_opts))
shared.Building.llvm_opt(in_temp(unsuffixed(uniquename(input_file)) + '.o'), llvm_opts)
# Optimize source files
if llvm_opts > 0:
for i in range(len(input_files)):
input_file = input_files[i]
if input_files[i].endswith(SOURCE_SUFFIXES):
temp_file = temp_files[i]
logging.debug('optimizing %s with -O%d' % (input_file, llvm_opts))
shared.Building.llvm_opt(temp_file, llvm_opts)

# If we were just asked to generate bitcode, stop there
if final_suffix not in JS_CONTAINING_SUFFIXES:
@@ -1138,6 +1150,8 @@ try:
symbols = filter(lambda symbol: symbol not in exclude, symbols)
return set(symbols)

lib_opts = ['-O2']

# XXX We also need to add libc symbols that use malloc, for example strdup. It's very rare to use just them and not
# a normal malloc symbol (like free, after calling strdup), so we haven't hit this yet, but it is possible.
libc_symbols = read_symbols(shared.path_from_root('system', 'lib', 'libc.symbols'))
@@ -1155,7 +1169,7 @@ try:
musl_internal_includes = shared.path_from_root('system', 'lib', 'libc', 'musl', 'src', 'internal')
for src in files:
o = in_temp(os.path.basename(src) + '.o')
execute([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', src), '-o', o, '-I', musl_internal_includes], stdout=stdout, stderr=stderr)
execute([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', src), '-o', o, '-I', musl_internal_includes] + lib_opts, stdout=stdout, stderr=stderr)
o_s.append(o)
if prev_cxx: os.environ['EMMAKEN_CXX'] = prev_cxx
shared.Building.link(o_s, in_temp(lib_filename))
@@ -1166,7 +1180,7 @@ try:
for src in files:
o = in_temp(src + '.o')
srcfile = shared.path_from_root(src_dirname, src)
execute([shared.PYTHON, shared.EMXX, srcfile, '-o', o, '-std=c++11'], stdout=stdout, stderr=stderr)
execute([shared.PYTHON, shared.EMXX, srcfile, '-o', o, '-std=c++11'] + lib_opts, stdout=stdout, stderr=stderr)
o_s.append(o)
shared.Building.link(o_s, in_temp(lib_filename))
return in_temp(lib_filename)
@@ -1414,9 +1428,14 @@ try:
if not LEAVE_INPUTS_RAW:
link_opts = [] if debug_level >= 4 else ['-strip-debug'] # remove LLVM debug if we are not asked for it

if llvm_lto >= 2:
logging.debug('running LLVM opt -O3 as pre-LTO')
shared.Building.llvm_opt(in_temp(target_basename + '.bc'), ['-O3'])
if DEBUG: save_intermediate('opt', 'bc')

if shared.Building.can_build_standalone():
# If we can LTO, do it before dce, since it opens up dce opportunities
if llvm_lto and shared.Building.can_use_unsafe_opts():
if llvm_lto and llvm_lto != 2 and shared.Building.can_use_unsafe_opts():
if not shared.Building.can_inline(): link_opts.append('-disable-inlining')
# do not internalize in std-link-opts - it ignores internalize-public-api-list - and add a manual internalize
link_opts += ['-disable-internalize'] + shared.Building.get_safe_internalize() + ['-std-link-opts']
80 changes: 49 additions & 31 deletions src/jsifier.js
Original file line number Diff line number Diff line change
@@ -285,42 +285,60 @@ function JSify(data, functionsOnly, givenFunctions) {
index = makeGlobalUse(item.ident); // index !== null indicates we are indexing this
allocator = 'ALLOC_NONE';
}
if (item.external) {
if (Runtime.isNumberType(item.type) || isPointerType(item.type)) {
constant = zeros(Runtime.getNativeFieldSize(item.type));
} else {
constant = makeEmptyStruct(item.type);

if (isBSS(item)) {
var length = calcAllocatedSize(item.type);
length = Runtime.alignMemory(length);

// If using indexed globals, go ahead and early out (no need to explicitly
// initialize).
if (!NAMED_GLOBALS) {
return ret;
}
// If using named globals, we can at least shorten the call to allocate by
// passing an integer representing the size of memory to alloc instead of
// an array of 0s of size length.
else {
constant = length;
}
} else {
constant = parseConst(item.value, item.type, item.ident);
}
assert(typeof constant === 'object');//, [typeof constant, JSON.stringify(constant), item.external]);

// This is a flattened object. We need to find its idents, so they can be assigned to later
constant.forEach(function(value, i) {
if (needsPostSet(value)) { // ident, or expression containing an ident
ret.push({
intertype: 'GlobalVariablePostSet',
JS: makeSetValue(makeGlobalUse(item.ident), i, value, 'i32', false, true) + ';' // ignore=true, since e.g. rtti and statics cause lots of safe_heap errors
});
constant[i] = '0';
if (item.external) {
if (Runtime.isNumberType(item.type) || isPointerType(item.type)) {
constant = zeros(Runtime.getNativeFieldSize(item.type));
} else {
constant = makeEmptyStruct(item.type);
}
} else {
constant = parseConst(item.value, item.type, item.ident);
}
});
assert(typeof constant === 'object');//, [typeof constant, JSON.stringify(constant), item.external]);

// This is a flattened object. We need to find its idents, so they can be assigned to later
constant.forEach(function(value, i) {
if (needsPostSet(value)) { // ident, or expression containing an ident
ret.push({
intertype: 'GlobalVariablePostSet',
JS: makeSetValue(makeGlobalUse(item.ident), i, value, 'i32', false, true) + ';' // ignore=true, since e.g. rtti and statics cause lots of safe_heap errors
});
constant[i] = '0';
}
});

if (item.external) {
// External variables in shared libraries should not be declared as
// they would shadow similarly-named globals in the parent, so do nothing here.
if (BUILD_AS_SHARED_LIB) return ret;
// Library items need us to emit something, but everything else requires nothing.
if (!LibraryManager.library[item.ident.slice(1)]) return ret;
}
if (item.external) {
// External variables in shared libraries should not be declared as
// they would shadow similarly-named globals in the parent, so do nothing here.
if (BUILD_AS_SHARED_LIB) return ret;
// Library items need us to emit something, but everything else requires nothing.
if (!LibraryManager.library[item.ident.slice(1)]) return ret;
}

// ensure alignment
constant = constant.concat(zeros(Runtime.alignMemory(constant.length) - constant.length));
// ensure alignment
constant = constant.concat(zeros(Runtime.alignMemory(constant.length) - constant.length));

// Special case: class vtables. We make sure they are null-terminated, to allow easy runtime operations
if (item.ident.substr(0, 5) == '__ZTV') {
constant = constant.concat(zeros(Runtime.alignMemory(QUANTUM_SIZE)));
// Special case: class vtables. We make sure they are null-terminated, to allow easy runtime operations
if (item.ident.substr(0, 5) == '__ZTV') {
constant = constant.concat(zeros(Runtime.alignMemory(QUANTUM_SIZE)));
}
}

// NOTE: This is the only place that could potentially create static
@@ -1568,7 +1586,7 @@ function JSify(data, functionsOnly, givenFunctions) {
print('STATICTOP = STATIC_BASE + ' + Runtime.alignMemory(Variables.nextIndexedOffset) + ';\n');
}
var generated = itemsDict.function.concat(itemsDict.type).concat(itemsDict.GlobalVariableStub).concat(itemsDict.GlobalVariable);
print(generated.map(function(item) { return item.JS }).join('\n'));
print(generated.map(function(item) { return item.JS; }).join('\n'));

if (phase == 'pre') {
if (memoryInitialization.length > 0) {
16 changes: 15 additions & 1 deletion src/parseTools.js
Original file line number Diff line number Diff line change
@@ -467,6 +467,17 @@ function isIndexableGlobal(ident) {
return !data.alias && !data.external;
}

function isBSS(item) {
if (!USE_BSS) {
return false;
}

// return true if a global is uninitialized or initialized to 0
return item.external ||
(item.value && item.value.intertype === 'emptystruct') ||
(item.value && item.value.value !== undefined && item.value.value === '0');
}

function makeGlobalDef(ident) {
if (!NAMED_GLOBALS && isIndexableGlobal(ident)) return '';
return 'var ' + ident + ';';
@@ -490,7 +501,10 @@ function sortGlobals(globals) {
ks.sort();
var inv = invertArray(ks);
return values(globals).sort(function(a, b) {
return inv[b.ident] - inv[a.ident];
// sort globals based on if they need to be explicitly initialized or not (moving
// values that don't need to be to the end of the array). if equal, sort by name.
return (Number(isBSS(a)) - Number(isBSS(b))) ||
(inv[b.ident] - inv[a.ident]);
});
}

Loading