00001 /***************************************************************************** 00002 * Copyright (c) 1997-2007, Intel Corporation. 00003 * All rights reserved. This program and the accompanying materials 00004 * are made available under the terms of the Eclipse Public License v1.0 00005 * which accompanies this distribution, and is available at 00006 * http://www.eclipse.org/legal/epl-v10.html 00007 * 00008 * Contributors: 00009 * Intel Corporation - Initial API and implementation 00010 * 00011 * $Id$ 00012 *****************************************************************************/ 00013 // 00014 #ifndef MRTE_MIE 00015 #define MRTE_MIE 00016 00017 #include <stdio.h> 00018 00019 00020 #include "MRTEResults.h" 00021 #include "MRTETypes.h" 00022 #include "MIterator.h" 00023 00024 00071 //TODO: //DOC: behavior of "wide" instructions in Java (the "wide" opcode is converted to the instruction it widens) 00072 00073 #define MIE_VERSION_01 00074 00075 namespace Martini { 00076 00077 namespace JIE 00078 { 00079 typedef U16 TConstantPoolIndex; 00080 } 00081 00087 namespace MIE 00088 { 00092 typedef U16 TVariableID; 00093 00097 enum EMnemonic 00098 { 00099 #ifdef MARTINI_JIE 00100 00101 #include "JavaMnemonics" // Java opcodes 00102 00103 #elif defined MARTINI_CIE 00104 00105 #include "CLR_ILMnemonics" // .NET opcodes 00106 #endif 00107 00108 #include "PsuedoMnemonics" 00109 #include "MieSpecialMnemonics" // Special MIE opcodes 00110 00111 }; 00112 00113 00122 enum EInstrumentationError 00123 { 00124 IE_NO_ERROR = 0, 00125 IE_INSTRUCTION_HAS_NO_OPERAND, 00126 00127 IE_OPERAND_TYPE_MISMATCH, 00128 IE_LAST, 00129 }; 00130 00131 class IInstruction; // forward reference 00132 00136 enum EInstructionIteratorType 00137 { 00138 IET_ORIGINAL_INSTRUCTIONS = 0, 00139 // method instructions and pseudo-instructions 00140 IET_ALL_INSTRUCTIONS 00141 // including those that were added or modified 00142 // during instrumentation. Instructions that were 00143 // deleted are not seen. 00144 }; 00145 00153 typedef RTUtil::IListIterator<IInstruction*> TInstructionListIterator; 00154 00163 struct SInstrumentationError 00164 { 00165 IInstruction* pInvalidInstruction; 00166 EInstrumentationError errorType; 00167 }; 00168 00178 struct SInstrumentationErrorsArray 00179 { 00180 SInstrumentationError* pErrors; 00181 unsigned int uiErrorEntries; 00182 unsigned int uiActualNumErrors; 00183 }; 00184 00195 struct SBuffer 00196 { 00197 unsigned char* pBuffer; 00198 unsigned int uiBufferSize; 00199 unsigned int uiActualSize; 00200 // required size when it is too short 00201 }; 00202 00213 struct SWideString 00214 { 00215 unsigned short *pStr; 00216 unsigned int uiBufferSize; 00217 unsigned int uiActualSize; 00218 }; 00219 00223 enum EOperandType 00224 { 00225 OT_NO_OPERAND = 0, 00226 OT_INT8, 00227 OT_UINT8, 00228 OT_INT16, 00229 OT_UINT16, 00230 OT_INT32, 00231 OT_UINT32, 00232 OT_INT64, 00233 OT_UINT64, 00234 OT_FLOAT32, 00235 OT_FLOAT64, 00236 OT_TARGET, 00237 OT_TARGETS_ARRAY, 00238 OT_VAR_ID, 00239 OT_DOT_NET_TOKEN, 00240 OT_JAVA_CP_INDEX, 00241 OT_LAST, 00242 }; 00243 00253 struct SCaseTarget 00254 { 00255 S32 caseValue; 00256 // lookupswitch instruction. 00257 IInstruction* pTarget; 00258 // case value. 00259 }; 00260 00270 struct STargetsArray 00271 { 00272 SCaseTarget *pTargetsArray; 00273 IInstruction *pDefaultTarget; 00274 // equals to the switch value 00275 unsigned int uiEntries; 00276 unsigned int uiUsedEntries; 00277 }; 00278 00279 00287 struct SOperand 00288 { 00289 00290 EOperandType type; 00291 00292 union 00293 { 00294 S8 s8Op; 00295 U8 ui8Op; 00296 S16 s16Op; 00297 U16 ui16Op; 00298 S32 s32Op; 00299 U32 ui32Op; 00300 S64 s64Op; 00301 U64 ui64Op; 00302 float f32Op; 00303 double d64Op; 00304 IInstruction* pTarget; 00305 STargetsArray targetsArray; 00306 // instruction 00307 TVariableID varID; 00308 00309 #ifdef MARTINI_CIE 00310 // .NET specific 00311 U32 token; 00312 #endif 00313 00314 #ifdef MARTINI_JIE 00315 // Java specific 00316 JIE::TConstantPoolIndex cpIndex; 00317 #endif 00318 } val; 00319 }; 00320 00325 // 00326 // Interface is named IMIEInterface to distinguish it from IMIE defined in 00327 // MieAPI.h. This is temporary until CIE is reimplemented to fully support 00328 // the MIE interface. See note at the beginning of this file for more 00329 // information. 00330 // 00331 //class IMIEInterface 00332 class IMIE 00333 { 00334 public: 00339 virtual unsigned int GetVersion() const = 0; 00340 }; 00341 00352 class IInstruction 00353 { 00354 public: 00355 00364 virtual const EMnemonic GetMnemonic() const = 0; 00365 00386 virtual TResult SetMnemonic(const EMnemonic newMnemonic) = 0; 00387 00429 virtual TResult GetOperand(SOperand* pOperand1, 00430 SOperand *pOperand2 = NULL, 00431 SOperand *pOperand3 = NULL, 00432 SOperand *pOperand4 = NULL) const = 0; 00433 00480 virtual TResult SetOperand(SOperand *pOperand1, 00481 SOperand *pOperand2 = NULL, 00482 SOperand *pOperand3 = NULL, 00483 SOperand *pOperand4 = NULL) = 0; 00484 00523 virtual TResult AddBefore(IInstruction **ppInstruction, 00524 const EMnemonic newInstMnemonic, 00525 const SOperand *pNewInstOperand1 = NULL, 00526 const SOperand *pNewInstOperand2 = NULL, 00527 const SOperand *pNewInstOperand3 = NULL) = 0; 00528 00566 virtual TResult AddAfter(IInstruction **ppInstruction, 00567 const EMnemonic newInstMnemonic, 00568 const SOperand *pNewInstOperand1 = NULL, 00569 const SOperand *pNewInstOperand2 = NULL, 00570 const SOperand *pNewInstOperand3 = NULL) = 0; 00571 00585 virtual bool IsOriginalInst() const = 0; 00586 00600 virtual TResult GetOriginalOffset(unsigned int* puiOriginalOffset) const = 0; 00601 00614 virtual IInstruction* GetBranchTarget() const = 0; 00615 00631 virtual IInstruction* SetBranchTarget(IInstruction *pTargetInst) = 0; 00632 }; 00633 00648 class IMethod 00649 { 00650 public: 00651 00669 virtual TInstructionListIterator *GetInstructionListIterator( 00670 const EInstructionIteratorType iteratorType) = 0; 00671 00717 virtual TResult BindTryFinallyBlock(IInstruction* iTry, 00718 IInstruction* iEndTry, 00719 IInstruction* iFinally, 00720 IInstruction* iEndFinally) = 0; 00721 00741 virtual TResult VerifyCode(SInstrumentationErrorsArray* pErrorsArray = NULL) const = 0; 00742 00765 virtual TResult ApplyInstrumentation() = 0; 00766 00782 virtual TResult DebugPrint(bool bToResolveNames, char* fileName = NULL) = 0; 00783 }; 00784 }} 00785 00786 #endif // #define MRTE_MIE 00787 00788
(C) Copyright Intel Corporation 2007-2008. All Rights Reserved.
Generated on Thu Mar 6 15:07:54 2008 for Martini by