src/hotspot/share/oops/typeArrayKlass.cpp
changeset 50094 2f79462aab9b
parent 49383 bf2ff45e592f
child 50304 d5331b94f821
equal deleted inserted replaced
50093:55153a374d18 50094:2f79462aab9b
   136     THROW(vmSymbols::java_lang_ArrayStoreException());
   136     THROW(vmSymbols::java_lang_ArrayStoreException());
   137   }
   137   }
   138 
   138 
   139   // Check is all offsets and lengths are non negative
   139   // Check is all offsets and lengths are non negative
   140   if (src_pos < 0 || dst_pos < 0 || length < 0) {
   140   if (src_pos < 0 || dst_pos < 0 || length < 0) {
   141     THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
   141     // Pass specific exception reason.
       
   142     ResourceMark rm;
       
   143     stringStream ss;
       
   144     if (src_pos < 0) {
       
   145       ss.print("arraycopy: source index %d out of bounds for %s[%d]",
       
   146                src_pos, type2name_tab[ArrayKlass::cast(s->klass())->element_type()], s->length());
       
   147     } else if (dst_pos < 0) {
       
   148       ss.print("arraycopy: destination index %d out of bounds for %s[%d]",
       
   149                dst_pos, type2name_tab[ArrayKlass::cast(d->klass())->element_type()], d->length());
       
   150     } else {
       
   151       ss.print("arraycopy: length %d is negative", length);
       
   152     }
       
   153     THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
   142   }
   154   }
   143   // Check if the ranges are valid
   155   // Check if the ranges are valid
   144   if  ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length())
   156   if ((((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) ||
   145      || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) {
   157       (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length())) {
   146     THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
   158     // Pass specific exception reason.
       
   159     ResourceMark rm;
       
   160     stringStream ss;
       
   161     if (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) {
       
   162       ss.print("arraycopy: last source index %u out of bounds for %s[%d]",
       
   163                (unsigned int) length + (unsigned int) src_pos,
       
   164                type2name_tab[ArrayKlass::cast(s->klass())->element_type()], s->length());
       
   165     } else {
       
   166       ss.print("arraycopy: last destination index %u out of bounds for %s[%d]",
       
   167                (unsigned int) length + (unsigned int) dst_pos,
       
   168                type2name_tab[ArrayKlass::cast(d->klass())->element_type()], d->length());
       
   169     }
       
   170     THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
   147   }
   171   }
   148   // Check zero copy
   172   // Check zero copy
   149   if (length == 0)
   173   if (length == 0)
   150     return;
   174     return;
   151 
   175 
   154   int ihs = array_header_in_bytes() / wordSize;
   178   int ihs = array_header_in_bytes() / wordSize;
   155   void* src = (char*) (s->base(element_type())) + ((size_t)src_pos << l2es);
   179   void* src = (char*) (s->base(element_type())) + ((size_t)src_pos << l2es);
   156   void* dst = (char*) (d->base(element_type())) + ((size_t)dst_pos << l2es);
   180   void* dst = (char*) (d->base(element_type())) + ((size_t)dst_pos << l2es);
   157   HeapAccess<ARRAYCOPY_ATOMIC>::arraycopy(s, d, src, dst, (size_t)length << l2es);
   181   HeapAccess<ARRAYCOPY_ATOMIC>::arraycopy(s, d, src, dst, (size_t)length << l2es);
   158 }
   182 }
   159 
       
   160 
   183 
   161 // create a klass of array holding typeArrays
   184 // create a klass of array holding typeArrays
   162 Klass* TypeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
   185 Klass* TypeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
   163   int dim = dimension();
   186   int dim = dimension();
   164   assert(dim <= n, "check order of chain");
   187   assert(dim <= n, "check order of chain");
   238 }
   261 }
   239 
   262 
   240 void TypeArrayKlass::print_value_on(outputStream* st) const {
   263 void TypeArrayKlass::print_value_on(outputStream* st) const {
   241   assert(is_klass(), "must be klass");
   264   assert(is_klass(), "must be klass");
   242   st->print("{type array ");
   265   st->print("{type array ");
   243   switch (element_type()) {
   266   BasicType bt = element_type();
   244     case T_BOOLEAN: st->print("bool");    break;
   267   if (bt == T_BOOLEAN) {
   245     case T_CHAR:    st->print("char");    break;
   268     st->print("bool");
   246     case T_FLOAT:   st->print("float");   break;
   269   } else {
   247     case T_DOUBLE:  st->print("double");  break;
   270     st->print("%s", type2name_tab[bt]);
   248     case T_BYTE:    st->print("byte");    break;
       
   249     case T_SHORT:   st->print("short");   break;
       
   250     case T_INT:     st->print("int");     break;
       
   251     case T_LONG:    st->print("long");    break;
       
   252     default: ShouldNotReachHere();
       
   253   }
   271   }
   254   st->print("}");
   272   st->print("}");
   255 }
   273 }
   256 
   274 
   257 #ifndef PRODUCT
   275 #ifndef PRODUCT