nameDesc.cpp

Go to the documentation of this file.
00001 /* Copyright 1994 - 1996, LongView Technologies L.L.C. $Revision: 1.19 $ */
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 
00026 #ifdef DELTA_COMPILER
00027 
00028 # include "incls/_nameDesc.cpp.incl"
00029 
00030 void LocationNameDesc::print() {
00031   std->print("@%s (%d)", location().name(), offset);
00032 }
00033 
00034 void ValueNameDesc::print() {
00035   std->print("=");
00036   value()->print_value();
00037   std->print(" (%d)", offset);
00038 }
00039 
00040 void BlockValueNameDesc::print() {
00041   std->print("[=");
00042   block_method()->print_value();
00043   std->print("]");
00044   std->print(" (%d)", offset);
00045 }
00046 
00047 void MemoizedBlockNameDesc::print() {
00048   std->print("[@%s =", location().name());
00049   block_method()->print_value();
00050   std->print("]");
00051   std->print(" (%d)", offset);
00052 }
00053 
00054 void IllegalNameDesc::print() {
00055   std->print("###illegal###");
00056   std->print(" (%d)", offset);
00057 }
00058 
00059 bool LocationNameDesc::equal(NameDesc* other) const {
00060   if (other->isLocation()) {
00061     return location() == ((LocationNameDesc*) other)->location();
00062   }
00063   return false;
00064 }
00065 
00066 bool ValueNameDesc::equal(NameDesc* other) const {
00067   if (other->isValue()) {
00068     return value() == ((ValueNameDesc*) other)->value();
00069   }
00070   return false;
00071 }
00072 
00073 bool BlockValueNameDesc::equal(NameDesc* other) const {
00074   if (other->isBlockValue()) {
00075     return block_method() == ((BlockValueNameDesc*) other)->block_method()
00076         && parent_scope()->s_equivalent(((BlockValueNameDesc*) other)->parent_scope());
00077   }
00078   return false;
00079 }
00080 
00081 bool MemoizedBlockNameDesc::equal(NameDesc* other) const {
00082   if (other->isMemoizedBlock()) {
00083     return location()     == ((MemoizedBlockNameDesc*) other)->location()
00084         && block_method() == ((MemoizedBlockNameDesc*) other)->block_method()
00085         && parent_scope()->s_equivalent(((MemoizedBlockNameDesc*) other)->parent_scope());
00086   }
00087   return false;
00088 }
00089 
00090 bool IllegalNameDesc::equal(NameDesc* other) const {
00091   return other->isIllegal();
00092 }
00093 
00094 extern "C" oop allocateBlock(smiOop nofArgs);
00095 
00096 oop BlockValueNameDesc::value(const frame* fr) const {
00097   // create a block closure
00098   if (MaterializeEliminatedBlocks || StackChunkBuilder::is_deoptimizing()) {
00099     blockClosureOop blk = blockClosureOop(
00100          allocateBlock(as_smiOop(block_method()->number_of_arguments())));
00101     blk->set_method(block_method());
00102 
00103     compiledVFrame* vf = compiledVFrame::new_vframe(fr, parent_scope(), 0);
00104     blk->set_lexical_scope(vf->canonical_context());
00105     return blk;
00106   } else {
00107     ResourceMark rm;
00108     stringStream st(50);
00109     st.print("eliminated [] in ");
00110     block_method()->home()->selector()->print_symbol_on(&st);
00111     return oopFactory::new_symbol(st.as_string());
00112   }
00113 }
00114 
00115 oop MemoizedBlockNameDesc::value(const frame* fr) const {
00116   // check is the block has been created
00117   compiledVFrame* vf = fr 
00118                      ? compiledVFrame::new_vframe(fr, parent_scope(), 0)
00119                      : NULL;
00120 
00121   oop stored_value = compiledVFrame::resolve_location(location(), vf);
00122   if (stored_value != uncreatedBlockValue()) {
00123     return stored_value;
00124   }
00125   
00126   // otherwise do the same as for a BlockValueNameDesc
00127   if (MaterializeEliminatedBlocks || StackChunkBuilder::is_deoptimizing()) {
00128     blockClosureOop blk = blockClosureOop(
00129          allocateBlock(as_smiOop(block_method()->number_of_arguments())));
00130     blk->set_method(block_method());
00131 
00132     blk->set_lexical_scope(vf->canonical_context());
00133     return blk;
00134   } else {
00135     ResourceMark rm;
00136     stringStream st(50);
00137     st.print("memoized [] in ");
00138     block_method()->home()->selector()->print_symbol_on(&st);
00139     return oopFactory::new_symbol(st.as_string());
00140   }
00141 }
00142 
00143 #endif

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