mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Floating Point Power and While Loop JIT (#5614)
* Initial commit for power function * Float power jit developed * Addded support for Floats and Ints * Integration Testing for JITPower implementation. * Update instructions.rs * Update int_tests.rs * Update float_tests.rs * Updated cranelift and power function to use magic bs * Updated the compile_fpow accuracy * updating while loop test * Update instructions.rs cranelift more like painlift * Update instructions.rs * Update instructions.rs * initial commit for making stable PR ready features * fixed final edge case for compile_ipow * fixed final edge case for compile_ipow * commenting out compile_ipow * fixed spelling errors * removed unused tests * forgot to run clippy * Cleaned the branch * While loop implementation for Cranelift 0.116.1 * Floating Point * Removed testing print statement * Resolved some formatting * Fixed cargo fmt warning * Fixed int div and int exp issues * Fixed formatting --------- Co-authored-by: Nick <nick@Samanthas-MBP.wi.rr.com> Co-authored-by: JoeLoparco <loparcojoseph@gmail.com> Co-authored-by: Daniel O'Hear <149127239+dohear@users.noreply.github.com> Co-authored-by: Joseph Loparco <149088810+JoeLoparco@users.noreply.github.com> Co-authored-by: Nick <nick@pcp090057pcs.mu.edu> Co-authored-by: dohear <daniel.ohear@marquette.edu> Co-authored-by: Nathan Rusch <nathan.rusch@icloud.com> Co-authored-by: Nick <nick@pcp093574pcs.mu.edu> Co-authored-by: Joseph Loparco <--global loparcoJoseph@gmail.com> Co-authored-by: Nick <nick@Samanthas-MacBook-Pro.local>
This commit is contained in:
233
Cargo.lock
generated
233
Cargo.lock
generated
@@ -36,6 +36,12 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
|
||||
|
||||
[[package]]
|
||||
name = "android-tzdata"
|
||||
version = "0.1.1"
|
||||
@@ -67,10 +73,10 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.7.6"
|
||||
name = "arbitrary"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
|
||||
checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223"
|
||||
|
||||
[[package]]
|
||||
name = "ascii"
|
||||
@@ -156,6 +162,9 @@ name = "bumpalo"
|
||||
version = "3.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
|
||||
dependencies = [
|
||||
"allocator-api2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
@@ -309,118 +318,145 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift"
|
||||
version = "0.88.2"
|
||||
version = "0.116.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea1b0c164043c16a8ece6813eef609ac2262a32a0bb0f5ed6eecf5d7bfb79ba8"
|
||||
checksum = "a71de5e59f616d79d14d2c71aa2799ce898241d7f10f7e64a4997014b4000a28"
|
||||
dependencies = [
|
||||
"cranelift-codegen",
|
||||
"cranelift-frontend",
|
||||
"cranelift-module",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-bforest"
|
||||
version = "0.88.2"
|
||||
version = "0.116.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52056f6d0584484b57fa6c1a65c1fcb15f3780d8b6a758426d9e3084169b2ddd"
|
||||
checksum = "e15d04a0ce86cb36ead88ad68cf693ffd6cda47052b9e0ac114bc47fd9cd23c4"
|
||||
dependencies = [
|
||||
"cranelift-entity",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-codegen"
|
||||
version = "0.88.2"
|
||||
name = "cranelift-bitset"
|
||||
version = "0.116.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18fed94c8770dc25d01154c3ffa64ed0b3ba9d583736f305fed7beebe5d9cf74"
|
||||
checksum = "7c6e3969a7ce267259ce244b7867c5d3bc9e65b0a87e81039588dfdeaede9f34"
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-codegen"
|
||||
version = "0.116.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c22032c4cb42558371cf516bb47f26cdad1819d3475c133e93c49f50ebf304e"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bumpalo",
|
||||
"cranelift-bforest",
|
||||
"cranelift-bitset",
|
||||
"cranelift-codegen-meta",
|
||||
"cranelift-codegen-shared",
|
||||
"cranelift-control",
|
||||
"cranelift-entity",
|
||||
"cranelift-isle",
|
||||
"gimli",
|
||||
"hashbrown 0.14.5",
|
||||
"log",
|
||||
"regalloc2",
|
||||
"rustc-hash 2.1.1",
|
||||
"serde",
|
||||
"smallvec",
|
||||
"target-lexicon",
|
||||
"target-lexicon 0.13.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-codegen-meta"
|
||||
version = "0.88.2"
|
||||
version = "0.116.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c451b81faf237d11c7e4f3165eeb6bac61112762c5cfe7b4c0fb7241474358f"
|
||||
checksum = "c904bc71c61b27fc57827f4a1379f29de64fe95653b620a3db77d59655eee0b8"
|
||||
dependencies = [
|
||||
"cranelift-codegen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-codegen-shared"
|
||||
version = "0.88.2"
|
||||
version = "0.116.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7c940133198426d26128f08be2b40b0bd117b84771fd36798969c4d712d81fc"
|
||||
checksum = "40180f5497572f644ce88c255480981ae2ec1d7bb4d8e0c0136a13b87a2f2ceb"
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-control"
|
||||
version = "0.116.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26d132c6d0bd8a489563472afc171759da0707804a65ece7ceb15a8c6d7dd5ef"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-entity"
|
||||
version = "0.88.2"
|
||||
version = "0.116.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87a0f1b2fdc18776956370cf8d9b009ded3f855350c480c1c52142510961f352"
|
||||
checksum = "4b2d0d9618275474fbf679dd018ac6e009acbd6ae6850f6a67be33fb3b00b323"
|
||||
dependencies = [
|
||||
"cranelift-bitset",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-frontend"
|
||||
version = "0.88.2"
|
||||
version = "0.116.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34897538b36b216cc8dd324e73263596d51b8cf610da6498322838b2546baf8a"
|
||||
checksum = "4fac41e16729107393174b0c9e3730fb072866100e1e64e80a1a963b2e484d57"
|
||||
dependencies = [
|
||||
"cranelift-codegen",
|
||||
"log",
|
||||
"smallvec",
|
||||
"target-lexicon",
|
||||
"target-lexicon 0.13.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-isle"
|
||||
version = "0.88.2"
|
||||
version = "0.116.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b2629a569fae540f16a76b70afcc87ad7decb38dc28fa6c648ac73b51e78470"
|
||||
checksum = "1ca20d576e5070044d0a72a9effc2deacf4d6aa650403189d8ea50126483944d"
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-jit"
|
||||
version = "0.88.2"
|
||||
version = "0.116.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "625be33ce54cf906c408f5ad9d08caa6e2a09e52d05fd0bd1bd95b132bfbba73"
|
||||
checksum = "5e65c42755a719b09662b00c700daaf76cc35d5ace1f5c002ad404b591ff1978"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cranelift-codegen",
|
||||
"cranelift-control",
|
||||
"cranelift-entity",
|
||||
"cranelift-module",
|
||||
"cranelift-native",
|
||||
"libc",
|
||||
"log",
|
||||
"region",
|
||||
"target-lexicon",
|
||||
"windows-sys 0.36.1",
|
||||
"target-lexicon 0.13.2",
|
||||
"wasmtime-jit-icache-coherence",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-module"
|
||||
version = "0.88.2"
|
||||
version = "0.116.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "883f8d42e07fd6b283941688f6c41a9e3b97fbf2b4ddcfb2756e675b86dc5edb"
|
||||
checksum = "4d55612bebcf16ff7306c8a6f5bdb6d45662b8aa1ee058ecce8807ad87db719b"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cranelift-codegen",
|
||||
"cranelift-control",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-native"
|
||||
version = "0.88.2"
|
||||
version = "0.116.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20937dab4e14d3e225c5adfc9c7106bafd4ac669bdb43027b911ff794c6fb318"
|
||||
checksum = "b8dee82f3f1f2c4cba9177f1cc5e350fe98764379bcd29340caa7b01f85076c7"
|
||||
dependencies = [
|
||||
"cranelift-codegen",
|
||||
"libc",
|
||||
"target-lexicon",
|
||||
"target-lexicon 0.13.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -658,6 +694,12 @@ version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193"
|
||||
|
||||
[[package]]
|
||||
name = "fallible-iterator"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
|
||||
|
||||
[[package]]
|
||||
name = "fd-lock"
|
||||
version = "4.0.2"
|
||||
@@ -737,15 +779,6 @@ version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
||||
|
||||
[[package]]
|
||||
name = "fxhash"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
@@ -802,6 +835,17 @@ dependencies = [
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.31.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||
dependencies = [
|
||||
"fallible-iterator",
|
||||
"indexmap",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.2"
|
||||
@@ -1186,10 +1230,10 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mach"
|
||||
version = "0.3.2"
|
||||
name = "mach2"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa"
|
||||
checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
@@ -1668,7 +1712,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"target-lexicon",
|
||||
"target-lexicon 0.12.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1840,13 +1884,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regalloc2"
|
||||
version = "0.3.2"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d43a209257d978ef079f3d446331d0f1794f5e0fc19b306a199983857833a779"
|
||||
checksum = "145c1c267e14f20fb0f88aa76a1c5ffec42d592c1d28b3cd9148ae35916158d3"
|
||||
dependencies = [
|
||||
"fxhash",
|
||||
"allocator-api2",
|
||||
"bumpalo",
|
||||
"hashbrown 0.15.2",
|
||||
"log",
|
||||
"slice-group-by",
|
||||
"rustc-hash 2.1.1",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
@@ -1881,14 +1927,14 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||
|
||||
[[package]]
|
||||
name = "region"
|
||||
version = "2.2.0"
|
||||
version = "3.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0"
|
||||
checksum = "e6b6ebd13bc009aef9cd476c1310d49ac354d36e240cf1bd753290f3dc7199a7"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"libc",
|
||||
"mach",
|
||||
"winapi",
|
||||
"mach2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1918,6 +1964,12 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.1"
|
||||
@@ -2128,7 +2180,7 @@ dependencies = [
|
||||
"num-traits",
|
||||
"phf",
|
||||
"phf_codegen",
|
||||
"rustc-hash",
|
||||
"rustc-hash 1.1.0",
|
||||
"rustpython-ast",
|
||||
"rustpython-parser-core",
|
||||
"tiny-keccak",
|
||||
@@ -2522,12 +2574,6 @@ version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
|
||||
|
||||
[[package]]
|
||||
name = "slice-group-by"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.14.0"
|
||||
@@ -2544,6 +2590,12 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stable_deref_trait"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
@@ -2635,6 +2687,12 @@ version = "0.12.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
||||
|
||||
[[package]]
|
||||
name = "target-lexicon"
|
||||
version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5a69a"
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.4.1"
|
||||
@@ -3118,6 +3176,18 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmtime-jit-icache-coherence"
|
||||
version = "29.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec5e8552e01692e6c2e5293171704fed8abdec79d1a6995a0870ab190e5747d1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.77"
|
||||
@@ -3196,19 +3266,6 @@ dependencies = [
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2"
|
||||
dependencies = [
|
||||
"windows_aarch64_msvc 0.36.1",
|
||||
"windows_i686_gnu 0.36.1",
|
||||
"windows_i686_msvc 0.36.1",
|
||||
"windows_x86_64_gnu 0.36.1",
|
||||
"windows_x86_64_msvc 0.36.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
@@ -3279,12 +3336,6 @@ version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.48.5"
|
||||
@@ -3297,12 +3348,6 @@ version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.48.5"
|
||||
@@ -3321,12 +3366,6 @@ version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.48.5"
|
||||
@@ -3339,12 +3378,6 @@ version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.48.5"
|
||||
@@ -3369,12 +3402,6 @@ version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.48.5"
|
||||
|
||||
@@ -16,9 +16,9 @@ rustpython-compiler-core = { workspace = true }
|
||||
num-traits = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
|
||||
cranelift = "0.88.0"
|
||||
cranelift-jit = "0.88.0"
|
||||
cranelift-module = "0.88.0"
|
||||
cranelift = "0.116.1"
|
||||
cranelift-jit = "0.116.1"
|
||||
cranelift-module = "0.116.1"
|
||||
|
||||
[dependencies.libffi]
|
||||
version = "3.1.0"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -114,7 +114,7 @@ pub fn compile<C: bytecode::Constant>(
|
||||
|
||||
let (id, sig) = jit.build_function(bytecode, args, ret)?;
|
||||
|
||||
jit.module.finalize_definitions();
|
||||
jit.module.finalize_definitions()?;
|
||||
|
||||
let code = jit.module.get_finalized_function(id);
|
||||
Ok(CompiledCode {
|
||||
|
||||
@@ -110,6 +110,117 @@ fn test_mul_with_integer() {
|
||||
assert_bits_eq!(mul(-0.0, -1), Ok(0.0f64));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_power() {
|
||||
let pow = jit_function! { pow(a:f64, b:f64) -> f64 => r##"
|
||||
def pow(a:float, b: float):
|
||||
return a**b
|
||||
"##};
|
||||
// Test base cases
|
||||
assert_approx_eq!(pow(0.0, 0.0), Ok(1.0));
|
||||
assert_approx_eq!(pow(0.0, 1.0), Ok(0.0));
|
||||
assert_approx_eq!(pow(1.0, 0.0), Ok(1.0));
|
||||
assert_approx_eq!(pow(1.0, 1.0), Ok(1.0));
|
||||
assert_approx_eq!(pow(1.0, -1.0), Ok(1.0));
|
||||
assert_approx_eq!(pow(-1.0, 0.0), Ok(1.0));
|
||||
assert_approx_eq!(pow(-1.0, 1.0), Ok(-1.0));
|
||||
assert_approx_eq!(pow(-1.0, -1.0), Ok(-1.0));
|
||||
|
||||
// NaN and Infinity cases
|
||||
assert_approx_eq!(pow(f64::NAN, 0.0), Ok(1.0));
|
||||
//assert_approx_eq!(pow(f64::NAN, 1.0), Ok(f64::NAN)); // Return the correct answer but fails compare
|
||||
//assert_approx_eq!(pow(0.0, f64::NAN), Ok(f64::NAN)); // Return the correct answer but fails compare
|
||||
assert_approx_eq!(pow(f64::INFINITY, 0.0), Ok(1.0));
|
||||
assert_approx_eq!(pow(f64::INFINITY, 1.0), Ok(f64::INFINITY));
|
||||
assert_approx_eq!(pow(f64::INFINITY, f64::INFINITY), Ok(f64::INFINITY));
|
||||
// Negative infinity cases:
|
||||
// For any exponent of 0.0, the result is 1.0.
|
||||
assert_approx_eq!(pow(f64::NEG_INFINITY, 0.0), Ok(1.0));
|
||||
// For negative infinity base, when b is an odd integer, result is -infinity;
|
||||
// when b is even, result is +infinity.
|
||||
assert_approx_eq!(pow(f64::NEG_INFINITY, 1.0), Ok(f64::NEG_INFINITY));
|
||||
assert_approx_eq!(pow(f64::NEG_INFINITY, 2.0), Ok(f64::INFINITY));
|
||||
assert_approx_eq!(pow(f64::NEG_INFINITY, 3.0), Ok(f64::NEG_INFINITY));
|
||||
// Exponent -infinity gives 0.0.
|
||||
assert_approx_eq!(pow(f64::NEG_INFINITY, f64::NEG_INFINITY), Ok(0.0));
|
||||
|
||||
// Test positive float base, positive float exponent
|
||||
assert_approx_eq!(pow(2.0, 2.0), Ok(4.0));
|
||||
assert_approx_eq!(pow(3.0, 3.0), Ok(27.0));
|
||||
assert_approx_eq!(pow(4.0, 4.0), Ok(256.0));
|
||||
assert_approx_eq!(pow(2.0, 3.0), Ok(8.0));
|
||||
assert_approx_eq!(pow(2.0, 4.0), Ok(16.0));
|
||||
// Test negative float base, positive float exponent (integral exponents only)
|
||||
assert_approx_eq!(pow(-2.0, 2.0), Ok(4.0));
|
||||
assert_approx_eq!(pow(-3.0, 3.0), Ok(-27.0));
|
||||
assert_approx_eq!(pow(-4.0, 4.0), Ok(256.0));
|
||||
assert_approx_eq!(pow(-2.0, 3.0), Ok(-8.0));
|
||||
assert_approx_eq!(pow(-2.0, 4.0), Ok(16.0));
|
||||
// Test positive float base, positive float exponent
|
||||
assert_approx_eq!(pow(2.5, 2.0), Ok(6.25));
|
||||
assert_approx_eq!(pow(3.5, 3.0), Ok(42.875));
|
||||
assert_approx_eq!(pow(4.5, 4.0), Ok(410.0625));
|
||||
assert_approx_eq!(pow(2.5, 3.0), Ok(15.625));
|
||||
assert_approx_eq!(pow(2.5, 4.0), Ok(39.0625));
|
||||
// Test negative float base, positive float exponent (integral exponents only)
|
||||
assert_approx_eq!(pow(-2.5, 2.0), Ok(6.25));
|
||||
assert_approx_eq!(pow(-3.5, 3.0), Ok(-42.875));
|
||||
assert_approx_eq!(pow(-4.5, 4.0), Ok(410.0625));
|
||||
assert_approx_eq!(pow(-2.5, 3.0), Ok(-15.625));
|
||||
assert_approx_eq!(pow(-2.5, 4.0), Ok(39.0625));
|
||||
// Test positive float base, positive float exponent with nonintegral exponents
|
||||
assert_approx_eq!(pow(2.0, 2.5), Ok(5.656854249492381));
|
||||
assert_approx_eq!(pow(3.0, 3.5), Ok(46.76537180435969));
|
||||
assert_approx_eq!(pow(4.0, 4.5), Ok(512.0));
|
||||
assert_approx_eq!(pow(2.0, 3.5), Ok(11.313708498984761));
|
||||
assert_approx_eq!(pow(2.0, 4.5), Ok(22.627416997969522));
|
||||
// Test positive float base, negative float exponent
|
||||
assert_approx_eq!(pow(2.0, -2.5), Ok(0.1767766952966369));
|
||||
assert_approx_eq!(pow(3.0, -3.5), Ok(0.021383343303319473));
|
||||
assert_approx_eq!(pow(4.0, -4.5), Ok(0.001953125));
|
||||
assert_approx_eq!(pow(2.0, -3.5), Ok(0.08838834764831845));
|
||||
assert_approx_eq!(pow(2.0, -4.5), Ok(0.04419417382415922));
|
||||
// Test negative float base, negative float exponent (integral exponents only)
|
||||
assert_approx_eq!(pow(-2.0, -2.0), Ok(0.25));
|
||||
assert_approx_eq!(pow(-3.0, -3.0), Ok(-0.037037037037037035));
|
||||
assert_approx_eq!(pow(-4.0, -4.0), Ok(0.00390625));
|
||||
assert_approx_eq!(pow(-2.0, -3.0), Ok(-0.125));
|
||||
assert_approx_eq!(pow(-2.0, -4.0), Ok(0.0625));
|
||||
|
||||
// Currently negative float base with nonintegral exponent is not supported:
|
||||
// assert_approx_eq!(pow(-2.0, 2.5), Ok(5.656854249492381));
|
||||
// assert_approx_eq!(pow(-3.0, 3.5), Ok(-46.76537180435969));
|
||||
// assert_approx_eq!(pow(-4.0, 4.5), Ok(512.0));
|
||||
// assert_approx_eq!(pow(-2.0, -2.5), Ok(0.1767766952966369));
|
||||
// assert_approx_eq!(pow(-3.0, -3.5), Ok(0.021383343303319473));
|
||||
// assert_approx_eq!(pow(-4.0, -4.5), Ok(0.001953125));
|
||||
|
||||
// Extra cases **NOTE** these are not all working:
|
||||
// * If they are commented in then they work
|
||||
// * If they are commented out with a number that is the current return value it throws vs the expected value
|
||||
// * If they are commented out with a "fail to run" that means I couldn't get them to work, could add a case for really big or small values
|
||||
// 1e308^2.0
|
||||
assert_approx_eq!(pow(1e308, 2.0), Ok(f64::INFINITY));
|
||||
// 1e308^(1e-2)
|
||||
assert_approx_eq!(pow(1e308, 1e-2), Ok(1202.2644346174131));
|
||||
// 1e-308^2.0
|
||||
//assert_approx_eq!(pow(1e-308, 2.0), Ok(0.0)); // --8.403311421507407
|
||||
// 1e-308^-2.0
|
||||
assert_approx_eq!(pow(1e-308, -2.0), Ok(f64::INFINITY));
|
||||
// 1e100^(1e50)
|
||||
//assert_approx_eq!(pow(1e100, 1e50), Ok(1.0000000000000002e+150)); // fail to run (Crashes as "illegal hardware instruction")
|
||||
// 1e50^(1e-100)
|
||||
assert_approx_eq!(pow(1e50, 1e-100), Ok(1.0));
|
||||
// 1e308^(-1e2)
|
||||
//assert_approx_eq!(pow(1e308, -1e2), Ok(0.0)); // 2.961801792837933e25
|
||||
// 1e-308^(1e2)
|
||||
//assert_approx_eq!(pow(1e-308, 1e2), Ok(f64::INFINITY)); // 1.6692559244043896e46
|
||||
// 1e308^(-1e308)
|
||||
// assert_approx_eq!(pow(1e308, -1e308), Ok(0.0)); // fail to run (Crashes as "illegal hardware instruction")
|
||||
// 1e-308^(1e308)
|
||||
// assert_approx_eq!(pow(1e-308, 1e308), Ok(0.0)); // fail to run (Crashes as "illegal hardware instruction")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_div() {
|
||||
let div = jit_function! { div(a:f64, b:f64) -> f64 => r##"
|
||||
|
||||
@@ -45,7 +45,6 @@ fn test_mul() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
fn test_div() {
|
||||
let div = jit_function! { div(a:i64, b:i64) -> f64 => r##"
|
||||
def div(a: int, b: int):
|
||||
@@ -87,23 +86,23 @@ fn test_floor_div() {
|
||||
#[test]
|
||||
|
||||
fn test_exp() {
|
||||
let exp = jit_function! { exp(a: i64, b: i64) -> f64 => r##"
|
||||
let exp = jit_function! { exp(a: i64, b: i64) -> i64 => r##"
|
||||
def exp(a: int, b: int):
|
||||
return a ** b
|
||||
"## };
|
||||
|
||||
assert_eq!(exp(2, 3), Ok(8.0));
|
||||
assert_eq!(exp(3, 2), Ok(9.0));
|
||||
assert_eq!(exp(5, 0), Ok(1.0));
|
||||
assert_eq!(exp(0, 0), Ok(1.0));
|
||||
assert_eq!(exp(-5, 0), Ok(1.0));
|
||||
assert_eq!(exp(0, 1), Ok(0.0));
|
||||
assert_eq!(exp(0, 5), Ok(0.0));
|
||||
assert_eq!(exp(-2, 2), Ok(4.0));
|
||||
assert_eq!(exp(-3, 4), Ok(81.0));
|
||||
assert_eq!(exp(-2, 3), Ok(-8.0));
|
||||
assert_eq!(exp(-3, 3), Ok(-27.0));
|
||||
assert_eq!(exp(1000, 2), Ok(1000000.0));
|
||||
assert_eq!(exp(2, 3), Ok(8));
|
||||
assert_eq!(exp(3, 2), Ok(9));
|
||||
assert_eq!(exp(5, 0), Ok(1));
|
||||
assert_eq!(exp(0, 0), Ok(1));
|
||||
assert_eq!(exp(-5, 0), Ok(1));
|
||||
assert_eq!(exp(0, 1), Ok(0));
|
||||
assert_eq!(exp(0, 5), Ok(0));
|
||||
assert_eq!(exp(-2, 2), Ok(4));
|
||||
assert_eq!(exp(-3, 4), Ok(81));
|
||||
assert_eq!(exp(-2, 3), Ok(-8));
|
||||
assert_eq!(exp(-3, 3), Ok(-27));
|
||||
assert_eq!(exp(1000, 2), Ok(1000000));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -121,6 +120,18 @@ fn test_mod() {
|
||||
assert_eq!(modulo(-5, 10), Ok(-5));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_power() {
|
||||
let power = jit_function! { power(a:i64, b:i64) -> i64 => r##"
|
||||
def power(a: int, b: int):
|
||||
return a ** b
|
||||
"##
|
||||
};
|
||||
assert_eq!(power(10, 2), Ok(100));
|
||||
assert_eq!(power(5, 1), Ok(5));
|
||||
assert_eq!(power(1, 0), Ok(1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lshift() {
|
||||
let lshift = jit_function! { lshift(a:i64, b:i64) -> i64 => r##"
|
||||
|
||||
@@ -95,7 +95,6 @@ fn test_while_loop() {
|
||||
a -= 1
|
||||
return b
|
||||
"## };
|
||||
|
||||
assert_eq!(while_loop(0), Ok(0));
|
||||
assert_eq!(while_loop(-1), Ok(0));
|
||||
assert_eq!(while_loop(1), Ok(1));
|
||||
|
||||
Reference in New Issue
Block a user