Skip to content

Commit 1559950

Browse files
committed
feat: unlikely ic prop offset search
1 parent a39a131 commit 1559950

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ bin
33
.idea
44
.vscode
55
lib
6-
cmake-build-debug
6+
cmake-build-*
7+
perf.*
78
build
89
*.expand
910
*.svg

src/core/ic.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,13 @@ force_inline int32_t get_ic_prop_offset(InlineCache *ic, uint32_t cache_offset,
5151
}
5252

5353
i = (i + 1) % IC_CACHE_ITEM_CAPACITY;
54-
if (i == cr->index) {
54+
if (unlikely(i == cr->index)) {
5555
break;
5656
}
5757
}
5858

5959
return -1;
6060
}
61-
6261
force_inline JSAtom get_ic_atom(InlineCache *ic, uint32_t cache_offset) {
6362
assert(cache_offset < ic->capacity);
6463
return ic->cache[cache_offset].atom;

src/core/object.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,9 @@ force_inline JSValue JS_GetPropertyInternalWithIC(JSContext *ctx, JSValueConst o
551551
goto slow_path;
552552
p = JS_VALUE_GET_OBJ(obj);
553553
offset = get_ic_prop_offset(ic, offset, p->shape);
554-
if (offset >= 0)
555-
return JS_DupValue(ctx, p->prop[offset].u.value);
556-
slow_path:
554+
if (likely(offset >= 0))
555+
return JS_DupValue(ctx, p->prop[offset].u.value);
556+
slow_path:
557557
return JS_GetPropertyInternal(ctx, obj, prop, this_obj, ic, throw_ref_error);
558558
}
559559

0 commit comments

Comments
 (0)