oopFactory.cpp

Go to the documentation of this file.
00001 /* Copyright 1994, 1995 LongView Technologies L.L.C. $Revision: 1.20 $ */
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/_oopFactory.cpp.incl"
00026 
00027 byteArrayOop oopFactory::new_byteArray(int size) {
00028   byteArrayKlass* bk =
00029     (byteArrayKlass*) Universe::byteArrayKlassObj()->klass_part();
00030   return byteArrayOop(bk->allocateObjectSize(size));
00031 }
00032 
00033 byteArrayOop oopFactory::new_byteArray(char* name) {
00034   int len = strlen(name);
00035   byteArrayOop result = new_byteArray(len);
00036   for (int index = 0; index < len; index++) {
00037     result->byte_at_put(index+1, name[index]);
00038   }
00039   return result;
00040 }
00041 
00042 objArrayOop oopFactory::new_objArray(int size) {
00043   objArrayKlass* ok =
00044     (objArrayKlass*) Universe::objArrayKlassObj()->klass_part();
00045   return objArrayOop(ok->allocateObjectSize(size));
00046 }
00047 
00048 objArrayOop oopFactory::new_objArray(GrowableArray<oop>* array) {
00049   BlockScavenge bs;
00050   FlagSetting(processSemaphore, true);
00051   int size = array->length();
00052   objArrayKlass* ok =
00053     (objArrayKlass*) Universe::objArrayKlassObj()->klass_part();
00054 
00055   objArrayOop result = objArrayOop(ok->allocateObjectSize(size));
00056   for (int index = 1; index <= size; index++) {
00057     result->obj_at_put(index, array->at(index-1));
00058   }
00059   return result;
00060 }
00061 
00062 doubleOop oopFactory::new_double(double value) {
00063   doubleOop d = as_doubleOop(Universe::allocate(sizeof(doubleOopDesc)/oopSize));
00064   d->init_untagged_contents_mark();
00065   d->set_klass_field(doubleKlassObj);
00066   d->set_value(value);
00067   return d;
00068 }
00069 
00070 doubleOop oopFactory::clone_double_to_oldspace(doubleOop value) {
00071   doubleOop d = as_doubleOop(Universe::allocate_tenured(sizeof(doubleOopDesc)/oopSize));
00072   d->init_untagged_contents_mark();
00073   d->set_klass_field(doubleKlassObj);
00074   d->set_value(value->value());
00075   return d;
00076 }
00077 
00078 symbolOop oopFactory::new_symbol(char* name,int len) {
00079   return Universe::symbol_table->lookup(name, len);
00080 }
00081 
00082 symbolOop oopFactory::new_symbol(char* name) {
00083   return new_symbol(name, strlen(name));
00084 }
00085 
00086 symbolOop oopFactory::new_symbol(byteArrayOop b) {
00087   return new_symbol(b->chars(), b->length());
00088 }
00089 
00090 associationOop oopFactory::new_association(symbolOop key, oop value, bool is_constant) {
00091   associationOop as = associationOop(Universe::associationKlassObj()->klass_part()->allocateObject());
00092   assert(as->is_association(), "type check");
00093   as->set_key(key);
00094   as->set_value(value);
00095   as->set_is_constant(is_constant);
00096   return as;
00097 }
00098 
00099 vframeOop oopFactory::new_vframe(processOop process, int index) {
00100   BlockScavenge bs;
00101   vframeKlass* vk =(vframeKlass*) Universe::vframeKlassObj()->klass_part();
00102 
00103   vframeOop result = vframeOop(vk->allocateObject());
00104 
00105   result->set_process(process);
00106   result->set_index(index);
00107   result->set_time_stamp(process->process()->time_stamp());
00108 
00109   return result;
00110 }

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