Skip to content

Commit 7453224

Browse files
Clean up inline usage
Following two changes: - Replace __inline with inline - Mark definitions of template specialization functions as inline Also minor other changes, replaced __forceinline with inline through a macro rather than a string replacement so that we can search later and see if we need to actually force-inline on non-VC++ compilers Notable Changes in SpareArraySegment.h, Symbol.h, JavascriptLibrary.inl
1 parent 5e04257 commit 7453224

117 files changed

Lines changed: 870 additions & 817 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bin/GCStress/StubExternalApi.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "Core/ConfigParser.h"
99

1010
// TODO: REMOVE
11-
__forceinline void js_memcpy_s(__bcount(sizeInBytes) void *dst, size_t sizeInBytes, __in_bcount(count) const void *src, size_t count)
11+
void js_memcpy_s(__bcount(sizeInBytes) void *dst, size_t sizeInBytes, __in_bcount(count) const void *src, size_t count)
1212
{
1313
Assert((count) <= (sizeInBytes));
1414
if ((count) <= (sizeInBytes))
@@ -17,7 +17,7 @@ __forceinline void js_memcpy_s(__bcount(sizeInBytes) void *dst, size_t sizeInByt
1717
ReportFatalException(NULL, E_FAIL, Fatal_Internal_Error, 2);
1818
}
1919

20-
__forceinline void js_wmemcpy_s(__ecount(sizeInWords) char16 *dst, size_t sizeInWords, __in_ecount(count) const char16 *src, size_t count)
20+
void js_wmemcpy_s(__ecount(sizeInWords) char16 *dst, size_t sizeInWords, __in_ecount(count) const char16 *src, size_t count)
2121
{
2222
//Multiplication Overflow check
2323
Assert(count <= sizeInWords && count <= SIZE_MAX/sizeof(char16));

lib/Common/Common/Api.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//-------------------------------------------------------------------------------------------------------
55
#include "CommonCommonPch.h"
66

7-
__inline void __stdcall js_memcpy_s(__bcount(sizeInBytes) void *dst, size_t sizeInBytes, __in_bcount(count) const void *src, size_t count)
7+
void __stdcall js_memcpy_s(__bcount(sizeInBytes) void *dst, size_t sizeInBytes, __in_bcount(count) const void *src, size_t count)
88
{
99
Assert((count) <= (sizeInBytes));
1010
if ((count) <= (sizeInBytes))
@@ -13,7 +13,7 @@ __inline void __stdcall js_memcpy_s(__bcount(sizeInBytes) void *dst, size_t size
1313
Js::Throw::FatalInternalError();
1414
}
1515

16-
__inline void __stdcall js_wmemcpy_s(__ecount(sizeInWords) char16 *dst, size_t sizeInWords, __in_ecount(count) const char16 *src, size_t count)
16+
void __stdcall js_wmemcpy_s(__ecount(sizeInWords) char16 *dst, size_t sizeInWords, __in_ecount(count) const char16 *src, size_t count)
1717
{
1818
//Multiplication Overflow check
1919
Assert(count <= sizeInWords && count <= SIZE_MAX/sizeof(char16));

lib/Common/CommonPal.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,26 @@ typedef wchar_t char16;
3131
#else // !_WIN32
3232

3333
#define USING_PAL_STDLIB 1
34+
#define STRSAFE_INLINE 1
35+
3436
#ifdef PAL_STDCPP_COMPAT
3537
#include <math.h>
3638
#include <time.h>
3739
#include <smmintrin.h>
3840
#include <xmmintrin.h>
3941
#endif
42+
4043
#include "inc/pal.h"
4144
#include "inc/rt/palrt.h"
4245
#include "inc/rt/no_sal2.h"
4346
#include "inc/rt/oaidl.h"
4447

48+
// In general, we don't need to force-inline any of Chakra's functions
49+
// on Linux- we'd rather let the compiler figure this out for us
50+
// If, in the future, perf investigations reveal that force inlining
51+
// would help, we can address on a case-by-case basis.
52+
#define __forceinline inline
53+
4554
typedef char16_t char16;
4655
#define _u(s) u##s
4756
#define INIT_PRIORITY(x) __attribute__((init_priority(x)))

lib/Common/DataStructures/BaseDictionary.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ namespace JsUtil
779779
}
780780

781781
template <typename LookupType>
782-
__inline int FindEntryWithKey(const LookupType& key) const
782+
inline int FindEntryWithKey(const LookupType& key) const
783783
{
784784
#if PROFILE_DICTIONARY
785785
uint depth = 0;
@@ -820,7 +820,7 @@ namespace JsUtil
820820
}
821821

822822
template <typename LookupType>
823-
__inline bool FindEntryWithKey(const LookupType& key, int *const i, int *const last, uint *const targetBucket)
823+
inline bool FindEntryWithKey(const LookupType& key, int *const i, int *const last, uint *const targetBucket)
824824
{
825825
#if PROFILE_DICTIONARY
826826
uint depth = 0;
@@ -1103,7 +1103,7 @@ namespace JsUtil
11031103
*ppEntries = entries;
11041104
}
11051105

1106-
__inline void RemoveAt(const int i, const int last, const uint targetBucket)
1106+
inline void RemoveAt(const int i, const int last, const uint targetBucket)
11071107
{
11081108
if (last < 0)
11091109
{
@@ -1709,15 +1709,15 @@ namespace JsUtil
17091709
}
17101710

17111711
template <typename TLookup>
1712-
__inline bool TryGetReference(const TLookup& key, TValue** value)
1712+
inline bool TryGetReference(const TLookup& key, TValue** value)
17131713
{
17141714
typename LockPolicy::ReadLock autoLock(syncObj);
17151715

17161716
return __super::TryGetReference(key, value);
17171717
}
17181718

17191719
template <typename TLookup>
1720-
__inline bool TryGetReference(const TLookup& key, TValue** value, int* index)
1720+
inline bool TryGetReference(const TLookup& key, TValue** value, int* index)
17211721
{
17221722
typename LockPolicy::ReadLock autoLock(syncObj);
17231723

lib/Common/DataStructures/Comparer.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ typedef uint hash_t;
1212
template <typename T>
1313
struct DefaultComparer
1414
{
15-
__inline static bool Equals(const T &x, const T &y)
15+
inline static bool Equals(const T &x, const T &y)
1616
{
1717
return x == y;
1818
}
1919

20-
__inline static hash_t GetHashCode(const T &i)
20+
inline static hash_t GetHashCode(const T &i)
2121
{
2222
return (hash_t)i;
2323
}
@@ -26,12 +26,12 @@ struct DefaultComparer
2626
template <>
2727
struct DefaultComparer<double>
2828
{
29-
__inline static bool Equals(double x, double y)
29+
inline static bool Equals(double x, double y)
3030
{
3131
return x == y;
3232
}
3333

34-
__inline static hash_t GetHashCode(double d)
34+
inline static hash_t GetHashCode(double d)
3535
{
3636
__int64 i64 = *(__int64*)&d;
3737
return (uint)((i64>>32) ^ (uint)i64);
@@ -41,12 +41,12 @@ struct DefaultComparer<double>
4141
template <typename T>
4242
struct DefaultComparer<T *>
4343
{
44-
__inline static bool Equals(T * x, T * y)
44+
inline static bool Equals(T * x, T * y)
4545
{
4646
return x == y;
4747
}
4848

49-
__inline static hash_t GetHashCode(T * i)
49+
inline static hash_t GetHashCode(T * i)
5050
{
5151
// Shifting helps us eliminate any sameness due to our alignment strategy.
5252
// TODO: This works for Arena memory only. Recycler memory is 16 byte aligned.
@@ -59,12 +59,12 @@ struct DefaultComparer<T *>
5959
template <>
6060
struct DefaultComparer<size_t>
6161
{
62-
__inline static bool Equals(size_t x, size_t y)
62+
inline static bool Equals(size_t x, size_t y)
6363
{
6464
return x == y;
6565
}
6666

67-
__inline static uint GetHashCode(size_t i)
67+
inline static uint GetHashCode(size_t i)
6868
{
6969
#if _WIN64
7070
// For 64 bits we want all 64 bits of the pointer to be represented in the hash code.
@@ -99,12 +99,12 @@ struct DefaultComparer<size_t>
9999
template <typename T>
100100
struct RecyclerPointerComparer
101101
{
102-
__inline static bool Equals(T x, T y)
102+
inline static bool Equals(T x, T y)
103103
{
104104
return x == y;
105105
}
106106

107-
__inline static hash_t GetHashCode(T i)
107+
inline static hash_t GetHashCode(T i)
108108
{
109109
// Shifting helps us eliminate any sameness due to our alignment strategy.
110110
// TODO: This works for Recycler memory only. Arena memory is 8 byte aligned.
@@ -117,12 +117,12 @@ struct RecyclerPointerComparer
117117
template <>
118118
struct DefaultComparer<GUID>
119119
{
120-
__inline static bool Equals(GUID const& x, GUID const& y)
120+
inline static bool Equals(GUID const& x, GUID const& y)
121121
{
122122
return x == y;
123123
}
124124

125-
__inline static hash_t GetHashCode(GUID const& guid)
125+
inline static hash_t GetHashCode(GUID const& guid)
126126
{
127127
char* p = (char*)&guid;
128128
int hash = 0;
@@ -138,12 +138,12 @@ struct DefaultComparer<GUID>
138138
template<typename T>
139139
struct StringComparer
140140
{
141-
__inline static bool Equals(T str1, T str2)
141+
inline static bool Equals(T str1, T str2)
142142
{
143143
return ::wcscmp(str1, str2) == 0;
144144
}
145145

146-
__inline static hash_t GetHashCode(T str)
146+
inline static hash_t GetHashCode(T str)
147147
{
148148
int hash = 0;
149149
while (*str)

0 commit comments

Comments
 (0)