The document discusses implementing multiple-precision arithmetic in WebAssembly. It describes how carry operations are important for multiple-precision addition and multiplication but are not supported natively in WebAssembly. It proposes some strategies for emulating carry operations in WebAssembly using instructions like add, lt_u, and select to add multiples of 64-bit elements with carry propagation. Benchmark results show that 32-bit element processing can outperform 64-bit element processing for some operations like multiplication in WebAssembly. Overall, implementing efficient multiple-precision arithmetic in WebAssembly requires emulating carry operations that are supported directly in x64 processors.
The document discusses implementing multiple-precision arithmetic in WebAssembly. It describes how carry operations are important for multiple-precision addition and multiplication but are not supported natively in WebAssembly. It proposes some strategies for emulating carry operations in WebAssembly using instructions like add, lt_u, and select to add multiples of 64-bit elements with carry propagation. Benchmark results show that 32-bit element processing can outperform 64-bit element processing for some operations like multiplication in WebAssembly. Overall, implementing efficient multiple-precision arithmetic in WebAssembly requires emulating carry operations that are supported directly in x64 processors.
This document discusses macros in the Nemerle programming language. It provides an overview of the different types of macros in Nemerle, including lexical level macros, AST level macros, and custom attribute macros. AST level macros allow transforming AST nodes similar to Lisp macros. Custom attribute macros enable global rewriting of a program at compile time. Examples demonstrate using macros for tasks like solving mazes at compile time and custom syntax like json data literals.
8. スタックマシンの動作イメージ var pc: int var ops: byte[] ... while(pc < ops.length) { switch(ops[pc]) { case ADD: r = pop; l = pop; push(l + r); case SUB: r = pop; l = pop; push(l - r); case DIV: ... } pc++; }
11. 実際の型と計算上の型とカテゴリ 2 double double 2 long long 1 returnAddress returnAddress 1 reference reference 1 float float 1 int int 1 int short 1 int char 1 int byte 1 int boolean カテゴリ 計算上の型 実際の型
17. iload ローカル変数から int をロードする フォーマット: <0x15,index> オペランドスタック: ..., ⇒ ..., value index 番目のローカル変数の値がスタックにプッシュされる index 番目のローカル変数には int 型の値が保持されていなければならない
18. fload ローカル変数から float をロードする フォーマット: <0x17,index> オペランドスタック: ..., ⇒ ..., value index 番目のローカル変数の値がスタックにプッシュされる index 番目のローカル変数には float 型の値が保持されていなければならない
49. >java Uninitialized Exception in thread "main" java.lang.VerifyError : (class: Uninitialized, method: main signature: ([L java/lang/String;)V) Accessing value from uninitialized register 1 ベリファイアがはねるプログラム (2) – 未初期化ローカル変数へのアクセス .class public Uninitialized .super java/lang/Object .method public static main([Ljava/lang/String;)V .limit stack 2 .limit locals 3 iload_1 return .end method
50. >java Incompatible Exception in thread "main" java.lang.VerifyError : (class: Incompatible, method: main signature: ([Lj ava/lang/String;)V) Expecting to find integer on stack ベリファイアがはねるプログラム (3) - 型エラー .class public Incompatible .super java/lang/Object .method public static main([Ljava/lang/String;)V .limit stack 2 ldc 3.5 ldc 4.0 iadd return .end method
51. >java PopLong Exception in thread "main" java.lang.VerifyError : (class: PopLong, method: main signature: ([Ljava/lang/String;)V) Attempt to split long or double on the stack ベリファイアがはねるプログラム (4) - カテゴリ間違い .class public PopLong .super java/lang/Object .method public static main([Ljava/lang/String;)V .limit stack 3 invokestatic java/lang/System/currentTimeMillis()J pop ; pop2 なら OK . pop はカテゴリ 1 の値しか pop できないが long はカテゴリ 2 return .end method
52. 練習問題 ↓ のコンパイル結果を逆アセンブルしたものを読んでみる ',' で区切られた項目 ( 整数 ) の合計値を計算 import java.util.Scanner; public class CalcSum { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while(scanner.hasNext()) { int result = 0; String[] line = scanner.nextLine().split(","); for(String element:line) result += Integer.parseInt(element); System.out.println("result:" + result); } } }
53. 練習問題 逆アセンブル (javap –c CalcSum) した結果 public class CalcSum { ↓ Compiled from "CalcSum.java" public class CalcSum extends java.lang.Object{ public CalcSum(); Code: 0: aload_0 1: invokespecial #1; //Method java/lang/Object."<init>":()V 4: return