-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pin non-primitive function parameters (#87)
* Trying to build a repro case * Use Rehkitz’ repro * Fix it * Getting travis to run after .org to .com migration * Travis Please! * Updated the webhook, maybe now travis will update? * Next day, maybe Travis will be happy now? * Travis should work for sure now :) Co-authored-by: Aaron Turner <aaron@aaronthedev.com>
- Loading branch information
Showing
6 changed files
with
99 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// The entry file of your WebAssembly module. | ||
|
||
declare function string_log(str: string): void; | ||
|
||
class MemoryTrash { | ||
public t1: string; | ||
public t2: string; | ||
public t3: i32; | ||
|
||
constructor() { | ||
this.t1 = "trash1"; | ||
this.t2 = "trash1"; | ||
this.t3 = 42; | ||
} | ||
} | ||
|
||
export function trash(amount: i32): void { | ||
for (let i = 0; i < amount; i++) { | ||
let t = new MemoryTrash(); | ||
} | ||
} | ||
|
||
export function string_parameter( | ||
s1: string, | ||
s2: string, | ||
s3: string, | ||
s4: string | ||
): void { | ||
string_log(s1); | ||
string_log(s2); | ||
string_log(s3); | ||
string_log(s4); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
exports.mangleCompilerParams = params => { | ||
// Remove runtime parameter | ||
const idx = params.indexOf("stub"); | ||
params.splice(idx - 1, 2); | ||
// Add debug | ||
params.unshift("--target", "debug"); | ||
console.log({ params }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
describe("as-bind", function() { | ||
// Shoutout to @RehkitzDev for the repro | ||
it("should not GC strings", function(done) { | ||
let num_logs = 0; | ||
function string_log(s) { | ||
num_logs += 1; | ||
assert(!/[^ABCD]/.test(s)); | ||
if (num_logs === 4) { | ||
done(); | ||
} | ||
} | ||
|
||
(async () => { | ||
const instance = await AsBind.instantiate(this.rawModule, { | ||
asc: { string_log } | ||
}); | ||
|
||
instance.exports.trash(10000); | ||
let a = "A".repeat(30); | ||
let b = "B".repeat(30); | ||
let c = "C".repeat(60); | ||
let d = "D".repeat(60); | ||
|
||
instance.exports.string_parameter(a, b, c, d); | ||
})(); | ||
}); | ||
}); |