diff options
Diffstat (limited to 'chapter31')
| -rw-r--r-- | chapter31/README.ja.md | 3 | ||||
| -rw-r--r-- | chapter31/README.md | 14 | ||||
| -rw-r--r-- | chapter31/pom.xml | 2 | ||||
| -rw-r--r-- | chapter31/src/main/smp/sys/rt/simple_args.smp | 18 |
4 files changed, 20 insertions, 17 deletions
diff --git a/chapter31/README.ja.md b/chapter31/README.ja.md index 190245a2..2326f921 100644 --- a/chapter31/README.ja.md +++ b/chapter31/README.ja.md @@ -2,7 +2,8 @@ [English](README.md) | 日本語 -[前の章:第30章 — テキスト整形と診断](../chapter30/README.ja.md) +[前の章:第30章 — テキスト整形と診断](../chapter30/README.ja.md) | +[次の章:第32章 — コンパイラ内部の高速化](../chapter32/README.ja.md) 第30章で完成したコンパイラと標準ライブラリを出発点とする章です。 Simple で描画する `sys.draw.Canvas` と、MiniFB を使うオプションの diff --git a/chapter31/README.md b/chapter31/README.md index 0b46ea68..57f5557c 100644 --- a/chapter31/README.md +++ b/chapter31/README.md @@ -1,6 +1,7 @@ # Chapter 31: Software Drawing, Time, and Graphical Games -[Previous: Chapter 30 — Text Formatting and Diagnostics](../chapter30/README.md) +[Previous: Chapter 30 — Text Formatting and Diagnostics](../chapter30/README.md) | +[Next: Chapter 32 — Compiler Internal Speedups](../chapter32/README.md) In this chapter we use small graphical games to drive the language and library work. We add graphics, sound, and time support, with a few small C adapters @@ -182,7 +183,7 @@ that library. See the native references for [trigonometry](https://sourceware.org/glibc/manual/2.43/html_node/Trig-Functions.html) and [exponents, logarithms, and square roots](https://sourceware.org/glibc/manual/latest/html_node/Exponents-and-Logarithms.html). They remain ordinary C calls, so they are not constant-folded or discarded as -pure intrinsics. Clock uses `sin` and `cos` for its dial and hands. +pure intrinsics. Clock uses `sin` and `cos` for its dial and hands. `make test CLASS=MathTest` checks native results, special values, indirect calls, and code generation for all three targets. @@ -225,10 +226,10 @@ to preserve representations without aliasing tricks. A replacement definition must honor the same contract. Ordinary C functions remain opaque to the optimizer. The ideal nodes support constant folding, inverse cancellation, evaluation, and -serialization. Floating-point constant interning and serialization retain raw -NaN bits. x86 emits `MOVQ` between XMM and integer registers; ARM emits `FMOV`, -and RISC-V emits `FMV.X.D` / `FMV.D.X`. Register allocation may add copies or -spills, and normal module-initialization checks still apply. +serialization. Floating-point constant interning and serialization retain raw +NaN bits. x86 emits `MOVQ` between XMM and integer registers; ARM emits +`FMOV`, and RISC-V emits `FMV.X.D` / `FMV.D.X`. Register allocation may add +copies or spills, and normal module-initialization checks still apply. Future intrinsics such as compare-and-swap or fences must define their memory and escape effects explicitly, using nodes with the required ordering @@ -257,6 +258,7 @@ Simple also now recognizes hexadecimal (`0xff0000`) and leading-zero octal - Imported read-only primitive arrays retain their types. Object files can represent more than 255 distinct memory regions. - Floating-point constants and register copies preserve raw NaN bits. +- Fixed X86 combined Load+Cmp op scheduling. ## Further reading diff --git a/chapter31/pom.xml b/chapter31/pom.xml index 0b0436cd..b73284d3 100644 --- a/chapter31/pom.xml +++ b/chapter31/pom.xml @@ -10,7 +10,7 @@ </parent> <artifactId>chapter31</artifactId> <packaging>jar</packaging> - <name>Work in Progress</name> + <name>Software Drawing, Games, and Libraries</name> <properties> <simple.graph.directory>${project.basedir}/../graph</simple.graph.directory> <simple.print.directory>${project.basedir}/../print</simple.print.directory> diff --git a/chapter31/src/main/smp/sys/rt/simple_args.smp b/chapter31/src/main/smp/sys/rt/simple_args.smp index 8bfcc1a7..6f857d91 100644 --- a/chapter31/src/main/smp/sys/rt/simple_args.smp +++ b/chapter31/src/main/smp/sys/rt/simple_args.smp @@ -6,19 +6,19 @@ u32 _MAX_U32 = (1<<32)-1; { i64 -> i64 } strlen = "C"; { i64 i64 i64 -> i64 } memcpy = "C"; +// Returns a constant argc-length array, filled with not-null constant u8 +// arrays. val simple_args = { i64 argc, i64 argv -> if( argc < 0 || argc > _MAX_U32 ) return null; - // Zero-filled reference arrays require nullable elements. Every slot is - // filled before returning; the native entry bridge publishes u8[~][]. - val args = new u8[~]?[argc]; - for( i64 i = 0; i < argc; i++ ) { + // Build an initialized + return new u8[][argc] { int i -> i64 src = simple_argv(argv,i); i64 len = strlen(src); - if( len < 0 || len > _MAX_U32 ) return null; + if( !(0 < len <= _MAX_U32) ) // If not the u32 range, just use zero-length + len = 0; val bytes = new u8[len]; i64 dst = bytes; - memcpy(dst,src,len); - args[i] = bytes; - } - return args; + memcpy(dst,src,len); // Copy from C memory to Simple memory + return bytes; + }; }; |
