prim_impl.hpp

Go to the documentation of this file.
00001 /* Copyright 1994 - 1996 LongView Technologies L.L.C. $Revision: 1.12 $ */
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 // Macroes for the primitive implementation
00025 
00026 #define PRIM_NOT_IMPLEMENTED \
00027    return markSymbol(vmSymbols::not_yet_implemented());
00028 
00029 
00030 // Macros to disable certain primitives in the final product.
00031 // Note: Some primitives cannot fail (and in the compiled code
00032 //       there might be no check for failure), thus they cannot
00033 //       return a markOop but must return a normal oop.
00034 
00035 #ifdef PRODUCT
00036   #define PRINT_WARNING                     warning("warning: disabled primitive called");
00037   #define PRIMITIVE_FAILS_IN_PRODUCT        return markSymbol(vmSymbols::primitive_disabled_in_product());
00038   #define PRIMITIVE_RETURNS_TRUE_IN_PRODUCT PRINT_WARNING return Universe::trueObj();
00039   #define PRIMITIVE_RETURNS_ZERO_IN_PRODUCT PRINT_WARNING return as_smiOop(0);
00040 #else
00041   #define PRIMITIVE_FAILS_IN_PRODUCT
00042   #define PRIMITIVE_RETURNS_TRUE_IN_PRODUCT
00043   #define PRIMITIVE_RETURNS_ZERO_IN_PRODUCT
00044 #endif
00045 
00046 
00047 // Macros to do primitive tracing
00048 
00049 #ifdef ASSERT
00050 #define TRACE_FUNC(flag,label) \
00051   static void Trace(char* name, \
00052                     char* s1 = NULL, oop a1 = NULL, \
00053                     char* s2 = NULL, oop a2 = NULL, \
00054                     char* s3 = NULL, oop a3 = NULL, \
00055                     char* s4 = NULL, oop a4 = NULL, \
00056                     char* s5 = NULL, oop a5 = NULL, \
00057                     char* s6 = NULL, oop a6 = NULL, \
00058                     char* s7 = NULL, oop a7 = NULL) { \
00059   if (!flag) return; \
00060   lprintf("{%s::%s", label, name); \
00061   if (s1) { lprintf(" %s=", s1); a1->print_value(); } \
00062   if (s2) { lprintf(" %s=", s2); a2->print_value(); } \
00063   if (s3) { lprintf(" %s=", s3); a3->print_value(); } \
00064   if (s4) { lprintf(" %s=", s4); a4->print_value(); } \
00065   if (s5) { lprintf(" %s=", s5); a5->print_value(); } \
00066   if (s6) { lprintf(" %s=", s6); a6->print_value(); } \
00067   if (s7) { lprintf(" %s=", s7); a7->print_value(); } \
00068   lprintf("}\n"); \
00069 }
00070 #define TRACE_0(name) \
00071   inc_calls();  \
00072   Trace(name);
00073 
00074 #define TRACE_1(name, a1) \
00075   inc_calls();      \
00076   Trace(name, XSTR(a1), a1);
00077 
00078 #define TRACE_2(name, a1, a2) \
00079   inc_calls();          \
00080   Trace(name, XSTR(a1), a1, XSTR(a2), a2);
00081 
00082 #define TRACE_3(name, a1, a2, a3) \
00083   inc_calls();              \
00084   Trace(name, XSTR(a1), a1, XSTR(a2), a2, XSTR(a3), a3);
00085 
00086 #define TRACE_4(name, a1, a2, a3, a4) \
00087   inc_calls();                  \
00088   Trace(name, XSTR(a1), a1, XSTR(a2), a2, XSTR(a3), a3, XSTR(a4), a4);
00089 
00090 #define TRACE_5(name, a1, a2, a3, a4, a5) \
00091   inc_calls();                      \
00092   Trace(name, XSTR(a1), a1, XSTR(a2), a2, XSTR(a3), a3, XSTR(a4), a4, XSTR(a5), a5);
00093 
00094 #define TRACE_6(name, a1, a2, a3, a4, a5, a6) \
00095   inc_calls();                          \
00096   Trace(name, XSTR(a1), a1, XSTR(a2), a2, XSTR(a3), a3, XSTR(a4), a4, XSTR(a5), a5, XSTR(a6), a6);
00097 
00098 #define TRACE_7(name, a1, a2, a3, a4, a5, a6, a7) \
00099   inc_calls();                              \
00100   Trace(name, XSTR(a1), a1, XSTR(a2), a2, XSTR(a3), a3, XSTR(a4), a4, XSTR(a5), a5, XSTR(a6), a6, XSTR(a7), a7);
00101 #else
00102 #define TRACE_FUNC(flag, label)
00103 #define TRACE_0(name)
00104 #define TRACE_1(name, a1)
00105 #define TRACE_2(name, a1, a2)
00106 #define TRACE_3(name, a1, a2, a3)
00107 #define TRACE_4(name, a1, a2, a3, a4)
00108 #define TRACE_5(name, a1, a2, a3, a4, a5)
00109 #define TRACE_6(name, a1, a2, a3, a4, a5, a6)
00110 #define TRACE_7(name, a1, a2, a3, a4, a5, a6, a7)
00111 #endif
00112 
00113 
00114 #define PROLOGUE_0(name)                             TRACE_0(name)
00115 #define PROLOGUE_1(name, a1)                         TRACE_1(name, a1)
00116 #define PROLOGUE_2(name, a1, a2)                     TRACE_2(name, a1, a2)
00117 #define PROLOGUE_3(name, a1, a2, a3)                 TRACE_3(name, a1, a2, a3)
00118 #define PROLOGUE_4(name, a1, a2, a3, a4)             TRACE_4(name, a1, a2, a3, a4)
00119 #define PROLOGUE_5(name, a1, a2, a3, a4, a5)         TRACE_5(name, a1, a2, a3, a4, a5)
00120 #define PROLOGUE_6(name, a1, a2, a3, a4, a5, a6)     TRACE_6(name, a1, a2, a3, a4, a5, a6)
00121 #define PROLOGUE_7(name, a1, a2, a3, a4, a5, a6, a7) TRACE_7(name, a1, a2, a3, a4, a5, a6, a7)

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