Text file src/runtime/sys_wasm.s

     1  // Copyright 2018 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  #include "textflag.h"
     6  
     7  TEXT runtime·wasmMove(SB), NOSPLIT, $0-0
     8  loop:
     9  	Loop
    10  		// *dst = *src
    11  		Get R0
    12  		Get R1
    13  		I64Load $0
    14  		I64Store $0
    15  
    16  		// n--
    17  		Get R2
    18  		I32Const $1
    19  		I32Sub
    20  		Tee R2
    21  
    22  		// n == 0
    23  		I32Eqz
    24  		If
    25  			Return
    26  		End
    27  
    28  		// dst += 8
    29  		Get R0
    30  		I32Const $8
    31  		I32Add
    32  		Set R0
    33  
    34  		// src += 8
    35  		Get R1
    36  		I32Const $8
    37  		I32Add
    38  		Set R1
    39  
    40  		Br loop
    41  	End
    42  	UNDEF
    43  
    44  TEXT runtime·wasmZero(SB), NOSPLIT, $0-0
    45  loop:
    46  	Loop
    47  		// *dst = 0
    48  		Get R0
    49  		I64Const $0
    50  		I64Store $0
    51  
    52  		// n--
    53  		Get R1
    54  		I32Const $1
    55  		I32Sub
    56  		Tee R1
    57  
    58  		// n == 0
    59  		I32Eqz
    60  		If
    61  			Return
    62  		End
    63  
    64  		// dst += 8
    65  		Get R0
    66  		I32Const $8
    67  		I32Add
    68  		Set R0
    69  
    70  		Br loop
    71  	End
    72  	UNDEF
    73  
    74  TEXT runtime·wasmDiv(SB), NOSPLIT, $0-0
    75  	Get R0
    76  	I64Const $-0x8000000000000000
    77  	I64Eq
    78  	If
    79  		Get R1
    80  		I64Const $-1
    81  		I64Eq
    82  		If
    83  			I64Const $-0x8000000000000000
    84  			Return
    85  		End
    86  	End
    87  	Get R0
    88  	Get R1
    89  	I64DivS
    90  	Return
    91  
    92  TEXT runtime·wasmTruncS(SB), NOSPLIT, $0-0
    93  	Get R0
    94  	Get R0
    95  	F64Ne // NaN
    96  	If
    97  		I64Const $0x8000000000000000
    98  		Return
    99  	End
   100  
   101  	Get R0
   102  	F64Const $0x7ffffffffffffc00p0 // Maximum truncated representation of 0x7fffffffffffffff
   103  	F64Gt
   104  	If
   105  		I64Const $0x8000000000000000
   106  		Return
   107  	End
   108  
   109  	Get R0
   110  	F64Const $-0x7ffffffffffffc00p0 // Minimum truncated representation of -0x8000000000000000
   111  	F64Lt
   112  	If
   113  		I64Const $0x8000000000000000
   114  		Return
   115  	End
   116  
   117  	Get R0
   118  	I64TruncF64S
   119  	Return
   120  
   121  TEXT runtime·wasmTruncU(SB), NOSPLIT, $0-0
   122  	Get R0
   123  	Get R0
   124  	F64Ne // NaN
   125  	If
   126  		I64Const $0x8000000000000000
   127  		Return
   128  	End
   129  
   130  	Get R0
   131  	F64Const $0xfffffffffffff800p0 // Maximum truncated representation of 0xffffffffffffffff
   132  	F64Gt
   133  	If
   134  		I64Const $0x8000000000000000
   135  		Return
   136  	End
   137  
   138  	Get R0
   139  	F64Const $0.
   140  	F64Lt
   141  	If
   142  		I64Const $0x8000000000000000
   143  		Return
   144  	End
   145  
   146  	Get R0
   147  	I64TruncF64U
   148  	Return
   149  
   150  TEXT runtime·exitThread(SB), NOSPLIT, $0-0
   151  	UNDEF
   152  
   153  TEXT runtime·osyield(SB), NOSPLIT, $0-0
   154  	UNDEF
   155  
   156  TEXT runtime·usleep(SB), NOSPLIT, $0-0
   157  	RET // TODO(neelance): implement usleep
   158  
   159  TEXT runtime·currentMemory(SB), NOSPLIT, $0
   160  	Get SP
   161  	CurrentMemory
   162  	I32Store ret+0(FP)
   163  	RET
   164  
   165  TEXT runtime·growMemory(SB), NOSPLIT, $0
   166  	Get SP
   167  	I32Load pages+0(FP)
   168  	GrowMemory
   169  	I32Store ret+8(FP)
   170  	RET
   171  
   172  TEXT ·resetMemoryDataView(SB), NOSPLIT, $0
   173  	CallImport
   174  	RET
   175  
   176  TEXT ·wasmExit(SB), NOSPLIT, $0
   177  	CallImport
   178  	RET
   179  
   180  TEXT ·wasmWrite(SB), NOSPLIT, $0
   181  	CallImport
   182  	RET
   183  
   184  TEXT ·nanotime1(SB), NOSPLIT, $0
   185  	CallImport
   186  	RET
   187  
   188  TEXT ·walltime(SB), NOSPLIT, $0
   189  	CallImport
   190  	RET
   191  
   192  TEXT ·scheduleTimeoutEvent(SB), NOSPLIT, $0
   193  	CallImport
   194  	RET
   195  
   196  TEXT ·clearTimeoutEvent(SB), NOSPLIT, $0
   197  	CallImport
   198  	RET
   199  
   200  TEXT ·getRandomData(SB), NOSPLIT, $0
   201  	CallImport
   202  	RET
   203  

View as plain text