aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2019-01-31 08:18:16 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2019-01-31 08:18:16 +0800
commit6ef8f3db38f6a60cfe6c091b9f6d6a888b2325e1 (patch)
tree0757346e7022520181cf0741767761251c2a4314 /src
parentf1f607d5e501bb064bfd1bf28d128d78ec4c7fc4 (diff)
downloadtangerine-mcl-6ef8f3db38f6a60cfe6c091b9f6d6a888b2325e1.tar.gz
tangerine-mcl-6ef8f3db38f6a60cfe6c091b9f6d6a888b2325e1.tar.zst
tangerine-mcl-6ef8f3db38f6a60cfe6c091b9f6d6a888b2325e1.zip
fix crash on x64-CPU without AVX
Diffstat (limited to 'src')
-rw-r--r--src/fp.cpp4
-rw-r--r--src/fp_generator.hpp5
2 files changed, 5 insertions, 4 deletions
diff --git a/src/fp.cpp b/src/fp.cpp
index 41e98e4..ebd9477 100644
--- a/src/fp.cpp
+++ b/src/fp.cpp
@@ -318,9 +318,9 @@ static bool initForMont(Op& op, const Unit *p, Mode mode)
if (mode != FP_XBYAK) return true;
#ifdef MCL_USE_XBYAK
if (op.fg == 0) op.fg = Op::createFpGenerator();
- op.fg->init(op);
+ bool useXbyak = op.fg->init(op);
- if (op.isMont && N <= 4) {
+ if (useXbyak && op.isMont && N <= 4) {
op.fp_invOp = &invOpForMontC;
initInvTbl(op);
}
diff --git a/src/fp_generator.hpp b/src/fp_generator.hpp
index a018c03..b496bc4 100644
--- a/src/fp_generator.hpp
+++ b/src/fp_generator.hpp
@@ -307,19 +307,20 @@ struct FpGenerator : Xbyak::CodeGenerator {
useMulx_ = cpu_.has(Xbyak::util::Cpu::tBMI2);
useAdx_ = cpu_.has(Xbyak::util::Cpu::tADX);
}
- void init(Op& op)
+ bool init(Op& op)
{
+ if (!cpu_.has(Xbyak::util::Cpu::tAVX)) return false;
reset(); // reset jit code for reuse
setProtectModeRW(); // read/write memory
init_inner(op);
// printf("code size=%d\n", (int)getSize());
setProtectModeRE(); // set read/exec memory
+ return true;
}
private:
void init_inner(Op& op)
{
op_ = &op;
- if (!cpu_.has(Xbyak::util::Cpu::tAVX)) return;
L(pL_);
p_ = reinterpret_cast<const uint64_t*>(getCurr());
for (size_t i = 0; i < op.N; i++) {