00001 /* Copyright 1994, 1995 LongView Technologies L.L.C. $Revision: 1.18 $ */ 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 // Primitives for small integers 00026 00027 class smiOopPrimitives : AllStatic { 00028 private: 00029 static void inc_calls() { number_of_calls++; } 00030 public: 00031 static int number_of_calls; 00032 00033 //%prim 00034 // <SmallInteger> primitiveLessThan: aNumber <SmallInteger> 00035 // ifFail: failBlock <PrimFailBlock> ^<Boolean> = 00036 // Internal { flags = #(Pure SmiCompare LastDeltaFrameNotNeeded) 00037 // name = 'smiOopPrimitives::lessThan' } 00038 //% 00039 static PRIM_DECL_2(lessThan, oop receiver, oop argument); 00040 00041 //%prim 00042 // <SmallInteger> primitiveGreaterThan: aNumber <SmallInteger> 00043 // ifFail: failBlock <PrimFailBlock> ^<Boolean> = 00044 // Internal { flags = #(Pure SmiCompare LastDeltaFrameNotNeeded) 00045 // name = 'smiOopPrimitives::greaterThan' } 00046 //% 00047 static PRIM_DECL_2(greaterThan, oop receiver, oop argument); 00048 00049 //%prim 00050 // <SmallInteger> primitiveLessThanOrEqual: aNumber <SmallInteger> 00051 // ifFail: failBlock <PrimFailBlock> ^<Boolean> = 00052 // Internal { flags = #(Pure SmiCompare LastDeltaFrameNotNeeded) 00053 // name = 'smiOopPrimitives::lessThanOrEqual' } 00054 //% 00055 static PRIM_DECL_2(lessThanOrEqual, oop receiver, oop argument); 00056 00057 //%prim 00058 // <SmallInteger> primitiveGreaterThanOrEqual: aNumber <SmallInteger> 00059 // ifFail: failBlock <PrimFailBlock> ^<Boolean> = 00060 // Internal { flags = #(Pure SmiCompare LastDeltaFrameNotNeeded) 00061 // name = 'smiOopPrimitives::greaterThanOrEqual' } 00062 //% 00063 static PRIM_DECL_2(greaterThanOrEqual, oop receiver, oop argument); 00064 00065 //%prim 00066 // <SmallInteger> primitiveSmallIntegerEqual: aNumber <SmallInteger> 00067 // ifFail: failBlock <PrimFailBlock> ^<Boolean> = 00068 // Internal { flags = #(Pure SmiCompare LastDeltaFrameNotNeeded) 00069 // name = 'smiOopPrimitives::equal' } 00070 //% 00071 static PRIM_DECL_2(equal, oop receiver, oop argument); 00072 00073 //%prim 00074 // <SmallInteger> primitiveSmallIntegerNotEqual: aNumber <SmallInteger> 00075 // ifFail: failBlock <PrimFailBlock> ^<Boolean> = 00076 // Internal { flags = #(Pure SmiCompare LastDeltaFrameNotNeeded) 00077 // name = 'smiOopPrimitives::notEqual' } 00078 //% 00079 static PRIM_DECL_2(notEqual, oop receiver, oop argument); 00080 00081 //%prim 00082 // <SmallInteger> primitiveBitAnd: aNumber <SmallInteger> 00083 // ifFail: failBlock <PrimFailBlock> ^<SmallInteger> = 00084 // Internal { flags = #(Pure SmiArith LastDeltaFrameNotNeeded) 00085 // name = 'smiOopPrimitives::bitAnd' } 00086 //% 00087 static PRIM_DECL_2(bitAnd, oop receiver, oop argument); 00088 00089 //%prim 00090 // <SmallInteger> primitiveBitOr: aNumber <SmallInteger> 00091 // ifFail: failBlock <PrimFailBlock> ^<SmallInteger> = 00092 // Internal { flags = #(Pure SmiArith LastDeltaFrameNotNeeded) 00093 // name = 'smiOopPrimitives::bitOr' } 00094 //% 00095 static PRIM_DECL_2(bitOr, oop receiver, oop argument); 00096 00097 //%prim 00098 // <SmallInteger> primitiveBitXor: aNumber <SmallInteger> 00099 // ifFail: failBlock <PrimFailBlock> ^<SmallInteger> = 00100 // Internal { flags = #(Pure SmiArith LastDeltaFrameNotNeeded) 00101 // name = 'smiOopPrimitives::bitXor' } 00102 //% 00103 static PRIM_DECL_2(bitXor, oop receiver, oop argument); 00104 00105 //%prim 00106 // <SmallInteger> primitiveBitShift: aNumber <SmallInteger> 00107 // ifFail: failBlock <PrimFailBlock> ^<SmallInteger> = 00108 // Internal { flags = #(Pure SmiArith LastDeltaFrameNotNeeded) 00109 // name = 'smiOopPrimitives::bitShift' } 00110 //% 00111 static PRIM_DECL_2(bitShift, oop receiver, oop argument); 00112 00113 //%prim 00114 // <SmallInteger> primitiveRawBitShift: aNumber <SmallInteger> 00115 // ifFail: failBlock <PrimFailBlock> ^<SmallInteger> = 00116 // Internal { flags = #(Pure SmiArith LastDeltaFrameNotNeeded) 00117 // name = 'smiOopPrimitives::rawBitShift' } 00118 //% 00119 static PRIM_DECL_2(rawBitShift, oop receiver, oop argument); 00120 00121 //%prim 00122 // <SmallInteger> primitiveAsObjectIfFail: failBlock <PrimFailBlock> ^<Object> = 00123 // Internal { error = #(OutOfBounds) 00124 // flags = #Function 00125 // name = 'smiOopPrimitives::asObject' } 00126 //% 00127 static PRIM_DECL_1(asObject, oop receiver); 00128 00129 // For debugging only 00130 //%prim 00131 // <SmallInteger> primitivePrintCharacterIfFail: failBlock <PrimFailBlock> ^<SmallInteger> = 00132 // Internal { error = #(OutOfBounds) 00133 // flags = #Function 00134 // name = 'smiOopPrimitives::printCharacter' } 00135 //% 00136 static PRIM_DECL_1(printCharacter, oop receiver); 00137 }; 00138 00139 // Assembler optimized primitives 00140 00141 //%prim 00142 // <SmallInteger> primitiveAdd: aNumber <SmallInteger> 00143 // ifFail: failBlock <PrimFailBlock> ^<SmallInteger> = 00144 // Internal { error = #(Overflow) 00145 // flags = #(Pure SmiArith LastDeltaFrameNotNeeded) 00146 // name = 'smiOopPrimitives_add' } 00147 //% 00148 extern "C" oop smiOopPrimitives_add(oop receiver, oop argument); 00149 00150 //%prim 00151 // <SmallInteger> primitiveSubtract: aNumber <SmallInteger> 00152 // ifFail: failBlock <PrimFailBlock> ^<SmallInteger> = 00153 // Internal { error = #(Overflow) 00154 // flags = #(Pure SmiArith LastDeltaFrameNotNeeded) 00155 // name = 'smiOopPrimitives_subtract' } 00156 //% 00157 extern "C" oop smiOopPrimitives_subtract(oop receiver, oop argument); 00158 00159 //%prim 00160 // <SmallInteger> primitiveMultiply: aNumber <SmallInteger> 00161 // ifFail: failBlock <PrimFailBlock> ^<SmallInteger> = 00162 // Internal { error = #(Overflow) 00163 // flags = #(Pure SmiArith LastDeltaFrameNotNeeded) 00164 // name = 'smiOopPrimitives_multiply' } 00165 //% 00166 extern "C" oop smiOopPrimitives_multiply(oop receiver, oop argument); 00167 00168 //%prim 00169 // <SmallInteger> primitiveMod: aNumber <SmallInteger> 00170 // ifFail: failBlock <PrimFailBlock> ^<SmallInteger> = 00171 // Internal { error = #(Overflow DivisionByZero) 00172 // flags = #(Pure SmiArith LastDeltaFrameNotNeeded) 00173 // name = 'smiOopPrimitives_mod' } 00174 //% 00175 extern "C" oop smiOopPrimitives_mod(oop receiver, oop argument); 00176 00177 //%prim 00178 // <SmallInteger> primitiveDiv: aNumber <SmallInteger> 00179 // ifFail: failBlock <PrimFailBlock> ^<SmallInteger> = 00180 // Internal { error = #(Overflow DivisionByZero) 00181 // flags = #(Pure SmiArith LastDeltaFrameNotNeeded) 00182 // name = 'smiOopPrimitives_div' } 00183 //% 00184 extern "C" oop smiOopPrimitives_div(oop receiver, oop argument); 00185 00186 //%prim 00187 // <SmallInteger> primitiveQuo: aNumber <SmallInteger> 00188 // ifFail: failBlock <PrimFailBlock> ^<SmallInteger> = 00189 // Internal { error = #(NotImplementedYet) 00190 // flags = #(Pure SmiArith LastDeltaFrameNotNeeded) 00191 // name = 'smiOopPrimitives_quo' } 00192 //% 00193 extern "C" oop smiOopPrimitives_quo(oop receiver, oop argument); 00194 00195 //%prim 00196 // <SmallInteger> primitiveRemainder: aNumber <SmallInteger> 00197 // ifFail: failBlock <PrimFailBlock> ^<SmallInteger> = 00198 // Internal { error = #(DivisionByZero) 00199 // flags = #(Pure SmiArith LastDeltaFrameNotNeeded) 00200 // name = 'smiOopPrimitives_remainder' } 00201 //% 00202 extern "C" oop smiOopPrimitives_remainder(oop receiver, oop argument); 00203 00204 //%prim 00205 // <SmallInteger> primitiveAsFloat ^<Float> = 00206 // Internal { flags = #(Pure SmiArith) 00207 // name = 'double_from_smi' } 00208 //% 00209 extern "C" oop double_from_smi(oop receiver);