vframe_prims.cpp

Go to the documentation of this file.
00001 /* Copyright 1996 LongView Technologies L.L.C. $Revision: 1.3 $ */
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 
00025 # include "incls/_precompiled.incl"
00026 # include "incls/_vframe_prims.cpp.incl"
00027 
00028 TRACE_FUNC(TraceVframePrims, "vframe")
00029 
00030 int vframeOopPrimitives::number_of_calls;
00031 
00032 #define ASSERT_RECEIVER assert(receiver->is_vframe(), "receiver must be vframe")
00033 
00034 PRIM_DECL_1(vframeOopPrimitives::process, oop receiver) {
00035   PROLOGUE_1("process", receiver);
00036   ASSERT_RECEIVER;
00037   return vframeOop(receiver)->process();
00038 }
00039 
00040 PRIM_DECL_1(vframeOopPrimitives::index, oop receiver) {
00041   PROLOGUE_1("index", receiver);
00042   ASSERT_RECEIVER;
00043   return as_smiOop(vframeOop(receiver)->index());
00044 }
00045 
00046 PRIM_DECL_1(vframeOopPrimitives::time_stamp, oop receiver) {
00047   PROLOGUE_1("time_stamp", receiver);
00048   ASSERT_RECEIVER;
00049   return as_smiOop(vframeOop(receiver)->time_stamp());
00050 }
00051 
00052 
00053 PRIM_DECL_1(vframeOopPrimitives::is_smalltalk_activation, oop receiver) {
00054   PROLOGUE_1("is_smalltalk_activation", receiver);
00055   ASSERT_RECEIVER;
00056 
00057   ResourceMark rm;
00058 
00059   vframe* vf = vframeOop(receiver)->get_vframe();
00060 
00061   if (vf == NULL)
00062     return markSymbol(vmSymbols::activation_is_invalid());
00063     
00064   return vf->is_delta_frame() ? trueObj : falseObj;
00065 }
00066 
00067 PRIM_DECL_1(vframeOopPrimitives::byte_code_index, oop receiver) {
00068   PROLOGUE_1("byte_code_index", receiver);
00069   ASSERT_RECEIVER;
00070 
00071   ResourceMark rm;
00072 
00073   vframe* vf = vframeOop(receiver)->get_vframe();
00074 
00075   if (vf == NULL)
00076     return markSymbol(vmSymbols::activation_is_invalid());
00077     
00078   if (!vf->is_delta_frame())
00079     return markSymbol(vmSymbols::external_activation());
00080   
00081   return as_smiOop(((deltaVFrame*) vf)->bci());
00082 }
00083 
00084 PRIM_DECL_1(vframeOopPrimitives::expression_stack, oop receiver) {
00085   PROLOGUE_1("expression_stack", receiver);
00086   ASSERT_RECEIVER;
00087 
00088   ResourceMark rm;
00089 
00090   vframe* vf = vframeOop(receiver)->get_vframe();
00091 
00092   if (vf == NULL)
00093     return markSymbol(vmSymbols::activation_is_invalid());
00094     
00095   if (!vf->is_delta_frame())
00096     return markSymbol(vmSymbols::external_activation());
00097 
00098   BlockScavenge bs;
00099 
00100   GrowableArray<oop>* stack = ((deltaVFrame*) vf)->expression_stack();
00101 
00102   return oopFactory::new_objArray(stack);
00103 }
00104 
00105 PRIM_DECL_1(vframeOopPrimitives::method, oop receiver) {
00106   PROLOGUE_1("method", receiver);
00107   ASSERT_RECEIVER;
00108 
00109   ResourceMark rm;
00110 
00111   vframe* vf = vframeOop(receiver)->get_vframe();
00112 
00113   if (vf == NULL)
00114     return markSymbol(vmSymbols::activation_is_invalid());
00115     
00116   if (!vf->is_delta_frame())
00117     return markSymbol(vmSymbols::external_activation());
00118 
00119   return ((deltaVFrame*) vf)->method();
00120 }
00121 
00122 PRIM_DECL_1(vframeOopPrimitives::receiver, oop recv) {
00123   PROLOGUE_1("receiver", recv);
00124 
00125   assert(recv->is_vframe(), "receiver must be vframe")
00126 
00127   ResourceMark rm;
00128 
00129   vframe* vf = vframeOop(recv)->get_vframe();
00130 
00131   if (vf == NULL)
00132     return markSymbol(vmSymbols::activation_is_invalid());
00133     
00134   if (!vf->is_delta_frame())
00135     return markSymbol(vmSymbols::external_activation());
00136 
00137   return ((deltaVFrame*) vf)->receiver();
00138 }
00139 
00140 PRIM_DECL_1(vframeOopPrimitives::temporaries, oop receiver) {
00141   PROLOGUE_1("temporaries", receiver);
00142   ASSERT_RECEIVER;
00143 
00144   return receiver;
00145 }
00146 
00147 PRIM_DECL_1(vframeOopPrimitives::arguments, oop receiver) {
00148   PROLOGUE_1("arguments", receiver);
00149   ASSERT_RECEIVER;
00150 
00151   ResourceMark rm;
00152 
00153   vframe* vf = vframeOop(receiver)->get_vframe();
00154 
00155   if (vf == NULL)
00156     return markSymbol(vmSymbols::activation_is_invalid());
00157     
00158   if (!vf->is_delta_frame())
00159     return markSymbol(vmSymbols::external_activation());
00160 
00161   BlockScavenge bs;
00162 
00163   GrowableArray<oop>* stack = ((deltaVFrame*) vf)->arguments();
00164 
00165   return oopFactory::new_objArray(stack);
00166 }
00167 
00168 class vframeStream: public byteArrayPrettyPrintStream {
00169   void begin_highlight() { set_highlight(true); print_char(27); }
00170   void end_highlight()   { set_highlight(false); print_char(27); }
00171 };
00172 
00173 PRIM_DECL_1(vframeOopPrimitives::pretty_print, oop receiver) {
00174   PROLOGUE_1("receiver", receiver);
00175   ASSERT_RECEIVER;
00176 
00177   ResourceMark rm;
00178   BlockScavenge bs;
00179 
00180   vframe* vf = vframeOop(receiver)->get_vframe();
00181 
00182   if (vf == NULL)
00183     return markSymbol(vmSymbols::activation_is_invalid());
00184 
00185   if (!vf->is_delta_frame())
00186     return markSymbol(vmSymbols::external_activation());
00187 
00188   byteArrayPrettyPrintStream* stream = new vframeStream;
00189   prettyPrinter::print_body((deltaVFrame*) vf, stream);
00190 
00191   return stream->asByteArray();
00192 }

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