aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/parseTools.js4
-rw-r--r--src/settings.js6
2 files changed, 10 insertions, 0 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index db834206..d0d66929 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1118,6 +1118,8 @@ var asmPrintCounter = 0;
// See makeSetValue
function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSafe, forceAsm) {
if (UNALIGNED_MEMORY) align = 1;
+ else if (FORCE_ALIGNED_MEMORY) align = 8;
+
if (isStructType(type)) {
var typeData = Types.types[type];
var ret = [];
@@ -1220,6 +1222,8 @@ function indexizeFunctions(value, type) {
//! @param noNeedFirst Whether to ignore the offset in the pointer itself.
function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe, sep, forcedAlign, forceAsm) {
if (UNALIGNED_MEMORY && !forcedAlign) align = 1;
+ else if (FORCE_ALIGNED_MEMORY) align = 8;
+
sep = sep || ';';
if (isStructType(type)) {
var typeData = Types.types[type];
diff --git a/src/settings.js b/src/settings.js
index d029598a..8766277b 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -89,6 +89,12 @@ var UNALIGNED_MEMORY = 0; // If enabled, all memory accesses are assumed to be u
// typed arrays mode 2 where alignment is relevant.) In unaligned memory mode, you
// can run nonportable code that typically would break in JS (or on ARM for that
// matter, which also cannot do unaligned reads/writes), at the cost of slowness
+var FORCE_ALIGNED_MEMORY = 0; // If enabled, assumes all reads and writes are fully aligned for the type they
+ // use. This is true in proper C code (no undefined behavior), but is sadly
+ // common enough that we can't do it by default. See SAFE_HEAP and CHECK_HEAP_ALIGN
+ // for ways to help find places in your code where unaligned reads/writes are done -
+ // you might be able to refactor your codebase to prevent them, which leads to
+ // smaller and faster code, or even the option to turn this flag on.
var PRECISE_I64_MATH = 1; // If enabled, i64 addition etc. is emulated - which is slow but precise. If disabled,
// we use the 'double trick' which is fast but incurs rounding at high values.
// Note that we do not catch 32-bit multiplication by default (which must be done in