mirror of
https://github.com/corda/corda.git
synced 2025-06-23 09:25:36 +00:00
clean up float-vs.-int tracking in constant pools
This commit is contained in:
@ -4166,7 +4166,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->constant
|
(c->constant
|
||||||
(singletonValue(t, pool, index - 1),
|
(singletonValue(t, pool, index - 1),
|
||||||
singletonIsFloat(t, pool, index - 1)
|
singletonBit(t, pool, poolSize(t, pool), index - 1)
|
||||||
? Compiler::FloatType : Compiler::IntegerType));
|
? Compiler::FloatType : Compiler::IntegerType));
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@ -4180,7 +4180,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
memcpy(&v, &singletonValue(t, pool, index - 1), 8);
|
memcpy(&v, &singletonValue(t, pool, index - 1), 8);
|
||||||
frame->pushLong
|
frame->pushLong
|
||||||
(c->constant
|
(c->constant
|
||||||
(v, singletonIsFloat(t, pool, index - 1)
|
(v, singletonBit(t, pool, poolSize(t, pool), index - 1)
|
||||||
? Compiler::FloatType : Compiler::IntegerType));
|
? Compiler::FloatType : Compiler::IntegerType));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -826,13 +826,7 @@ object
|
|||||||
parsePool(Thread* t, Stream& s)
|
parsePool(Thread* t, Stream& s)
|
||||||
{
|
{
|
||||||
unsigned count = s.read2() - 1;
|
unsigned count = s.read2() - 1;
|
||||||
unsigned old;
|
object pool = makeSingletonOfSize(t, count + poolMaskSize(count));
|
||||||
unsigned floatMaskSize = 0;
|
|
||||||
do {
|
|
||||||
old = floatMaskSize;
|
|
||||||
floatMaskSize = singletonMaskSize(count + floatMaskSize);
|
|
||||||
} while (floatMaskSize != old);
|
|
||||||
object pool = makeSingletonOfSize(t, count + floatMaskSize);
|
|
||||||
PROTECT(t, pool);
|
PROTECT(t, pool);
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
@ -844,18 +838,16 @@ parsePool(Thread* t, Stream& s)
|
|||||||
switch (s.read1()) {
|
switch (s.read1()) {
|
||||||
case CONSTANT_Class:
|
case CONSTANT_Class:
|
||||||
case CONSTANT_String:
|
case CONSTANT_String:
|
||||||
assert(t, !singletonIsFloat(t, pool, i));
|
|
||||||
singletonMarkObject(t, pool, i);
|
singletonMarkObject(t, pool, i);
|
||||||
s.skip(2);
|
s.skip(2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONSTANT_Integer:
|
case CONSTANT_Integer:
|
||||||
assert(t, !singletonIsFloat(t, pool, i));
|
|
||||||
s.skip(4);
|
s.skip(4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONSTANT_Float:
|
case CONSTANT_Float:
|
||||||
singletonMarkBit(t, pool, count, i);
|
singletonSetBit(t, pool, count, i);
|
||||||
assert(t, singletonIsFloat(t, pool, i));
|
|
||||||
s.skip(4);
|
s.skip(4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -863,27 +855,22 @@ parsePool(Thread* t, Stream& s)
|
|||||||
case CONSTANT_Fieldref:
|
case CONSTANT_Fieldref:
|
||||||
case CONSTANT_Methodref:
|
case CONSTANT_Methodref:
|
||||||
case CONSTANT_InterfaceMethodref:
|
case CONSTANT_InterfaceMethodref:
|
||||||
assert(t, !singletonIsFloat(t, pool, i));
|
|
||||||
singletonMarkObject(t, pool, i);
|
singletonMarkObject(t, pool, i);
|
||||||
s.skip(4);
|
s.skip(4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONSTANT_Long:
|
case CONSTANT_Long:
|
||||||
assert(t, !singletonIsFloat(t, pool, i));
|
|
||||||
s.skip(8);
|
s.skip(8);
|
||||||
++ i;
|
++ i;
|
||||||
break;
|
break;
|
||||||
case CONSTANT_Double:
|
case CONSTANT_Double:
|
||||||
singletonMarkBit(t, pool, count, i);
|
singletonSetBit(t, pool, count, i);
|
||||||
singletonMarkBit(t, pool, count, i + 1);
|
singletonSetBit(t, pool, count, i + 1);
|
||||||
assert(t, singletonIsFloat(t, pool, i));
|
|
||||||
assert(t, singletonIsFloat(t, pool, i + 1));
|
|
||||||
s.skip(8);
|
s.skip(8);
|
||||||
++ i;
|
++ i;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONSTANT_Utf8:
|
case CONSTANT_Utf8:
|
||||||
assert(t, !singletonIsFloat(t, pool, i));
|
|
||||||
singletonMarkObject(t, pool, i);
|
singletonMarkObject(t, pool, i);
|
||||||
s.skip(s.read2());
|
s.skip(s.read2());
|
||||||
break;
|
break;
|
||||||
|
@ -2531,23 +2531,35 @@ makeSingletonOfSize(Thread* t, unsigned count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
singletonMarkBit(Thread* t, object singleton, unsigned start, unsigned index)
|
singletonSetBit(Thread* t, object singleton, unsigned start, unsigned index)
|
||||||
{
|
{
|
||||||
uintptr_t& val = singletonValue(t, singleton, start + (index / BitsPerWord));
|
singletonValue(t, singleton, start + (index / BitsPerWord))
|
||||||
val |= static_cast<uintptr_t>(1) << (index % BitsPerWord);
|
|= static_cast<uintptr_t>(1) << (index % BitsPerWord);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
singletonGetBit(Thread* t, object singleton, unsigned start, unsigned index)
|
singletonBit(Thread* t, object singleton, unsigned start, unsigned index)
|
||||||
{
|
{
|
||||||
uintptr_t& val = singletonValue(t, singleton, start + (index / BitsPerWord));
|
return (singletonValue(t, singleton, start + (index / BitsPerWord))
|
||||||
return (val & static_cast<uintptr_t>(1) << (index % BitsPerWord)) != 0;
|
& (static_cast<uintptr_t>(1) << (index % BitsPerWord))) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline unsigned
|
||||||
singletonIsFloat(Thread* t, object singleton, unsigned index)
|
poolMaskSize(unsigned count)
|
||||||
{
|
{
|
||||||
return singletonGetBit(t, singleton, singletonLength(t, singleton) - 2 * singletonMaskSize(t, singleton), index);
|
return ceiling(count, BitsPerWord);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline unsigned
|
||||||
|
poolMaskSize(Thread* t, object pool)
|
||||||
|
{
|
||||||
|
return ceiling(singletonCount(t, pool), BitsPerWord + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline unsigned
|
||||||
|
poolSize(Thread* t, object pool)
|
||||||
|
{
|
||||||
|
return singletonCount(t, pool) - poolMaskSize(t, pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline object
|
inline object
|
||||||
|
Reference in New Issue
Block a user