PRIM_DECL_3(doubleByteArrayPrimitives::atPut, oop receiver, oop index, oop value) { PROLOGUE_3("atPut", receiver, index, value); ASSERT_RECEIVER; // check index type if (!index->is_smi()) return markSymbol(vmSymbols::first_argument_has_wrong_type()); // check value type if (!value->is_smi()) return markSymbol(vmSymbols::second_argument_has_wrong_type()); // check index value if (!doubleByteArrayOop(receiver)->is_within_bounds(smiOop(index)->value())) return markSymbol(vmSymbols::out_of_bounds()); // check value as double byte unsigned int v = (unsigned int) smiOop(value)->value(); if (v >= (1<<16)) return markSymbol(vmSymbols::value_out_of_range()); // do the operation doubleByteArrayOop(receiver)->doubleByte_at_put(smiOop(index)->value(), v); return receiver; }
void doubleByteArrayKlass::oop_layout_iterate(oop obj, ObjectLayoutClosure* blk) { doubleByte* p = doubleByteArrayOop(obj)->doubleBytes(); oop* l = doubleByteArrayOop(obj)->length_addr(); int len = doubleByteArrayOop(obj)->length(); memOopKlass::oop_layout_iterate(obj, blk); blk->do_oop("length", l); blk->begin_indexables(); for (int index = 1; index <= len; index++) { blk->do_indexable_doubleByte(index, p++); } blk->end_indexables(); }
PRIM_DECL_2(doubleByteArrayPrimitives::at, oop receiver, oop index) { PROLOGUE_2("at", receiver, index); ASSERT_RECEIVER; // check index type if (!index->is_smi()) return markSymbol(vmSymbols::first_argument_has_wrong_type()); // check index value if (!doubleByteArrayOop(receiver)->is_within_bounds(smiOop(index)->value())) return markSymbol(vmSymbols::out_of_bounds()); return as_smiOop(doubleByteArrayOop(receiver)->doubleByte_at(smiOop(index)->value())); }
PRIM_DECL_2(doubleByteArrayPrimitives::compare, oop receiver, oop argument) { PROLOGUE_2("compare", receiver, argument); ASSERT_RECEIVER; if(receiver == argument) return as_smiOop(0); if (argument->is_doubleByteArray()) return as_smiOop(doubleByteArrayOop(receiver)->compare(doubleByteArrayOop(argument))); if (argument->is_byteArray()) return as_smiOop(- byteArrayOop(argument)->compare_doubleBytes(doubleByteArrayOop(receiver))); return markSymbol(vmSymbols::first_argument_has_wrong_type()); }
PRIM_DECL_1(doubleByteArrayPrimitives::size, oop receiver) { PROLOGUE_1("size", receiver); ASSERT_RECEIVER; // do the operation return as_smiOop(doubleByteArrayOop(receiver)->length()); }
PRIM_DECL_1(doubleByteArrayPrimitives::intern, oop receiver) { PROLOGUE_1("intern", receiver); ASSERT_RECEIVER; ResourceMark rm; int len = doubleByteArrayOop(receiver)->length(); char* buffer = NEW_RESOURCE_ARRAY(char, len); for (int i = 0; i < len; i++) { int c = doubleByteArrayOop(receiver)->doubleByte_at(i + 1); if (c >= (1<<8)) { return markSymbol(vmSymbols::value_out_of_range()); } buffer[i] = c; } symbolOop sym = Universe::symbol_table->lookup(buffer, len); return sym; }
PRIM_DECL_2(doubleByteArrayPrimitives::characterAt, oop receiver, oop index) { PROLOGUE_2("characterAt", receiver, index); ASSERT_RECEIVER; // check index type if (!index->is_smi()) return markSymbol(vmSymbols::first_argument_has_wrong_type()); // range check if (!doubleByteArrayOop(receiver)->is_within_bounds(smiOop(index)->value())) return markSymbol(vmSymbols::out_of_bounds()); // fetch double byte doubleByte byte = doubleByteArrayOop(receiver)->doubleByte_at(smiOop(index)->value()); if (byte < 256) { // return the byte+1'th element in asciiCharacter return Universe::asciiCharacters()->obj_at(byte+1); } else return markSymbol(vmSymbols::out_of_bounds()); }
void doubleByteArrayKlass::oop_print_value_on(oop obj, outputStream* st) { assert_doubleByteArray(obj,"Argument must be doubleByteArray"); doubleByteArrayOop array = doubleByteArrayOop(obj); int len = array->length(); int n = min(MaxElementPrintSize, len); st->print("'"); for(int index = 1; index <= n; index++) { int c = array->doubleByte_at(index); if (isprint(c)) st->print("%c", c); else st->print("\\%o", c); } if (n < len) st->print("..."); st->print("'"); }
bool doubleByteArrayKlass::oop_verify(oop obj) { assert_doubleByteArray(obj,"Argument must be doubleByteArray"); return doubleByteArrayOop(obj)->verify(); }
int doubleByteArrayKlass::oop_scavenge_tenured_contents(oop obj) { memOopKlass::oop_scavenge_tenured_contents(obj); return object_size(doubleByteArrayOop(obj)->length()); }
void doubleByteArrayKlass::oop_oop_iterate(oop obj, OopClosure* blk) { oop* l = doubleByteArrayOop(obj)->length_addr(); memOopKlass::oop_oop_iterate(obj, blk); blk->do_oop(l); }
PRIM_DECL_1(doubleByteArrayPrimitives::hash, oop receiver) { PROLOGUE_1("intern", receiver); ASSERT_RECEIVER; return as_smiOop(doubleByteArrayOop(receiver)->hash_value()); }