Skip to content

Commit 7ff8dd4

Browse files
committed
Implement native fast path for ctx_Long_AsLongLong
1 parent 95898f3 commit 7ff8dd4

File tree

1 file changed

+12
-0
lines changed
  • graalpython/com.oracle.graal.python.jni/src

1 file changed

+12
-0
lines changed

graalpython/com.oracle.graal.python.jni/src/hpy_jni.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ static HPy (*original_Long)(HPyContext *ctx, HPy h);
434434
static HPy (*original_Float_FromDouble)(HPyContext *ctx, double v);
435435
static double (*original_Float_AsDouble)(HPyContext *ctx, HPy h);
436436
static long (*original_Long_AsLong)(HPyContext *ctx, HPy h);
437+
static long long (*original_Long_AsLongLong)(HPyContext *ctx, HPy h);
437438
static unsigned long (*original_Long_AsUnsignedLong)(HPyContext *ctx, HPy h);
438439
static double (*original_Long_AsDouble)(HPyContext *ctx, HPy h);
439440
static HPy (*original_Long_FromLong)(HPyContext *ctx, long l);
@@ -524,6 +525,15 @@ static long augment_Long_AsLong(HPyContext *ctx, HPy h) {
524525
}
525526
}
526527

528+
static long long augment_Long_AsLongLong(HPyContext *ctx, HPy h) {
529+
uint64_t bits = toBits(h);
530+
if (isBoxedInt(bits)) {
531+
return (long long) unboxInt(bits);
532+
} else {
533+
return original_Long_AsLongLong(ctx, h);
534+
}
535+
}
536+
527537
static unsigned long augment_Long_AsUnsignedLong(HPyContext *ctx, HPy h) {
528538
uint64_t bits = toBits(h);
529539
if (isBoxedInt(bits)) {
@@ -762,6 +772,8 @@ void initDirectFastPaths(HPyContext *context) {
762772

763773
AUGMENT(Long_AsLong);
764774

775+
AUGMENT(Long_AsLongLong);
776+
765777
AUGMENT(Long_AsUnsignedLong);
766778

767779
AUGMENT(Long_AsDouble);

0 commit comments

Comments
 (0)