From 4faa8611c04e6a39cfc9aee10115946989f35ec7 Mon Sep 17 00:00:00 2001 From: Geoff Norton Date: Tue, 10 Feb 2015 21:56:48 -0800 Subject: [PATCH] Implement JIT_MemSet and JIT_MemCpy for clang The windows build has a hand written version of these functions, but modern systems should have an equivalent performant version of this. We do need to wrap them to get the trap for a null reference exception, but after that we can tail call directly. --- src/vm/CMakeLists.txt | 1 + src/vm/amd64/crthelpers.S | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/vm/amd64/crthelpers.S diff --git a/src/vm/CMakeLists.txt b/src/vm/CMakeLists.txt index f777e41..b89daac 100644 --- a/src/vm/CMakeLists.txt +++ b/src/vm/CMakeLists.txt @@ -326,6 +326,7 @@ set(VM_SOURCES_WKS_AMD64_ASM else() set(VM_SOURCES_WKS_AMD64_ASM + ${AMD64_SOURCES_DIR}/crthelpers.S ${AMD64_SOURCES_DIR}/jithelpers_fastwritebarriers.S ${AMD64_SOURCES_DIR}/jithelpers_slow.S ${AMD64_SOURCES_DIR}/jithelpers_fast.S diff --git a/src/vm/amd64/crthelpers.S b/src/vm/amd64/crthelpers.S new file mode 100644 index 0000000..0b36e00 --- /dev/null +++ b/src/vm/amd64/crthelpers.S @@ -0,0 +1,43 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Geoff Norton. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +.intel_syntax noprefix +#include "unixasmmacros.inc" +#include "asmconstants.h" + +// JIT_MemSet/JIT_MemCpy +// +// It is IMPORANT that the exception handling code is able to find these guys +// on the stack, but on non-windows platforms we can just defer to the platform +// implementation. +// + +LEAF_ENTRY JIT_MemSet, _TEXT + test rdx, rdx + jz Exit_MemSet + + cmp byte ptr [rdi], 0 + + jmp C_FUNC(memset) + +Exit_MemSet: + ret + +LEAF_END JIT_MemSet, _TEXT + +LEAF_ENTRY JIT_MemCpy, _TEXT + test rdx, rdx + jz Exit_MemCpy + + cmp byte ptr [rdi], 0 + cmp byte ptr [rsi], 0 + + jmp C_FUNC(memcpy) + +Exit_MemCpy: + ret + +LEAF_END JIT_MemCpy, _TEXT -- 2.7.4