summaryrefslogtreecommitdiff
path: root/test/wasm2js
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-11-18 15:43:11 -0800
committerGitHub <noreply@github.com>2024-11-18 15:43:11 -0800
commit25b8e6a714d2217e8735a925bc751900bce09d53 (patch)
tree752e3a6f51b07bd1b02de73523c2f663257f7b40 /test/wasm2js
parent08b7496306915dbe11030a7a4cf79207f9460d2f (diff)
downloadbinaryen-25b8e6a714d2217e8735a925bc751900bce09d53.tar.gz
binaryen-25b8e6a714d2217e8735a925bc751900bce09d53.tar.bz2
binaryen-25b8e6a714d2217e8735a925bc751900bce09d53.zip
Use hints when generating fresh labels in IRBuilder (#7086)
IRBuilder often has to generate new label names for blocks and other scopes. Previously it would generate each new name by starting with "block" or "label" and incrementing a suffix until finding a fresh name, but this made name generation quadratic in the number of names to generate. To spend less time generating names, track a hint index at which to start looking for a fresh name and increment it every time a name is generated. This speeds up a version of the binary parser that uses IRBuilder by about 15%.
Diffstat (limited to 'test/wasm2js')
-rw-r--r--test/wasm2js/br_table_temp.2asm.js68
-rw-r--r--test/wasm2js/br_table_temp.2asm.js.opt20
-rw-r--r--test/wasm2js/labels.2asm.js8
3 files changed, 48 insertions, 48 deletions
diff --git a/test/wasm2js/br_table_temp.2asm.js b/test/wasm2js/br_table_temp.2asm.js
index 9bc6cafa4..a8592a186 100644
--- a/test/wasm2js/br_table_temp.2asm.js
+++ b/test/wasm2js/br_table_temp.2asm.js
@@ -115,7 +115,7 @@ function asmFunc(imports) {
function $11($0_1) {
$0_1 = $0_1 | 0;
var $2_1 = 0, $4_1 = 0, $3_1 = 0;
- block0 : {
+ block1 : {
block : {
$2_1 = 33;
$3_1 = $2_1;
@@ -124,7 +124,7 @@ function asmFunc(imports) {
case 0:
break block;
default:
- break block0;
+ break block1;
};
}
$4_1 = 32;
@@ -134,7 +134,7 @@ function asmFunc(imports) {
function $12($0_1) {
$0_1 = $0_1 | 0;
- block3 : {
+ block4 : {
switch ($0_1 | 0) {
case 3:
return 100 | 0;
@@ -145,7 +145,7 @@ function asmFunc(imports) {
case 0:
return 103 | 0;
default:
- break block3;
+ break block4;
};
}
return 104 | 0;
@@ -154,11 +154,11 @@ function asmFunc(imports) {
function $13($0_1) {
$0_1 = $0_1 | 0;
var $1_1 = 0, $3_1 = 0, $4_1 = 0, $5_1 = 0, $6_1 = 0, $7_1 = 0, $8_1 = 0;
- block3 : {
+ block4 : {
block : {
- block0 : {
- block1 : {
- block2 : {
+ block1 : {
+ block2 : {
+ block3 : {
$3_1 = 200;
$4_1 = $3_1;
$5_1 = $3_1;
@@ -169,13 +169,13 @@ function asmFunc(imports) {
case 0:
break block;
case 1:
- break block0;
- case 2:
break block1;
- case 3:
+ case 2:
break block2;
- default:
+ case 3:
break block3;
+ default:
+ break block4;
};
}
$1_1 = $7_1;
@@ -196,7 +196,7 @@ function asmFunc(imports) {
function $14($0_1) {
$0_1 = $0_1 | 0;
- block0 : {
+ block1 : {
switch ($0_1 | 0) {
case 0:
case 2:
@@ -12508,7 +12508,7 @@ function asmFunc(imports) {
case 24614:
return 0 | 0;
default:
- break block0;
+ break block1;
};
}
return 1 | 0;
@@ -13052,8 +13052,8 @@ function asmFunc(imports) {
function $58($0_1) {
$0_1 = $0_1 | 0;
var $2_1 = 0, $4_1 = 0, $5_1 = 0, $3_1 = 0;
- block1 : {
- block0 : {
+ block2 : {
+ block1 : {
block : {
$2_1 = 16;
$3_1 = $2_1;
@@ -13063,9 +13063,9 @@ function asmFunc(imports) {
case 0:
break block;
case 1:
- break block0;
- default:
break block1;
+ default:
+ break block2;
};
}
$4_1 = 2 + $3_1 | 0;
@@ -13079,8 +13079,8 @@ function asmFunc(imports) {
$0_1 = $0_1 | 0;
var $2_1 = 0, $3_1 = 0, $4_1 = 0, $5_1 = 0;
block : {
- block0 : {
- block1 : {
+ block1 : {
+ block2 : {
$2_1 = 8;
$3_1 = $2_1;
$4_1 = $2_1;
@@ -13089,9 +13089,9 @@ function asmFunc(imports) {
case 0:
break block;
case 1:
- break block0;
- default:
break block1;
+ default:
+ break block2;
};
}
$4_1 = 16;
@@ -13104,8 +13104,8 @@ function asmFunc(imports) {
function $60($0_1) {
$0_1 = $0_1 | 0;
var $2_1 = 0, $3_1 = 0, $4_1 = 0, $5_1 = 0;
- block1 : {
- block0 : {
+ block2 : {
+ block1 : {
block : {
$2_1 = 8;
$3_1 = $2_1;
@@ -13115,9 +13115,9 @@ function asmFunc(imports) {
case 0:
break block;
case 1:
- break block0;
- default:
break block1;
+ default:
+ break block2;
};
}
$4_1 = 16;
@@ -13130,14 +13130,14 @@ function asmFunc(imports) {
function $61($0_1) {
$0_1 = $0_1 | 0;
var $3_1 = 0, $2_1 = 0, $4_1 = 0;
- block0 : {
+ block1 : {
block : {
$2_1 = 8;
$3_1 = $2_1;
$4_1 = $2_1;
switch ($0_1 | 0) {
case 1:
- break block0;
+ break block1;
default:
break block;
};
@@ -13150,8 +13150,8 @@ function asmFunc(imports) {
function $62($0_1) {
$0_1 = $0_1 | 0;
var $2_1 = 0, $3_1 = 0, $4_1 = 0, $5_1 = 0;
- block1 : {
- block0 : {
+ block2 : {
+ block1 : {
block : {
$2_1 = 8;
$3_1 = $2_1;
@@ -13161,9 +13161,9 @@ function asmFunc(imports) {
case 0:
break block;
case 1:
- break block0;
- default:
break block1;
+ default:
+ break block2;
};
}
$4_1 = 16;
@@ -13176,14 +13176,14 @@ function asmFunc(imports) {
function $63($0_1) {
$0_1 = $0_1 | 0;
var $3_1 = 0, $2_1 = 0, $4_1 = 0;
- block0 : {
+ block1 : {
block : {
$2_1 = 8;
$3_1 = $2_1;
$4_1 = $2_1;
switch ($0_1 | 0) {
case 1:
- break block0;
+ break block1;
default:
break block;
};
diff --git a/test/wasm2js/br_table_temp.2asm.js.opt b/test/wasm2js/br_table_temp.2asm.js.opt
index b64e46a77..f1dad0ab2 100644
--- a/test/wasm2js/br_table_temp.2asm.js.opt
+++ b/test/wasm2js/br_table_temp.2asm.js.opt
@@ -60,7 +60,7 @@ function asmFunc(imports) {
function $12($0) {
$0 = $0 | 0;
- block3 : {
+ block4 : {
switch ($0 | 0) {
case 3:
return 100;
@@ -71,7 +71,7 @@ function asmFunc(imports) {
case 0:
return 103;
default:
- break block3;
+ break block4;
};
}
return 104;
@@ -79,7 +79,7 @@ function asmFunc(imports) {
function $13($0) {
$0 = $0 | 0;
- block3 : {
+ block4 : {
switch ($0 | 0) {
case 3:
return 210;
@@ -90,7 +90,7 @@ function asmFunc(imports) {
case 0:
return 213;
default:
- break block3;
+ break block4;
};
}
return 214;
@@ -98,7 +98,7 @@ function asmFunc(imports) {
function $14($0) {
$0 = $0 | 0;
- block0 : {
+ block1 : {
switch ($0 | 0) {
case 0:
case 2:
@@ -12410,7 +12410,7 @@ function asmFunc(imports) {
case 24614:
return 0;
default:
- break block0;
+ break block1;
};
}
return 1;
@@ -12554,7 +12554,7 @@ function asmFunc(imports) {
$0 = $0 | 0;
var $1 = 0;
$1 = 16;
- block1 : {
+ block2 : {
switch ($0 | 0) {
case 0:
$1 = 18;
@@ -12562,7 +12562,7 @@ function asmFunc(imports) {
$1 = $1 + 1 | 0;
break;
default:
- break block1;
+ break block2;
};
}
return $1 | 0;
@@ -12590,7 +12590,7 @@ function asmFunc(imports) {
$0 = $0 | 0;
var $1 = 0;
$1 = 8;
- block1 : {
+ block2 : {
switch ($0 | 0) {
case 0:
$1 = 16;
@@ -12598,7 +12598,7 @@ function asmFunc(imports) {
$1 = $1 + 1 | 0;
break;
default:
- break block1;
+ break block2;
};
}
return $1 | 0;
diff --git a/test/wasm2js/labels.2asm.js b/test/wasm2js/labels.2asm.js
index ac2978300..431e172d9 100644
--- a/test/wasm2js/labels.2asm.js
+++ b/test/wasm2js/labels.2asm.js
@@ -143,10 +143,6 @@ function asmFunc(imports) {
break label;
}
i = i + 1 | 0;
- label0 : {
- break label0;
- }
- i = i + 1 | 0;
label1 : {
break label1;
}
@@ -159,6 +155,10 @@ function asmFunc(imports) {
break label3;
}
i = i + 1 | 0;
+ label4 : {
+ break label4;
+ }
+ i = i + 1 | 0;
return i | 0;
}