Example #1
0
 floatOop as_floatOop(float value) {
   union { float f; uint32 i; } x;
   x.f = value;
   uint32 i = x.i;
   int32 exp     = i >> expOffset  &  nthMask(expSize);
   int32 selfExp = exp - bias + selfBias;
   int32 fract   = i & nthMask(fractSize);
   int32 r       = (i & (nthMask(signSize) << signOffset)) | Float_Tag;
   
   if (selfExp <= 0) {
     // underflow - round towards zero
   } else if (selfExp >= nthMask(selfExpSize)) {
     if (exp < nthMask(expSize)) {
       // warning1("converting float %g to Inf", value);
       r |= nthMask(selfExpSize) << selfExpOffset;
     } else if (fract == 0) {
       r |= int32(infinityOop);
     } else { // NaN
       r |= (nthMask(selfExpSize) << selfExpOffset) | (fract << Tag_Size);
     }
   } else {
     r |= (selfExp << selfExpOffset) | (fract << Tag_Size);
   }
   return floatOop(r);
 }
Example #2
0
  void BitVector::addFromTo(int32 first, int32 last) {
    // mark bits [first..last]
    assert(first >= 0 && first < length, "wrong index");
    assert(last >= 0 && last < length, "wrong index");
    fint startIndex = indexFromNumber(first);
    fint   endIndex = indexFromNumber(last);
    if (startIndex == endIndex) {
      assert(last - first < BitsPerWord, "oops");
      int32 mask = nthMask(last - first + 1);
      bits[startIndex] |= mask << offsetFromNumber(first);
    } else {
      bits[startIndex] |= AllBits << offsetFromNumber(first);
      for (fint i = startIndex + 1; i < endIndex; i++) bits[i] = AllBits;
      bits[endIndex] |= nthMask(offsetFromNumber(last) + 1);
    }
#   if GENERATE_DEBUGGING_AIDS
      if (CheckAssertions)
        for (fint i = first; i <= last; i++)
          assert(includes(i), "bit should be set");
#   endif
  }
Example #3
0
oop* oldSpace::object_start(oop* p) {
  // Find the page start
  oop* q = p;
  int b = (int) q;
  clearBits(b, nthMask(card_shift));
  q = (oop*) b;
  assert(contains(q), "q must be in this space");
  int index  = (q - bottom()) / card_size_in_oops;

  int offset = offset_array[index--];
  while(offset == card_size_in_oops) {
    q -= card_size_in_oops;
    offset = offset_array[index--];
  }
  q -= offset;
  oop* n = q;
  assert((*n)->is_mark(), "check for header");
  while (n <= p) {
    q = n;
    n += as_memOop(n)->size();
  }
  assert( as_memOop(q)->mark()->is_mark(), "Must be mark");
  return q;
}
Example #4
0
 float floatOopClass::value() {
   uint32 i = uint32(this);
   int32 selfExp = i >> selfExpOffset  &  nthMask(selfExpSize);
   int32 fract   = i >> Tag_Size  &  nthMask(fractSize);
   int32 exp     = selfExp - selfBias + bias;
   int32 r       = i & (nthMask(signSize) << signOffset);
   
   if (selfExp == 0) {
     assert(fract == 0, "self float is denormalized");
     // zero
   } else if (selfExp >= nthMask(selfExpSize)) {
     if (fract == 0) {
       r |= nthMask(expSize) << expOffset; // infinity
     } else {
       r |= (nthMask(expSize) << expOffset) | fract; // NaN
     }
   } else {
     r |= (exp << expOffset) | fract;
   }
   
   union { float f; uint32 i; } x;
   x.i = r;
   return x.f;
 }
Example #5
0
# include "_scopeDescRecorder.cpp.incl"

# if  defined(FAST_COMPILER) || defined(SIC_COMPILER)


# define INITIAL_SLOT_SIZE     10
# define INITIAL_EXPR_SIZE     10
# define INITIAL_BLOCK_SIZE    10

# define INITIAL_OOPS_SIZE    100
# define INITIAL_VALUES_SIZE  100

const u_char nameDescHeaderByte::code_width     = 2;
const u_char nameDescHeaderByte::index_width    = 5;
const u_char nameDescHeaderByte::hasId_bit_num  = code_width+index_width;
const u_char nameDescHeaderByte::max_code       = nthMask(code_width);
const u_char nameDescHeaderByte::illegal_value  = nthMask(BitsPerByte);
const u_char nameDescHeaderByte::no_index       = nthMask(index_width) - 1;
const u_char nameDescHeaderByte::max_index      = nthMask(index_width) - 2;

const u_char scopeDescHeaderByte::code_width        = 3;
const u_char scopeDescHeaderByte::lookup_width      = 3;
const u_char scopeDescHeaderByte::lite_bit_num      = code_width+lookup_width;
const u_char scopeDescHeaderByte::nameDescs_bit_num = lite_bit_num+1;
const u_char scopeDescHeaderByte::max_code          = nthMask(code_width);
const u_char scopeDescHeaderByte::max_lookup        = nthMask(lookup_width);

class Vector: public ResourceObj {
 public:
  fint index;
  fint size;
Example #6
0
/* float formats:
   IEEE_float = { int sign:1; int fract: 23; int exp: 8 }

   Normally:
   Self_float = { int sign:1; int fract: 23; int exp: 6; int tag: 2}

   if FAST_FLOATS is defined
   Self_float = { int sign:1; int fract: 21; int exp: 8; int tag: 2}
*/
  
static const fint fractSize = 23;
static const fint expSize = 8;
static const fint expOffset = fractSize;

# ifdef FAST_FLOATS
  floatOop infinityOop = floatOop(nthMask(expSize) << expOffset
                                  |  Float_Tag);
# else

  static const fint signSize = 1;
  static const fint signOffset = fractSize + expSize;
  
  static const fint selfExpSize   = fint(expSize   - Tag_Size);
  static const fint selfExpOffset = fint(expOffset + Tag_Size);
  
  static const fint bias = nthBit(expSize) / 2  -  1;
  static const fint selfBias = nthBit(selfExpSize) / 2  -  1;
  
  floatOop infinityOop = floatOop(nthMask(selfExpSize) << selfExpOffset
                                  |  Float_Tag);
  
Example #7
0
inline int32 nmln::hash() {
  return (int32(this) >> IgnoreBits) & nthMask(MapBits);
}