AI協調開発研究ドキュメントの完成と Phase 10.9-β 進捗
【AI協調開発研究】 - AI二重化モデルの学術論文draft完成(workshop_paper_draft.md) - 「隠れた危機」分析とbirthの原則哲学化 - TyEnv「唯一の真実」協調会話を保存・研究資料に統合 - papers管理構造の整備(wip/under-review/published分離) 【Phase 10.9-β HostCall進捗】 - JitConfigBox: relax_numeric フラグ追加(i64→f64コアーション制御) - HostcallRegistryBox: 署名検証・白黒リスト・コアーション対応 - JitHostcallRegistryBox: Nyash側レジストリ操作API - Lower統合: env直読 → jit::config::current() 参照に統一 - 数値緩和設定: NYASH_JIT_HOSTCALL_RELAX_NUMERIC/Config.set_flag 【検証サンプル拡充】 - math.sin/cos/abs/min/max 関数スタイル(examples/jit_math_function_style_*.nyash) - 境界ケース: 署名不一致・コアーション許可・mutating拒否サンプル - E2E実証: String.length→allow, Array.push→fallback, math関数の署名一致観測 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
12
examples/jit_hostcall_array_append.nyash
Normal file
12
examples/jit_hostcall_array_append.nyash
Normal file
@ -0,0 +1,12 @@
|
||||
// Fallback case: Array.append/push is mutating; with read-only policy it should fallback
|
||||
// Run: NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 ./target/release/nyash --backend vm examples/jit_hostcall_array_append.nyash
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
local xs
|
||||
xs = new ArrayBox()
|
||||
xs.push(1)
|
||||
return xs.length() // expect 1 in VM; under JIT read-only policy push is denied → still 1 via VM path
|
||||
}
|
||||
}
|
||||
|
||||
18
examples/jit_hostcall_array_push_mutating.nyash
Normal file
18
examples/jit_hostcall_array_push_mutating.nyash
Normal file
@ -0,0 +1,18 @@
|
||||
// Array push - mutating operation
|
||||
// Expect: decision="fallback", reason="policy_denied_mutating"
|
||||
// Run:
|
||||
// NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_EVENTS=1 NYASH_JIT_HOSTCALL=1 \
|
||||
// ./target/release/nyash --backend vm examples/jit_hostcall_array_push_mutating.nyash
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
local a, x
|
||||
a = new ArrayBox()
|
||||
x = "item1"
|
||||
|
||||
// Mutating operation - should fallback with policy_denied_mutating
|
||||
a.push(x)
|
||||
|
||||
return a.length() // ReadOnly - should allow
|
||||
}
|
||||
}
|
||||
11
examples/jit_hostcall_len_string.nyash
Normal file
11
examples/jit_hostcall_len_string.nyash
Normal file
@ -0,0 +1,11 @@
|
||||
// Success case: String.length() via JIT hostcall (read-only)
|
||||
// Run: NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 ./target/release/nyash --backend vm examples/jit_hostcall_len_string.nyash
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
local s
|
||||
s = "abc"
|
||||
return s.length()
|
||||
}
|
||||
}
|
||||
|
||||
18
examples/jit_hostcall_map_get_handle.nyash
Normal file
18
examples/jit_hostcall_map_get_handle.nyash
Normal file
@ -0,0 +1,18 @@
|
||||
// Map get with handle arguments
|
||||
// Expect: decision="allow", arg_types=["Handle","Handle"]
|
||||
// Run:
|
||||
// NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_EVENTS=1 NYASH_JIT_HOSTCALL=1 \
|
||||
// ./target/release/nyash --backend vm examples/jit_hostcall_map_get_handle.nyash
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
local m, k, v
|
||||
m = new MapBox()
|
||||
k = "key1"
|
||||
v = "value1"
|
||||
m.set(k, v) // This will fallback (mutating)
|
||||
|
||||
// ReadOnly operation - should allow
|
||||
return m.get(k)
|
||||
}
|
||||
}
|
||||
16
examples/jit_hostcall_math_sin_allow_float.nyash
Normal file
16
examples/jit_hostcall_math_sin_allow_float.nyash
Normal file
@ -0,0 +1,16 @@
|
||||
// Allow case: math.sin expects f64; JIT records sig_ok (allow) and VM executes (thin bridge)
|
||||
// Run:
|
||||
// NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_EVENTS=1 \
|
||||
// ./target/release/nyash --backend vm examples/jit_hostcall_math_sin_allow_float.nyash
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
local m, x
|
||||
m = new MathBox()
|
||||
// pi/2 in double precision
|
||||
x = 1.5707963267948966
|
||||
// Registry signature matches (f64 -> f64), event: {decision: "allow", reason: "sig_ok"}
|
||||
return m.sin(x)
|
||||
}
|
||||
}
|
||||
|
||||
15
examples/jit_hostcall_math_sin_allow_int_coerce.nyash
Normal file
15
examples/jit_hostcall_math_sin_allow_int_coerce.nyash
Normal file
@ -0,0 +1,15 @@
|
||||
// Allow via coercion: math.sin expects f64; integer arg coerces i64->f64 in signature check
|
||||
// Run:
|
||||
// NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_NATIVE_F64=1 NYASH_JIT_HOSTCALL=1 NYASH_JIT_EVENTS=1 \
|
||||
// ./target/release/nyash --backend vm examples/jit_hostcall_math_sin_allow_int_coerce.nyash
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
local m, x
|
||||
m = new MathBox()
|
||||
x = 0
|
||||
// Registry signature allows i64 -> f64 coercion (v0 policy)
|
||||
return m.sin(x)
|
||||
}
|
||||
}
|
||||
|
||||
13
examples/jit_hostcall_math_sin_mismatch.nyash
Normal file
13
examples/jit_hostcall_math_sin_mismatch.nyash
Normal file
@ -0,0 +1,13 @@
|
||||
// Boundary case: math.sin expects f64; v0 emits sig_mismatch fallback event
|
||||
// Run: NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_EVENTS=1 ./target/release/nyash --backend vm examples/jit_hostcall_math_sin_mismatch.nyash
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
local m, x
|
||||
m = new MathBox()
|
||||
x = 0
|
||||
// Int arg; v0 JIT records sig_mismatch and VM executes
|
||||
return m.sin(x)
|
||||
}
|
||||
}
|
||||
|
||||
11
examples/jit_math_function_style_abs_float.nyash
Normal file
11
examples/jit_math_function_style_abs_float.nyash
Normal file
@ -0,0 +1,11 @@
|
||||
// Function-style math: abs(x)
|
||||
// Run:
|
||||
// NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_NATIVE_F64=1 NYASH_JIT_EVENTS=1 \
|
||||
// ./target/release/nyash --backend vm examples/jit_math_function_style_abs_float.nyash
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
return abs(-3.25)
|
||||
}
|
||||
}
|
||||
|
||||
11
examples/jit_math_function_style_cos_float.nyash
Normal file
11
examples/jit_math_function_style_cos_float.nyash
Normal file
@ -0,0 +1,11 @@
|
||||
// Function-style math: cos(x)
|
||||
// Run:
|
||||
// NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_NATIVE_F64=1 NYASH_JIT_EVENTS=1 \
|
||||
// ./target/release/nyash --backend vm examples/jit_math_function_style_cos_float.nyash
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
return cos(0.0)
|
||||
}
|
||||
}
|
||||
|
||||
11
examples/jit_math_function_style_max_float.nyash
Normal file
11
examples/jit_math_function_style_max_float.nyash
Normal file
@ -0,0 +1,11 @@
|
||||
// Function-style math: max(a,b)
|
||||
// Run:
|
||||
// NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_NATIVE_F64=1 NYASH_JIT_EVENTS=1 \
|
||||
// ./target/release/nyash --backend vm examples/jit_math_function_style_max_float.nyash
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
return max(2.5, 7.0)
|
||||
}
|
||||
}
|
||||
|
||||
11
examples/jit_math_function_style_min_float.nyash
Normal file
11
examples/jit_math_function_style_min_float.nyash
Normal file
@ -0,0 +1,11 @@
|
||||
// Function-style math: min(a,b)
|
||||
// Run:
|
||||
// NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_NATIVE_F64=1 NYASH_JIT_EVENTS=1 \
|
||||
// ./target/release/nyash --backend vm examples/jit_math_function_style_min_float.nyash
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
return min(2.5, 7.0)
|
||||
}
|
||||
}
|
||||
|
||||
12
examples/jit_math_function_style_sin_float.nyash
Normal file
12
examples/jit_math_function_style_sin_float.nyash
Normal file
@ -0,0 +1,12 @@
|
||||
// Function-style math: sin(x) should normalize to MathBox.sin(x)
|
||||
// Run:
|
||||
// NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_NATIVE_F64=1 NYASH_JIT_EVENTS=1 \
|
||||
// ./target/release/nyash --backend vm examples/jit_math_function_style_sin_float.nyash
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
// Expect allow(sig_ok) with native f64 enabled
|
||||
return sin(1.5707963267948966)
|
||||
}
|
||||
}
|
||||
|
||||
12
examples/jit_math_min_relax_numeric.nyash
Normal file
12
examples/jit_math_min_relax_numeric.nyash
Normal file
@ -0,0 +1,12 @@
|
||||
// Math min with mixed int/float arguments requiring coercion
|
||||
// Expect: decision="allow(coerce_f64)", arg_types=["I64","F64"]
|
||||
// Run:
|
||||
// NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_NATIVE_F64=1 NYASH_JIT_RELAX_NUMERIC=1 NYASH_JIT_EVENTS=1 \
|
||||
// ./target/release/nyash --backend vm examples/jit_math_min_relax_numeric.nyash
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
// Mixed i64 and f64 arguments
|
||||
return min(3, 1.5) // 3 is i64, 1.5 is f64
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user