Stabel

Check-in [9c5f55e7c2]
Login
Overview
Comment:Simplify implementation of __copy_struct by using memory_copy instruction.
Timelines: family | ancestors | descendants | both | arrays
Files: files | file ages | folders
SHA3-256: 9c5f55e7c2ac6650f358f58d8852f71351b7aa564beef48a4f60349877ce4fcc
User & Date: robin.hansen on 2021-08-29 17:14:54
Other Links: branch diff | manifest | tags
Context
2021-08-29
17:24
Simplify implementation of array-set by using a block and break-if instead of using if instructions ... check-in: bc0bc601c3 user: robin.hansen tags: arrays
17:14
Simplify implementation of __copy_struct by using memory_copy instruction. check-in: 9c5f55e7c2 user: robin.hansen tags: arrays
2021-08-28
17:56
Implement array-set. check-in: c00f05aca3 user: robin.hansen tags: arrays
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified src/Stabel/Codegen/BaseModule.elm from [70add3368f] to [f2161dd629].

335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
      , name = copyStructFn
      , args = [ Wasm.Int32, Wasm.Int32 ]
      , results = [ Wasm.Int32 ]
      , locals = [ Wasm.Int32, Wasm.Int32 ]
      , instructions =
            [ Wasm.Local_Get 1 -- Size in bytes
            , callAllocFn
            , Wasm.Local_Set 2 -- Save output instance
            , Wasm.Block
                [ Wasm.Loop
                    [ Wasm.Local_Get 1
                    , Wasm.I32_EqZero
                    , Wasm.BreakIf 1 -- break out of loop
                    , Wasm.Local_Get 1
                    , Wasm.I32_Const wasmPtrSize
                    , Wasm.I32_Sub
                    , Wasm.Local_Set 1 -- Decreased pointer size
                    , Wasm.Local_Get 0 -- Source struct
                    , Wasm.Local_Get 1
                    , Wasm.I32_Add
                    , Wasm.I32_Load -- Get a byte from source struct
                    , Wasm.Local_Set 3 -- Save byte to copy
                    , Wasm.Local_Get 2 -- Dest struct
                    , Wasm.Local_Get 1
                    , Wasm.I32_Add
                    , Wasm.Local_Get 3
                    , Wasm.I32_Store -- Copy byte from source to dest struct
                    , Wasm.Break 0 -- loop
                    ]
                ]
            , Wasm.Local_Get 2
            ]
      }
    , { id = 3
      , name = stackPushFn
      , args = [ Wasm.Int32 ]
      , results = []







<
<
<
<
<
<
|
<
<
<
<
|
<
<
<
<
|
|
<
<
<
<
<







335
336
337
338
339
340
341






342




343




344
345





346
347
348
349
350
351
352
      , name = copyStructFn
      , args = [ Wasm.Int32, Wasm.Int32 ]
      , results = [ Wasm.Int32 ]
      , locals = [ Wasm.Int32, Wasm.Int32 ]
      , instructions =
            [ Wasm.Local_Get 1 -- Size in bytes
            , callAllocFn






            , Wasm.Local_Tee 2 -- Output struct




            , Wasm.Local_Get 0 -- Original struct




            , Wasm.Local_Get 1
            , Wasm.Memory_Copy





            , Wasm.Local_Get 2
            ]
      }
    , { id = 3
      , name = stackPushFn
      , args = [ Wasm.Int32 ]
      , results = []