diff options
author | Michal Strehovsky <michals@microsoft.com> | 2017-08-14 20:59:13 +0300 |
---|---|---|
committer | Michal Strehovsky <michals@microsoft.com> | 2017-08-14 20:59:13 +0300 |
commit | 1e9054a91177eed92094790ae063a4d741185aa2 (patch) | |
tree | 2b37c7212aed534b66c9843b8cf2b86c0c24925b /src/Native/Runtime/unix | |
parent | d714e3be0bb99c0f76f3b62ce310878be0b3f66e (diff) |
Speed up string allocations by 35%
`FastAllocateString` (the choke point through which all string allocations go through) wasn't as fast as it could be and we were 30% slower than CLR on allocating strings. We were leaving a lot of perf on the table.
Before this change, string allocation was using the same allocator as arrays. Since there's a subtle difference between the failure modes on overflow (string allocation throws OOM, array allocation throws OverflowException), `FastAllocateString` required a try/catch block to handle the corner case. This was inhibiting codegen optimizations around this code path - to fix that problem, we needed a separate allocator. And since we now had a separate allocator for strings, I also took the liberty of inlining some details around strings (component size and base size) into the helper. It turns out runtime already hardcodes the details around strings (the component size) in a couple places anyway, so this is not that big of a "separation of concerns" violation as it looks like.
[tfs-changeset: 1670224]
Diffstat (limited to 'src/Native/Runtime/unix')
-rw-r--r-- | src/Native/Runtime/unix/AsmOffsets.cpp | 7 | ||||
-rw-r--r-- | src/Native/Runtime/unix/unixasmmacrosarm.inc | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/Native/Runtime/unix/AsmOffsets.cpp b/src/Native/Runtime/unix/AsmOffsets.cpp index f13bb3014..a0c429c2f 100644 --- a/src/Native/Runtime/unix/AsmOffsets.cpp +++ b/src/Native/Runtime/unix/AsmOffsets.cpp @@ -2,8 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#define PLAT_ASM_OFFSET(offset, cls, member) .set OFFSETOF__##cls##__##member, 0x##offset -#define PLAT_ASM_SIZEOF(size, cls ) .set SIZEOF__##cls, 0x##size -#define PLAT_ASM_CONST(constant, expr) .set expr, 0x##constant +#define HASH_DEFINE #define +#define PLAT_ASM_OFFSET(offset, cls, member) HASH_DEFINE OFFSETOF__##cls##__##member 0x##offset +#define PLAT_ASM_SIZEOF(size, cls ) HASH_DEFINE SIZEOF__##cls 0x##size +#define PLAT_ASM_CONST(constant, expr) HASH_DEFINE expr 0x##constant #include <AsmOffsets.h> diff --git a/src/Native/Runtime/unix/unixasmmacrosarm.inc b/src/Native/Runtime/unix/unixasmmacrosarm.inc index 41886b127..e7a78f3e2 100644 --- a/src/Native/Runtime/unix/unixasmmacrosarm.inc +++ b/src/Native/Runtime/unix/unixasmmacrosarm.inc @@ -191,6 +191,12 @@ C_FUNC(\Name): #endif .endm +// Loads a 32bit constant into destination register +.macro MOV32 DestReg, Constant + movw \DestReg, #((\Constant) & 0xFFFF) + movt \DestReg, #((\Constant) >> 16) +.endm + .macro EXPORT_POINTER_TO_ADDRESS Name 1: |