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·wasmDiv(SB), NOSPLIT, $0-0
     8  	Get R0
     9  	I64Const $-0x8000000000000000
    10  	I64Eq
    11  	If
    12  		Get R1
    13  		I64Const $-1
    14  		I64Eq
    15  		If
    16  			I64Const $-0x8000000000000000
    17  			Return
    18  		End
    19  	End
    20  	Get R0
    21  	Get R1
    22  	I64DivS
    23  	Return
    24  
    25  TEXT runtime·wasmTruncS(SB), NOSPLIT, $0-0
    26  	Get R0
    27  	Get R0
    28  	F64Ne // NaN
    29  	If
    30  		I64Const $0x8000000000000000
    31  		Return
    32  	End
    33  
    34  	Get R0
    35  	F64Const $0x7ffffffffffffc00p0 // Maximum truncated representation of 0x7fffffffffffffff
    36  	F64Gt
    37  	If
    38  		I64Const $0x8000000000000000
    39  		Return
    40  	End
    41  
    42  	Get R0
    43  	F64Const $-0x7ffffffffffffc00p0 // Minimum truncated representation of -0x8000000000000000
    44  	F64Lt
    45  	If
    46  		I64Const $0x8000000000000000
    47  		Return
    48  	End
    49  
    50  	Get R0
    51  	I64TruncF64S
    52  	Return
    53  
    54  TEXT runtime·wasmTruncU(SB), NOSPLIT, $0-0
    55  	Get R0
    56  	Get R0
    57  	F64Ne // NaN
    58  	If
    59  		I64Const $0x8000000000000000
    60  		Return
    61  	End
    62  
    63  	Get R0
    64  	F64Const $0xfffffffffffff800p0 // Maximum truncated representation of 0xffffffffffffffff
    65  	F64Gt
    66  	If
    67  		I64Const $0x8000000000000000
    68  		Return
    69  	End
    70  
    71  	Get R0
    72  	F64Const $0.
    73  	F64Lt
    74  	If
    75  		I64Const $0x8000000000000000
    76  		Return
    77  	End
    78  
    79  	Get R0
    80  	I64TruncF64U
    81  	Return
    82  
    83  TEXT runtime·exitThread(SB), NOSPLIT, $0-0
    84  	UNDEF
    85  
    86  TEXT runtime·osyield(SB), NOSPLIT, $0-0
    87  	UNDEF
    88  
    89  TEXT runtime·usleep(SB), NOSPLIT, $0-0
    90  	RET // TODO(neelance): implement usleep
    91  
    92  TEXT runtime·currentMemory(SB), NOSPLIT, $0
    93  	Get SP
    94  	CurrentMemory
    95  	I32Store ret+0(FP)
    96  	RET
    97  
    98  TEXT runtime·growMemory(SB), NOSPLIT, $0
    99  	Get SP
   100  	I32Load pages+0(FP)
   101  	GrowMemory
   102  	I32Store ret+8(FP)
   103  	RET
   104  
   105  TEXT ·resetMemoryDataView(SB), NOSPLIT, $0
   106  	CallImport
   107  	RET
   108  
   109  TEXT ·wasmExit(SB), NOSPLIT, $0
   110  	CallImport
   111  	RET
   112  
   113  TEXT ·wasmWrite(SB), NOSPLIT, $0
   114  	CallImport
   115  	RET
   116  
   117  TEXT ·nanotime1(SB), NOSPLIT, $0
   118  	CallImport
   119  	RET
   120  
   121  TEXT ·walltime(SB), NOSPLIT, $0
   122  	CallImport
   123  	RET
   124  
   125  TEXT ·scheduleTimeoutEvent(SB), NOSPLIT, $0
   126  	CallImport
   127  	RET
   128  
   129  TEXT ·clearTimeoutEvent(SB), NOSPLIT, $0
   130  	CallImport
   131  	RET
   132  
   133  TEXT ·getRandomData(SB), NOSPLIT, $0
   134  	CallImport
   135  	RET
   136  

View as plain text