Skip to content

Commit 325ce95

Browse files
authored
Remove js_unlikely macro (#370)
It was a wrapper around gcc's __builtin_expect macro but it was only used in three places and not in a way that suggests it really helps branch prediction on modern (or even not so modern) CPUs. Refs: #369
1 parent b20aad8 commit 325ce95

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

quickjs.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ extern "C" {
3535
#endif
3636

3737
#if defined(__GNUC__) || defined(__clang__)
38-
#define js_unlikely(x) __builtin_expect(!!(x), 0)
3938
#define js_force_inline inline __attribute__((always_inline))
4039
#define __js_printf_like(f, a) __attribute__((format(printf, f, a)))
4140
#define JS_EXTERN __attribute__((visibility("default")))
4241
#else
43-
#define js_unlikely(x) (x)
4442
#define js_force_inline inline
4543
#define __js_printf_like(a, b)
4644
#define JS_EXTERN /* nothing */
@@ -124,7 +122,7 @@ static inline JSValue __JS_NewFloat64(double d)
124122
JSValue v;
125123
u.d = d;
126124
/* normalize NaN */
127-
if (js_unlikely((u.u64 & 0x7fffffffffffffff) > 0x7ff0000000000000))
125+
if ((u.u64 & 0x7fffffffffffffff) > 0x7ff0000000000000)
128126
v = JS_NAN;
129127
else
130128
v = u.u64 - ((uint64_t)JS_FLOAT64_TAG_ADDEND << 32);
@@ -538,12 +536,12 @@ static inline JS_BOOL JS_IsUndefined(JSValue v)
538536

539537
static inline JS_BOOL JS_IsException(JSValue v)
540538
{
541-
return js_unlikely(JS_VALUE_GET_TAG(v) == JS_TAG_EXCEPTION);
539+
return JS_VALUE_GET_TAG(v) == JS_TAG_EXCEPTION;
542540
}
543541

544542
static inline JS_BOOL JS_IsUninitialized(JSValue v)
545543
{
546-
return js_unlikely(JS_VALUE_GET_TAG(v) == JS_TAG_UNINITIALIZED);
544+
return JS_VALUE_GET_TAG(v) == JS_TAG_UNINITIALIZED;
547545
}
548546

549547
static inline JS_BOOL JS_IsString(JSValue v)
@@ -997,7 +995,6 @@ JS_EXTERN JSValue JS_PromiseResult(JSContext *ctx, JSValue promise);
997995
JS_EXTERN const char* JS_GetVersion(void);
998996

999997
#undef JS_EXTERN
1000-
#undef js_unlikely
1001998
#undef js_force_inline
1002999
#undef __js_printf_like
10031000

0 commit comments

Comments
 (0)