8000 Fix emitting memcpys · repos-javascript-compilers/LLJS@e737e57 · GitHub
[go: up one dir, main page]

Skip to content

Commit e737e57

Browse files
committed
Fix emitting memcpys
1 parent b8bf418 commit e737e57

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/compiler.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@
690690

691691
StructType.prototype.lint = function () {
692692
var maxSize = 1;
693-
var maxSizeType;
693+
var maxSizeType = u8ty;
694694
var fields = this.fields
695695
var field, type;
696696
var prev = { offset: 0, type: { size: 0 } };
@@ -1212,18 +1212,20 @@
12121212

12131213
if (lty instanceof StructType) {
12141214
// Emit a memcpy using the largest alignment size we can.
1215-
var mc, size;
1216-
if (isAlignedTo(lty.size, 4)) {
1215+
var mc, size, pty;
1216+
if (lty.align === u32ty) {
12171217
mc = scope.MEMCPY(4);
12181218
size = lty.size / 4;
1219-
} else if (isAlignedTo(lty.size, 2)) {
1219+
} else if (lty.align === u16ty) {
12201220
mc = scope.MEMCPY(2);
12211221
size = lty.size / 2;
12221222
} else {
1223-
mc = scope.MEMCPY(1);
1223+
mc = scope.MEMCPY(u8ty.size);
12241224
size = lty.size;
12251225
}
1226-
return cast(new CallExpression(mc, [this.left, this.right, new Literal(size)]), lty);
1226+
var left = new UnaryExpression("&", this.left);
1227+
var right = new UnaryExpression("&", this.right);
1228+
return cast(new CallExpression(mc, [left, right, new Literal(size)]), lty).transform(o);
12271229
} else {
12281230
this.right = cast(this.right, lty);
12291231
return cast(this, lty);

0 commit comments

Comments
 (0)
0