nativeInstruction.cpp

Go to the documentation of this file.
00001 /* Copyright 1994 - 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 # include "incls/_precompiled.incl"
00025 # include "incls/_nativeInstruction.cpp.incl"
00026 
00027 
00028 // Implementation of NativeCall
00029 
00030 void NativeCall::verify() {
00031   // make sure code pattern is actually a call imm32 instruction
00032   if (*(u_char*)instruction_address() != instruction_code) fatal("not a call imm32");
00033 }
00034 
00035 
00036 void NativeCall::print() {
00037   std->print_cr("0x%x: call 0x%x", instruction_address(), destination());
00038 }
00039 
00040   NativeCall* nativeCall_at(char* address) {
00041     NativeCall* call = (NativeCall*)(address - NativeCall::instruction_offset);
00042     #ifdef ASSERT
00043       call->verify();
00044     #endif
00045     return call;
00046   }
00047 
00048   NativeCall* nativeCall_from_return_address(char* return_address) {
00049     NativeCall* call = (NativeCall*)(return_address - NativeCall::return_address_offset);
00050     #ifdef ASSERT
00051       call->verify();
00052     #endif
00053     return call;
00054   }
00055 
00056   NativeCall* nativeCall_from_relocInfo(char* displacement_address) {
00057     NativeCall* call = (NativeCall*)(displacement_address - NativeCall::displacement_offset);
00058     #ifdef ASSERT
00059       call->verify();
00060     #endif
00061     return call;
00062   }
00063 
00064 // Implementation of NativeMov
00065 void NativeMov::verify() {
00066   // make sure code pattern is actually a mov reg, imm32 instruction
00067   if (*(u_char*)instruction_address() & !register_mask != instruction_code) fatal("not a mov reg, imm32");
00068 }
00069 
00070 
00071 void NativeMov::print() {
00072   std->print_cr("0x%x: mov reg, 0x%x", instruction_address(), data());
00073 }
00074 
00075   NativeMov* nativeMov_at(char* address) {
00076     NativeMov* test = (NativeMov*)(address - NativeMov::instruction_offset);
00077     #ifdef ASSERT
00078       test->verify();
00079     #endif
00080     return test;
00081   }
00082 
00083 
00084 
00085 // Implementation of NativeTest
00086 void NativeTest::verify() {
00087   // make sure code pattern is actually a test eax, imm32 instruction
00088   if (*(u_char*)instruction_address() != instruction_code) fatal("not a test eax, imm32");
00089 }
00090 
00091 
00092 void NativeTest::print() {
00093   std->print_cr("0x%x: test eax, 0x%x", instruction_address(), data());
00094 }
00095 
00096 NativeTest* nativeTest_at(char* address)
00097 {
00098     NativeTest* test = (NativeTest*)(address - NativeTest::instruction_offset);
00099     #ifdef ASSERT
00100       test->verify();
00101     #endif
00102     return test;
00103 }
00104 
00105 IC_Info* ic_info_at(char* address)
00106 {
00107     return (IC_Info*)nativeTest_at(address);
00108 }

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