Skip to content

Commit eb32f10

Browse files
bashorakozlova
authored andcommitted
[Wasm] Apply recent changes in TFR proposal and update v8
Type index immediate was added to call_ref and return_call_ref instructions. More details here WebAssembly/function-references#76
1 parent d1c2f74 commit eb32f10

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/BodyGenerator.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ class BodyGenerator(
396396

397397
body.buildStructGet(context.referenceGcType(klass.symbol), WasmSymbol(0))
398398
body.buildStructGet(context.referenceVTableGcType(klass.symbol), WasmSymbol(vfSlot))
399-
body.buildInstr(WasmOp.CALL_REF)
399+
body.buildInstr(WasmOp.CALL_REF, WasmImmediate.TypeIdx(context.referenceFunctionType(function.symbol)))
400400
} else {
401401
val symbol = klass.symbol
402402
if (symbol in hierarchyDisjointUnions) {
@@ -412,7 +412,7 @@ class BodyGenerator(
412412
.indexOfFirst { it.function == function }
413413

414414
body.buildStructGet(context.referenceVTableGcType(symbol), WasmSymbol(vfSlot))
415-
body.buildInstr(WasmOp.CALL_REF)
415+
body.buildInstr(WasmOp.CALL_REF, WasmImmediate.TypeIdx(context.referenceFunctionType(function.symbol)))
416416
} else {
417417
body.buildUnreachable()
418418
}
@@ -877,4 +877,3 @@ class BodyGenerator(
877877
return false
878878
}
879879
}
880-

gradle/versions.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ versions.protobuf-relocated=2.6.1-1
6464
versions.r8=2.2.64
6565
versions.robolectric=4.0
6666
versions.nodejs=18.12.1
67-
versions.v8=10.7.157
67+
versions.v8=10.9.130

libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8RootExtension.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ open class D8RootExtension(@Transient val rootProject: Project) : ConfigurationP
2525

2626
var installationPath by Property(gradleHome.resolve("d8"))
2727
var downloadBaseUrl by Property("https://storage.googleapis.com/chromium-v8/official/canary/")
28-
var version by Property("10.2.9")
28+
29+
// Latest version number could be found here https://storage.googleapis.com/chromium-v8/official/canary/v8-linux64-rel-latest.json
30+
var version by Property("10.9.130")
2931
var edition by Property("rel") // rel or dbg
3032

3133
val setupTaskProvider: TaskProvider<out Copy>

wasm/wasm.ir/src/org/jetbrains/kotlin/wasm/ir/Operators.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ enum class WasmOp(
338338
// ============================================================
339339
// Typed Function References
340340
// WIP: https://github.com/WebAssembly/function-references
341-
CALL_REF("call_ref", 0x14),
342-
RETURN_CALL_REF("return_call_ref", 0x15),
341+
CALL_REF("call_ref", 0x14, TYPE_IDX),
342+
RETURN_CALL_REF("return_call_ref", 0x15, TYPE_IDX),
343343
REF_AS_NOT_NULL("ref.as_non_null", 0xD3),
344344
BR_ON_NULL("br_on_null", 0xD4, LABEL_IDX),
345345
BR_ON_NON_NULL("br_on_non_null", 0xD6, LABEL_IDX),

0 commit comments

Comments
 (0)