Skip to content

Commit aedd275

Browse files
committed
zz
1 parent 0b41299 commit aedd275

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

docs/public/wa-chan/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
## 🎨 设计理念
2121

22-
WA酱是凹语言(Wa-lang)的拟人化吉祥物,形象设计结合了二次元萌系风格与现代科技感,以亲和力、可扩展性、自由精神为核心概念,充分展现凹语言的核心特点。
22+
WA酱是凹语言(The Wa Programming Language)的拟人化吉祥物,形象设计结合了二次元萌系风格与现代科技感,以亲和力、可扩展性、自由精神为核心概念,充分展现凹语言的核心特点。
2323

2424
1️⃣ **科技感配色**
2525
主色调采用**浅蓝绿+白色+银灰**,象征凹语言的高效、灵活以及现代感,同时也呼应 WebAssembly 的前沿技术气息。

docs/smalltalk/en/st0060.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
# Process of solving the "Parallel ϕ-nodes" problem in Go and Wa-lang
1+
# Process of solving the "Parallel ϕ-nodes" problem in Go and Wa
22

33
Ernan Ding, Shushan Chai
44

55
---
66

7-
Recently, we (the [Wa-lang](https://github.com/wa-lang/wa) development team), discovered a bug that also exists in Go. It's related to SSA and the process was quite dramatic, as recorded below.
7+
Recently, we (the [Wa](https://github.com/wa-lang/wa) development team), discovered a bug that also exists in Go. It's related to SSA and the process was quite dramatic, as recorded below.
88

99
## 1. Background introduction
1010

11-
Wa-lang is a general-purpose programming language based on Go, its semantics is quite similar with Go, but designed for WebAssembly. The frontend of Wa-lang (source code to AST) is modified from Go 1.17, AST to SSA conversion uses the `golang.org/x/tools/go/ssa` package, and we write the backend (SSA to Wasm) from scrath.
11+
Wa (Chinese name "凹", which pronounced "Wa") is a general-purpose programming language based on Go, its semantics is quite similar with Go, but designed for WebAssembly. The frontend of Wa (source code to AST) is modified from Go 1.17, AST to SSA conversion uses the `golang.org/x/tools/go/ssa` package, and we write the backend (SSA to Wasm) from scrath.
1212

1313
SSA (Static Single-Assignment) is an intermediate representation of code, where variables are assigned only once. SSA form helps with program analysis and optimization. For more information, see [https://en.wikipedia.org/wiki/Static_single-assignment_form](https://en.wikipedia.org/wiki/Static_single-assignment_form).
1414

15-
The `golang.org/x/tools/go/ssa` package is a toolkit provided by Go, which provides functions such as converting Go-AST to Go-SSA. Many Go-based language projects are based on or use it, including TinyGo, Go+, etc., as well as Wa-lang. But it is worth noting that **this package is not used for the Go compiler itself**, but is mainly used for external tools such as code analysis.
15+
The `golang.org/x/tools/go/ssa` package is a toolkit provided by Go, which provides functions such as converting Go-AST to Go-SSA. Many Go-based language projects are based on or use it, including TinyGo, Go+, etc., as well as Wa. But it is worth noting that **this package is not used for the Go compiler itself**, but is mainly used for external tools such as code analysis.
1616

1717
## 2. Problem appears
1818

19-
Wa-lang recently supports the semantics of Map. However, when we tried to optimize its implementation using binary search tree, the results did not meet expectations. After a day of investigation, we reduced and located the problem code as follows:
19+
Wa recently supports the semantics of Map. However, when we tried to optimize its implementation using binary search tree, the results did not meet expectations. After a day of investigation, we reduced and located the problem code as follows:
2020

2121
![](/st0060-01.png)
2222

23-
The left side of the figure is the Wa-lang code, and the right side is the equivalent Go code.
24-
According to the program logic, since `root` has been initialized in the `main` function, lines 20 and 24 of the `insert` function should be executed and print the same non-empty value. However, the running results of the above Wa-lang code are as follows:
23+
The left side of the figure is the Wa code, and the right side is the equivalent Go code.
24+
According to the program logic, since `root` has been initialized in the `main` function, lines 20 and 24 of the `insert` function should be executed and print the same non-empty value. However, the running results of the above Wa code are as follows:
2525

2626
```
2727
===
@@ -71,7 +71,7 @@ That is, after leaving the loop body, `y` will be incorrectly assigned to nil. W
7171

7272
Soon after the issue was opened, Alan Donovan closed it. He said that SSA was fine and suggested that we learn the basics of SSA first.
7373

74-
However, we insisted that there was a problem with the `ssa` package. On the one hand, the above SSA code is not long, and its execution logic is not difficult to reason about; more importantly, we found that when the `Interpret()` function of the `ssa/interp` package was used to interpret the above SSA code, `y` was still incorrectly assigned to a nil value, and the printed result was no different from the output of the Wa-lang version! So we submitted these evidence, hoping to reopen the issue.
74+
However, we insisted that there was a problem with the `ssa` package. On the one hand, the above SSA code is not long, and its execution logic is not difficult to reason about; more importantly, we found that when the `Interpret()` function of the `ssa/interp` package was used to interpret the above SSA code, `y` was still incorrectly assigned to a nil value, and the printed result was no different from the output of the Wa version! So we submitted these evidence, hoping to reopen the issue.
7575

7676
## 4. Turning point
7777

@@ -86,7 +86,7 @@ The problem is here:
8686
...
8787
```
8888

89-
There are two ϕ-nodes in Block 3. According to the **conventional logic** mentioned earlier, we think the result of the first phi is the input parameter of the second one, and there is a sequence relationship between the execution of the instructions. However, when generating phis, it is based on such an assumption that "**Phis in the same Block are executed in parallel**". That is, `t6` in `phi [0: t1, 1: t6]` should take its value before entering Block 3, rather than the return value of `phi [0: t1, 1: t4]`. According to this assumption, the value of `t7` (i.e. y) is `t6` (i.e. x) of the previous iteration, and the logic is consistent with the intention of the source code. Coincidentally, the Wa-lang compiler and `ssa/interp` made the same mistake - processing phis in serial.
89+
There are two ϕ-nodes in Block 3. According to the **conventional logic** mentioned earlier, we think the result of the first phi is the input parameter of the second one, and there is a sequence relationship between the execution of the instructions. However, when generating phis, it is based on such an assumption that "**Phis in the same Block are executed in parallel**". That is, `t6` in `phi [0: t1, 1: t6]` should take its value before entering Block 3, rather than the return value of `phi [0: t1, 1: t4]`. According to this assumption, the value of `t7` (i.e. y) is `t6` (i.e. x) of the previous iteration, and the logic is consistent with the intention of the source code. Coincidentally, the Wa compiler and `ssa/interp` made the same mistake - processing phis in serial.
9090

9191
In fact, in previous private discussions, we did consider the possibility that "ϕ-nodes should be executed in parallel":
9292

@@ -100,7 +100,7 @@ But the fact that the `interp` package has problems is beyond our expectation.
100100
Alan Donovan promptly submitted a fix to the `ssa/interp` package:
101101
[https://go-review.googlesource.com/c/tools/+/621595](https://go-review.googlesource.com/c/tools/+/621595).
102102

103-
We also made a fix to the handling of ϕ-nodes in the Wa-lang: [https://github.com/wa-lang/wa/commit/8138ee420dac88463515328b1edaef99eda43974](https://github.com/wa-lang/wa/commit/8138ee420dac88463515328b1edaef99eda43974).
103+
We also made a fix to the handling of ϕ-nodes in the Wa: [https://github.com/wa-lang/wa/commit/8138ee420dac88463515328b1edaef99eda43974](https://github.com/wa-lang/wa/commit/8138ee420dac88463515328b1edaef99eda43974).
104104

105105
The test results are correct, so this problem is solved.
106106

docs/smalltalk/st0046.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ global smiley = [8]byte{...}
5050
#wa:export update
5151
func Update {
5252
wasm4.SetDrawColors(2, 0, 0, 0)
53-
wasm4.Text("Hello from Wa-lang!", 10, 10)
53+
wasm4.Text("Hello from Wa!", 10, 10)
5454
5555
gamepad := wasm4.GetGamePad1()
5656
if gamepad&wasm4.BUTTON_1 != 0 {

docs/smalltalk/st0069.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
## 🎨 设计理念
2323

24-
WA酱是凹语言(Wa-lang)的拟人化吉祥物,形象设计结合了二次元萌系风格与现代科技感,以亲和力、可扩展性、自由精神为核心概念,充分展现凹语言的核心特点。
24+
WA酱是凹语言(The Wa Programming Language)的拟人化吉祥物,形象设计结合了二次元萌系风格与现代科技感,以亲和力、可扩展性、自由精神为核心概念,充分展现凹语言的核心特点。
2525

2626
1️⃣ **科技感配色**
2727
主色调采用**浅蓝绿+白色+银灰**,象征凹语言的高效、灵活以及现代感,同时也呼应 WebAssembly 的前沿技术气息。

0 commit comments

Comments
 (0)