[Wasm] Add compiler flag to disable exception handling proposal
Fail with unreachable instead of throwing an exception Merge-request: KT-MR-11481 Merged-by: Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
ec73815f80
commit
47ade4530c
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.js.JavaScript
|
||||
import org.jetbrains.kotlin.test.DebugMode
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.jetbrains.kotlin.test.directives.WasmEnvironmentConfigurationDirectives
|
||||
import org.jetbrains.kotlin.test.directives.WasmEnvironmentConfigurationDirectives.DISABLE_WASM_EXCEPTION_HANDLING
|
||||
import org.jetbrains.kotlin.test.directives.WasmEnvironmentConfigurationDirectives.RUN_UNIT_TESTS
|
||||
import org.jetbrains.kotlin.test.model.TestFile
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
@@ -191,6 +192,8 @@ class WasmBoxRunner(
|
||||
val testFileText = originalFile.readText()
|
||||
val failsIn: List<String> = InTextDirectivesUtils.findListWithPrefixes(testFileText, "// WASM_FAILS_IN: ")
|
||||
|
||||
val disableExceptions = DISABLE_WASM_EXCEPTION_HANDLING in testServices.moduleStructure.allDirectives
|
||||
|
||||
val exceptions = listOf(WasmVM.V8, WasmVM.SpiderMonkey).mapNotNull map@{ vm ->
|
||||
try {
|
||||
if (debugMode >= DebugMode.DEBUG) {
|
||||
@@ -199,7 +202,8 @@ class WasmBoxRunner(
|
||||
vm.run(
|
||||
"./${entryMjs}",
|
||||
jsFilePaths,
|
||||
workingDirectory = dir
|
||||
workingDirectory = dir,
|
||||
disableExceptionHandlingIfPossible = disableExceptions
|
||||
)
|
||||
if (vm.shortName in failsIn) {
|
||||
return@map AssertionError("The test expected to fail in ${vm.name}. Please update the testdata.")
|
||||
|
||||
@@ -17,10 +17,10 @@ internal sealed class WasmVM(val shortName: String) {
|
||||
val name: String = javaClass.simpleName
|
||||
protected val tool = ExternalTool(System.getProperty("javascript.engine.path.$name"))
|
||||
|
||||
abstract fun run(entryMjs: String, jsFiles: List<String>, workingDirectory: File?)
|
||||
abstract fun run(entryMjs: String, jsFiles: List<String>, workingDirectory: File?, disableExceptionHandlingIfPossible: Boolean = false)
|
||||
|
||||
object V8 : WasmVM("V8") {
|
||||
override fun run(entryMjs: String, jsFiles: List<String>, workingDirectory: File?) {
|
||||
override fun run(entryMjs: String, jsFiles: List<String>, workingDirectory: File?, disableExceptionHandlingIfPossible: Boolean) {
|
||||
tool.run(
|
||||
"--experimental-wasm-gc",
|
||||
"--wasm-final-types",
|
||||
@@ -34,10 +34,11 @@ internal sealed class WasmVM(val shortName: String) {
|
||||
}
|
||||
|
||||
object SpiderMonkey : WasmVM("SM") {
|
||||
override fun run(entryMjs: String, jsFiles: List<String>, workingDirectory: File?) {
|
||||
override fun run(entryMjs: String, jsFiles: List<String>, workingDirectory: File?, disableExceptionHandlingIfPossible: Boolean) {
|
||||
tool.run(
|
||||
"--wasm-verbose",
|
||||
"--wasm-gc",
|
||||
*if (disableExceptionHandlingIfPossible) arrayOf("--no-wasm-exceptions") else emptyArray(),
|
||||
"--wasm-function-references",
|
||||
*jsFiles.flatMap { listOf("-f", it) }.toTypedArray(),
|
||||
"--module=$entryMjs",
|
||||
|
||||
Reference in New Issue
Block a user