dByteArrayKlass.cpp

Go to the documentation of this file.
00001 /* Copyright 1994, 1995 LongView Technologies L.L.C. $Revision: 1.17 $ */
00002 /* Copyright (c) 2006, Sun Microsystems, Inc.
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 
00006 following conditions are met:
00007 
00008     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 
00010           disclaimer in the documentation and/or other materials provided with the distribution.
00011     * Neither the name of Sun Microsystems nor the names of its contributors may be used to endorse or promote products derived 
00012           from this software without specific prior written permission.
00013 
00014 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 
00015 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
00016 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
00017 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00018 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
00019 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
00020 
00021 
00022 */
00023 
00024 # include "incls/_precompiled.incl"
00025 # include "incls/_dByteArrayKlass.cpp.incl"
00026 # include <ctype.h>
00027 
00028 oop doubleByteArrayKlass::allocateObject() {
00029   fatal("should never call allocateObject in doubleByteArrayKlass");
00030   return badOop;
00031 }
00032 
00033 oop doubleByteArrayKlass::allocateObjectSize(int size) {
00034   klassOop k        = as_klassOop();
00035   int      ni_size  = non_indexable_size();
00036   int      obj_size = ni_size + 1 + roundTo(size * 2, oopSize) / oopSize;
00037   // allocate
00038   doubleByteArrayOop obj = as_doubleByteArrayOop(Universe::allocate(obj_size, (memOop*)&k));
00039   // header
00040   memOop(obj)->initialize_header(true, k);
00041   // instance variables
00042   memOop(obj)->initialize_body(memOopDesc::header_size(), ni_size);
00043   // indexables
00044   oop* base = (oop*) obj->addr();
00045   oop* end  = base + obj_size;
00046   // %optimized 'obj->set_length(size)'
00047   base[ni_size] = as_smiOop(size);
00048   // %optimized 'for (int index = 1; index <= size; index++)
00049   //               obj->doubleByte_at_put(index, 0)'
00050   base = &base[ni_size+1];
00051   while (base < end) *base++ = (oop) 0;
00052   return obj;
00053 }
00054 
00055 klassOop doubleByteArrayKlass::create_subclass(mixinOop mixin, Format format) {
00056   if (format == mem_klass || format == doubleByteArray_klass) {
00057     return doubleByteArrayKlass::create_class(as_klassOop(), mixin);
00058   }
00059   return NULL;
00060 }
00061 
00062 klassOop doubleByteArrayKlass::create_class(klassOop super_class, mixinOop mixin) {
00063   doubleByteArrayKlass o;
00064   return create_generic_class(super_class, mixin, o.vtbl_value());
00065 }
00066 
00067 void set_doubleByteArrayKlass_vtbl(Klass* k) {
00068   doubleByteArrayKlass o;
00069   k->set_vtbl_value(o.vtbl_value());
00070 }
00071 
00072 bool doubleByteArrayKlass::oop_verify(oop obj) {
00073   assert_doubleByteArray(obj,"Argument must be doubleByteArray");
00074   return doubleByteArrayOop(obj)->verify();
00075 }
00076 
00077 void doubleByteArrayKlass::oop_print_value_on(oop obj, outputStream* st) {
00078   assert_doubleByteArray(obj,"Argument must be doubleByteArray");
00079   doubleByteArrayOop array = doubleByteArrayOop(obj);
00080   int len = array->length();
00081   int n   = min(MaxElementPrintSize, len);
00082   st->print("'");
00083   for(int index = 1; index <= n; index++) {
00084     int c = array->doubleByte_at(index);
00085     if (isprint(c)) st->print("%c",   c);
00086     else            st->print("\\%o", c);
00087   }
00088   if (n < len) st->print("...");
00089   st->print("'");
00090 }
00091 
00092 void doubleByteArrayKlass::oop_layout_iterate(oop obj, ObjectLayoutClosure* blk) {
00093   doubleByte* p   = doubleByteArrayOop(obj)->doubleBytes();
00094   oop*        l   = doubleByteArrayOop(obj)->length_addr();
00095   int         len = doubleByteArrayOop(obj)->length();
00096   memOopKlass::oop_layout_iterate(obj, blk);
00097   blk->do_oop("length", l);
00098   blk->begin_indexables();
00099   for (int index = 1; index <= len; index++) {
00100     blk->do_indexable_doubleByte(index, p++);
00101   }
00102   blk->end_indexables();
00103 }
00104 
00105 void doubleByteArrayKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
00106   oop* l = doubleByteArrayOop(obj)->length_addr();
00107   memOopKlass::oop_oop_iterate(obj, blk);
00108   blk->do_oop(l);
00109 }
00110 
00111 int doubleByteArrayKlass::oop_scavenge_contents(oop obj) {
00112   memOopKlass::oop_scavenge_contents(obj);
00113   return object_size(doubleByteArrayOop(obj)->length());  
00114 }
00115 
00116 int doubleByteArrayKlass::oop_scavenge_tenured_contents(oop obj) {
00117   memOopKlass::oop_scavenge_tenured_contents(obj);
00118   return object_size(doubleByteArrayOop(obj)->length());  
00119 }
00120 

Generated on Mon Oct 9 13:37:08 2006 for Strongtalk VM by  doxygen 1.4.7