This commit is contained in:
blueloveTH 2023-10-12 12:45:11 +08:00
parent cc512a76e3
commit 6d6c2935f4
3 changed files with 7 additions and 5 deletions

View File

@ -74,12 +74,18 @@ template <>
struct NumberTraits<4> { struct NumberTraits<4> {
using int_t = int32_t; using int_t = int32_t;
using float_t = float; using float_t = float;
static constexpr int_t kMaxSmallInt = (1 << 28) - 1;
static constexpr int_t kMinSmallInt = - (1 << 28);
}; };
template <> template <>
struct NumberTraits<8> { struct NumberTraits<8> {
using int_t = int64_t; using int_t = int64_t;
using float_t = double; using float_t = double;
static constexpr int_t kMaxSmallInt = (1ll << 60) - 1;
static constexpr int_t kMinSmallInt = - (1ll << 60);
}; };
using Number = NumberTraits<sizeof(void*)>; using Number = NumberTraits<sizeof(void*)>;

View File

@ -530,13 +530,10 @@ template<> inline double _py_cast<double>(VM* vm, PyObject* obj){
return py_cast<double>(vm, obj); return py_cast<double>(vm, obj);
} }
const i64 kMaxSmallInt = (1ll << 28) - 1;
const i64 kMinSmallInt = -(1ll << 28);
#define PY_VAR_INT(T) \ #define PY_VAR_INT(T) \
inline PyObject* py_var(VM* vm, T _val){ \ inline PyObject* py_var(VM* vm, T _val){ \
i64 val = static_cast<i64>(_val); \ i64 val = static_cast<i64>(_val); \
if(val >= kMinSmallInt && val <= kMaxSmallInt){ \ if(val >= Number::kMinSmallInt && val <= Number::kMaxSmallInt){ \
val = (val << 2) | 0b10; \ val = (val << 2) | 0b10; \
return reinterpret_cast<PyObject*>(val); \ return reinterpret_cast<PyObject*>(val); \
}else{ \ }else{ \

View File

@ -627,7 +627,6 @@ __NEXT_STEP:;
frame->f_globals().set(name, value); frame->f_globals().set(name, value);
} }
} }
frame->f_globals()._try_perfect_rehash();
} DISPATCH(); } DISPATCH();
/*****************************************/ /*****************************************/
TARGET(UNPACK_SEQUENCE){ TARGET(UNPACK_SEQUENCE){