8GB_memory.wat 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. (module
  2. ;; Memory definition: 4 GB = 65536
  3. ;; 8 GB = 131072
  4. ;; 16 GB = 262144
  5. ;; 20 GB = 327680
  6. ;; 32 GB = 524288
  7. (memory (;0;) i64 131072 131072)
  8. ;; if touch too many pages more than physical memory can provide,
  9. ;; the signal will kill the process
  10. (func (export "touch_every_page") (result i64 i64 i32 i32)
  11. (local $i i64)
  12. i64.const 0x0000000000000ff8
  13. local.set $i
  14. loop $loop
  15. ;; a[i] = i
  16. local.get $i
  17. local.get $i
  18. i64.store
  19. local.get $i
  20. i64.const 4096
  21. i64.add
  22. local.set $i
  23. local.get $i
  24. ;; max boundary(exclusive) 8GB - 8 = 0x0000000200000000 - 8
  25. i64.const 0x0000000200000000
  26. i64.const 8
  27. i64.sub
  28. i64.lt_u
  29. br_if $loop
  30. end
  31. i64.const 0x000000000000fff8
  32. i64.load
  33. i64.const 0x000000010000fff8
  34. i64.load
  35. ;; lower 8 bytes of 0x000000010001fff8 -> 0x0001fff8
  36. i64.const 0x000000010001fff8
  37. i32.load
  38. ;; higher 8 bytes of 0x000000010001fff8 -> 0x1
  39. i64.const 0x000000010001fffc
  40. i32.load
  41. return
  42. )
  43. ;; Function to test i64.atomic.store with i64 address
  44. (func (export "i64_store_offset_4GB") (param $addr i64) (param $value i64)
  45. (i64.store offset=0x100000000 (local.get $addr) (local.get $value))
  46. )
  47. (func (export "i64_load_offset_4GB") (param $addr i64) (result i64)
  48. (i64.load offset=0x100000000 (local.get $addr))
  49. )
  50. )