1
diff --git a/src/analyzer.js b/src/analyzer.js
2
index 526d024..a5074e1 100644
5
@@ -462,15 +462,17 @@ function analyzer(data) {
7
// See settings.js for the meaning of QUANTUM_SIZE. The issue we fix here is,
8
// to correct the .ll assembly code so that things work with QUANTUM_SIZE=1.
10
substrate.addActor('QuantumFixer', {
11
processItem: function(item) {
12
this.forwardItem(item, 'LabelAnalyzer');
14
if (QUANTUM_SIZE !== 1) return;
15
+dprint('cheez qf 2!');
17
// ptrs: the indexes of parameters that are pointers, whose originalType is what we want
18
// bytes: the index of the 'bytes' parameter
19
// TODO: malloc, realloc?
21
'memcpy': { ptrs: [0,1], bytes: 2 },
22
'memmove': { ptrs: [0,1], bytes: 2 },
23
@@ -495,16 +497,22 @@ function analyzer(data) {
27
item.functions.forEach(function(func) {
28
function getOriginalType(param) {
30
if (param.intertype === 'value' && !isNumber(param.ident)) {
31
- if (func.variables[param.ident]) {
32
- return func.variables[param.ident].originalType || null;
33
+ var varData = func.variables[param.ident];
35
+ if (varData.origin == 'load') {
36
+ return varData.type; // we can trust this
38
+// To continue, we need proper type data inside getelementptr, by using type data. not a one liner.
39
+// TESTING: this makes a difference in fasta
40
+ return varData.originalType || null;
42
return item.globalVariables[param.ident].originalType;
44
} else if (param.intertype === 'bitcast') {
45
return param.params[0].type;
46
} else if (param.intertype === 'getelementptr') {
47
if (param.params[0].type[0] === '[') return param.params[0].type;
48
@@ -527,18 +535,21 @@ function analyzer(data) {
49
var fixData = FIXABLE_CALLS[funcIdent];
51
var ptrs = fixData.ptrs.map(function(ptr) { return line.params[ptr] });
52
var bytes = line.params[fixData.bytes].ident;
54
// Only consider original types. This assumes memcpy always has pointers bitcast to i8*
55
var originalTypes = ptrs.map(getOriginalType);
56
+dprint('cheez qf 2! ' + dump(func.variables) + ' :: ' + funcIdent + ',' + line.lineNum + ' : ' + dump(ptrs) + ' ==> ' + dump(originalTypes));
57
for (var i = 0; i < originalTypes.length; i++) {
58
if (!originalTypes[i]) return;
60
+dprint('cheez qf 3!');
61
originalTypes = originalTypes.map(function(type) { return removePointing(type) });
62
+dprint('zz cheez ' + [funcIdent, originalTypes]);
63
var sizes = originalTypes.map(function(type) { return getSize(Types.types, type) });
64
var fatSizes = originalTypes.map(function(type) { return getSize(Types.fatTypes, type, true) });
65
// The sizes may not be identical, if we copy a descendant class into a parent class. We use
66
// the smaller size in that case. However, this may also be a bug, it is hard to tell, hence a warning
67
warn(dedup(sizes).length === 1, 'All sizes should probably be identical here: ' + dump(originalTypes) + ':' + dump(sizes) + ':' +
69
warn(dedup(fatSizes).length === 1, 'All fat sizes should probably be identical here: ' + dump(originalTypes) + ':' + dump(sizes) + ':' +
70
diff --git a/src/parseTools.js b/src/parseTools.js
71
index 024026c..a15b89f 100644
72
--- a/src/parseTools.js
73
+++ b/src/parseTools.js
74
@@ -1078,14 +1078,29 @@ function makeSetValues(ptr, pos, value, type, num) {
79
var TYPED_ARRAY_SET_MIN = Infinity; // .set() as memcpy seems to just slow us down
81
function makeCopyValues(dest, src, num, type, modifier) {
82
+ return '/* zz1 */ ' + makeCopyValuesX(dest, src, num, type, modifier) + ';' +
83
+ makeCopyValuesX(dest, src, num, type, modifier) + ';' +
84
+ makeCopyValuesX(dest, src, num, type, modifier) + ';' +
85
+ makeCopyValuesX(dest, src, num, type, modifier) + ';' +
86
+ makeCopyValuesX(dest, src, num, type, modifier) + ';' +
87
+ makeCopyValuesX(dest, src, num, type, modifier) + ';' +
88
+ makeCopyValuesX(dest, src, num, type, modifier) + ';' +
89
+ makeCopyValuesX(dest, src, num, type, modifier) + ';' +
90
+ makeCopyValuesX(dest, src, num, type, modifier) + ';' +
91
+ makeCopyValuesX(dest, src, num, type, modifier) + ';' +
92
+ makeCopyValuesX(dest, src, num, type, modifier) + ';' +
93
+ makeCopyValuesX(dest, src, num, type, modifier) + '; /* zz2*/';
96
+function makeCopyValuesX(dest, src, num, type, modifier) {
97
function safety(to, from) {
98
to = to || (dest + '+' + 'mcpi');
99
from = from || (src + '+' + 'mcpi');
100
return (SAFE_HEAP ? 'SAFE_HEAP_COPY_HISTORY(' + to + ', ' + from + ')' : '');
102
if (USE_TYPED_ARRAYS <= 1) {
104
diff --git a/src/utility.js b/src/utility.js
105
index 1ebbe52..1724c62 100644
108
@@ -15,15 +15,15 @@ function dump(item) {
109
while (text.length > 80) {
110
ret += '// ' + text.substr(0,80) + '\n';
111
text = text.substr(80);
113
return ret + '// ' + text;
116
- return lineify(JSON.stringify(item).substr(0, 80*25));
117
+ return lineify(JSON.stringify(item).substr(0, 800*25));
120
for (var i in item) {
122
if (typeof j === 'string' || typeof j === 'number') {
123
ret.push(i + ': ' + j);