Skip to content

Commit

Permalink
Bug 1599517 - Add support for bulk-memory operations with Cranelift. …
Browse files Browse the repository at this point in the history
…r=bbouvier

Depends on: bytecodealliance/cranelift#1258

This commit adds support for bulk-mem in CL using our builtin methods.

The major change is in wasm2clif where I added support for more declarative
'instance calls', and used them for the bulk-mem instructions.

Differential Revision: https://phabricator.services.mozilla.com/D54778

UltraBlame original commit: 9129ac29705f517e589fa6232c1987679e0f0e46
  • Loading branch information
marco-c committed Dec 10, 2019
1 parent db3e7ec commit 602957d
Show file tree
Hide file tree
Showing 6 changed files with 4,530 additions and 2,511 deletions.
24 changes: 0 additions & 24 deletions js/src/builtin/TestingFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4320,30 +4320,6 @@ isSupported
true
;
#
ifdef
ENABLE_WASM_CRANELIFT
if
(
cx
-
>
options
(
)
.
wasmCranelift
(
)
)
{
isSupported
=
false
;
}
#
endif
#
else
bool
isSupported
Expand Down
189 changes: 189 additions & 0 deletions js/src/wasm/WasmCraneliftCompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,174 @@ case
BD_SymbolicAddress
:
:
MemoryCopy
:
return
SymbolicAddress
:
:
MemCopy
;
case
BD_SymbolicAddress
:
:
MemoryCopyShared
:
return
SymbolicAddress
:
:
MemCopyShared
;
case
BD_SymbolicAddress
:
:
DataDrop
:
return
SymbolicAddress
:
:
DataDrop
;
case
BD_SymbolicAddress
:
:
MemoryFill
:
return
SymbolicAddress
:
:
MemFill
;
case
BD_SymbolicAddress
:
:
MemoryFillShared
:
return
SymbolicAddress
:
:
MemFillShared
;
case
BD_SymbolicAddress
:
:
MemoryInit
:
return
SymbolicAddress
:
:
MemInit
;
case
BD_SymbolicAddress
:
:
TableCopy
:
return
SymbolicAddress
:
:
TableCopy
;
case
BD_SymbolicAddress
:
:
ElemDrop
:
return
SymbolicAddress
:
:
ElemDrop
;
case
BD_SymbolicAddress
:
:
TableFill
:
return
SymbolicAddress
:
:
TableFill
;
case
BD_SymbolicAddress
:
:
TableGet
:
return
SymbolicAddress
:
:
TableGet
;
case
BD_SymbolicAddress
:
:
TableGrow
:
return
SymbolicAddress
:
:
TableGrow
;
case
BD_SymbolicAddress
:
:
TableInit
:
return
SymbolicAddress
:
:
TableInit
;
case
BD_SymbolicAddress
:
:
TableSet
:
return
SymbolicAddress
:
:
TableSet
;
case
BD_SymbolicAddress
:
:
TableSize
:
return
SymbolicAddress
:
:
TableSize
;
case
BD_SymbolicAddress
:
:
FloorF32
:
return
Expand Down Expand Up @@ -1506,6 +1674,27 @@ packed
)
;
}
bool
env_uses_shared_memory
(
const
CraneliftModuleEnvironment
*
wrapper
)
{
return
wrapper
-
>
env
-
>
usesSharedMemory
(
)
;
}
const
FuncTypeWithId
*
Expand Down
27 changes: 27 additions & 0 deletions js/src/wasm/cranelift/baldrapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,27 @@ packed
enum
class
BD_SymbolicAddress
:
uint32_t
{
MemoryGrow
=
0
MemorySize
MemoryCopy
MemoryCopyShared
DataDrop
MemoryFill
MemoryFillShared
MemoryInit
TableCopy
ElemDrop
TableFill
TableGet
TableGrow
TableInit
TableSet
TableSize
FloorF32
FloorF64
CeilF32
Expand Down Expand Up @@ -336,6 +354,15 @@ BD_ValType
type
)
;
bool
env_uses_shared_memory
(
const
CraneliftModuleEnvironment
*
env
)
;
const
js
:
Expand Down
24 changes: 24 additions & 0 deletions js/src/wasm/cranelift/src/bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,30 @@ env
}
pub
fn
uses_shared_memory
(
&
self
)
-
>
bool
{
unsafe
{
low_level
:
:
env_uses_shared_memory
(
self
.
env
)
}
}
pub
fn
function_signature
(
&
Expand Down
25 changes: 25 additions & 0 deletions js/src/wasm/cranelift/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ wasm2clif
init_sig
native_pointer_size
TransEnv
TRAP_THROW_REPORTED
}
;
const
Expand Down Expand Up @@ -2287,6 +2288,30 @@ TrapCode
:
User
(
x
)
if
x
=
=
TRAP_THROW_REPORTED
=
>
bindings
:
:
Trap
:
:
ThrowReported
ir
:
:
TrapCode
:
:
User
(
_
)
=
Expand Down
Loading

0 comments on commit 602957d

Please sign in to comment.