Skip to content

Commit

Permalink
add circular-call test which leads to stack overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
doehyunbaek committed Aug 26, 2024
1 parent 5888313 commit 3f2b6c9
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
Binary file added tests/core/circular-call/index.wasm
Binary file not shown.
55 changes: 55 additions & 0 deletions tests/core/circular-call/website/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>WebAssembly Test</title>
</head>

<body>
<script>
(async function () {
const startTime = performance.now();
let instance;
let counter_200 = -1
function func_200() {
counter_200 += 1
if (counter_200 === 0) {
instance.exports.func_724();
} else if (counter_200 === 1) {
instance.exports.func_724()
} else {
return
}
}
let counter_725 = -1
function func_725() {
counter_725 += 1
if (counter_725 === 0) {
return
} else if (counter_725 === 1) {
func_200();
}
}
let imports = {
env: {
200: func_200,
725: func_725,
},
};
const indexResponse = await fetch("index.wasm");
const indexBinary = await indexResponse.arrayBuffer();
let wasm = await WebAssembly.instantiate(indexBinary, imports);
instance = wasm.instance;
func_200();
const endTime = performance.now();
const executionTime = endTime - startTime;
const executionTimeElement = document.createElement('p');
executionTimeElement.textContent = `Execution time: ${executionTime} milliseconds`;
document.body.appendChild(executionTimeElement);
})();
</script>
</body>

</html>
Binary file added tests/core/circular-call/website/index.wasm
Binary file not shown.

0 comments on commit 3f2b6c9

Please sign in to comment.