diff options
Diffstat (limited to 'docs/paper.tex')
-rw-r--r-- | docs/paper.tex | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/docs/paper.tex b/docs/paper.tex index 4ad795b8..9e460bac 100644 --- a/docs/paper.tex +++ b/docs/paper.tex @@ -114,7 +114,7 @@ main ones of which are Clang and LLVM-GCC) into the LLVM intermediary representation (which can be machine-readable bitcode, or human-readable assembly), and then passes it through a \emph{backend} which generates actual machine code for a particular -architecure. Emscripten plays the role of a backend which targets JavaScript. +architecture. Emscripten plays the role of a backend which targets JavaScript. By using Emscripten, potentially many languages can be run on the web, using one of the following methods: @@ -138,7 +138,7 @@ run on the web, using one of the following methods: From a technical standpoint, one challenge in designing and implementing Emscripten is that it compiles a low-level language -- LLVM assembly -- into -a high-level one -- JavaScript. This is somethat the reverse of the usual +a high-level one -- JavaScript. This is somewhat the reverse of the usual situation one is in when building a compiler, and leads to some unique difficulties. For example, to get good performance in JavaScript one must use natural JavaScript code flow structures, like loops and ifs, but @@ -214,7 +214,7 @@ following simple example of a C program: int main() { int sum = 0; - for (int i = 1; i < 100; i++) + for (int i = 1; i <= 100; i++) sum += i; printf("1+...+100=%d\n", sum); return 0; @@ -239,7 +239,7 @@ define i32 @main() { ; <label>:2 %3 = load i32* %i, align 4 - %4 = icmp slt i32 %3, 100 + %4 = icmp sle i32 %3, 100 br i1 %4, label %5, label %12 ; <label>:5 @@ -314,7 +314,7 @@ function _main() { __label__ = 0; break; case 0: var $3 = HEAP[$i]; - var $4 = $3 < 100; + var $4 = $3 <= 100; if ($4) { __label__ = 1; break; } else { __label__ = 2; break; } case 1: @@ -475,7 +475,7 @@ a compilation option, SAFE\_HEAP, which generates code that checks that LSC hold doesn't. It also warns about other memory-related issues like reading from memory before a value was written (somewhat similarly to tools like Valgrind\footnote{\url{http://valgrind.org/}}). When such problems are detected, possible solutions are to ignore the issue (if it has no actual -consqeuences), or alter the source code. +consequences), or alter the source code. Note that it is somewhat wasteful to allocate 4 memory locations for a 32-bit integer, and use only one of them. It is possible to change @@ -594,7 +594,7 @@ function _main() { $i = 0; $2$2: while(1) { var $3 = $i; - var $4 = $3 < 100; + var $4 = $3 <= 100; if (!($4)) { __label__ = 2; break $2$2; } var $6 = $i; var $7 = $sum; @@ -616,7 +616,7 @@ function K() { var a, b; b = a = 0; a:for(;;) { - if(!(b < 100)) { + if(!(b <= 100)) { break a } a += b; @@ -737,7 +737,7 @@ surprisingly easy to implement. For example, C++ exceptions are represented in LLVM by \emph{invoke} and \emph{unwind}, where \emph{invoke} is a call to a function that will potentially trigger an \emph{unwind}, and \emph{unwind} returns to the earliest invoke. If one were to implement those -in a typical compiler, doing so would require careful work. In Emscripen, however, +in a typical compiler, doing so would require careful work. In Emscripten, however, it is possible to do so using JavaScript exceptions in a straightforward manner: \emph{invoke} becomes a function call wrapped in a \emph{try} block, and \emph{unwind} becomes \emph{throw}. This is a case where compiling to a high-level language turns |