mirror of
https://github.com/denoland/deno.git
synced 2024-11-30 16:40:57 -05:00
Upgrade to rusty_v8 0.4.2 / V8 8.5.216 (#6503)
This commit is contained in:
parent
0c735ebdc7
commit
e10d74a3d3
8 changed files with 378 additions and 572 deletions
201
Cargo.lock
generated
201
Cargo.lock
generated
|
@ -27,9 +27,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
version = "0.7.10"
|
version = "0.7.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada"
|
checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
@ -55,7 +55,7 @@ version = "0.11.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -81,7 +81,7 @@ dependencies = [
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
"swc_macros_common",
|
"swc_macros_common",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -106,7 +106,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hermit-abi",
|
"hermit-abi",
|
||||||
"libc",
|
"libc",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -138,9 +138,9 @@ checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.12.2"
|
version = "0.12.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e223af0dc48c96d4f8342ec01a4974f139df863896b316681efd36742f22cc67"
|
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
|
@ -245,9 +245,9 @@ checksum = "5ba7d7f7b201dfcbc314b14f2176c92f8ba521dab538b40e426ffed25ed7cd80"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.54"
|
version = "1.0.55"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311"
|
checksum = "b1be3409f94d7bdceeb5f5fac551039d9b3f00e25da7a74fc4d33400a0d96368"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
|
@ -255,16 +255,6 @@ version = "0.1.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "chashmap"
|
|
||||||
version = "2.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ff41a3c2c1e39921b9003de14bf0439c7b63a9039637c291e1a64925d8ddfa45"
|
|
||||||
dependencies = [
|
|
||||||
"owning_ref 0.3.3",
|
|
||||||
"parking_lot 0.4.8",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "2.33.1"
|
version = "2.33.1"
|
||||||
|
@ -360,7 +350,7 @@ dependencies = [
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
"strsim 0.9.3",
|
"strsim 0.9.3",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -371,7 +361,7 @@ checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling_core",
|
"darling_core",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -390,7 +380,7 @@ name = "deno"
|
||||||
version = "1.1.1"
|
version = "1.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"base64 0.12.2",
|
"base64 0.12.3",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"bytes 0.5.5",
|
"bytes 0.5.5",
|
||||||
"clap",
|
"clap",
|
||||||
|
@ -436,7 +426,7 @@ dependencies = [
|
||||||
"warp",
|
"warp",
|
||||||
"webpki",
|
"webpki",
|
||||||
"webpki-roots",
|
"webpki-roots",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -514,7 +504,7 @@ dependencies = [
|
||||||
"dlopen_derive",
|
"dlopen_derive",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -587,7 +577,7 @@ dependencies = [
|
||||||
"pmutil",
|
"pmutil",
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"swc_macros_common",
|
"swc_macros_common",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -616,7 +606,7 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
"redox_syscall",
|
"redox_syscall",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -646,7 +636,7 @@ dependencies = [
|
||||||
"pmutil",
|
"pmutil",
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"swc_macros_common",
|
"swc_macros_common",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -754,7 +744,7 @@ dependencies = [
|
||||||
"proc-macro-hack",
|
"proc-macro-hack",
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -823,7 +813,7 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"log 0.4.8",
|
"log 0.4.8",
|
||||||
"rustc_version",
|
"rustc_version",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -871,7 +861,7 @@ version = "0.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed18eb2459bf1a09ad2d6b1547840c3e5e62882fa09b9a6a20b1de8e3228848f"
|
checksum = "ed18eb2459bf1a09ad2d6b1547840c3e5e62882fa09b9a6a20b1de8e3228848f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.12.2",
|
"base64 0.12.3",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"bytes 0.5.5",
|
"bytes 0.5.5",
|
||||||
"headers-core",
|
"headers-core",
|
||||||
|
@ -1104,7 +1094,7 @@ version = "0.1.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"
|
checksum = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"owning_ref 0.4.1",
|
"owning_ref",
|
||||||
"scopeguard 0.3.3",
|
"scopeguard 0.3.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1241,7 +1231,7 @@ dependencies = [
|
||||||
"log 0.4.8",
|
"log 0.4.8",
|
||||||
"mio",
|
"mio",
|
||||||
"miow 0.3.5",
|
"miow 0.3.5",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1274,7 +1264,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e"
|
checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"socket2",
|
"socket2",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1303,7 +1293,7 @@ checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1327,13 +1317,12 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "notify"
|
name = "notify"
|
||||||
version = "5.0.0-pre.2"
|
version = "5.0.0-pre.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7b00c0b65188bffb5598c302e19b062feb94adef02c31f15622a163c95d673c3"
|
checksum = "77d03607cf88b4b160ba0e9ed425fff3cee3b55ac813f0c685b3a3772da37d0e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anymap",
|
"anymap",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"chashmap",
|
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
"filetime",
|
"filetime",
|
||||||
"fsevent",
|
"fsevent",
|
||||||
|
@ -1343,7 +1332,7 @@ dependencies = [
|
||||||
"mio",
|
"mio",
|
||||||
"mio-extras",
|
"mio-extras",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1406,16 +1395,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fb233f06c2307e1f5ce2ecad9f8121cffbbee2c95428f44ea85222e460d0d213"
|
checksum = "fb233f06c2307e1f5ce2ecad9f8121cffbbee2c95428f44ea85222e460d0d213"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "owning_ref"
|
|
||||||
version = "0.3.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
|
|
||||||
dependencies = [
|
|
||||||
"stable_deref_trait",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1427,16 +1407,6 @@ dependencies = [
|
||||||
"stable_deref_trait",
|
"stable_deref_trait",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "parking_lot"
|
|
||||||
version = "0.4.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "149d8f5b97f3c1133e3cfcd8886449959e856b557ff281e292b733d7c69e005e"
|
|
||||||
dependencies = [
|
|
||||||
"owning_ref 0.3.3",
|
|
||||||
"parking_lot_core 0.2.14",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parking_lot"
|
name = "parking_lot"
|
||||||
version = "0.7.1"
|
version = "0.7.1"
|
||||||
|
@ -1444,19 +1414,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337"
|
checksum = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lock_api",
|
"lock_api",
|
||||||
"parking_lot_core 0.4.0",
|
"parking_lot_core",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "parking_lot_core"
|
|
||||||
version = "0.2.14"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"rand 0.4.6",
|
|
||||||
"smallvec 0.6.13",
|
|
||||||
"winapi 0.3.8",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1469,7 +1427,7 @@ dependencies = [
|
||||||
"rand 0.6.5",
|
"rand 0.6.5",
|
||||||
"rustc_version",
|
"rustc_version",
|
||||||
"smallvec 0.6.13",
|
"smallvec 0.6.13",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1559,7 +1517,7 @@ checksum = "6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1582,7 +1540,7 @@ checksum = "3894e5d549cccbe44afecf72922f277f603cd4bb0219c8342631ef18fffbe004"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1624,7 +1582,7 @@ version = "1.0.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa"
|
checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-xid 0.2.0",
|
"unicode-xid 0.2.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1661,19 +1619,6 @@ dependencies = [
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand"
|
|
||||||
version = "0.4.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
|
|
||||||
dependencies = [
|
|
||||||
"fuchsia-cprng",
|
|
||||||
"libc",
|
|
||||||
"rand_core 0.3.1",
|
|
||||||
"rdrand",
|
|
||||||
"winapi 0.3.8",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand"
|
name = "rand"
|
||||||
version = "0.6.5"
|
version = "0.6.5"
|
||||||
|
@ -1690,7 +1635,7 @@ dependencies = [
|
||||||
"rand_os",
|
"rand_os",
|
||||||
"rand_pcg 0.1.2",
|
"rand_pcg 0.1.2",
|
||||||
"rand_xorshift",
|
"rand_xorshift",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1786,7 +1731,7 @@ checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"rand_core 0.4.2",
|
"rand_core 0.4.2",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1800,7 +1745,7 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"rand_core 0.4.2",
|
"rand_core 0.4.2",
|
||||||
"rdrand",
|
"rdrand",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1870,7 +1815,7 @@ version = "0.5.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
|
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1880,7 +1825,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3b82c9238b305f26f53443e3a4bc8528d64b8d0bee408ec949eb7bf5635ec680"
|
checksum = "3b82c9238b305f26f53443e3a4bc8528d64b8d0bee408ec949eb7bf5635ec680"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-compression",
|
"async-compression",
|
||||||
"base64 0.12.2",
|
"base64 0.12.3",
|
||||||
"bytes 0.5.5",
|
"bytes 0.5.5",
|
||||||
"encoding_rs",
|
"encoding_rs",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
|
@ -1921,7 +1866,7 @@ dependencies = [
|
||||||
"spin",
|
"spin",
|
||||||
"untrusted",
|
"untrusted",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1948,9 +1893,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rusty_v8"
|
name = "rusty_v8"
|
||||||
version = "0.5.1"
|
version = "0.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "acb51793f34f267b197a6688c986ddcd7a60c94894d77702f1b4a3febf6e1eda"
|
checksum = "da4dd2d680bf9812b3156b44f89fdd7b508c1369fbc69a14150972c6919c84d1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cargo_gn",
|
"cargo_gn",
|
||||||
|
@ -1974,7 +1919,7 @@ dependencies = [
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
"utf8parse",
|
"utf8parse",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2055,22 +2000,22 @@ checksum = "b46e1121e8180c12ff69a742aabc4f310542b6ccb69f1691689ac17fdf8618aa"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.112"
|
version = "1.0.114"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "736aac72d1eafe8e5962d1d1c3d99b0df526015ba40915cb3c49d042e92ec243"
|
checksum = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.112"
|
version = "1.0.114"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bf0343ce212ac0d3d6afd9391ac8e9c9efe06b533c8d33f660f6390cc4093f57"
|
checksum = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2161,7 +2106,7 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
"redox_syscall",
|
"redox_syscall",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2227,7 +2172,7 @@ dependencies = [
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
"swc_macros_common",
|
"swc_macros_common",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2266,7 +2211,7 @@ dependencies = [
|
||||||
"from_variant",
|
"from_variant",
|
||||||
"fxhash",
|
"fxhash",
|
||||||
"log 0.4.8",
|
"log 0.4.8",
|
||||||
"parking_lot 0.7.1",
|
"parking_lot",
|
||||||
"scoped-tls 1.0.0",
|
"scoped-tls 1.0.0",
|
||||||
"serde",
|
"serde",
|
||||||
"sourcemap",
|
"sourcemap",
|
||||||
|
@ -2307,7 +2252,7 @@ dependencies = [
|
||||||
"swc_common",
|
"swc_common",
|
||||||
"swc_ecma_ast",
|
"swc_ecma_ast",
|
||||||
"swc_ecma_parser_macros",
|
"swc_ecma_parser_macros",
|
||||||
"unicode-xid 0.2.0",
|
"unicode-xid 0.2.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2320,7 +2265,7 @@ dependencies = [
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
"swc_macros_common",
|
"swc_macros_common",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2347,7 +2292,7 @@ dependencies = [
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
"swc_macros_common",
|
"swc_macros_common",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2359,7 +2304,7 @@ dependencies = [
|
||||||
"pmutil",
|
"pmutil",
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2375,13 +2320,13 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.31"
|
version = "1.0.33"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b5304cfdf27365b7585c25d4af91b35016ed21ef88f17ced89c7093b43dba8b6"
|
checksum = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
"unicode-xid 0.2.0",
|
"unicode-xid 0.2.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2405,7 +2350,7 @@ dependencies = [
|
||||||
"rand 0.7.3",
|
"rand 0.7.3",
|
||||||
"redox_syscall",
|
"redox_syscall",
|
||||||
"remove_dir_all",
|
"remove_dir_all",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2462,7 +2407,7 @@ checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2481,7 +2426,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
|
checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2511,7 +2456,7 @@ dependencies = [
|
||||||
"signal-hook-registry",
|
"signal-hook-registry",
|
||||||
"slab",
|
"slab",
|
||||||
"tokio-macros",
|
"tokio-macros",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2533,7 +2478,7 @@ checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2677,9 +2622,9 @@ checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "untrusted"
|
name = "untrusted"
|
||||||
|
@ -2778,7 +2723,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"
|
checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"same-file",
|
"same-file",
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
"winapi-util",
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -2847,7 +2792,7 @@ dependencies = [
|
||||||
"log 0.4.8",
|
"log 0.4.8",
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -2881,7 +2826,7 @@ checksum = "3156052d8ec77142051a533cdd686cba889537b213f948cd1d20869926e68e92"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.18",
|
"proc-macro2 1.0.18",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
"syn 1.0.31",
|
"syn 1.0.33",
|
||||||
"wasm-bindgen-backend",
|
"wasm-bindgen-backend",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
@ -2923,9 +2868,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "which"
|
name = "which"
|
||||||
version = "4.0.0"
|
version = "4.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bd3edc3cf5458851a4d6a2329232bd5f42c7f9bbe4c4782c4ef9ce37e5d101b2"
|
checksum = "b5fe1a9cb33fe7cf77d431070d0223e544b1e4e7f7764bad0a3e691a6678a131"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
@ -2939,9 +2884,9 @@ checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.8"
|
version = "0.3.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
|
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winapi-i686-pc-windows-gnu",
|
"winapi-i686-pc-windows-gnu",
|
||||||
"winapi-x86_64-pc-windows-gnu",
|
"winapi-x86_64-pc-windows-gnu",
|
||||||
|
@ -2965,7 +2910,7 @@ version = "0.1.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2980,7 +2925,7 @@ version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69"
|
checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winapi 0.3.8",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -378,8 +378,7 @@ impl DenoInspector {
|
||||||
let core_state_rc = deno_core::CoreIsolate::state(isolate);
|
let core_state_rc = deno_core::CoreIsolate::state(isolate);
|
||||||
let core_state = core_state_rc.borrow();
|
let core_state = core_state_rc.borrow();
|
||||||
|
|
||||||
let mut hs = v8::HandleScope::new(isolate);
|
let scope = &mut v8::HandleScope::new(&mut **isolate);
|
||||||
let scope = hs.enter();
|
|
||||||
|
|
||||||
let (new_websocket_tx, new_websocket_rx) =
|
let (new_websocket_tx, new_websocket_rx) =
|
||||||
mpsc::unbounded::<WebSocketProxy>();
|
mpsc::unbounded::<WebSocketProxy>();
|
||||||
|
@ -402,7 +401,7 @@ impl DenoInspector {
|
||||||
|
|
||||||
let sessions = InspectorSessions::new(self_ptr, new_websocket_rx);
|
let sessions = InspectorSessions::new(self_ptr, new_websocket_rx);
|
||||||
let flags = InspectorFlags::new();
|
let flags = InspectorFlags::new();
|
||||||
let waker = InspectorWaker::new(scope.isolate().thread_safe_handle());
|
let waker = InspectorWaker::new(scope.thread_safe_handle());
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
v8_inspector_client,
|
v8_inspector_client,
|
||||||
|
|
|
@ -19,7 +19,7 @@ futures = { version = "0.3.5", features = ["thread-pool", "compat"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
libc = "0.2.71"
|
libc = "0.2.71"
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
rusty_v8 = "0.5.1"
|
rusty_v8 = "0.6.0"
|
||||||
serde_json = "1.0.55"
|
serde_json = "1.0.55"
|
||||||
url = "2.1.1"
|
url = "2.1.1"
|
||||||
|
|
||||||
|
|
452
core/bindings.rs
452
core/bindings.rs
|
@ -53,7 +53,7 @@ lazy_static! {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn script_origin<'a>(
|
pub fn script_origin<'a>(
|
||||||
s: &mut impl v8::ToLocal<'a>,
|
s: &mut v8::HandleScope<'a>,
|
||||||
resource_name: v8::Local<'a, v8::String>,
|
resource_name: v8::Local<'a, v8::String>,
|
||||||
) -> v8::ScriptOrigin<'a> {
|
) -> v8::ScriptOrigin<'a> {
|
||||||
let resource_line_offset = v8::Integer::new(s, 0);
|
let resource_line_offset = v8::Integer::new(s, 0);
|
||||||
|
@ -78,7 +78,7 @@ pub fn script_origin<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn module_origin<'a>(
|
pub fn module_origin<'a>(
|
||||||
s: &mut impl v8::ToLocal<'a>,
|
s: &mut v8::HandleScope<'a>,
|
||||||
resource_name: v8::Local<'a, v8::String>,
|
resource_name: v8::Local<'a, v8::String>,
|
||||||
) -> v8::ScriptOrigin<'a> {
|
) -> v8::ScriptOrigin<'a> {
|
||||||
let resource_line_offset = v8::Integer::new(s, 0);
|
let resource_line_offset = v8::Integer::new(s, 0);
|
||||||
|
@ -103,127 +103,92 @@ pub fn module_origin<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn initialize_context<'s>(
|
pub fn initialize_context<'s>(
|
||||||
scope: &mut impl v8::ToLocal<'s>,
|
scope: &mut v8::HandleScope<'s, ()>,
|
||||||
) -> v8::Local<'s, v8::Context> {
|
) -> v8::Local<'s, v8::Context> {
|
||||||
let mut hs = v8::EscapableHandleScope::new(scope);
|
let scope = &mut v8::EscapableHandleScope::new(scope);
|
||||||
let scope = hs.enter();
|
|
||||||
|
|
||||||
let context = v8::Context::new(scope);
|
let context = v8::Context::new(scope);
|
||||||
let global = context.global(scope);
|
let global = context.global(scope);
|
||||||
|
|
||||||
let mut cs = v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
let scope = cs.enter();
|
|
||||||
|
|
||||||
|
let deno_key = v8::String::new(scope, "Deno").unwrap();
|
||||||
let deno_val = v8::Object::new(scope);
|
let deno_val = v8::Object::new(scope);
|
||||||
global.set(
|
global.set(scope, deno_key.into(), deno_val.into());
|
||||||
context,
|
|
||||||
v8::String::new(scope, "Deno").unwrap().into(),
|
|
||||||
deno_val.into(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut core_val = v8::Object::new(scope);
|
let core_key = v8::String::new(scope, "core").unwrap();
|
||||||
deno_val.set(
|
let core_val = v8::Object::new(scope);
|
||||||
context,
|
deno_val.set(scope, core_key.into(), core_val.into());
|
||||||
v8::String::new(scope, "core").unwrap().into(),
|
|
||||||
core_val.into(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut print_tmpl = v8::FunctionTemplate::new(scope, print);
|
let print_key = v8::String::new(scope, "print").unwrap();
|
||||||
let print_val = print_tmpl.get_function(scope, context).unwrap();
|
let print_tmpl = v8::FunctionTemplate::new(scope, print);
|
||||||
core_val.set(
|
let print_val = print_tmpl.get_function(scope).unwrap();
|
||||||
context,
|
core_val.set(scope, print_key.into(), print_val.into());
|
||||||
v8::String::new(scope, "print").unwrap().into(),
|
|
||||||
print_val.into(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut recv_tmpl = v8::FunctionTemplate::new(scope, recv);
|
let recv_key = v8::String::new(scope, "recv").unwrap();
|
||||||
let recv_val = recv_tmpl.get_function(scope, context).unwrap();
|
let recv_tmpl = v8::FunctionTemplate::new(scope, recv);
|
||||||
core_val.set(
|
let recv_val = recv_tmpl.get_function(scope).unwrap();
|
||||||
context,
|
core_val.set(scope, recv_key.into(), recv_val.into());
|
||||||
v8::String::new(scope, "recv").unwrap().into(),
|
|
||||||
recv_val.into(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut send_tmpl = v8::FunctionTemplate::new(scope, send);
|
let send_key = v8::String::new(scope, "send").unwrap();
|
||||||
let send_val = send_tmpl.get_function(scope, context).unwrap();
|
let send_tmpl = v8::FunctionTemplate::new(scope, send);
|
||||||
core_val.set(
|
let send_val = send_tmpl.get_function(scope).unwrap();
|
||||||
context,
|
core_val.set(scope, send_key.into(), send_val.into());
|
||||||
v8::String::new(scope, "send").unwrap().into(),
|
|
||||||
send_val.into(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut set_macrotask_callback_tmpl =
|
let set_macrotask_callback_key =
|
||||||
|
v8::String::new(scope, "setMacrotaskCallback").unwrap();
|
||||||
|
let set_macrotask_callback_tmpl =
|
||||||
v8::FunctionTemplate::new(scope, set_macrotask_callback);
|
v8::FunctionTemplate::new(scope, set_macrotask_callback);
|
||||||
let set_macrotask_callback_val = set_macrotask_callback_tmpl
|
let set_macrotask_callback_val =
|
||||||
.get_function(scope, context)
|
set_macrotask_callback_tmpl.get_function(scope).unwrap();
|
||||||
.unwrap();
|
|
||||||
core_val.set(
|
core_val.set(
|
||||||
context,
|
scope,
|
||||||
v8::String::new(scope, "setMacrotaskCallback")
|
set_macrotask_callback_key.into(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
set_macrotask_callback_val.into(),
|
set_macrotask_callback_val.into(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut eval_context_tmpl = v8::FunctionTemplate::new(scope, eval_context);
|
let eval_context_key = v8::String::new(scope, "evalContext").unwrap();
|
||||||
let eval_context_val =
|
let eval_context_tmpl = v8::FunctionTemplate::new(scope, eval_context);
|
||||||
eval_context_tmpl.get_function(scope, context).unwrap();
|
let eval_context_val = eval_context_tmpl.get_function(scope).unwrap();
|
||||||
core_val.set(
|
core_val.set(scope, eval_context_key.into(), eval_context_val.into());
|
||||||
context,
|
|
||||||
v8::String::new(scope, "evalContext").unwrap().into(),
|
|
||||||
eval_context_val.into(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut format_error_tmpl = v8::FunctionTemplate::new(scope, format_error);
|
let format_error_key = v8::String::new(scope, "formatError").unwrap();
|
||||||
let format_error_val =
|
let format_error_tmpl = v8::FunctionTemplate::new(scope, format_error);
|
||||||
format_error_tmpl.get_function(scope, context).unwrap();
|
let format_error_val = format_error_tmpl.get_function(scope).unwrap();
|
||||||
core_val.set(
|
core_val.set(scope, format_error_key.into(), format_error_val.into());
|
||||||
context,
|
|
||||||
v8::String::new(scope, "formatError").unwrap().into(),
|
|
||||||
format_error_val.into(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut encode_tmpl = v8::FunctionTemplate::new(scope, encode);
|
let encode_key = v8::String::new(scope, "encode").unwrap();
|
||||||
let encode_val = encode_tmpl.get_function(scope, context).unwrap();
|
let encode_tmpl = v8::FunctionTemplate::new(scope, encode);
|
||||||
core_val.set(
|
let encode_val = encode_tmpl.get_function(scope).unwrap();
|
||||||
context,
|
core_val.set(scope, encode_key.into(), encode_val.into());
|
||||||
v8::String::new(scope, "encode").unwrap().into(),
|
|
||||||
encode_val.into(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut decode_tmpl = v8::FunctionTemplate::new(scope, decode);
|
let decode_key = v8::String::new(scope, "decode").unwrap();
|
||||||
let decode_val = decode_tmpl.get_function(scope, context).unwrap();
|
let decode_tmpl = v8::FunctionTemplate::new(scope, decode);
|
||||||
core_val.set(
|
let decode_val = decode_tmpl.get_function(scope).unwrap();
|
||||||
context,
|
core_val.set(scope, decode_key.into(), decode_val.into());
|
||||||
v8::String::new(scope, "decode").unwrap().into(),
|
|
||||||
decode_val.into(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut get_promise_details_tmpl =
|
let get_promise_details_key =
|
||||||
|
v8::String::new(scope, "getPromiseDetails").unwrap();
|
||||||
|
let get_promise_details_tmpl =
|
||||||
v8::FunctionTemplate::new(scope, get_promise_details);
|
v8::FunctionTemplate::new(scope, get_promise_details);
|
||||||
let get_promise_details_val = get_promise_details_tmpl
|
let get_promise_details_val =
|
||||||
.get_function(scope, context)
|
get_promise_details_tmpl.get_function(scope).unwrap();
|
||||||
.unwrap();
|
|
||||||
core_val.set(
|
core_val.set(
|
||||||
context,
|
scope,
|
||||||
v8::String::new(scope, "getPromiseDetails").unwrap().into(),
|
get_promise_details_key.into(),
|
||||||
get_promise_details_val.into(),
|
get_promise_details_val.into(),
|
||||||
);
|
);
|
||||||
|
|
||||||
core_val.set_accessor(
|
let shared_key = v8::String::new(scope, "shared").unwrap();
|
||||||
context,
|
core_val.set_accessor(scope, shared_key.into(), shared_getter);
|
||||||
v8::String::new(scope, "shared").unwrap().into(),
|
|
||||||
shared_getter,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Direct bindings on `window`.
|
// Direct bindings on `window`.
|
||||||
let mut queue_microtask_tmpl =
|
let queue_microtask_key = v8::String::new(scope, "queueMicrotask").unwrap();
|
||||||
v8::FunctionTemplate::new(scope, queue_microtask);
|
let queue_microtask_tmpl = v8::FunctionTemplate::new(scope, queue_microtask);
|
||||||
let queue_microtask_val =
|
let queue_microtask_val = queue_microtask_tmpl.get_function(scope).unwrap();
|
||||||
queue_microtask_tmpl.get_function(scope, context).unwrap();
|
|
||||||
global.set(
|
global.set(
|
||||||
context,
|
scope,
|
||||||
v8::String::new(scope, "queueMicrotask").unwrap().into(),
|
queue_microtask_key.into(),
|
||||||
queue_microtask_val.into(),
|
queue_microtask_val.into(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -231,7 +196,7 @@ pub fn initialize_context<'s>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn boxed_slice_to_uint8array<'sc>(
|
pub fn boxed_slice_to_uint8array<'sc>(
|
||||||
scope: &mut impl v8::ToLocal<'sc>,
|
scope: &mut v8::HandleScope<'sc>,
|
||||||
buf: Box<[u8]>,
|
buf: Box<[u8]>,
|
||||||
) -> v8::Local<'sc, v8::Uint8Array> {
|
) -> v8::Local<'sc, v8::Uint8Array> {
|
||||||
assert!(!buf.is_empty());
|
assert!(!buf.is_empty());
|
||||||
|
@ -248,9 +213,7 @@ pub extern "C" fn host_import_module_dynamically_callback(
|
||||||
referrer: v8::Local<v8::ScriptOrModule>,
|
referrer: v8::Local<v8::ScriptOrModule>,
|
||||||
specifier: v8::Local<v8::String>,
|
specifier: v8::Local<v8::String>,
|
||||||
) -> *mut v8::Promise {
|
) -> *mut v8::Promise {
|
||||||
let mut cbs = v8::CallbackScope::new_escapable(context);
|
let scope = &mut unsafe { v8::CallbackScope::new(context) };
|
||||||
let mut hs = v8::EscapableHandleScope::new(cbs.enter());
|
|
||||||
let scope = hs.enter();
|
|
||||||
|
|
||||||
// NOTE(bartlomieju): will crash for non-UTF-8 specifier
|
// NOTE(bartlomieju): will crash for non-UTF-8 specifier
|
||||||
let specifier_str = specifier
|
let specifier_str = specifier
|
||||||
|
@ -269,19 +232,19 @@ pub extern "C" fn host_import_module_dynamically_callback(
|
||||||
let host_defined_options = referrer.get_host_defined_options();
|
let host_defined_options = referrer.get_host_defined_options();
|
||||||
assert_eq!(host_defined_options.length(), 0);
|
assert_eq!(host_defined_options.length(), 0);
|
||||||
|
|
||||||
let resolver = v8::PromiseResolver::new(scope, context).unwrap();
|
let resolver = v8::PromiseResolver::new(scope).unwrap();
|
||||||
let promise = resolver.get_promise(scope);
|
let promise = resolver.get_promise(scope);
|
||||||
|
|
||||||
let mut resolver_handle = v8::Global::new();
|
let mut resolver_handle = v8::Global::new();
|
||||||
resolver_handle.set(scope, resolver);
|
resolver_handle.set(scope, resolver);
|
||||||
|
|
||||||
{
|
{
|
||||||
let state_rc = EsIsolate::state(scope.isolate());
|
let state_rc = EsIsolate::state(scope);
|
||||||
let mut state = state_rc.borrow_mut();
|
let mut state = state_rc.borrow_mut();
|
||||||
state.dyn_import_cb(resolver_handle, &specifier_str, &referrer_name_str);
|
state.dyn_import_cb(resolver_handle, &specifier_str, &referrer_name_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
&mut *scope.escape(promise)
|
&*promise as *const _ as *mut _
|
||||||
}
|
}
|
||||||
|
|
||||||
pub extern "C" fn host_initialize_import_meta_object_callback(
|
pub extern "C" fn host_initialize_import_meta_object_callback(
|
||||||
|
@ -289,10 +252,8 @@ pub extern "C" fn host_initialize_import_meta_object_callback(
|
||||||
module: v8::Local<v8::Module>,
|
module: v8::Local<v8::Module>,
|
||||||
meta: v8::Local<v8::Object>,
|
meta: v8::Local<v8::Object>,
|
||||||
) {
|
) {
|
||||||
let mut cbs = v8::CallbackScope::new(context);
|
let scope = &mut unsafe { v8::CallbackScope::new(context) };
|
||||||
let mut hs = v8::HandleScope::new(cbs.enter());
|
let state_rc = EsIsolate::state(scope);
|
||||||
let scope = hs.enter();
|
|
||||||
let state_rc = EsIsolate::state(scope.isolate());
|
|
||||||
let state = state_rc.borrow();
|
let state = state_rc.borrow();
|
||||||
|
|
||||||
let id = module.get_identity_hash();
|
let id = module.get_identity_hash();
|
||||||
|
@ -300,30 +261,21 @@ pub extern "C" fn host_initialize_import_meta_object_callback(
|
||||||
|
|
||||||
let info = state.modules.get_info(id).expect("Module not found");
|
let info = state.modules.get_info(id).expect("Module not found");
|
||||||
|
|
||||||
meta.create_data_property(
|
let url_key = v8::String::new(scope, "url").unwrap();
|
||||||
context,
|
let url_val = v8::String::new(scope, &info.name).unwrap();
|
||||||
v8::String::new(scope, "url").unwrap().into(),
|
meta.create_data_property(scope, url_key.into(), url_val.into());
|
||||||
v8::String::new(scope, &info.name).unwrap().into(),
|
|
||||||
);
|
let main_key = v8::String::new(scope, "main").unwrap();
|
||||||
meta.create_data_property(
|
let main_val = v8::Boolean::new(scope, info.main);
|
||||||
context,
|
meta.create_data_property(scope, main_key.into(), main_val.into());
|
||||||
v8::String::new(scope, "main").unwrap().into(),
|
|
||||||
v8::Boolean::new(scope, info.main).into(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub extern "C" fn promise_reject_callback(message: v8::PromiseRejectMessage) {
|
pub extern "C" fn promise_reject_callback(message: v8::PromiseRejectMessage) {
|
||||||
let mut cbs = v8::CallbackScope::new(&message);
|
let scope = &mut unsafe { v8::CallbackScope::new(&message) };
|
||||||
let mut hs = v8::HandleScope::new(cbs.enter());
|
|
||||||
let scope = hs.enter();
|
|
||||||
|
|
||||||
let state_rc = CoreIsolate::state(scope.isolate());
|
let state_rc = CoreIsolate::state(scope);
|
||||||
let mut state = state_rc.borrow_mut();
|
let mut state = state_rc.borrow_mut();
|
||||||
|
|
||||||
let context = state.global_context.get(scope).unwrap();
|
|
||||||
let mut cs = v8::ContextScope::new(scope, context);
|
|
||||||
let scope = cs.enter();
|
|
||||||
|
|
||||||
let promise = message.get_promise();
|
let promise = message.get_promise();
|
||||||
let promise_id = promise.get_identity_hash();
|
let promise_id = promise.get_identity_hash();
|
||||||
|
|
||||||
|
@ -374,7 +326,7 @@ pub(crate) unsafe fn get_backing_store_slice_mut(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print(
|
fn print(
|
||||||
scope: v8::FunctionCallbackScope,
|
scope: &mut v8::HandleScope,
|
||||||
args: v8::FunctionCallbackArguments,
|
args: v8::FunctionCallbackArguments,
|
||||||
_rv: v8::ReturnValue,
|
_rv: v8::ReturnValue,
|
||||||
) {
|
) {
|
||||||
|
@ -384,9 +336,6 @@ fn print(
|
||||||
let obj = args.get(0);
|
let obj = args.get(0);
|
||||||
let is_err_arg = args.get(1);
|
let is_err_arg = args.get(1);
|
||||||
|
|
||||||
let mut hs = v8::HandleScope::new(scope);
|
|
||||||
let scope = hs.enter();
|
|
||||||
|
|
||||||
let mut is_err = false;
|
let mut is_err = false;
|
||||||
if arg_len == 2 {
|
if arg_len == 2 {
|
||||||
let int_val = is_err_arg
|
let int_val = is_err_arg
|
||||||
|
@ -394,30 +343,29 @@ fn print(
|
||||||
.expect("Unable to convert to integer");
|
.expect("Unable to convert to integer");
|
||||||
is_err = int_val != 0;
|
is_err = int_val != 0;
|
||||||
};
|
};
|
||||||
let mut try_catch = v8::TryCatch::new(scope);
|
let tc_scope = &mut v8::TryCatch::new(scope);
|
||||||
let _tc = try_catch.enter();
|
let str_ = match obj.to_string(tc_scope) {
|
||||||
let str_ = match obj.to_string(scope) {
|
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => v8::String::new(scope, "").unwrap(),
|
None => v8::String::new(tc_scope, "").unwrap(),
|
||||||
};
|
};
|
||||||
if is_err {
|
if is_err {
|
||||||
eprint!("{}", str_.to_rust_string_lossy(scope));
|
eprint!("{}", str_.to_rust_string_lossy(tc_scope));
|
||||||
} else {
|
} else {
|
||||||
print!("{}", str_.to_rust_string_lossy(scope));
|
print!("{}", str_.to_rust_string_lossy(tc_scope));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn recv(
|
fn recv(
|
||||||
scope: v8::FunctionCallbackScope,
|
scope: &mut v8::HandleScope,
|
||||||
args: v8::FunctionCallbackArguments,
|
args: v8::FunctionCallbackArguments,
|
||||||
_rv: v8::ReturnValue,
|
_rv: v8::ReturnValue,
|
||||||
) {
|
) {
|
||||||
let state_rc = CoreIsolate::state(scope.isolate());
|
let state_rc = CoreIsolate::state(scope);
|
||||||
let mut state = state_rc.borrow_mut();
|
let mut state = state_rc.borrow_mut();
|
||||||
|
|
||||||
if !state.js_recv_cb.is_empty() {
|
if !state.js_recv_cb.is_empty() {
|
||||||
let msg = v8::String::new(scope, "Deno.core.recv already called.").unwrap();
|
let msg = v8::String::new(scope, "Deno.core.recv already called.").unwrap();
|
||||||
scope.isolate().throw_exception(msg.into());
|
scope.throw_exception(msg.into());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,7 +374,7 @@ fn recv(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send(
|
fn send(
|
||||||
scope: v8::FunctionCallbackScope,
|
scope: &mut v8::HandleScope,
|
||||||
args: v8::FunctionCallbackArguments,
|
args: v8::FunctionCallbackArguments,
|
||||||
mut rv: v8::ReturnValue,
|
mut rv: v8::ReturnValue,
|
||||||
) {
|
) {
|
||||||
|
@ -435,7 +383,7 @@ fn send(
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
let msg = format!("invalid op id: {}", err);
|
let msg = format!("invalid op id: {}", err);
|
||||||
let msg = v8::String::new(scope, &msg).unwrap();
|
let msg = v8::String::new(scope, &msg).unwrap();
|
||||||
scope.isolate().throw_exception(msg.into());
|
scope.throw_exception(msg.into());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -453,7 +401,7 @@ fn send(
|
||||||
Err(_) => &[],
|
Err(_) => &[],
|
||||||
};
|
};
|
||||||
|
|
||||||
let state_rc = CoreIsolate::state(scope.isolate());
|
let state_rc = CoreIsolate::state(scope);
|
||||||
let mut state = state_rc.borrow_mut();
|
let mut state = state_rc.borrow_mut();
|
||||||
assert!(!state.global_context.is_empty());
|
assert!(!state.global_context.is_empty());
|
||||||
|
|
||||||
|
@ -493,7 +441,7 @@ fn send(
|
||||||
let maybe_response = match buf_iter_result {
|
let maybe_response = match buf_iter_result {
|
||||||
Ok(bufs) => state.dispatch_op(scope, op_id, control, bufs),
|
Ok(bufs) => state.dispatch_op(scope, op_id, control, bufs),
|
||||||
Err(exc) => {
|
Err(exc) => {
|
||||||
scope.isolate().throw_exception(exc);
|
scope.throw_exception(exc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -511,18 +459,18 @@ fn send(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_macrotask_callback(
|
fn set_macrotask_callback(
|
||||||
scope: v8::FunctionCallbackScope,
|
scope: &mut v8::HandleScope,
|
||||||
args: v8::FunctionCallbackArguments,
|
args: v8::FunctionCallbackArguments,
|
||||||
_rv: v8::ReturnValue,
|
_rv: v8::ReturnValue,
|
||||||
) {
|
) {
|
||||||
let state_rc = CoreIsolate::state(scope.isolate());
|
let state_rc = CoreIsolate::state(scope);
|
||||||
let mut state = state_rc.borrow_mut();
|
let mut state = state_rc.borrow_mut();
|
||||||
|
|
||||||
if !state.js_macrotask_cb.is_empty() {
|
if !state.js_macrotask_cb.is_empty() {
|
||||||
let msg =
|
let msg =
|
||||||
v8::String::new(scope, "Deno.core.setMacrotaskCallback already called.")
|
v8::String::new(scope, "Deno.core.setMacrotaskCallback already called.")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
scope.isolate().throw_exception(msg.into());
|
scope.throw_exception(msg.into());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,23 +480,16 @@ fn set_macrotask_callback(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn eval_context(
|
fn eval_context(
|
||||||
scope: v8::FunctionCallbackScope,
|
scope: &mut v8::HandleScope,
|
||||||
args: v8::FunctionCallbackArguments,
|
args: v8::FunctionCallbackArguments,
|
||||||
mut rv: v8::ReturnValue,
|
mut rv: v8::ReturnValue,
|
||||||
) {
|
) {
|
||||||
let state_rc = CoreIsolate::state(scope.isolate());
|
|
||||||
let context = {
|
|
||||||
let state = state_rc.borrow();
|
|
||||||
assert!(!state.global_context.is_empty());
|
|
||||||
state.global_context.get(scope).unwrap()
|
|
||||||
};
|
|
||||||
|
|
||||||
let source = match v8::Local::<v8::String>::try_from(args.get(0)) {
|
let source = match v8::Local::<v8::String>::try_from(args.get(0)) {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let msg = v8::String::new(scope, "Invalid argument").unwrap();
|
let msg = v8::String::new(scope, "Invalid argument").unwrap();
|
||||||
let exception = v8::Exception::type_error(scope, msg);
|
let exception = v8::Exception::type_error(scope, msg);
|
||||||
scope.isolate().throw_exception(exception);
|
scope.throw_exception(exception);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -566,116 +507,108 @@ fn eval_context(
|
||||||
isCompileError: boolean,
|
isCompileError: boolean,
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
let mut try_catch = v8::TryCatch::new(scope);
|
let tc_scope = &mut v8::TryCatch::new(scope);
|
||||||
let tc = try_catch.enter();
|
|
||||||
let name =
|
let name =
|
||||||
v8::String::new(scope, url.as_ref().map_or("<unknown>", Url::as_str))
|
v8::String::new(tc_scope, url.as_ref().map_or("<unknown>", Url::as_str))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let origin = script_origin(scope, name);
|
let origin = script_origin(tc_scope, name);
|
||||||
let maybe_script = v8::Script::compile(scope, context, source, Some(&origin));
|
let maybe_script = v8::Script::compile(tc_scope, source, Some(&origin));
|
||||||
|
|
||||||
if maybe_script.is_none() {
|
if maybe_script.is_none() {
|
||||||
assert!(tc.has_caught());
|
assert!(tc_scope.has_caught());
|
||||||
let exception = tc.exception(scope).unwrap();
|
let exception = tc_scope.exception().unwrap();
|
||||||
|
|
||||||
output.set(
|
let js_zero = v8::Integer::new(tc_scope, 0);
|
||||||
context,
|
let js_null = v8::null(tc_scope);
|
||||||
v8::Integer::new(scope, 0).into(),
|
output.set(tc_scope, js_zero.into(), js_null.into());
|
||||||
v8::null(scope).into(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let errinfo_obj = v8::Object::new(scope);
|
let errinfo_obj = v8::Object::new(tc_scope);
|
||||||
|
|
||||||
|
let is_compile_error_key =
|
||||||
|
v8::String::new(tc_scope, "isCompileError").unwrap();
|
||||||
|
let is_compile_error_val = v8::Boolean::new(tc_scope, true);
|
||||||
errinfo_obj.set(
|
errinfo_obj.set(
|
||||||
context,
|
tc_scope,
|
||||||
v8::String::new(scope, "isCompileError").unwrap().into(),
|
is_compile_error_key.into(),
|
||||||
v8::Boolean::new(scope, true).into(),
|
is_compile_error_val.into(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let is_native_error_key =
|
||||||
|
v8::String::new(tc_scope, "isNativeError").unwrap();
|
||||||
|
let is_native_error_val =
|
||||||
|
v8::Boolean::new(tc_scope, exception.is_native_error());
|
||||||
errinfo_obj.set(
|
errinfo_obj.set(
|
||||||
context,
|
tc_scope,
|
||||||
v8::String::new(scope, "isNativeError").unwrap().into(),
|
is_native_error_key.into(),
|
||||||
v8::Boolean::new(scope, exception.is_native_error()).into(),
|
is_native_error_val.into(),
|
||||||
);
|
);
|
||||||
|
|
||||||
errinfo_obj.set(
|
let thrown_key = v8::String::new(tc_scope, "thrown").unwrap();
|
||||||
context,
|
errinfo_obj.set(tc_scope, thrown_key.into(), exception);
|
||||||
v8::String::new(scope, "thrown").unwrap().into(),
|
|
||||||
exception,
|
|
||||||
);
|
|
||||||
|
|
||||||
output.set(
|
let js_one = v8::Integer::new(tc_scope, 1);
|
||||||
context,
|
output.set(tc_scope, js_one.into(), errinfo_obj.into());
|
||||||
v8::Integer::new(scope, 1).into(),
|
|
||||||
errinfo_obj.into(),
|
|
||||||
);
|
|
||||||
|
|
||||||
rv.set(output.into());
|
rv.set(output.into());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = maybe_script.unwrap().run(scope, context);
|
let result = maybe_script.unwrap().run(tc_scope);
|
||||||
|
|
||||||
if result.is_none() {
|
if result.is_none() {
|
||||||
assert!(tc.has_caught());
|
assert!(tc_scope.has_caught());
|
||||||
let exception = tc.exception(scope).unwrap();
|
let exception = tc_scope.exception().unwrap();
|
||||||
|
|
||||||
output.set(
|
let js_zero = v8::Integer::new(tc_scope, 0);
|
||||||
context,
|
let js_null = v8::null(tc_scope);
|
||||||
v8::Integer::new(scope, 0).into(),
|
output.set(tc_scope, js_zero.into(), js_null.into());
|
||||||
v8::null(scope).into(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let errinfo_obj = v8::Object::new(scope);
|
let errinfo_obj = v8::Object::new(tc_scope);
|
||||||
|
|
||||||
|
let is_compile_error_key =
|
||||||
|
v8::String::new(tc_scope, "isCompileError").unwrap();
|
||||||
|
let is_compile_error_val = v8::Boolean::new(tc_scope, false);
|
||||||
errinfo_obj.set(
|
errinfo_obj.set(
|
||||||
context,
|
tc_scope,
|
||||||
v8::String::new(scope, "isCompileError").unwrap().into(),
|
is_compile_error_key.into(),
|
||||||
v8::Boolean::new(scope, false).into(),
|
is_compile_error_val.into(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let is_native_error = if exception.is_native_error() {
|
let is_native_error_key =
|
||||||
v8::Boolean::new(scope, true)
|
v8::String::new(tc_scope, "isNativeError").unwrap();
|
||||||
} else {
|
let is_native_error_val =
|
||||||
v8::Boolean::new(scope, false)
|
v8::Boolean::new(tc_scope, exception.is_native_error());
|
||||||
};
|
|
||||||
|
|
||||||
errinfo_obj.set(
|
errinfo_obj.set(
|
||||||
context,
|
tc_scope,
|
||||||
v8::String::new(scope, "isNativeError").unwrap().into(),
|
is_native_error_key.into(),
|
||||||
is_native_error.into(),
|
is_native_error_val.into(),
|
||||||
);
|
);
|
||||||
|
|
||||||
errinfo_obj.set(
|
let thrown_key = v8::String::new(tc_scope, "thrown").unwrap();
|
||||||
context,
|
errinfo_obj.set(tc_scope, thrown_key.into(), exception);
|
||||||
v8::String::new(scope, "thrown").unwrap().into(),
|
|
||||||
exception,
|
|
||||||
);
|
|
||||||
|
|
||||||
output.set(
|
let js_one = v8::Integer::new(tc_scope, 1);
|
||||||
context,
|
output.set(tc_scope, js_one.into(), errinfo_obj.into());
|
||||||
v8::Integer::new(scope, 1).into(),
|
|
||||||
errinfo_obj.into(),
|
|
||||||
);
|
|
||||||
|
|
||||||
rv.set(output.into());
|
rv.set(output.into());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
output.set(context, v8::Integer::new(scope, 0).into(), result.unwrap());
|
let js_zero = v8::Integer::new(tc_scope, 0);
|
||||||
output.set(
|
let js_one = v8::Integer::new(tc_scope, 1);
|
||||||
context,
|
let js_null = v8::null(tc_scope);
|
||||||
v8::Integer::new(scope, 1).into(),
|
output.set(tc_scope, js_zero.into(), result.unwrap());
|
||||||
v8::null(scope).into(),
|
output.set(tc_scope, js_one.into(), js_null.into());
|
||||||
);
|
|
||||||
rv.set(output.into());
|
rv.set(output.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn format_error(
|
fn format_error(
|
||||||
scope: v8::FunctionCallbackScope,
|
scope: &mut v8::HandleScope,
|
||||||
args: v8::FunctionCallbackArguments,
|
args: v8::FunctionCallbackArguments,
|
||||||
mut rv: v8::ReturnValue,
|
mut rv: v8::ReturnValue,
|
||||||
) {
|
) {
|
||||||
let e = JSError::from_v8_exception(scope, args.get(0));
|
let e = JSError::from_v8_exception(scope, args.get(0));
|
||||||
let state_rc = CoreIsolate::state(scope.isolate());
|
let state_rc = CoreIsolate::state(scope);
|
||||||
let state = state_rc.borrow();
|
let state = state_rc.borrow();
|
||||||
let e = (state.js_error_create_fn)(e);
|
let e = (state.js_error_create_fn)(e);
|
||||||
let e = e.to_string();
|
let e = e.to_string();
|
||||||
|
@ -684,7 +617,7 @@ fn format_error(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode(
|
fn encode(
|
||||||
scope: v8::FunctionCallbackScope,
|
scope: &mut v8::HandleScope,
|
||||||
args: v8::FunctionCallbackArguments,
|
args: v8::FunctionCallbackArguments,
|
||||||
mut rv: v8::ReturnValue,
|
mut rv: v8::ReturnValue,
|
||||||
) {
|
) {
|
||||||
|
@ -693,7 +626,7 @@ fn encode(
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let msg = v8::String::new(scope, "Invalid argument").unwrap();
|
let msg = v8::String::new(scope, "Invalid argument").unwrap();
|
||||||
let exception = v8::Exception::type_error(scope, msg);
|
let exception = v8::Exception::type_error(scope, msg);
|
||||||
scope.isolate().throw_exception(exception);
|
scope.throw_exception(exception);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -717,7 +650,7 @@ fn encode(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decode(
|
fn decode(
|
||||||
scope: v8::FunctionCallbackScope,
|
scope: &mut v8::HandleScope,
|
||||||
args: v8::FunctionCallbackArguments,
|
args: v8::FunctionCallbackArguments,
|
||||||
mut rv: v8::ReturnValue,
|
mut rv: v8::ReturnValue,
|
||||||
) {
|
) {
|
||||||
|
@ -726,7 +659,7 @@ fn decode(
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let msg = v8::String::new(scope, "Invalid argument").unwrap();
|
let msg = v8::String::new(scope, "Invalid argument").unwrap();
|
||||||
let exception = v8::Exception::type_error(scope, msg);
|
let exception = v8::Exception::type_error(scope, msg);
|
||||||
scope.isolate().throw_exception(exception);
|
scope.throw_exception(exception);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -746,27 +679,27 @@ fn decode(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn queue_microtask(
|
fn queue_microtask(
|
||||||
scope: v8::FunctionCallbackScope,
|
scope: &mut v8::HandleScope,
|
||||||
args: v8::FunctionCallbackArguments,
|
args: v8::FunctionCallbackArguments,
|
||||||
_rv: v8::ReturnValue,
|
_rv: v8::ReturnValue,
|
||||||
) {
|
) {
|
||||||
match v8::Local::<v8::Function>::try_from(args.get(0)) {
|
match v8::Local::<v8::Function>::try_from(args.get(0)) {
|
||||||
Ok(f) => scope.isolate().enqueue_microtask(f),
|
Ok(f) => scope.enqueue_microtask(f),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let msg = v8::String::new(scope, "Invalid argument").unwrap();
|
let msg = v8::String::new(scope, "Invalid argument").unwrap();
|
||||||
let exception = v8::Exception::type_error(scope, msg);
|
let exception = v8::Exception::type_error(scope, msg);
|
||||||
scope.isolate().throw_exception(exception);
|
scope.throw_exception(exception);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn shared_getter(
|
fn shared_getter(
|
||||||
scope: v8::PropertyCallbackScope,
|
scope: &mut v8::HandleScope,
|
||||||
_name: v8::Local<v8::Name>,
|
_name: v8::Local<v8::Name>,
|
||||||
_args: v8::PropertyCallbackArguments,
|
_args: v8::PropertyCallbackArguments,
|
||||||
mut rv: v8::ReturnValue,
|
mut rv: v8::ReturnValue,
|
||||||
) {
|
) {
|
||||||
let state_rc = CoreIsolate::state(scope.isolate());
|
let state_rc = CoreIsolate::state(scope);
|
||||||
let mut state = state_rc.borrow_mut();
|
let mut state = state_rc.borrow_mut();
|
||||||
|
|
||||||
// Lazily initialize the persistent external ArrayBuffer.
|
// Lazily initialize the persistent external ArrayBuffer.
|
||||||
|
@ -787,11 +720,9 @@ pub fn module_resolve_callback<'s>(
|
||||||
specifier: v8::Local<'s, v8::String>,
|
specifier: v8::Local<'s, v8::String>,
|
||||||
referrer: v8::Local<'s, v8::Module>,
|
referrer: v8::Local<'s, v8::Module>,
|
||||||
) -> Option<v8::Local<'s, v8::Module>> {
|
) -> Option<v8::Local<'s, v8::Module>> {
|
||||||
let mut scope = v8::CallbackScope::new_escapable(context);
|
let scope = &mut unsafe { v8::CallbackScope::new(context) };
|
||||||
let mut scope = v8::EscapableHandleScope::new(scope.enter());
|
|
||||||
let scope = scope.enter();
|
|
||||||
|
|
||||||
let state_rc = EsIsolate::state(scope.isolate());
|
let state_rc = EsIsolate::state(scope);
|
||||||
let mut state = state_rc.borrow_mut();
|
let mut state = state_rc.borrow_mut();
|
||||||
|
|
||||||
let referrer_id = referrer.get_identity_hash();
|
let referrer_id = referrer.get_identity_hash();
|
||||||
|
@ -819,13 +750,11 @@ pub fn module_resolve_callback<'s>(
|
||||||
req_str, referrer_name
|
req_str, referrer_name
|
||||||
);
|
);
|
||||||
let msg = v8::String::new(scope, &msg).unwrap();
|
let msg = v8::String::new(scope, &msg).unwrap();
|
||||||
scope.isolate().throw_exception(msg.into());
|
scope.throw_exception(msg.into());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return maybe_info
|
return maybe_info.and_then(|i| i.handle.get(scope));
|
||||||
.and_then(|i| i.handle.get(scope))
|
|
||||||
.map(|m| scope.escape(m));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -833,26 +762,21 @@ pub fn module_resolve_callback<'s>(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns promise details or throw TypeError, if argument passed isn't a Promise.
|
// Returns promise details or throw TypeError, if argument passed isn't a Promise.
|
||||||
// Promise details is a two elements array.
|
// Promise details is a js_two elements array.
|
||||||
// promise_details = [State, Result]
|
// promise_details = [State, Result]
|
||||||
// State = enum { Pending = 0, Fulfilled = 1, Rejected = 2}
|
// State = enum { Pending = 0, Fulfilled = 1, Rejected = 2}
|
||||||
// Result = PromiseResult<T> | PromiseError
|
// Result = PromiseResult<T> | PromiseError
|
||||||
fn get_promise_details(
|
fn get_promise_details(
|
||||||
scope: v8::FunctionCallbackScope,
|
scope: &mut v8::HandleScope,
|
||||||
args: v8::FunctionCallbackArguments,
|
args: v8::FunctionCallbackArguments,
|
||||||
mut rv: v8::ReturnValue,
|
mut rv: v8::ReturnValue,
|
||||||
) {
|
) {
|
||||||
let state_rc = CoreIsolate::state(scope.isolate());
|
|
||||||
let state = state_rc.borrow();
|
|
||||||
assert!(!state.global_context.is_empty());
|
|
||||||
let context = state.global_context.get(scope).unwrap();
|
|
||||||
|
|
||||||
let promise = match v8::Local::<v8::Promise>::try_from(args.get(0)) {
|
let promise = match v8::Local::<v8::Promise>::try_from(args.get(0)) {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let msg = v8::String::new(scope, "Invalid argument").unwrap();
|
let msg = v8::String::new(scope, "Invalid argument").unwrap();
|
||||||
let exception = v8::Exception::type_error(scope, msg);
|
let exception = v8::Exception::type_error(scope, msg);
|
||||||
scope.isolate().throw_exception(exception);
|
scope.throw_exception(exception);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -861,37 +785,25 @@ fn get_promise_details(
|
||||||
|
|
||||||
match promise.state() {
|
match promise.state() {
|
||||||
v8::PromiseState::Pending => {
|
v8::PromiseState::Pending => {
|
||||||
promise_details.set(
|
let js_zero = v8::Integer::new(scope, 0);
|
||||||
context,
|
promise_details.set(scope, js_zero.into(), js_zero.into());
|
||||||
v8::Integer::new(scope, 0).into(),
|
|
||||||
v8::Integer::new(scope, 0).into(),
|
|
||||||
);
|
|
||||||
rv.set(promise_details.into());
|
rv.set(promise_details.into());
|
||||||
}
|
}
|
||||||
v8::PromiseState::Fulfilled => {
|
v8::PromiseState::Fulfilled => {
|
||||||
promise_details.set(
|
let js_zero = v8::Integer::new(scope, 0);
|
||||||
context,
|
let js_one = v8::Integer::new(scope, 1);
|
||||||
v8::Integer::new(scope, 0).into(),
|
let promise_result = promise.result(scope);
|
||||||
v8::Integer::new(scope, 1).into(),
|
promise_details.set(scope, js_zero.into(), js_one.into());
|
||||||
);
|
promise_details.set(scope, js_one.into(), promise_result);
|
||||||
promise_details.set(
|
|
||||||
context,
|
|
||||||
v8::Integer::new(scope, 1).into(),
|
|
||||||
promise.result(scope),
|
|
||||||
);
|
|
||||||
rv.set(promise_details.into());
|
rv.set(promise_details.into());
|
||||||
}
|
}
|
||||||
v8::PromiseState::Rejected => {
|
v8::PromiseState::Rejected => {
|
||||||
promise_details.set(
|
let js_zero = v8::Integer::new(scope, 0);
|
||||||
context,
|
let js_one = v8::Integer::new(scope, 1);
|
||||||
v8::Integer::new(scope, 0).into(),
|
let js_two = v8::Integer::new(scope, 2);
|
||||||
v8::Integer::new(scope, 2).into(),
|
let promise_result = promise.result(scope);
|
||||||
);
|
promise_details.set(scope, js_zero.into(), js_two.into());
|
||||||
promise_details.set(
|
promise_details.set(scope, js_one.into(), promise_result);
|
||||||
context,
|
|
||||||
v8::Integer::new(scope, 1).into(),
|
|
||||||
promise.result(scope),
|
|
||||||
);
|
|
||||||
rv.set(promise_details.into());
|
rv.set(promise_details.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,14 +109,6 @@ pub struct CoreIsolateState {
|
||||||
waker: AtomicWaker,
|
waker: AtomicWaker,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(ry) The trait v8::InIsolate is superfluous. HandleScope::new should just
|
|
||||||
// take &mut v8::Isolate.
|
|
||||||
impl v8::InIsolate for CoreIsolate {
|
|
||||||
fn isolate(&mut self) -> &mut v8::Isolate {
|
|
||||||
self.v8_isolate.as_mut().unwrap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Deref for CoreIsolate {
|
impl Deref for CoreIsolate {
|
||||||
type Target = v8::Isolate;
|
type Target = v8::Isolate;
|
||||||
fn deref(&self) -> &v8::Isolate {
|
fn deref(&self) -> &v8::Isolate {
|
||||||
|
@ -193,14 +185,12 @@ impl CoreIsolate {
|
||||||
v8::SnapshotCreator::new(Some(&bindings::EXTERNAL_REFERENCES));
|
v8::SnapshotCreator::new(Some(&bindings::EXTERNAL_REFERENCES));
|
||||||
let isolate = unsafe { creator.get_owned_isolate() };
|
let isolate = unsafe { creator.get_owned_isolate() };
|
||||||
let mut isolate = CoreIsolate::setup_isolate(isolate);
|
let mut isolate = CoreIsolate::setup_isolate(isolate);
|
||||||
|
{
|
||||||
let mut hs = v8::HandleScope::new(&mut isolate);
|
let scope = &mut v8::HandleScope::new(&mut isolate);
|
||||||
let scope = hs.enter();
|
|
||||||
|
|
||||||
let context = bindings::initialize_context(scope);
|
let context = bindings::initialize_context(scope);
|
||||||
global_context.set(scope, context);
|
global_context.set(scope, context);
|
||||||
creator.set_default_context(context);
|
creator.set_default_context(context);
|
||||||
|
}
|
||||||
(isolate, Some(creator))
|
(isolate, Some(creator))
|
||||||
} else {
|
} else {
|
||||||
let mut params = v8::Isolate::create_params()
|
let mut params = v8::Isolate::create_params()
|
||||||
|
@ -218,10 +208,8 @@ impl CoreIsolate {
|
||||||
|
|
||||||
let isolate = v8::Isolate::new(params);
|
let isolate = v8::Isolate::new(params);
|
||||||
let mut isolate = CoreIsolate::setup_isolate(isolate);
|
let mut isolate = CoreIsolate::setup_isolate(isolate);
|
||||||
|
{
|
||||||
let mut hs = v8::HandleScope::new(&mut isolate);
|
let scope = &mut v8::HandleScope::new(&mut isolate);
|
||||||
let scope = hs.enter();
|
|
||||||
|
|
||||||
let context = if snapshot_loaded {
|
let context = if snapshot_loaded {
|
||||||
v8::Context::new(scope)
|
v8::Context::new(scope)
|
||||||
} else {
|
} else {
|
||||||
|
@ -230,7 +218,7 @@ impl CoreIsolate {
|
||||||
bindings::initialize_context(scope)
|
bindings::initialize_context(scope)
|
||||||
};
|
};
|
||||||
global_context.set(scope, context);
|
global_context.set(scope, context);
|
||||||
|
}
|
||||||
(isolate, None)
|
(isolate, None)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -297,11 +285,9 @@ impl CoreIsolate {
|
||||||
let state_rc = Self::state(self);
|
let state_rc = Self::state(self);
|
||||||
let state = state_rc.borrow();
|
let state = state_rc.borrow();
|
||||||
|
|
||||||
let mut hs = v8::HandleScope::new(self.v8_isolate.as_mut().unwrap());
|
let scope = &mut v8::HandleScope::new(self.v8_isolate.as_mut().unwrap());
|
||||||
let scope = hs.enter();
|
|
||||||
let context = state.global_context.get(scope).unwrap();
|
let context = state.global_context.get(scope).unwrap();
|
||||||
let mut cs = v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
let scope = cs.enter();
|
|
||||||
|
|
||||||
drop(state);
|
drop(state);
|
||||||
|
|
||||||
|
@ -309,24 +295,22 @@ impl CoreIsolate {
|
||||||
let name = v8::String::new(scope, js_filename).unwrap();
|
let name = v8::String::new(scope, js_filename).unwrap();
|
||||||
let origin = bindings::script_origin(scope, name);
|
let origin = bindings::script_origin(scope, name);
|
||||||
|
|
||||||
let mut try_catch = v8::TryCatch::new(scope);
|
let tc_scope = &mut v8::TryCatch::new(scope);
|
||||||
let tc = try_catch.enter();
|
|
||||||
|
|
||||||
let mut script =
|
let script = match v8::Script::compile(tc_scope, source, Some(&origin)) {
|
||||||
match v8::Script::compile(scope, context, source, Some(&origin)) {
|
|
||||||
Some(script) => script,
|
Some(script) => script,
|
||||||
None => {
|
None => {
|
||||||
let exception = tc.exception(scope).unwrap();
|
let exception = tc_scope.exception().unwrap();
|
||||||
return exception_to_err_result(scope, exception);
|
return exception_to_err_result(tc_scope, exception);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
match script.run(scope, context) {
|
match script.run(tc_scope) {
|
||||||
Some(_) => Ok(()),
|
Some(_) => Ok(()),
|
||||||
None => {
|
None => {
|
||||||
assert!(tc.has_caught());
|
assert!(tc_scope.has_caught());
|
||||||
let exception = tc.exception(scope).unwrap();
|
let exception = tc_scope.exception().unwrap();
|
||||||
exception_to_err_result(scope, exception)
|
exception_to_err_result(tc_scope, exception)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -346,8 +330,7 @@ impl CoreIsolate {
|
||||||
// TODO(piscisaureus): The rusty_v8 type system should enforce this.
|
// TODO(piscisaureus): The rusty_v8 type system should enforce this.
|
||||||
{
|
{
|
||||||
let v8_isolate = self.v8_isolate.as_mut().unwrap();
|
let v8_isolate = self.v8_isolate.as_mut().unwrap();
|
||||||
let mut hs = v8::HandleScope::new(v8_isolate);
|
let scope = &mut v8::HandleScope::new(v8_isolate);
|
||||||
let scope = hs.enter();
|
|
||||||
state.borrow_mut().global_context.reset(scope);
|
state.borrow_mut().global_context.reset(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,14 +371,12 @@ impl Future for CoreIsolate {
|
||||||
state.waker.register(cx.waker());
|
state.waker.register(cx.waker());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut hs = v8::HandleScope::new(core_isolate);
|
let scope = &mut v8::HandleScope::new(&mut **core_isolate);
|
||||||
let scope = hs.enter();
|
|
||||||
let context = {
|
let context = {
|
||||||
let state = state_rc.borrow();
|
let state = state_rc.borrow();
|
||||||
state.global_context.get(scope).unwrap()
|
state.global_context.get(scope).unwrap()
|
||||||
};
|
};
|
||||||
let mut cs = v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
let scope = cs.enter();
|
|
||||||
|
|
||||||
check_promise_exceptions(scope)?;
|
check_promise_exceptions(scope)?;
|
||||||
|
|
||||||
|
@ -502,7 +483,7 @@ impl CoreIsolateState {
|
||||||
|
|
||||||
pub fn dispatch_op<'s>(
|
pub fn dispatch_op<'s>(
|
||||||
&mut self,
|
&mut self,
|
||||||
scope: &mut impl v8::ToLocal<'s>,
|
scope: &mut v8::HandleScope<'s>,
|
||||||
op_id: OpId,
|
op_id: OpId,
|
||||||
control_buf: &[u8],
|
control_buf: &[u8],
|
||||||
zero_copy_bufs: &mut [ZeroCopyBuf],
|
zero_copy_bufs: &mut [ZeroCopyBuf],
|
||||||
|
@ -513,7 +494,7 @@ impl CoreIsolateState {
|
||||||
let message =
|
let message =
|
||||||
v8::String::new(scope, &format!("Unknown op id: {}", op_id)).unwrap();
|
v8::String::new(scope, &format!("Unknown op id: {}", op_id)).unwrap();
|
||||||
let exception = v8::Exception::type_error(scope, message);
|
let exception = v8::Exception::type_error(scope, message);
|
||||||
scope.isolate().throw_exception(exception);
|
scope.throw_exception(exception);
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -542,13 +523,13 @@ impl CoreIsolateState {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn async_op_response<'s>(
|
fn async_op_response<'s>(
|
||||||
scope: &mut impl v8::ToLocal<'s>,
|
scope: &mut v8::HandleScope<'s>,
|
||||||
maybe_buf: Option<(OpId, Box<[u8]>)>,
|
maybe_buf: Option<(OpId, Box<[u8]>)>,
|
||||||
) -> Result<(), ErrBox> {
|
) -> Result<(), ErrBox> {
|
||||||
let context = scope.get_current_context().unwrap();
|
let context = scope.get_current_context();
|
||||||
let global: v8::Local<v8::Value> = context.global(scope).into();
|
let global: v8::Local<v8::Value> = context.global(scope).into();
|
||||||
|
|
||||||
let state_rc = CoreIsolate::state(scope.isolate());
|
let state_rc = CoreIsolate::state(scope);
|
||||||
let state = state_rc.borrow_mut();
|
let state = state_rc.borrow_mut();
|
||||||
|
|
||||||
let js_recv_cb = state
|
let js_recv_cb = state
|
||||||
|
@ -557,35 +538,31 @@ fn async_op_response<'s>(
|
||||||
.expect("Deno.core.recv has not been called.");
|
.expect("Deno.core.recv has not been called.");
|
||||||
drop(state);
|
drop(state);
|
||||||
|
|
||||||
// TODO(piscisaureus): properly integrate TryCatch in the scope chain.
|
let tc_scope = &mut v8::TryCatch::new(scope);
|
||||||
let mut try_catch = v8::TryCatch::new(scope);
|
|
||||||
let tc = try_catch.enter();
|
|
||||||
|
|
||||||
match maybe_buf {
|
match maybe_buf {
|
||||||
Some((op_id, buf)) => {
|
Some((op_id, buf)) => {
|
||||||
let op_id: v8::Local<v8::Value> =
|
let op_id: v8::Local<v8::Value> =
|
||||||
v8::Integer::new(scope, op_id as i32).into();
|
v8::Integer::new(tc_scope, op_id as i32).into();
|
||||||
let ui8: v8::Local<v8::Value> =
|
let ui8: v8::Local<v8::Value> =
|
||||||
bindings::boxed_slice_to_uint8array(scope, buf).into();
|
bindings::boxed_slice_to_uint8array(tc_scope, buf).into();
|
||||||
js_recv_cb.call(scope, context, global, &[op_id, ui8])
|
js_recv_cb.call(tc_scope, global, &[op_id, ui8])
|
||||||
}
|
}
|
||||||
None => js_recv_cb.call(scope, context, global, &[]),
|
None => js_recv_cb.call(tc_scope, global, &[]),
|
||||||
};
|
};
|
||||||
|
|
||||||
match tc.exception(scope) {
|
match tc_scope.exception() {
|
||||||
None => Ok(()),
|
None => Ok(()),
|
||||||
Some(exception) => exception_to_err_result(scope, exception),
|
Some(exception) => exception_to_err_result(tc_scope, exception),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn drain_macrotasks<'s>(
|
fn drain_macrotasks<'s>(scope: &mut v8::HandleScope<'s>) -> Result<(), ErrBox> {
|
||||||
scope: &mut impl v8::ToLocal<'s>,
|
let context = scope.get_current_context();
|
||||||
) -> Result<(), ErrBox> {
|
|
||||||
let context = scope.get_current_context().unwrap();
|
|
||||||
let global: v8::Local<v8::Value> = context.global(scope).into();
|
let global: v8::Local<v8::Value> = context.global(scope).into();
|
||||||
|
|
||||||
let js_macrotask_cb = {
|
let js_macrotask_cb = {
|
||||||
let state_rc = CoreIsolate::state(scope.isolate());
|
let state_rc = CoreIsolate::state(scope);
|
||||||
let state = state_rc.borrow_mut();
|
let state = state_rc.borrow_mut();
|
||||||
state.js_macrotask_cb.get(scope)
|
state.js_macrotask_cb.get(scope)
|
||||||
};
|
};
|
||||||
|
@ -598,13 +575,12 @@ fn drain_macrotasks<'s>(
|
||||||
// such that ready microtasks would be automatically run before
|
// such that ready microtasks would be automatically run before
|
||||||
// next macrotask is processed.
|
// next macrotask is processed.
|
||||||
loop {
|
loop {
|
||||||
let mut try_catch = v8::TryCatch::new(scope);
|
let tc_scope = &mut v8::TryCatch::new(scope);
|
||||||
let tc = try_catch.enter();
|
|
||||||
|
|
||||||
let is_done = js_macrotask_cb.call(scope, context, global, &[]);
|
let is_done = js_macrotask_cb.call(tc_scope, global, &[]);
|
||||||
|
|
||||||
if let Some(exception) = tc.exception(scope) {
|
if let Some(exception) = tc_scope.exception() {
|
||||||
return exception_to_err_result(scope, exception);
|
return exception_to_err_result(tc_scope, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_done = is_done.unwrap();
|
let is_done = is_done.unwrap();
|
||||||
|
@ -617,15 +593,13 @@ fn drain_macrotasks<'s>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn exception_to_err_result<'s, T>(
|
pub(crate) fn exception_to_err_result<'s, T>(
|
||||||
scope: &mut impl v8::ToLocal<'s>,
|
scope: &mut v8::HandleScope<'s>,
|
||||||
exception: v8::Local<v8::Value>,
|
exception: v8::Local<v8::Value>,
|
||||||
) -> Result<T, ErrBox> {
|
) -> Result<T, ErrBox> {
|
||||||
// TODO(piscisaureus): in rusty_v8, `is_execution_terminating()` should
|
// TODO(piscisaureus): in rusty_v8, `is_execution_terminating()` should
|
||||||
// also be implemented on `struct Isolate`.
|
// also be implemented on `struct Isolate`.
|
||||||
let is_terminating_exception = scope
|
let is_terminating_exception =
|
||||||
.isolate()
|
scope.thread_safe_handle().is_execution_terminating();
|
||||||
.thread_safe_handle()
|
|
||||||
.is_execution_terminating();
|
|
||||||
let mut exception = exception;
|
let mut exception = exception;
|
||||||
|
|
||||||
if is_terminating_exception {
|
if is_terminating_exception {
|
||||||
|
@ -633,10 +607,7 @@ pub(crate) fn exception_to_err_result<'s, T>(
|
||||||
// exception can be created..
|
// exception can be created..
|
||||||
// TODO(piscisaureus): in rusty_v8, `cancel_terminate_execution()` should
|
// TODO(piscisaureus): in rusty_v8, `cancel_terminate_execution()` should
|
||||||
// also be implemented on `struct Isolate`.
|
// also be implemented on `struct Isolate`.
|
||||||
scope
|
scope.thread_safe_handle().cancel_terminate_execution();
|
||||||
.isolate()
|
|
||||||
.thread_safe_handle()
|
|
||||||
.cancel_terminate_execution();
|
|
||||||
|
|
||||||
// Maybe make a new exception object.
|
// Maybe make a new exception object.
|
||||||
if exception.is_null_or_undefined() {
|
if exception.is_null_or_undefined() {
|
||||||
|
@ -647,7 +618,7 @@ pub(crate) fn exception_to_err_result<'s, T>(
|
||||||
|
|
||||||
let js_error = JSError::from_v8_exception(scope, exception);
|
let js_error = JSError::from_v8_exception(scope, exception);
|
||||||
|
|
||||||
let state_rc = CoreIsolate::state(scope.isolate());
|
let state_rc = CoreIsolate::state(scope);
|
||||||
let state = state_rc.borrow();
|
let state = state_rc.borrow();
|
||||||
let js_error = (state.js_error_create_fn)(js_error);
|
let js_error = (state.js_error_create_fn)(js_error);
|
||||||
|
|
||||||
|
@ -655,16 +626,16 @@ pub(crate) fn exception_to_err_result<'s, T>(
|
||||||
// Re-enable exception termination.
|
// Re-enable exception termination.
|
||||||
// TODO(piscisaureus): in rusty_v8, `terminate_execution()` should also
|
// TODO(piscisaureus): in rusty_v8, `terminate_execution()` should also
|
||||||
// be implemented on `struct Isolate`.
|
// be implemented on `struct Isolate`.
|
||||||
scope.isolate().thread_safe_handle().terminate_execution();
|
scope.thread_safe_handle().terminate_execution();
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(js_error)
|
Err(js_error)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_promise_exceptions<'s>(
|
fn check_promise_exceptions<'s>(
|
||||||
scope: &mut impl v8::ToLocal<'s>,
|
scope: &mut v8::HandleScope<'s>,
|
||||||
) -> Result<(), ErrBox> {
|
) -> Result<(), ErrBox> {
|
||||||
let state_rc = CoreIsolate::state(scope.isolate());
|
let state_rc = CoreIsolate::state(scope);
|
||||||
let mut state = state_rc.borrow_mut();
|
let mut state = state_rc.borrow_mut();
|
||||||
|
|
||||||
if let Some(&key) = state.pending_promise_exceptions.keys().next() {
|
if let Some(&key) = state.pending_promise_exceptions.keys().next() {
|
||||||
|
|
|
@ -106,13 +106,12 @@ pub struct JSStackFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_property<'a>(
|
fn get_property<'a>(
|
||||||
scope: &mut impl v8::ToLocal<'a>,
|
scope: &mut v8::HandleScope<'a>,
|
||||||
context: v8::Local<v8::Context>,
|
|
||||||
object: v8::Local<v8::Object>,
|
object: v8::Local<v8::Object>,
|
||||||
key: &str,
|
key: &str,
|
||||||
) -> Option<v8::Local<'a, v8::Value>> {
|
) -> Option<v8::Local<'a, v8::Value>> {
|
||||||
let key = v8::String::new(scope, key).unwrap();
|
let key = v8::String::new(scope, key).unwrap();
|
||||||
object.get(scope, context, key.into())
|
object.get(scope, key.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JSError {
|
impl JSError {
|
||||||
|
@ -121,14 +120,12 @@ impl JSError {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_v8_exception(
|
pub fn from_v8_exception(
|
||||||
scope: &mut impl v8::InIsolate,
|
scope: &mut v8::HandleScope,
|
||||||
exception: v8::Local<v8::Value>,
|
exception: v8::Local<v8::Value>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// Create a new HandleScope because we're creating a lot of new local
|
// Create a new HandleScope because we're creating a lot of new local
|
||||||
// handles below.
|
// handles below.
|
||||||
let mut hs = v8::HandleScope::new(scope);
|
let scope = &mut v8::HandleScope::new(scope);
|
||||||
let scope = hs.enter();
|
|
||||||
let context = { scope.get_current_context().unwrap() };
|
|
||||||
|
|
||||||
let msg = v8::Exception::create_message(scope, exception);
|
let msg = v8::Exception::create_message(scope, exception);
|
||||||
|
|
||||||
|
@ -138,11 +135,11 @@ impl JSError {
|
||||||
exception.clone().try_into().unwrap();
|
exception.clone().try_into().unwrap();
|
||||||
|
|
||||||
// Get the message by formatting error.name and error.message.
|
// Get the message by formatting error.name and error.message.
|
||||||
let name = get_property(scope, context, exception, "name")
|
let name = get_property(scope, exception, "name")
|
||||||
.and_then(|m| m.to_string(scope))
|
.and_then(|m| m.to_string(scope))
|
||||||
.map(|s| s.to_rust_string_lossy(scope))
|
.map(|s| s.to_rust_string_lossy(scope))
|
||||||
.unwrap_or_else(|| "undefined".to_string());
|
.unwrap_or_else(|| "undefined".to_string());
|
||||||
let message_prop = get_property(scope, context, exception, "message")
|
let message_prop = get_property(scope, exception, "message")
|
||||||
.and_then(|m| m.to_string(scope))
|
.and_then(|m| m.to_string(scope))
|
||||||
.map(|s| s.to_rust_string_lossy(scope))
|
.map(|s| s.to_rust_string_lossy(scope))
|
||||||
.unwrap_or_else(|| "undefined".to_string());
|
.unwrap_or_else(|| "undefined".to_string());
|
||||||
|
@ -150,17 +147,16 @@ impl JSError {
|
||||||
|
|
||||||
// Access error.stack to ensure that prepareStackTrace() has been called.
|
// Access error.stack to ensure that prepareStackTrace() has been called.
|
||||||
// This should populate error.__callSiteEvals and error.__formattedFrames.
|
// This should populate error.__callSiteEvals and error.__formattedFrames.
|
||||||
let _ = get_property(scope, context, exception, "stack");
|
let _ = get_property(scope, exception, "stack");
|
||||||
|
|
||||||
// Read an array of structured frames from error.__callSiteEvals.
|
// Read an array of structured frames from error.__callSiteEvals.
|
||||||
let frames_v8 =
|
let frames_v8 = get_property(scope, exception, "__callSiteEvals");
|
||||||
get_property(scope, context, exception, "__callSiteEvals");
|
|
||||||
let frames_v8: Option<v8::Local<v8::Array>> =
|
let frames_v8: Option<v8::Local<v8::Array>> =
|
||||||
frames_v8.and_then(|a| a.try_into().ok());
|
frames_v8.and_then(|a| a.try_into().ok());
|
||||||
|
|
||||||
// Read an array of pre-formatted frames from error.__formattedFrames.
|
// Read an array of pre-formatted frames from error.__formattedFrames.
|
||||||
let formatted_frames_v8 =
|
let formatted_frames_v8 =
|
||||||
get_property(scope, context, exception, "__formattedFrames");
|
get_property(scope, exception, "__formattedFrames");
|
||||||
let formatted_frames_v8: Option<v8::Local<v8::Array>> =
|
let formatted_frames_v8: Option<v8::Local<v8::Array>> =
|
||||||
formatted_frames_v8.and_then(|a| a.try_into().ok());
|
formatted_frames_v8.and_then(|a| a.try_into().ok());
|
||||||
|
|
||||||
|
@ -171,92 +167,89 @@ impl JSError {
|
||||||
(frames_v8, formatted_frames_v8)
|
(frames_v8, formatted_frames_v8)
|
||||||
{
|
{
|
||||||
for i in 0..frames_v8.length() {
|
for i in 0..frames_v8.length() {
|
||||||
let call_site: v8::Local<v8::Object> = frames_v8
|
let call_site: v8::Local<v8::Object> =
|
||||||
.get_index(scope, context, i)
|
frames_v8.get_index(scope, i).unwrap().try_into().unwrap();
|
||||||
.unwrap()
|
|
||||||
.try_into()
|
|
||||||
.unwrap();
|
|
||||||
let type_name: Option<v8::Local<v8::String>> =
|
let type_name: Option<v8::Local<v8::String>> =
|
||||||
get_property(scope, context, call_site, "typeName")
|
get_property(scope, call_site, "typeName")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.ok();
|
.ok();
|
||||||
let type_name = type_name.map(|s| s.to_rust_string_lossy(scope));
|
let type_name = type_name.map(|s| s.to_rust_string_lossy(scope));
|
||||||
let function_name: Option<v8::Local<v8::String>> =
|
let function_name: Option<v8::Local<v8::String>> =
|
||||||
get_property(scope, context, call_site, "functionName")
|
get_property(scope, call_site, "functionName")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.ok();
|
.ok();
|
||||||
let function_name =
|
let function_name =
|
||||||
function_name.map(|s| s.to_rust_string_lossy(scope));
|
function_name.map(|s| s.to_rust_string_lossy(scope));
|
||||||
let method_name: Option<v8::Local<v8::String>> =
|
let method_name: Option<v8::Local<v8::String>> =
|
||||||
get_property(scope, context, call_site, "methodName")
|
get_property(scope, call_site, "methodName")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.ok();
|
.ok();
|
||||||
let method_name = method_name.map(|s| s.to_rust_string_lossy(scope));
|
let method_name = method_name.map(|s| s.to_rust_string_lossy(scope));
|
||||||
let file_name: Option<v8::Local<v8::String>> =
|
let file_name: Option<v8::Local<v8::String>> =
|
||||||
get_property(scope, context, call_site, "fileName")
|
get_property(scope, call_site, "fileName")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.ok();
|
.ok();
|
||||||
let file_name = file_name.map(|s| s.to_rust_string_lossy(scope));
|
let file_name = file_name.map(|s| s.to_rust_string_lossy(scope));
|
||||||
let line_number: Option<v8::Local<v8::Integer>> =
|
let line_number: Option<v8::Local<v8::Integer>> =
|
||||||
get_property(scope, context, call_site, "lineNumber")
|
get_property(scope, call_site, "lineNumber")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.ok();
|
.ok();
|
||||||
let line_number = line_number.map(|n| n.value());
|
let line_number = line_number.map(|n| n.value());
|
||||||
let column_number: Option<v8::Local<v8::Integer>> =
|
let column_number: Option<v8::Local<v8::Integer>> =
|
||||||
get_property(scope, context, call_site, "columnNumber")
|
get_property(scope, call_site, "columnNumber")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.ok();
|
.ok();
|
||||||
let column_number = column_number.map(|n| n.value());
|
let column_number = column_number.map(|n| n.value());
|
||||||
let eval_origin: Option<v8::Local<v8::String>> =
|
let eval_origin: Option<v8::Local<v8::String>> =
|
||||||
get_property(scope, context, call_site, "evalOrigin")
|
get_property(scope, call_site, "evalOrigin")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.ok();
|
.ok();
|
||||||
let eval_origin = eval_origin.map(|s| s.to_rust_string_lossy(scope));
|
let eval_origin = eval_origin.map(|s| s.to_rust_string_lossy(scope));
|
||||||
let is_top_level: Option<v8::Local<v8::Boolean>> =
|
let is_top_level: Option<v8::Local<v8::Boolean>> =
|
||||||
get_property(scope, context, call_site, "isTopLevel")
|
get_property(scope, call_site, "isTopLevel")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.ok();
|
.ok();
|
||||||
let is_top_level = is_top_level.map(|b| b.is_true());
|
let is_top_level = is_top_level.map(|b| b.is_true());
|
||||||
let is_eval: v8::Local<v8::Boolean> =
|
let is_eval: v8::Local<v8::Boolean> =
|
||||||
get_property(scope, context, call_site, "isEval")
|
get_property(scope, call_site, "isEval")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let is_eval = is_eval.is_true();
|
let is_eval = is_eval.is_true();
|
||||||
let is_native: v8::Local<v8::Boolean> =
|
let is_native: v8::Local<v8::Boolean> =
|
||||||
get_property(scope, context, call_site, "isNative")
|
get_property(scope, call_site, "isNative")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let is_native = is_native.is_true();
|
let is_native = is_native.is_true();
|
||||||
let is_constructor: v8::Local<v8::Boolean> =
|
let is_constructor: v8::Local<v8::Boolean> =
|
||||||
get_property(scope, context, call_site, "isConstructor")
|
get_property(scope, call_site, "isConstructor")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let is_constructor = is_constructor.is_true();
|
let is_constructor = is_constructor.is_true();
|
||||||
let is_async: v8::Local<v8::Boolean> =
|
let is_async: v8::Local<v8::Boolean> =
|
||||||
get_property(scope, context, call_site, "isAsync")
|
get_property(scope, call_site, "isAsync")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let is_async = is_async.is_true();
|
let is_async = is_async.is_true();
|
||||||
let is_promise_all: v8::Local<v8::Boolean> =
|
let is_promise_all: v8::Local<v8::Boolean> =
|
||||||
get_property(scope, context, call_site, "isPromiseAll")
|
get_property(scope, call_site, "isPromiseAll")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let is_promise_all = is_promise_all.is_true();
|
let is_promise_all = is_promise_all.is_true();
|
||||||
let promise_index: Option<v8::Local<v8::Integer>> =
|
let promise_index: Option<v8::Local<v8::Integer>> =
|
||||||
get_property(scope, context, call_site, "columnNumber")
|
get_property(scope, call_site, "columnNumber")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.ok();
|
.ok();
|
||||||
|
@ -278,7 +271,7 @@ impl JSError {
|
||||||
promise_index,
|
promise_index,
|
||||||
});
|
});
|
||||||
let formatted_frame: v8::Local<v8::String> = formatted_frames_v8
|
let formatted_frame: v8::Local<v8::String> = formatted_frames_v8
|
||||||
.get_index(scope, context, i)
|
.get_index(scope, i)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -301,9 +294,9 @@ impl JSError {
|
||||||
.and_then(|v| v8::Local::<v8::String>::try_from(v).ok())
|
.and_then(|v| v8::Local::<v8::String>::try_from(v).ok())
|
||||||
.map(|v| v.to_rust_string_lossy(scope)),
|
.map(|v| v.to_rust_string_lossy(scope)),
|
||||||
source_line: msg
|
source_line: msg
|
||||||
.get_source_line(scope, context)
|
.get_source_line(scope)
|
||||||
.map(|v| v.to_rust_string_lossy(scope)),
|
.map(|v| v.to_rust_string_lossy(scope)),
|
||||||
line_number: msg.get_line_number(context).and_then(|v| v.try_into().ok()),
|
line_number: msg.get_line_number(scope).and_then(|v| v.try_into().ok()),
|
||||||
start_column: msg.get_start_column().try_into().ok(),
|
start_column: msg.get_start_column().try_into().ok(),
|
||||||
end_column: msg.get_end_column().try_into().ok(),
|
end_column: msg.get_end_column().try_into().ok(),
|
||||||
frames,
|
frames,
|
||||||
|
@ -365,7 +358,7 @@ impl fmt::Display for JSError {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn attach_handle_to_error(
|
pub(crate) fn attach_handle_to_error(
|
||||||
scope: &mut impl v8::InIsolate,
|
scope: &mut v8::Isolate,
|
||||||
err: ErrBox,
|
err: ErrBox,
|
||||||
handle: v8::Local<v8::Value>,
|
handle: v8::Local<v8::Value>,
|
||||||
) -> ErrBox {
|
) -> ErrBox {
|
||||||
|
@ -381,7 +374,7 @@ pub struct ErrWithV8Handle {
|
||||||
|
|
||||||
impl ErrWithV8Handle {
|
impl ErrWithV8Handle {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
scope: &mut impl v8::InIsolate,
|
scope: &mut v8::Isolate,
|
||||||
err: ErrBox,
|
err: ErrBox,
|
||||||
handle: v8::Local<v8::Value>,
|
handle: v8::Local<v8::Value>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
|
|
@ -111,14 +111,11 @@ impl EsIsolate {
|
||||||
source: &str,
|
source: &str,
|
||||||
) -> Result<ModuleId, ErrBox> {
|
) -> Result<ModuleId, ErrBox> {
|
||||||
let state_rc = Self::state(self);
|
let state_rc = Self::state(self);
|
||||||
|
|
||||||
let core_state_rc = CoreIsolate::state(self);
|
let core_state_rc = CoreIsolate::state(self);
|
||||||
let core_state = core_state_rc.borrow();
|
let core_state = core_state_rc.borrow();
|
||||||
let mut hs = v8::HandleScope::new(&mut self.0);
|
let scope = &mut v8::HandleScope::new(&mut *self.0);
|
||||||
let scope = hs.enter();
|
|
||||||
let context = core_state.global_context.get(scope).unwrap();
|
let context = core_state.global_context.get(scope).unwrap();
|
||||||
let mut cs = v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
let scope = cs.enter();
|
|
||||||
|
|
||||||
let name_str = v8::String::new(scope, name).unwrap();
|
let name_str = v8::String::new(scope, name).unwrap();
|
||||||
let source_str = v8::String::new(scope, source).unwrap();
|
let source_str = v8::String::new(scope, source).unwrap();
|
||||||
|
@ -126,15 +123,14 @@ impl EsIsolate {
|
||||||
let origin = bindings::module_origin(scope, name_str);
|
let origin = bindings::module_origin(scope, name_str);
|
||||||
let source = v8::script_compiler::Source::new(source_str, &origin);
|
let source = v8::script_compiler::Source::new(source_str, &origin);
|
||||||
|
|
||||||
let mut try_catch = v8::TryCatch::new(scope);
|
let tc_scope = &mut v8::TryCatch::new(scope);
|
||||||
let tc = try_catch.enter();
|
|
||||||
|
|
||||||
let maybe_module = v8::script_compiler::compile_module(scope, source);
|
let maybe_module = v8::script_compiler::compile_module(tc_scope, source);
|
||||||
|
|
||||||
if tc.has_caught() {
|
if tc_scope.has_caught() {
|
||||||
assert!(maybe_module.is_none());
|
assert!(maybe_module.is_none());
|
||||||
let e = tc.exception(scope).unwrap();
|
let e = tc_scope.exception().unwrap();
|
||||||
return exception_to_err_result(scope, e);
|
return exception_to_err_result(tc_scope, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
let module = maybe_module.unwrap();
|
let module = maybe_module.unwrap();
|
||||||
|
@ -143,7 +139,7 @@ impl EsIsolate {
|
||||||
let mut import_specifiers: Vec<ModuleSpecifier> = vec![];
|
let mut import_specifiers: Vec<ModuleSpecifier> = vec![];
|
||||||
for i in 0..module.get_module_requests_length() {
|
for i in 0..module.get_module_requests_length() {
|
||||||
let import_specifier =
|
let import_specifier =
|
||||||
module.get_module_request(i).to_rust_string_lossy(scope);
|
module.get_module_request(i).to_rust_string_lossy(tc_scope);
|
||||||
let state = state_rc.borrow();
|
let state = state_rc.borrow();
|
||||||
let module_specifier =
|
let module_specifier =
|
||||||
state.loader.resolve(&import_specifier, name, false)?;
|
state.loader.resolve(&import_specifier, name, false)?;
|
||||||
|
@ -151,7 +147,7 @@ impl EsIsolate {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut handle = v8::Global::<v8::Module>::new();
|
let mut handle = v8::Global::<v8::Module>::new();
|
||||||
handle.set(scope, module);
|
handle.set(tc_scope, module);
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut state = state_rc.borrow_mut();
|
let mut state = state_rc.borrow_mut();
|
||||||
|
@ -173,34 +169,30 @@ impl EsIsolate {
|
||||||
|
|
||||||
let core_state_rc = CoreIsolate::state(self);
|
let core_state_rc = CoreIsolate::state(self);
|
||||||
let core_state = core_state_rc.borrow();
|
let core_state = core_state_rc.borrow();
|
||||||
let mut hs = v8::HandleScope::new(&mut self.0);
|
let scope = &mut v8::HandleScope::new(&mut *self.0);
|
||||||
let scope = hs.enter();
|
|
||||||
let context = core_state.global_context.get(scope).unwrap();
|
let context = core_state.global_context.get(scope).unwrap();
|
||||||
let mut cs = v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
let scope = cs.enter();
|
let tc_scope = &mut v8::TryCatch::new(scope);
|
||||||
|
|
||||||
let mut try_catch = v8::TryCatch::new(scope);
|
|
||||||
let tc = try_catch.enter();
|
|
||||||
|
|
||||||
let module_info = match state.modules.get_info(id) {
|
let module_info = match state.modules.get_info(id) {
|
||||||
Some(info) => info,
|
Some(info) => info,
|
||||||
None if id == 0 => return Ok(()),
|
None if id == 0 => return Ok(()),
|
||||||
_ => panic!("module id {} not found in module table", id),
|
_ => panic!("module id {} not found in module table", id),
|
||||||
};
|
};
|
||||||
let mut module = module_info.handle.get(scope).unwrap();
|
let module = module_info.handle.get(tc_scope).unwrap();
|
||||||
drop(state);
|
drop(state);
|
||||||
|
|
||||||
if module.get_status() == v8::ModuleStatus::Errored {
|
if module.get_status() == v8::ModuleStatus::Errored {
|
||||||
exception_to_err_result(scope, module.get_exception())?
|
exception_to_err_result(tc_scope, module.get_exception())?
|
||||||
}
|
}
|
||||||
|
|
||||||
let result =
|
let result =
|
||||||
module.instantiate_module(context, bindings::module_resolve_callback);
|
module.instantiate_module(tc_scope, bindings::module_resolve_callback);
|
||||||
match result {
|
match result {
|
||||||
Some(_) => Ok(()),
|
Some(_) => Ok(()),
|
||||||
None => {
|
None => {
|
||||||
let exception = tc.exception(scope).unwrap();
|
let exception = tc_scope.exception().unwrap();
|
||||||
exception_to_err_result(scope, exception)
|
exception_to_err_result(tc_scope, exception)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,14 +209,12 @@ impl EsIsolate {
|
||||||
|
|
||||||
let core_state_rc = CoreIsolate::state(self);
|
let core_state_rc = CoreIsolate::state(self);
|
||||||
|
|
||||||
let mut hs = v8::HandleScope::new(&mut self.0);
|
let scope = &mut v8::HandleScope::new(&mut *self.0);
|
||||||
let scope = hs.enter();
|
|
||||||
let context = {
|
let context = {
|
||||||
let core_state = core_state_rc.borrow();
|
let core_state = core_state_rc.borrow();
|
||||||
core_state.global_context.get(scope).unwrap()
|
core_state.global_context.get(scope).unwrap()
|
||||||
};
|
};
|
||||||
let mut cs = v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
let scope = cs.enter();
|
|
||||||
|
|
||||||
let info = state.modules.get_info(id).expect("ModuleInfo not found");
|
let info = state.modules.get_info(id).expect("ModuleInfo not found");
|
||||||
let module = info.handle.get(scope).expect("Empty module handle");
|
let module = info.handle.get(scope).expect("Empty module handle");
|
||||||
|
@ -247,7 +237,7 @@ impl EsIsolate {
|
||||||
// For more details see:
|
// For more details see:
|
||||||
// https://github.com/denoland/deno/issues/4908
|
// https://github.com/denoland/deno/issues/4908
|
||||||
// https://v8.dev/features/top-level-await#module-execution-order
|
// https://v8.dev/features/top-level-await#module-execution-order
|
||||||
let maybe_value = module.evaluate(scope, context);
|
let maybe_value = module.evaluate(scope);
|
||||||
|
|
||||||
// Update status after evaluating.
|
// Update status after evaluating.
|
||||||
status = module.get_status();
|
status = module.get_status();
|
||||||
|
@ -293,11 +283,9 @@ impl EsIsolate {
|
||||||
let core_state_rc = CoreIsolate::state(self);
|
let core_state_rc = CoreIsolate::state(self);
|
||||||
let core_state = core_state_rc.borrow();
|
let core_state = core_state_rc.borrow();
|
||||||
|
|
||||||
let mut hs = v8::HandleScope::new(&mut self.0);
|
let scope = &mut v8::HandleScope::new(&mut *self.0);
|
||||||
let scope = hs.enter();
|
|
||||||
let context = core_state.global_context.get(scope).unwrap();
|
let context = core_state.global_context.get(scope).unwrap();
|
||||||
let mut cs = v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
let scope = cs.enter();
|
|
||||||
|
|
||||||
drop(core_state);
|
drop(core_state);
|
||||||
|
|
||||||
|
@ -319,8 +307,8 @@ impl EsIsolate {
|
||||||
v8::Exception::type_error(scope, message)
|
v8::Exception::type_error(scope, message)
|
||||||
});
|
});
|
||||||
|
|
||||||
resolver.reject(context, exception).unwrap();
|
resolver.reject(scope, exception).unwrap();
|
||||||
scope.isolate().run_microtasks();
|
scope.run_microtasks();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,14 +323,12 @@ impl EsIsolate {
|
||||||
|
|
||||||
debug!("dyn_import_done {} {:?}", id, mod_id);
|
debug!("dyn_import_done {} {:?}", id, mod_id);
|
||||||
assert!(mod_id != 0);
|
assert!(mod_id != 0);
|
||||||
let mut hs = v8::HandleScope::new(&mut self.0);
|
let scope = &mut v8::HandleScope::new(&mut *self.0);
|
||||||
let scope = hs.enter();
|
|
||||||
let context = {
|
let context = {
|
||||||
let core_state = core_state_rc.borrow();
|
let core_state = core_state_rc.borrow();
|
||||||
core_state.global_context.get(scope).unwrap()
|
core_state.global_context.get(scope).unwrap()
|
||||||
};
|
};
|
||||||
let mut cs = v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
let scope = cs.enter();
|
|
||||||
|
|
||||||
let mut resolver_handle = {
|
let mut resolver_handle = {
|
||||||
let mut state = state_rc.borrow_mut();
|
let mut state = state_rc.borrow_mut();
|
||||||
|
@ -366,8 +352,8 @@ impl EsIsolate {
|
||||||
assert_eq!(module.get_status(), v8::ModuleStatus::Evaluated);
|
assert_eq!(module.get_status(), v8::ModuleStatus::Evaluated);
|
||||||
|
|
||||||
let module_namespace = module.get_module_namespace();
|
let module_namespace = module.get_module_namespace();
|
||||||
resolver.resolve(context, module_namespace).unwrap();
|
resolver.resolve(scope, module_namespace).unwrap();
|
||||||
scope.isolate().run_microtasks();
|
scope.run_microtasks();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ unsafe impl Send for ZeroCopyBuf {}
|
||||||
|
|
||||||
impl ZeroCopyBuf {
|
impl ZeroCopyBuf {
|
||||||
pub fn new<'s>(
|
pub fn new<'s>(
|
||||||
scope: &mut impl v8::ToLocal<'s>,
|
scope: &mut v8::HandleScope<'s>,
|
||||||
view: v8::Local<v8::ArrayBufferView>,
|
view: v8::Local<v8::ArrayBufferView>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let backing_store = view.buffer(scope).unwrap().get_backing_store();
|
let backing_store = view.buffer(scope).unwrap().get_backing_store();
|
||||||
|
|
Loading…
Reference in a new issue