Xu Jun 5 лет назад
Родитель
Сommit
21efe12505
2 измененных файлов с 67 добавлено и 1 удалено
  1. 62 0
      core/iwasm/common/arch/invokeNative_em64.asm
  2. 5 1
      core/iwasm/common/iwasm_common.cmake

+ 62 - 0
core/iwasm/common/arch/invokeNative_em64.asm

@@ -0,0 +1,62 @@
+;
+; Copyright (C) 2019 Intel Corporation.  All rights reserved.
+; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+;
+
+_TEXT  SEGMENT
+    ; rcx func_ptr
+    ; rdx argv
+    ; r8 n_stacks
+
+invokeNative PROC
+    push rbp
+    mov rbp, rsp
+
+    mov r10, rcx    ; func_ptr
+    mov rax, rdx    ; argv
+    mov rcx, r8     ; n_stacks
+
+; fill all fp args
+    movsd xmm0, qword ptr [rax + 0]
+    movsd xmm1, qword ptr [rax + 8]
+    movsd xmm2, qword ptr [rax + 16]
+    movsd xmm3, qword ptr [rax + 24]
+
+; check for stack args
+    cmp rcx, 0
+    jz cycle_end
+
+    mov rdx, rsp
+    and rdx, 15
+    jz no_abort
+    int 3
+no_abort:
+    mov rdx, rcx
+    and rdx, 1
+    shl rdx, 3
+    sub rsp, rdx
+
+; store stack args
+    lea r9, qword ptr [rax + rcx * 8 + 64]
+    sub r9, rsp ; offset
+cycle:
+    push qword ptr [rsp + r9]
+    loop cycle
+
+cycle_end:
+    mov rcx, [rax + 32]
+    mov rdx, [rax + 40]
+    mov r8,  [rax + 48]
+    mov r9,  [rax + 56]
+
+    sub rsp, 32 ; shadow space
+
+    call r10
+    leave
+    ret
+
+invokeNative ENDP
+
+_TEXT   ENDS
+
+END

+ 5 - 1
core/iwasm/common/iwasm_common.cmake

@@ -11,7 +11,11 @@ add_definitions(-DBH_FREE=wasm_runtime_free)
 file (GLOB c_source_all ${IWASM_COMMON_DIR}/*.c)
 
 if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
-  set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_em64.s)
+  if (WAMR_BUILD_PLATFORM STREQUAL "windows")
+    set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_em64.asm)
+  else ()
+    set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_em64.s)
+  endif ()
 elseif (WAMR_BUILD_TARGET STREQUAL "X86_32")
   if (WAMR_BUILD_PLATFORM STREQUAL "windows")
     set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_ia32.asm)