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