dValueArrayOop.hpp

Go to the documentation of this file.
00001 /* Copyright 1996 LongView Technologies L.L.C. $Revision: 1.1 $ */
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 // doubleValueArrays are arrays containing double value [8 bytes each]
00025 
00026 // memory layout:
00027 //    [header      ]
00028 //    [klass_field ]
00029 //    [instVars    ]*
00030 //    [length      ]      offset
00031 
00032 class doubleValueArrayOopDesc: public memOopDesc {
00033   public:
00034   // constructor
00035   friend doubleValueArrayOop as_doubleValueArrayOop(void* p) {
00036     return doubleValueArrayOop(as_memOop(p)); }
00037 
00038   void bootstrap_object(bootstrap* st);
00039 
00040   // accessors
00041   doubleValueArrayOopDesc* addr() const {
00042     return (doubleValueArrayOopDesc*) memOopDesc::addr(); }
00043 
00044   bool is_within_bounds(int index) const { return 1 <= index && index <= length(); }
00045 
00046   oop* addr_as_oops() const { return (oop*)addr(); }
00047 
00048   // returns the location of the length field
00049   oop* length_addr() const {
00050     return &addr_as_oops()[blueprint()->non_indexable_size()];
00051   }
00052 
00053   smi length() const {
00054     oop len = *length_addr();
00055     assert(len->is_smi(), "length of indexable should be smi");
00056     return smiOop(len)->value();}
00057 
00058   void set_length(smi len) {
00059     *length_addr() = (oop) as_smiOop(len); }
00060  
00061   // returns the location where the double bytes start
00062   double* double_start() const {
00063     return (double*) &length_addr()[1];  
00064   }
00065 
00066   double* double_at_addr(int which) const {
00067     assert(which > 0 && which <= length(), "index out of bounds");
00068     return &double_start()[which - 1];
00069   }
00070 
00071   double double_at(int which) const {
00072     return *double_at_addr(which); }
00073 
00074   void double_at_put(int which, double value) {
00075     *double_at_addr(which) = value; }
00076 
00077   // memory operations
00078   bool verify();
00079 
00080   friend doubleValueArrayKlass;
00081 };
00082 

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