From 6d6c2935f4c1cfe2e708da0214d0594208fe3ab2 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 12 Oct 2023 12:45:11 +0800 Subject: [PATCH] ... --- include/pocketpy/common.h | 6 ++++++ include/pocketpy/vm.h | 5 +---- src/ceval.cpp | 1 - 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/pocketpy/common.h b/include/pocketpy/common.h index 6946a9a9..b4f7b7fc 100644 --- a/include/pocketpy/common.h +++ b/include/pocketpy/common.h @@ -74,12 +74,18 @@ template <> struct NumberTraits<4> { using int_t = int32_t; using float_t = float; + + static constexpr int_t kMaxSmallInt = (1 << 28) - 1; + static constexpr int_t kMinSmallInt = - (1 << 28); }; template <> struct NumberTraits<8> { using int_t = int64_t; using float_t = double; + + static constexpr int_t kMaxSmallInt = (1ll << 60) - 1; + static constexpr int_t kMinSmallInt = - (1ll << 60); }; using Number = NumberTraits; diff --git a/include/pocketpy/vm.h b/include/pocketpy/vm.h index bd0a7f50..7200a176 100644 --- a/include/pocketpy/vm.h +++ b/include/pocketpy/vm.h @@ -530,13 +530,10 @@ template<> inline double _py_cast(VM* vm, PyObject* obj){ return py_cast(vm, obj); } -const i64 kMaxSmallInt = (1ll << 28) - 1; -const i64 kMinSmallInt = -(1ll << 28); - #define PY_VAR_INT(T) \ inline PyObject* py_var(VM* vm, T _val){ \ i64 val = static_cast(_val); \ - if(val >= kMinSmallInt && val <= kMaxSmallInt){ \ + if(val >= Number::kMinSmallInt && val <= Number::kMaxSmallInt){ \ val = (val << 2) | 0b10; \ return reinterpret_cast(val); \ }else{ \ diff --git a/src/ceval.cpp b/src/ceval.cpp index 40ec6dd2..c3605590 100644 --- a/src/ceval.cpp +++ b/src/ceval.cpp @@ -627,7 +627,6 @@ __NEXT_STEP:; frame->f_globals().set(name, value); } } - frame->f_globals()._try_perfect_rehash(); } DISPATCH(); /*****************************************/ TARGET(UNPACK_SEQUENCE){