Add gbs arm64 build support. accepted/tizen/unified/20200720.125602 submit/tizen/20200719.220954
authorMikhail Kurinnoi <m.kurinnoi@samsung.com>
Fri, 10 Jul 2020 16:02:16 +0000 (19:02 +0300)
committerAlexander Soldatov/AI Compiler Lab /SRR/Staff Engineer/Samsung Electronics <soldatov.a@samsung.com>
Fri, 17 Jul 2020 14:48:16 +0000 (17:48 +0300)
packaging/coreprofiler.spec
src/arch/arm64/archhelpers.cpp [new file with mode: 0644]
src/arch/arm64/asmhelpers.S [new file with mode: 0644]
src/trace/executiontrace.cpp

index 510f29020d2af15360bed202992d114c83d8ec0a..81714c69b12dad6c4f4b4e4a49d26a721c6b71e9 100644 (file)
@@ -9,8 +9,6 @@ License:   MIT
 Source0:   %{name}-%{version}.tar.gz
 Source1000: coreprofiler.manifest
 
-ExcludeArch: aarch64
-
 BuildRequires: cmake
 BuildRequires: clang >= 3.8
 BuildRequires: clang-devel >= 3.8
diff --git a/src/arch/arm64/archhelpers.cpp b/src/arch/arm64/archhelpers.cpp
new file mode 100644 (file)
index 0000000..7775076
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <sys/ucontext.h>
+
+#include <cor.h>
+#include <corhdr.h>
+#include <corprof.h>
+
+HRESULT ContextToStackSnapshotContext(
+    const void *context, CONTEXT *winContext) noexcept
+{
+    _ASSERTE(context != nullptr && winContext != nullptr);
+
+    *winContext = {CONTEXT_INTEGER};
+    const mcontext_t *mc =
+        &(reinterpret_cast<const ucontext_t*>(context))->uc_mcontext;
+
+    {
+        winContext->X0  = mc->regs[0];
+        winContext->X1  = mc->regs[1];
+        winContext->X2  = mc->regs[2];
+        winContext->X3  = mc->regs[3];
+        winContext->X4  = mc->regs[4];
+        winContext->X5  = mc->regs[5];
+        winContext->X6  = mc->regs[6];
+        winContext->X7  = mc->regs[7];
+        winContext->X8  = mc->regs[8];
+        winContext->X9  = mc->regs[9];
+        winContext->X10 = mc->regs[10];
+        winContext->X11 = mc->regs[11];
+        winContext->X12 = mc->regs[12];
+        winContext->X13 = mc->regs[13];
+        winContext->X14 = mc->regs[14];
+        winContext->X15 = mc->regs[15];
+        winContext->X16 = mc->regs[16];
+        winContext->X17 = mc->regs[17];
+        winContext->X18 = mc->regs[18];
+        winContext->X19 = mc->regs[19];
+        winContext->X20 = mc->regs[20];
+        winContext->X21 = mc->regs[21];
+        winContext->X22 = mc->regs[22];
+        winContext->X23 = mc->regs[23];
+        winContext->X24 = mc->regs[24];
+        winContext->X25 = mc->regs[25];
+        winContext->X26 = mc->regs[26];
+        winContext->X27 = mc->regs[27];
+        winContext->X28 = mc->regs[28];
+        winContext->Fp = mc->regs[29];
+        winContext->Lr = mc->regs[30];
+        winContext->Sp = mc->sp;
+        winContext->Pc = mc->pc;
+    }
+
+    return S_OK;
+}
diff --git a/src/arch/arm64/asmhelpers.S b/src/arch/arm64/asmhelpers.S
new file mode 100644 (file)
index 0000000..d91a85f
--- /dev/null
@@ -0,0 +1,81 @@
+#include "unixasmmacros.inc"
+
+// EnterNaked3, LeaveNaked3, TailcallNaked3
+// On entry:
+//   x10 = functionIDOrClientID
+//   x11 = profiledSp
+//   x12 = throwable
+//
+// On exit:
+//   Values of x0-x8, q0-q7, fp are preserved.
+//   Values of other volatile registers are not preserved.
+
+.macro PUSH_REGS
+    stp fp, lr, [sp, #-16]!
+
+    stp x0, x1, [sp, #-16]!
+    stp x2, x3, [sp, #-16]!
+    stp x4, x5, [sp, #-16]!
+    stp x6, x7, [sp, #-16]!
+    str x8, [sp, #-8]!
+    sub sp, sp, #8
+
+    stp q0, q1, [sp, #-32]!
+    stp q2, q3, [sp, #-32]!
+    stp q4, q5, [sp, #-32]!
+    stp q6, q7, [sp, #-32]!
+.endm
+
+.macro POP_REGS
+    ldp q6, q7, [sp], #32
+    ldp q4, q5, [sp], #32
+    ldp q2, q3, [sp], #32
+    ldp q0, q1, [sp], #32
+
+    add sp, sp, #8
+    ldr x8, [sp], #8
+    ldp x6, x7, [sp], #16
+    ldp x4, x5, [sp], #16
+    ldp x2, x3, [sp], #16
+    ldp x0, x1, [sp], #16
+
+    ldp fp, lr, [sp], #16
+.endm
+
+//
+// EXTERN_C void EnterNaked3(FunctionIDOrClientID functionIDOrClientID);
+//
+NESTED_ENTRY EnterNaked3, _TEXT, NoHandler
+    PUSH_REGS
+    mov x0, x10
+    bl C_FUNC(EnterStub)
+    POP_REGS
+    ret lr
+NESTED_END EnterNaked3, _TEXT
+
+//
+// EXTERN_C void LeaveNaked3(FunctionIDOrClientID functionIDOrClientID);
+//
+NESTED_ENTRY LeaveNaked3, _TEXT, NoHandler
+    PUSH_REGS
+    mov x0, x10
+    bl C_FUNC(LeaveStub)
+    POP_REGS
+    ret lr
+NESTED_END LeaveNaked3, _TEXT
+
+//
+// EXTERN_C void TailcallNaked3(FunctionIDOrClientID functionIDOrClientID);
+//
+NESTED_ENTRY TailcallNaked3, _TEXT, NoHandler
+    PUSH_REGS
+    mov x0, x10
+    bl C_FUNC(TailcallStub)
+    POP_REGS
+    ret lr
+NESTED_END TailcallNaked3, _TEXT
+
+NESTED_ENTRY getPrevPC, _TEXT, NoHandler
+    ldr x0, [fp, #8]
+    ret lr
+NESTED_END getPrevPC, _TEXT
index 8cd836b9f04a92aa62b520c86c21b7ec2116bb48..6e38da0a404956d55b5636ed1e4e1a7fac039016 100644 (file)
@@ -34,18 +34,18 @@ EXTERN_C void STDMETHODCALLTYPE EnterNaked3(FunctionIDOrClientID functionIDOrCli
 EXTERN_C void STDMETHODCALLTYPE LeaveNaked3(FunctionIDOrClientID functionIDOrClientID);
 EXTERN_C void STDMETHODCALLTYPE TailcallNaked3(FunctionIDOrClientID functionIDOrClientID);
 
-#ifdef _TARGET_ARM_
+#if defined(_TARGET_ARM_) || defined(_TARGET_ARM64_)
 EXTERN_C UINT_PTR getPrevPC();
-#endif // _TARGET_ARM_
+#endif // _TARGET_ARM_ || _TARGET_ARM64_
 
 // if you change calling conversion here, make sure, that x86 asm are corrected too (EnterNaked3)
 EXTERN_C void __stdcall EnterStub(FunctionIDOrClientID functionIDOrClientID)
 {
     UINT_PTR ip = 0;
 
-#ifdef _TARGET_ARM_
+#if defined(_TARGET_ARM_) || defined(_TARGET_ARM64_)
     ip = getPrevPC();
-#endif // _TARGET_ARM_
+#endif // _TARGET_ARM_ || _TARGET_ARM64_
 
     FunctionInfo *funcInfo = reinterpret_cast<FunctionInfo*>(
         functionIDOrClientID.clientID);