Commit b62d2ac0 authored by unknown's avatar unknown

Use native format in interpreter -

(old code mixed the 3 alternatives: native, [lo, hi], [hi, lo])

This fixes problem with auto increment on different byte order

(This also make adding of signed ints really simple...)


ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp:
  Use native format in interpreter
  (old code mixed the 3 alternatives: native, [lo, hi], [hi, lo])
ndb/src/ndbapi/Ndb.cpp:
  Use native format in interpreter
  (old code mixed the 3 alternatives: native, [lo, hi], [hi, lo])
ndb/src/ndbapi/NdbOperationInt.cpp:
  Use native format in interpreter
  (old code mixed the 3 alternatives: native, [lo, hi], [hi, lo])
parent 23b76504
......@@ -1505,6 +1505,8 @@ int Dbtup::interpreterNextLab(Signal* signal,
// the register to indicate a NULL value.
/* ------------------------------------------------------------- */
TregMemBuffer[theRegister] = 0;
TregMemBuffer[theRegister + 1] = 0;
TregMemBuffer[theRegister + 2] = 0;
} else if (TnoDataRW == (Uint32)-1) {
jam();
tupkeyErrorLab(signal);
......@@ -1593,23 +1595,22 @@ int Dbtup::interpreterNextLab(Signal* signal,
case Interpreter::LOAD_CONST16:
jam();
TregMemBuffer[theRegister] = 0x50; /* 32 BIT UNSIGNED CONSTANT */
TregMemBuffer[theRegister + 1] = theInstruction >> 16;
TregMemBuffer[theRegister + 2] = 0;
* (Int64*)(TregMemBuffer+theRegister+1) = theInstruction >> 16;
break;
case Interpreter::LOAD_CONST32:
jam();
TregMemBuffer[theRegister] = 0x50; /* 32 BIT UNSIGNED CONSTANT */
TregMemBuffer[theRegister + 1] = TcurrentProgram[TprogramCounter];
TregMemBuffer[theRegister + 2] = 0;
* (Int64*)(TregMemBuffer+theRegister+1) = *
(TcurrentProgram+TprogramCounter);
TprogramCounter++;
break;
case Interpreter::LOAD_CONST64:
jam();
TregMemBuffer[theRegister] = 0x60; /* 64 BIT UNSIGNED CONSTANT */
TregMemBuffer[theRegister + 1] = TcurrentProgram[TprogramCounter + 0];
TregMemBuffer[theRegister + 2] = TcurrentProgram[TprogramCounter + 1];
* (Int64*)(TregMemBuffer+theRegister+1) = * (Int64*)
(TcurrentProgram+TprogramCounter);
TprogramCounter += 2;
break;
......@@ -1620,27 +1621,16 @@ int Dbtup::interpreterNextLab(Signal* signal,
Uint32 TdestRegister = Interpreter::getReg3(theInstruction) << 2;
Uint32 TrightType = TregMemBuffer[TrightRegister];
Uint32 Tright0 = TregMemBuffer[TrightRegister + 1];
Uint32 Tright1 = TregMemBuffer[TrightRegister + 2];
Int64 Tright0 = * (Int64*)(TregMemBuffer + TrightRegister + 1);
Uint32 TleftType = TregMemBuffer[theRegister];
Uint32 Tleft0 = TregMemBuffer[theRegister + 1];
Uint32 Tleft1 = TregMemBuffer[theRegister + 2];
Uint32 Tany64bit = (((TleftType | TrightType) & 0x60) == 0x60);
Int64 Tleft0 = * (Int64*)(TregMemBuffer + theRegister + 1);
if ((TleftType | TrightType) != 0) {
Uint32 Tdest0 = Tleft0 + Tright0;
Uint32 Tdest1 = 0;
TregMemBuffer[TdestRegister + 1] = Tdest0;
TregMemBuffer[TdestRegister] = 0x50;
if (Tany64bit) {
Uint64 Tdest0 = Tleft0 + Tright0;
* (Int64*)(TregMemBuffer+TdestRegister+1) = Tdest0;
TregMemBuffer[TdestRegister] = 0x60;
Tdest1 = Tleft1 + Tright1;
if (Tdest0 < Tleft0) {
Tdest1++;
}
}//if
TregMemBuffer[TdestRegister + 2] = Tdest1;
} else {
return TUPKEY_abort(signal, 20);
}
......@@ -1654,30 +1644,18 @@ int Dbtup::interpreterNextLab(Signal* signal,
Uint32 TdestRegister = Interpreter::getReg3(theInstruction) << 2;
Uint32 TrightType = TregMemBuffer[TrightRegister];
Uint32 Tright0 = TregMemBuffer[TrightRegister + 1];
Uint32 Tright1 = TregMemBuffer[TrightRegister + 2];
Int64 Tright0 = * (Int64*)(TregMemBuffer + TrightRegister + 1);
Uint32 TleftType = TregMemBuffer[theRegister];
Uint32 Tleft0 = TregMemBuffer[theRegister + 1];
Uint32 Tleft1 = TregMemBuffer[theRegister + 2];
Uint32 Tany64bit = (((TleftType | TrightType) & 0x60) == 0x60);
Int64 Tleft0 = * (Int64*)(TregMemBuffer + theRegister + 1);
if ((TleftType | TrightType) != 0) {
Uint32 Tdest0 = Tleft0 - Tright0;
Uint32 Tdest1 = 0;
TregMemBuffer[TdestRegister + 1] = Tdest0;
TregMemBuffer[TdestRegister] = 0x50;
if (Tany64bit) {
Int64 Tdest0 = Tleft0 - Tright0;
* (Int64*)(TregMemBuffer+TdestRegister+1) = Tdest0;
TregMemBuffer[TdestRegister] = 0x60;
Tdest1 = Tleft1 - Tright1;
if (Tdest0 > Tleft0) {
Tdest1--;
}//if
}//if
TregMemBuffer[TdestRegister + 2] = Tdest1;
} else {
return TUPKEY_abort(signal, 21);
}//if
return TUPKEY_abort(signal, 20);
}
break;
}
......@@ -1754,17 +1732,16 @@ int Dbtup::interpreterNextLab(Signal* signal,
{
Uint32 TrightRegister = Interpreter::getReg2(theInstruction) << 2;
Uint32 TrightType = TregMemBuffer[TrightRegister];
Int64 Tright0 = * (Int64*)(TregMemBuffer + TrightRegister + 1);
Uint32 TleftType = TregMemBuffer[theRegister];
Uint32 Tleft0 = TregMemBuffer[theRegister + 1];
Uint32 Tleft1 = TregMemBuffer[theRegister + 2];
Int64 Tleft0 = * (Int64*)(TregMemBuffer + theRegister + 1);
Uint32 TrightType = TregMemBuffer[TrightRegister];
Uint32 Tright0 = TregMemBuffer[TrightRegister + 1];
Uint32 Tright1 = TregMemBuffer[TrightRegister + 2];
if ((TrightType | TleftType) != 0) {
jam();
if ((Tleft0 < Tright0) || ((Tleft0 == Tright0) &&
(Tleft1 < Tright1))) {
if (Tleft0 < Tright0) {
TprogramCounter = brancher(theInstruction, TprogramCounter);
}//if
} else {
......@@ -1777,17 +1754,16 @@ int Dbtup::interpreterNextLab(Signal* signal,
{
Uint32 TrightRegister = Interpreter::getReg2(theInstruction) << 2;
Uint32 TrightType = TregMemBuffer[TrightRegister];
Int64 Tright0 = * (Int64*)(TregMemBuffer + TrightRegister + 1);
Uint32 TleftType = TregMemBuffer[theRegister];
Uint32 Tleft0 = TregMemBuffer[theRegister + 1];
Uint32 Tleft1 = TregMemBuffer[theRegister + 2];
Int64 Tleft0 = * (Int64*)(TregMemBuffer + theRegister + 1);
Uint32 TrightType = TregMemBuffer[TrightRegister];
Uint32 Tright0 = TregMemBuffer[TrightRegister + 1];
Uint32 Tright1 = TregMemBuffer[TrightRegister + 2];
if ((TrightType | TleftType) != 0) {
jam();
if ((Tleft0 < Tright0) || ((Tleft0 == Tright0) &&
(Tleft1 <= Tright1))) {
if (Tleft0 <= Tright0) {
TprogramCounter = brancher(theInstruction, TprogramCounter);
}//if
} else {
......@@ -1800,17 +1776,16 @@ int Dbtup::interpreterNextLab(Signal* signal,
{
Uint32 TrightRegister = Interpreter::getReg2(theInstruction) << 2;
Uint32 TrightType = TregMemBuffer[TrightRegister];
Int64 Tright0 = * (Int64*)(TregMemBuffer + TrightRegister + 1);
Uint32 TleftType = TregMemBuffer[theRegister];
Uint32 Tleft0 = TregMemBuffer[theRegister + 1];
Uint32 Tleft1 = TregMemBuffer[theRegister + 2];
Int64 Tleft0 = * (Int64*)(TregMemBuffer + theRegister + 1);
Uint32 TrightType = TregMemBuffer[TrightRegister];
Uint32 Tright0 = TregMemBuffer[TrightRegister + 1];
Uint32 Tright1 = TregMemBuffer[TrightRegister + 2];
if ((TrightType | TleftType) != 0) {
jam();
if ((Tleft0 > Tright0) || ((Tleft0 == Tright0) &&
(Tleft1 > Tright1))) {
if (Tleft0 > Tright0){
TprogramCounter = brancher(theInstruction, TprogramCounter);
}//if
} else {
......@@ -1823,17 +1798,16 @@ int Dbtup::interpreterNextLab(Signal* signal,
{
Uint32 TrightRegister = Interpreter::getReg2(theInstruction) << 2;
Uint32 TrightType = TregMemBuffer[TrightRegister];
Int64 Tright0 = * (Int64*)(TregMemBuffer + TrightRegister + 1);
Uint32 TleftType = TregMemBuffer[theRegister];
Uint32 Tleft0 = TregMemBuffer[theRegister + 1];
Uint32 Tleft1 = TregMemBuffer[theRegister + 2];
Int64 Tleft0 = * (Int64*)(TregMemBuffer + theRegister + 1);
Uint32 TrightType = TregMemBuffer[TrightRegister];
Uint32 Tright0 = TregMemBuffer[TrightRegister + 1];
Uint32 Tright1 = TregMemBuffer[TrightRegister + 2];
if ((TrightType | TleftType) != 0) {
jam();
if ((Tleft0 > Tright0) || ((Tleft0 == Tright0) &&
(Tleft1 >= Tright1))) {
if (Tleft0 >= Tright0){
TprogramCounter = brancher(theInstruction, TprogramCounter);
}//if
} else {
......
......@@ -859,15 +859,7 @@ Ndb::opTupleIdOnNdb(Uint32 aTableId, Uint64 opValue, Uint32 op)
case 0:
tOperation->interpretedUpdateTuple();
tOperation->equal("SYSKEY_0", aTableId );
{
#ifdef WORDS_BIGENDIAN
Uint64 cacheSize64 = opValue; // XXX interpreter bug on Uint32
tOperation->incValue("NEXTID", cacheSize64);
#else
Uint32 cacheSize32 = opValue; // XXX for little-endian
tOperation->incValue("NEXTID", cacheSize32);
#endif
}
tOperation->incValue("NEXTID", opValue);
tRecAttrResult = tOperation->getValue("NEXTID");
if (tConnection->execute( Commit ) == -1 )
......
......@@ -408,9 +408,7 @@ NdbOperation::incValue(const NdbColumnImpl* tNdbColumnImpl, Uint64 aValue)
// Load aValue into register 7
if (insertATTRINFO( Interpreter::LoadConst64(7)) == -1)
goto incValue_error1;
if (insertATTRINFO((Uint32)(aValue >> 32)) == -1)
goto incValue_error1;
if (insertATTRINFO(Uint32(aValue & 0xFFFFFFFF)) == -1)
if (insertATTRINFOloop((Uint32*)&aValue, 2) == -1)
goto incValue_error1;
// Add register 6 and 7 and put result in register 7
if (insertATTRINFO( Interpreter::Add(7, 6, 7)) == -1)
......@@ -451,9 +449,7 @@ NdbOperation::subValue(const NdbColumnImpl* tNdbColumnImpl, Uint64 aValue)
// Load aValue into register 7
if (insertATTRINFO( Interpreter::LoadConst64(7)) == -1)
goto subValue_error1;
if (insertATTRINFO((Uint32)(aValue >> 32)) == -1)
goto subValue_error1;
if (insertATTRINFO(Uint32(aValue & 0xFFFFFFFF)) == -1)
if (insertATTRINFOloop((Uint32*)&aValue, 2) == -1)
goto subValue_error1;
// Subtract register 6 and 7 and put result in register 7
if (insertATTRINFO( Interpreter::Sub(7, 6, 7)) == -1)
......@@ -690,8 +686,6 @@ int
NdbOperation::load_const_u64(Uint32 RegDest, Uint64 Constant)
{
INT_DEBUG(("load_const_u64 %u %llu", RegDest, Constant));
Uint32 tTemp1;
Uint32 tTemp2;
if (initial_interpreterCheck() == -1)
return -1;
if (RegDest >= 8)
......@@ -699,15 +693,11 @@ NdbOperation::load_const_u64(Uint32 RegDest, Uint64 Constant)
setErrorCodeAbort(4229);
return -1;
}
tTemp1 = (Uint32)(Constant >> 32);
tTemp2 = (Uint32)(Constant & 0xFFFFFFFF);
// 64 bit value
if (insertATTRINFO( Interpreter::LoadConst64(RegDest)) == -1)
return -1;
if (insertATTRINFO(tTemp1) == -1)
return -1;
if (insertATTRINFO(tTemp2) == -1)
if (insertATTRINFOloop((Uint32*)&Constant, 2) == -1)
return -1;
theErrorLine++;
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment