Skip to content

Commit d4420cf

Browse files
committed
add some support for le32=2 mode, where varargs is just 4-byte aligned
1 parent 1b755e1 commit d4420cf

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

emscripten.py

+5
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,7 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
755755
if DEBUG:
756756
shutil.copyfile(temp2, os.path.join(shared.CANONICAL_TEMP_DIR, 'temp2.bc'))
757757
shared.jsrun.timeout_run(subprocess.Popen([os.path.join(shared.PNACL_ROOT, 'llvm-dis'), 'temp2.bc', '-o', 'temp2.ll']))
758+
#temp2 = temp1
758759

759760
if DEBUG: logging.debug(' ..3..')
760761
temp3 = temp_files.get('.3.bc').name
@@ -796,6 +797,10 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
796797
# Integrate info from backend
797798
settings['DEFAULT_LIBRARY_FUNCS_TO_INCLUDE'] = settings['DEFAULT_LIBRARY_FUNCS_TO_INCLUDE'] + metadata['declares']
798799

800+
# Settings changes
801+
assert settings['TARGET_LE32'] == 1
802+
settings['TARGET_LE32'] = 2
803+
799804
# Save settings to a file to work around v8 issue 1579
800805
settings_file = temp_files.get('.txt').name
801806
def save_settings():

src/library.js

+8
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,11 @@ LibraryManager.library = {
18551855
// int x = 4; printf("%c\n", (char)x);
18561856
var ret;
18571857
if (type === 'double') {
1858+
#if TARGET_LE32 == 2
1859+
ret = {{{ makeGetValue('varargs', 'argIndex', 'double', undefined, undefined, true, 4) }}};
1860+
#else
18581861
ret = {{{ makeGetValue('varargs', 'argIndex', 'double', undefined, undefined, true) }}};
1862+
#endif
18591863
#if USE_TYPED_ARRAYS == 2
18601864
} else if (type == 'i64') {
18611865

@@ -1876,7 +1880,11 @@ LibraryManager.library = {
18761880
type = 'i32'; // varargs are always i32, i64, or double
18771881
ret = {{{ makeGetValue('varargs', 'argIndex', 'i32', undefined, undefined, true) }}};
18781882
}
1883+
#if TARGET_LE32 == 2
1884+
argIndex += Runtime.getNativeFieldSize(type);
1885+
#else
18791886
argIndex += Math.max(Runtime.getNativeFieldSize(type), Runtime.getAlignSize(type, null, true));
1887+
#endif
18801888
return ret;
18811889
}
18821890

src/settings.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ var QUANTUM_SIZE = 4; // This is the size of an individual field in a structure.
2323
// Changing this from the default of 4 is deprecated.
2424

2525
var TARGET_X86 = 0; // For i386-pc-linux-gnu
26-
var TARGET_LE32 = 1; // For le32-unknown-nacl
26+
var TARGET_LE32 = 1; // For le32-unknown-nacl. 1 is normal, 2 is for the fastcomp llvm
27+
// backend using pnacl abi simplification
2728

2829
var CORRECT_SIGNS = 1; // Whether we make sure to convert unsigned values to signed values.
2930
// Decreases performance with additional runtime checks. Might not be

0 commit comments

Comments
 (0)