Index: trunk/vm/port/include/apr_thread_ext.h =================================================================== --- trunk/vm/port/include/apr_thread_ext.h (revision 504464) +++ trunk/vm/port/include/apr_thread_ext.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,12 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Andrey Chernyshev - * @version $Revision$ - */ - - #ifndef APR_EXT_H #define APR_EXT_H Index: trunk/vm/port/include/clog.h =================================================================== --- trunk/vm/port/include/clog.h (revision 504464) +++ trunk/vm/port/include/clog.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,11 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** -* @author Roman S. Bushmanov -* @version $Revision: 1.1.2.1.4.3 $ -*/ - #ifndef _C_LOG_H_ #define _C_LOG_H_ Index: trunk/vm/port/include/cxxlog.h =================================================================== --- trunk/vm/port/include/cxxlog.h (revision 504464) +++ trunk/vm/port/include/cxxlog.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -13,11 +13,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ -/** - * @author Alexey V. Varlamov, Evgueni Brevnov - * @version $Revision: 1.1.2.2.4.4 $ - */ + */ #ifndef _CXX_LOG_H_ #define _CXX_LOG_H_ @@ -28,19 +24,15 @@ namespace util { - /** - * Predefined classloader filter. - */ - const char CLASS_LOGGER[] = "class"; - /** - * Predefined gc filter. - */ - const char GC_LOGGER[] = "gc"; - /** - * Predefined jni filter. - */ - const char JNI_LOGGER[] = "jni"; + /** Predefined classloader filter.*/ + const char CLASS_LOGGER[] = "class"; + /** Predefined gc filter.*/ + const char GC_LOGGER[] = "gc"; + + /** Predefined jni filter.*/ + const char JNI_LOGGER[] = "jni"; + } // namespace util #define LOGGER_EXIT(code) { \ Index: trunk/vm/port/include/lil.h =================================================================== --- trunk/vm/port/include/lil.h (revision 504464) +++ trunk/vm/port/include/lil.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,12 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Intel, Evgueni Brevnov, Ivan Volosyuk - * @version $Revision: 1.1.2.1.4.4 $ - */ - - #ifndef _LIL_H_ #define _LIL_H_ @@ -29,218 +23,284 @@ #include "tl/memory_pool.h" #include "m2n.h" -/* This file describes LIL - the architecture-independent language used to generate code stubs etc. +/** + * @file + * This file describes LIL - the architecture-independent language used to + * generate code stubs etc. + * + * Goals: + * + * + * Design constaints: + * + * + * The basic unit of LIL is a code stub. It is intended to be the entry point + * of a function that can be called by managed or native code, and executes in + * the presence of an activation frame. The frame consists of up to six parts: + * inputs, standard places, an m2n frame, locals, outputs, and a return variable. + * Which parts are present in the activation frame, and how big each part is, can + * vary across points in the code stub. + * + * A LIL code stub is an entry and a sequence of statements. The entry specifies + * the inputs and their types, the number of standard places, the type of the + * return, and the calling convention (which determines where the inputs, + * return address, and return goes, which registers are caller save vs callee save, + * and who pops the inputs; standard places are determined by LIL and the platform, + * and are intended for trampolines). An entry can have an "arbitrary" + * signature, meaning that the number and type of inputs and type of return is + * unknown (the stub must work for all possibilities). After entry the declared + * number of input variables are available, the declared number of standard + * places are available, there is no m2n frame, there are no locals, there are no + * outputs, and there is no return variable. + *
+ * cs ::= entry i:cc:sig; ss
+ * ss ::= s | s ss
+ * 
+ * The statements are: + *
+ * s ::= :l;
+ * |  locals i;
+ * |  std_places i;
+ * |  alloc v,i;
+ * |  v=uop o;
+ * |  v=o op o;
+ * |  v=o;
+ * |  v=ts;
+ * |  handles=o;
+ * |  ld v,addr(,zx|,sx)?;
+ * |  st addr,o;
+ * |  inc addr;
+ * |  cas addr=o,o,l;
+ * |  j l;
+ * |  jc cond,l;
+ * |  out cc:sig;
+ * |  in2out cc:RT;
+ * |  calli o;
+ * |  ret; 
+ * |  push_m2n i oh;
+ * |  m2n_save_all;
+ * |  pop_m2n;
+ * |  print str, o;
+ *
+ * uop ::= neg | not | sx1 | sx2 | sx4 | zx1 | zx2 | zx4 | ...
+ * op ::= + | - | * | & | << | ...
+ *
+ * addr ::= [ov osv i :T ackrel]
+ * ov ::= | v+
+ * osv ::= | 1*v+ | 2*v+ | 4*v+ | 8*v+
+ * acqrel ::= | ,acquire | ,release
+ *
+ * cond ::= v=0 | v!=0 | o=o | o!=o | o
+ *
+ * platform = default calling convention used by VM
+ * jni      = calling convention used by JNI
+ * managed  = calling convention used by jitted code
+ * rth      = calling convention used to call runtime helpers
+ * stdcall  = Windows's stdcall calling convention
+ *
+ * 20021204: The rth calling convention should be used for all runtime helpers.  
+ *           Unfortunately, on IA32 we are inconsistent in the calling
+ *           conventions used to call runtime helpers - some use stdcall, some 
+ *           use the managed code conventions. So for now, rth is to be
+ *           used for stdcall helpers, managed should be used for the rest.  
+ *           In the future we can harmonise this and correct the problem.
+ *
+ * l is a label (sequence of alpha, digit, _, starting with alpha or _)
+ * v is a variable, one of: i0, i1, ... (input variables), sp0, sp1, ... (standard places), 
+ * l0, l1, ... (local variables),
+ * o0, o1, ... (output variables), r (return variable)
+ * i is an immediate (sequence of digits, or 0x hex digits)
+ * str is either a string enclosed in single quotes, or a number denoting an address
+ *
+ * Operand semantics:
+ *
+ * An operand with a v stands for that variable; an operand with an i stands for 
+ * that immediate; an operand with an optional :t is cast to the
+ * type t (ie it has type t). Only certain casts are allowed by the verifier: 
+ * the types ref, pint, and g4/g8 (depending upon architecture) are
+ * castable to each other. Note that casting refs to/from the other types may be 
+ * GC unsafe.
+ *
+ * Statement semantics:
+ *
+ * :l declares a label l. A LIL code stub is not valid if such a label merges 
+ * control flow with inconsistent activation frames. Specifically, the number 
+ * and types of inputs must be the same (currently there is no way they
+ * could not be), only the minimum of the number of standard places will be 
+ * available after the statement, the m2n frame must either be present in 
+ * all incoming edges or absent in all incoming edges, the number of locals 
+ * must be the same, the number of outputs must be the same, and
+ * the return variable will be defined after the statement only if it is 
+ * defined on all incoming edges.
+ *
+ * locals i makes i locals available in the activation frame.  
+ * If there were locals available previously, they are lost.
+ * std_places i makes i standard places available in the activation frame.  
+ * If there were standard places available previously,
+ * they are lost.
+ *
+ * alloc v, i allocates i contigous bytes of space whose lifetime is up to the 
+ * next ret, tailcall, or pop_m2n instruction.
+ * The address of this space is placed into v. The space will not be moved for 
+ * any reason. The amount of space allocated by such instructions must
+ * be statically determinable for each code point in a code stub. This instruction 
+ * may not appear between out/in2out and call/call.noret/tailcall instructions.
+ *
+ * v=uop o evaluates o to a value, performs unary operation uop on it, and stores 
+ * the result in v. 
+ *
+ * v=o1 op o2 evaluates o1 & o2 to values, performs binary operation op on them, 
+ * and stores the result in v.
+ *
+ * v=ts places a pointer to the current thread's thread structure into v.
+ *
+ * handles=o evaluates o to a value and sets the handles pointer in the m2n frame 
+ * to this value. This instruction must be dominated by a push_m2n handles 
+ * instruction.
+ *
+ * ld v,addr evaluates addr to an address (see below) and loads the value 
+ * (of type given in addr) at this address into v. If ,zx appears at the end then the 
+ * value is zero extended into v, which gets type pint; if ,sx appears at the end then 
+ * the value is sign extended into v, which gets pint; otherwise, v gets the same type as 
+ * in addr.
+ *
+ * st addr,o evaluates addr to an address (see below) o to a value and stores the 
+ * value into the contents (of type given in addr) at the address.
+ *
+ * inc addr evaluates addr to an address (ses below) and increments the value 
+ * (of type given in addr) at this address.
+ *
+ * cas addr=o1,o2,l evaluates addr to an address (see below) a, o1 to a value v1, and 
+ * o2 to a value v2. Then it atomically: compares the value (of type gien in addr) 
+ * to o1 and if equal swaps the contents of a with o2. If the match fails then it 
+ * jumps to label l.
+ *
+ * ov+osv+i:T acqrel evaluates to (0 | contents of v) + (0 | 1 * contents of v
+ * | 2 * contents of v | 4 * contents of v | * 8 * contents of v) + i. 
+ * Further if acqrel is acquire then the operation in which it appears has 
+ * acquire semantics, and if it is release then the operation in which it 
+ * appears has release semantics.
+ *
+ * j l jumps to label l. A LIL code stub is invalid if l is not a declared label 
+ * in the code stub.
+ * jc cond, l either continues with the next statement or jumps to label l, 
+ * depending upon the evaluation of cond. A LIL code stub is invalid if l 
+ * is not declared in the stub. The conditions are evaluated as follows.  
+ * v=0 will branch if v has value 0; v!=0 will branch if v does not have value 0; 
+ * o1=o2 will branch if o1 & o2 evaluate to the same value; o1!=o2
+ * will branch if o1 & o2 evaluate to different values; o1
+ * T ::= g1 | g2 | g4 | g8 | f4 | f8 | ref | pint
+ * RT ::= T | void
+ *
+ * sig ::= Ts:RT | arbitrary
+ * Ts ::= | T,Ts
+ * 
+ * + * The meaning of the types is: g1 means a one-byte general-purpose (ie not + * floating point) quantitiy, g2 means two-byte, g4 means 4-bytes, g8 menas + * eight-byte, f4 means a 4-byte floating-point quantity, f8 means 8-byte, + * ref means a pointer into the managed heap, pint means a platform-sized + * general-purpose quantity which might be an integer or an unmanaged pointer, + * void means there is nothing returned. + * + * The LIL syntax allows comments that start with // and go to the end of the line. + */ -Goals: -* Lightweight - i.e. small language, quality code generation possible with small simple algorithms -* Remove most architecture dependencies from code -* (Future) allow inlining of VM stubs into JITed code -* (Future) allow inlining of GC or Thread/Sync code via LIL -* (Possibly future) be the lowest ir of a simple JIT - -Design constaints: -* Keep language syntax LL(1) so that parsing can be done with a recursive descent parser -* Make single-pass register allocation possible -* Allow easy experimentation with calling conventions - -The basic unit of LIL is a code stub. It is intended to be the entry point of a function that can be -called by managed or native code, and executes in the presence of an activation frame. The frame consists -of up to six parts: inputs, standard places, an m2n frame, locals, outputs, and a return variable. Which -parts are present in the activation frame, and how big each part is, can vary across points in the code stub. - -A LIL code stub is an entry and a sequence of statements. The entry specifies the inputs and their types, the -number of standard places, the type of the return, and the calling convention (which determines where the inputs, -return address, and return goes, which registers are caller save vs callee save, and who pops the inputs; standard -places are determined by LIL and the platform, and are intended for trampolines). An entry can have an "arbitrary" -signature, meaning that the number and type of inputs and type of return is unknown (the stub must work for all -possibilities). After entry the declared number -of input variables are available, the declared number of standard places are available, there is no m2n frame, -there are no locals, there are no outputs, and there is no return variable. - -cs ::= entry i:cc:sig; ss -ss ::= s | s ss - -The statements are: - -s ::= :l; -| locals i; -| std_places i; -| alloc v,i; -| v=uop o; -| v=o op o; -| v=o; -| v=ts; -| handles=o; -| ld v,addr(,zx|,sx)?; -| st addr,o; -| inc addr; -| cas addr=o,o,l; -| j l; -| jc cond,l; -| out cc:sig; -| in2out cc:RT; -| calli o; -| ret; -| push_m2n i oh; -| m2n_save_all; -| pop_m2n; -| print str, o; - -uop ::= neg | not | sx1 | sx2 | sx4 | zx1 | zx2 | zx4 | ... -op ::= + | - | * | & | << | ... - -addr ::= [ov osv i :T ackrel] -ov ::= | v+ -osv ::= | 1*v+ | 2*v+ | 4*v+ | 8*v+ -acqrel ::= | ,acquire | ,release - -cond ::= v=0 | v!=0 | o=o | o!=o | o + *
  • i in an immediate, takes the next argument as a pointer-size + * int (int on IA32, long long on IPF) as the value of the immediate
  • + *
  • i in a variable, takes the next argument as a platform int + * as the index (not valid for ret)
  • + *
  • m in a signature, takes the next argument as a + * Method_Handle and constructs the standard managed signature + * for it
  • + *
  • j in a signature, takes the next argument as a + * Method_Handle and constructs the standard JNI signature for it
  • + * + * + * % may also be used in a label to get generated labels, there are + * no numbers, but the specifiers are: + * + * + * @return NULL on parsing error + */ LilCodeStub* lil_parse_code_stub(const char* src, ...); -// Parse a string as a sequence of instructions and add them to the end of the input code stub. -// The % syntax above can be used. -// Return NULL on parsing error and the input is freed, otherwise the return is the same as the parameter. -LilCodeStub* lil_parse_onto_end(LilCodeStub*, const char* src, ...); -//*** Instruction Contexts +/** + * Parse a string as a sequence of instructions and add them to the end of the + * input code stub. + * The % syntax above can be used. + * + * @return NULL on parsing error and the input is freed, otherwise + * the return is the same as the parameter. + */ + LilCodeStub* lil_parse_onto_end(LilCodeStub*, const char* src, ...); +//@} +/** @name Instruction Contexts*/ +//@{ enum LilM2nState { LMS_NoM2n, LMS_NoHandles, LMS_Handles }; struct LilInstructionContext; @@ -318,173 +402,193 @@ VMEXPORT unsigned lil_ic_get_amt_alloced(LilInstructionContext*); VMEXPORT LilType lil_ic_get_type(LilCodeStub*, LilInstructionContext*, LilOperand*); - -// returns the type of an instruction's destination variable _after_ the -// instruction is performed. -// If the instruction has no destination, LT_Void is returned. -// Notice that this type may be different than the type returned by -// lil_ic_get_type for the destination variable, since the latter -// refers to the situation _before_ the instruction. +/** + * Returns the type of an instruction's destination variable _after_ + * the instruction is performed. + * If the instruction has no destination, LT_Void is returned. + * Notice that this type may be different than the type returned by + * lil_ic_get_type for the destination variable, since the latter + * refers to the situation _before_ the instruction. + */ VMEXPORT LilType lil_instruction_get_dest_type(LilCodeStub*, LilInstruction*, LilInstructionContext*); - -//*** Interogators - -// Is a LIL code stub valid? +//@} +/** @name Interogators*/ +//@{ +/////// Is a LIL code stub valid? VMEXPORT bool lil_is_valid(LilCodeStub* cs); -// Return a code stubs entry signature +/** Return a code stubs entry signature.*/ VMEXPORT LilSig* lil_cs_get_sig(LilCodeStub* cs); -// Return the number of instructions in a code stub -VMEXPORT unsigned lil_cs_get_num_instructions(LilCodeStub* cs); +/** Return the number of instructions in a code stub.*/ + VMEXPORT unsigned lil_cs_get_num_instructions(LilCodeStub* cs); -// Return the number of BBs in a code stub -VMEXPORT unsigned lil_cs_get_num_BBs(LilCodeStub *cs); +/** Return the number of BBs in a code stub.*/ + VMEXPORT unsigned lil_cs_get_num_BBs(LilCodeStub *cs); -// Return the first BB in the stub (from that one can get all BBs using get_next() -VMEXPORT LilBb* lil_cs_get_entry_BB(LilCodeStub* cs); +/** Return the first BB in the stub (from that one can get all + * BBs using + * get_next().*/ + VMEXPORT LilBb* lil_cs_get_entry_BB(LilCodeStub* cs); -// Compute the contexts of each instruction in the code stub -// This function must be called to use instruction iterators that track contexts -VMEXPORT void lil_compute_contexts(LilCodeStub* cs); +/** Compute the contexts of each instruction in the code stub + * This function must be called to use instruction iterators that track contexts.*/ + VMEXPORT void lil_compute_contexts(LilCodeStub* cs); -// Return maximum number of std places used in the stub -VMEXPORT unsigned lil_cs_get_max_std_places(LilCodeStub * cs); +/** Return maximum number of std places used in the stub.*/ + VMEXPORT unsigned lil_cs_get_max_std_places(LilCodeStub * cs); -// Return maximum number of locals used in the stub -VMEXPORT unsigned lil_cs_get_max_locals(LilCodeStub * cs); +/** Return maximum number of locals used in the stub.*/ + VMEXPORT unsigned lil_cs_get_max_locals(LilCodeStub * cs); -// Return size of generated code -VMEXPORT void lil_cs_set_code_size(LilCodeStub * cs, size_t size); +/** Return size of generated code.*/ + VMEXPORT void lil_cs_set_code_size(LilCodeStub * cs, size_t size); -// Return size of generated code +/** Return size of generated code.*/ VMEXPORT size_t lil_cs_get_code_size(LilCodeStub * cs); -// totally artificial limit; increase if needed -// the max number of predecessors any BB may have -#define MAX_BB_PRED 10 +/** Totally artificial limit; increase if needed the max number of predecessors + * any BB may have.*/ + #define MAX_BB_PRED 10 - class LilBb { private: - // the code stub +//@} +/** @name The Code Stub */ +//@{ LilCodeStub *cs; - - // since bb code will appear consecutively in the stub, - // all we need is the first and last instruction + /** Since BB code will appear consecutively in the stub, + * all we need is the first and last instruction.*/ LilInstruction *start; LilInstruction *end; // if end is NULL, the end of the stub is implied - // the LIL context right before the first instruction of the BB - LilInstructionContext* ctxt; + /** The LIL context right before the first instruction of the BB.*/ + LilInstructionContext* ctxt; - // successors of this BB in the flowgraph - LilBb* fallthru; - LilBb* branch_target; + /** Successors of this BB in the flowgraph.*/ + LilBb* fallthru; + LilBb* branch_target; - // predecessors of this BB in the flowgraph - unsigned num_pred; - LilBb *pred[MAX_BB_PRED]; - // for forming BB lists - LilBb* next; - // ID; within each stub, IDs will be unique and go from 0 to -1 - int id; - // private constructor; create BBs by calling init_fg() - LilBb(LilCodeStub *_cs, LilInstruction *_start, - LilInstructionContext* ctxt_at_start); + /** Predecessors of this BB in the flowgraph unsigned num_pred;*/ + LilBB *pred[MAX_BB_PRED]; - // private operator new; create BBs using new_bb() only + /** For forming BB lists.*/ + LilBb* next; + + /** ID; within each stub, IDs will be unique and go from 0 to + * -1*/ + int id; + + /** Private constructor; create BBs by calling init_fg().*/ + LilBb(LilCodeStub *_cs, LilInstruction *_start, + LilInstructionContext* ctxt_at_start); + + /** Private operator new; create BBs using new_bb() only.*/ void* operator new(size_t sz, tl::MemoryPool& m); - //MVM - //add empty destructor to avoid warning - void operator delete(void * UNREF obj, tl::MemoryPool& UNREF m){ - //do nothing + + /** MVM add empty destructor to avoid warning.*/ + void operator delete(void * UNREF obj, tl::MemoryPool& UNREF m){ + + /** Do nothing.*/ }; public: - // the only way to create new BBs; create a whole FG for a stub - VMEXPORT static void init_fg(LilCodeStub*); + /** The only way to create new BBs; create a whole FG for a stub.*/ + VMEXPORT static void init_fg(LilCodeStub*); - // sets the last instruction of the BB - VMEXPORT void set_last(LilInstruction *i); + /** Sets the last instruction of the BB.*/ + VMEXPORT void set_last(LilInstruction *i); - // gets the first instruction - VMEXPORT LilInstruction* get_first(); - // gets the last instruction - VMEXPORT LilInstruction* get_last(); + /** Gets the first instruction.*/ + VMEXPORT LilInstruction* get_first(); - // get the context right before the start of the BB - VMEXPORT LilInstructionContext* get_context(); + /** Gets the last instruction.*/ + VMEXPORT LilInstruction* get_last(); - // does this bb contain instruction i? - VMEXPORT bool contains(LilInstruction *i); + /** Get the context right before the start of the BB.*/ + VMEXPORT LilInstructionContext* get_context(); - // get the label of this BB; NULL if no label exists + //// Does this BB contain instruction i? + VMEXPORT bool contains(LilInstruction *i); + + /** Get the label of this BB; NULL if no label exists.*/ VMEXPORT LilLabel get_label(); - // set a fallthrough successor to this bb - VMEXPORT void set_fallthru(LilBb *); - // set a branch-target successor to this bb - VMEXPORT void set_branch_target(LilBb *); + /** Set a fallthrough successor to this BB.*/ + VMEXPORT void set_fallthru(LilBb *); - // get the fallthrough and branch target successors; - // either of them can be NULL if they don't exist + /** Set a branch-target successor to this BB.*/ + VMEXPORT void set_branch_target(LilBb *); + + /** Get the fallthrough and branch target successors; either of them can be + * NULL if they don't exist.*/ VMEXPORT LilBb* get_fallthru(); VMEXPORT LilBb* get_branch_target(); - // gets the i'th predecessor (NULL if i >= num_pred) - VMEXPORT LilBb *get_pred(unsigned i); + /** Gets the i'th predecessor (NULL if i >= num_pred).*/ + VMEXPORT LilBb *get_pred(unsigned i); - // gets the next BB in the list - VMEXPORT LilBb *get_next(); + /** Gets the next BB in the list.*/ + VMEXPORT LilBb *get_next(); - // returns whether this BB ends in a return instruction - // (tailcall implies return!) + /** Returns whether this BB ends in a return instruction (tailcall + * implies return!).*/ VMEXPORT bool is_ret(); - // the id of this BB - VMEXPORT int get_id(); + /** The id of this BB.*/ + VMEXPORT int get_id(); - // true if this BB contains calls (which means it may throw exceptions) + /** TRUE if this BB contains calls (which means it may + * throw exceptions)*/ VMEXPORT bool does_calls(); - // true if this BB ends with a call.noret (which means it is probably cold code) + /** TRUE if this BB ends with a call.noret (which means + * it is probably cold code).*/ VMEXPORT bool does_call_noret(); - // find a BB with the specified label; NULL if no such bb exists + /** Find a BB with the specified label; NULL if no + * such BB exists.*/ VMEXPORT static LilBb* get_by_label(LilCodeStub *cs, LilLabel l); - // find a BB which contains the specified instruction; NULL if no such BB exists + /** Find a BB which contains the specified instruction; NULL + * if no such BB exists.*/ VMEXPORT static LilBb* get_by_instruction(LilCodeStub *cs, LilInstruction *i); - // print a BB to a stream (does not print the BB's instructions) + /** Print a BB to a stream (does not print the BB's + * instructions).*/ VMEXPORT void print(FILE* out); }; - - -// Iterate over the instructions in a code stub +/** Iterate over the instructions in a code stub.*/ class LilInstructionIterator { public: - // Create an iterator from a code stub, if track_contexts then track the context prior to each instruction + + /** Create an iterator from a code stub, if track_contexts then + * track the context prior to each instruction.*/ VMEXPORT LilInstructionIterator(LilCodeStub*, bool track_contexts); - // Create an iterator for a BB in a code stub. - // NOTE: track_contexts is currently NOT supported for this type of iterator + /** Create an iterator for a BB in a code stub. + * + * @note track_contexts is currently NOT supported for this + * type of iterator.*/ VMEXPORT LilInstructionIterator(LilCodeStub*, LilBb*, bool track_contexts); - // Is iterator past the end of the instructions? - VMEXPORT bool at_end(); - // Return current instruction - VMEXPORT LilInstruction* get_current(); - // Return context prior to current instruction, must have created iterator to track contexts + ////// Is iterator past the end of the instructions? + VMEXPORT bool at_end(); + + /** Return current instruction.*/ + VMEXPORT LilInstruction* get_current(); + + /** Return context prior to current instruction, must have created iterator + * to track contexts.*/ VMEXPORT LilInstructionContext* get_context(); - // Goto the next instruction - VMEXPORT void goto_next(); + /** Goto the next instruction.*/ + VMEXPORT void goto_next(); + private: LilCodeStub* cs; LilBb *bb; // NULL, unless this is an iterator for a BB @@ -493,9 +597,10 @@ LilInstructionContext* ctxt; }; +//@} +/** @name Visitor pattern for instructions*/ +//@{ - -// Visitor pattern for instructions class LilInstructionVisitor { protected: VMEXPORT LilInstructionVisitor(); @@ -526,9 +631,9 @@ }; -// LilInstructionVisitor_Default provides empty implementations for the -// abstract functions in LilInstructionVisitor. It is a convenient base -// class for scanners that need to act only on a few instructions. + /** LilInstructionVisitor_Default provides empty implementations + * for the abstract functions in LilInstructionVisitor. It is a convenient base + * class for scanners that need to act only on a few instructions.*/ class LilInstructionVisitor_Default : public LilInstructionVisitor { protected: LilInstructionVisitor_Default(): @@ -560,33 +665,41 @@ }; -// Visit instruction using a visitor + /** Visit instruction using a visitor.*/ VMEXPORT void lil_visit_instruction(LilInstruction*, LilInstructionVisitor*); + /** Return variable's kind.*/ +VMEXPORT LilVariableKind lil_variable_get_kind(LilVariable* v); -// Return variable's kind -VMEXPORT LilVariableKind lil_variable_get_kind(LilVariable* v); -// Return variable's index + /** Return variable's index.*/ VMEXPORT unsigned lil_variable_get_index(LilVariable* v); -// Are two variables the same + +///// Are two variables the same VMEXPORT bool lil_variable_is_equal(LilVariable* v1, LilVariable* v2); -// Is operand an immediate? +///// Is operand an immediate? VMEXPORT bool lil_operand_is_immed(LilOperand* o); -// If operand is an immediate return the immediate value + + /** If operand is an immediate return the immediate value.*/ VMEXPORT POINTER_SIZE_INT lil_operand_get_immed(LilOperand* o); -// If operand is not an immediate return the variable it represents + + /** If operand is not an immediate return the variable it represents.*/ VMEXPORT LilVariable* lil_operand_get_variable(LilOperand* o); -// Return a signature's calling convention + /** Return a signature's calling convention.*/ VMEXPORT LilCc lil_sig_get_cc(LilSig* sig); -// Return whether this signature is arbitrary + + /** Return whether this signature is arbitrary.*/ VMEXPORT bool lil_sig_is_arbitrary(LilSig *sig); -// Return the number of arguments for a signature (0 if arbitrary) + + /** Return the number of arguments for a signature (0 if arbitrary).*/ VMEXPORT unsigned lil_sig_get_num_args(LilSig* sig); -// Return the num-th argument type of a signature (zero based) (undefined if signature is arbitrary) + + /** Return the num-th argument type of a signature (zero based) + * (undefined if signature is arbitrary).*/ VMEXPORT LilType lil_sig_get_arg_type(LilSig* sig, unsigned num); -// Return the return type of a signature + + /** Return the return type of a signature.*/ VMEXPORT LilType lil_sig_get_ret_type(LilSig* sig); // Is an operation binary? @@ -596,27 +709,36 @@ // Is a predicate signed? VMEXPORT bool lil_predicate_is_signed(LilPredicate c); -//*** Printers +//@} +/** @name Printers*/ +//@{ -// Print a type to a stream + /** Print a type to a stream.*/ VMEXPORT void lil_print_type(FILE*, LilType); -// Print a signature to a stream + + /** Print a signature to a stream.*/ VMEXPORT void lil_print_sig(FILE*, LilSig*); -// Print an instruction to a stream + + /** Print an instruction to a stream.*/ VMEXPORT void lil_print_instruction(FILE*, LilInstruction* i); -// Print a code stub to a stream + + /** Print a code stub to a stream.*/ VMEXPORT void lil_print_code_stub(FILE*, LilCodeStub* cs); -// Print just the entry of a code stub to a stream + + /** Print just the entry of a code stub to a stream.*/ VMEXPORT void lil_print_entry(FILE*, LilCodeStub* cs); -//*** Freers +//@} +/** @name Freers */ +//@{ -// Return all resources associated with a code stub -// Post: code stub no longer usable + /** Return all resources associated with a code stub + * Post: code stub no longer usable.*/ VMEXPORT void lil_free_code_stub(LilCodeStub* cs); -//*** Function pointer utilities - +//@} +/** @name Function pointer utilities*/ +//@{ VMEXPORT GenericFunctionPointer lil_npc_to_fp(NativeCodePtr); #endif // _LIL_H_ Index: trunk/vm/port/include/lil_code_generator.h =================================================================== --- trunk/vm/port/include/lil_code_generator.h (revision 504464) +++ trunk/vm/port/include/lil_code_generator.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,12 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Intel, Evgueni Brevnov, Ivan Volosyuk - * @version $Revision: 1.1.2.1.4.4 $ - */ - #ifndef _LIL_CODE_GENERATOR_H_ #define _LIL_CODE_GENERATOR_H_ @@ -28,42 +23,45 @@ #include "environment.h" #include "mem_alloc.h" -// This is an abstract base case for LIL code generators -// Subclasses compile LIL into native code for a particular -// architecture +/** + * @file + * This is an abstract base case for LIL code generators. + * + * Subclasses compile LIL into native code for a particular + * architecture. + * + * @note This is a compiler algorithm abstraction not a compilation process + * abstraction. Subclasses should not store state about any particular + * compilation, only options that configure the compilation.*/ -// Note that this is a compiler algorithm abstraction not -// a compilation process abstraction. Subclasses should -// not store state about any particular compilation, only -// options that configure the compilation. - class LilCodeGenerator { public: - // Return the code generator for the current platform - static LilCodeGenerator* get_platform(); + /** @return The code generator for the current platform.*/ + static LilCodeGenerator* get_platform(); - // Compile LIL code stub to native code and return it - // The stub_name is for vtune support - // Dump an ascii version of the compiled stub to stdout if dump_stub - // If cs_stats is nonnull add the number of bytes of the compiled code to *cs_stats + /** Compile LIL code stub to native code and return it. + * The stub_name is for vtune support. + * Dump an ascii version of the compiled stub to stdout if dump_stub + * If cs_stats is nonnull add the number of bytes of the compiled + * code to *cs_stats.*/ NativeCodePtr compile(LilCodeStub* cs, PoolManager* code_pool = VM_Global_State::loader_env->GlobalCodeMemoryManager); protected: LilCodeGenerator(); - // allocates a chunk of memory for a LIL stub; the user-provided function - // compile_main() should call this function instead of allocating memory - // directly. + /** Allocates a chunk of memory for a LIL stub; the user-provided function + * compile_main() should call this function instead of allocating + * memory directly.*/ NativeCodePtr allocate_memory(size_t, PoolManager*); - // generates compiled code for a LIL stub, and returns its address. The - // size of the compiled stub is placed in stub_size. Called by the - // compile() function to do most of the work. - // - // Each subclass of LilCodeGenerator should provide a platform-dependent - // implementation of compile_main(). The memory area that holds the - // compiled code should be allocated by calling allocate_memory(). + /** Generates compiled code for a LIL stub, and returns its address. + * The size of the compiled stub is placed in stub_size. + * Called by the compile() function to do most of the work. + * + * Each subclass of LilCodeGenerator should provide a platform-dependent + * implementation of compile_main(). The memory area that holds + * the compiled code should be allocated by calling allocate_memory().*/ virtual NativeCodePtr compile_main(LilCodeStub* cs, size_t* stub_size, PoolManager* code_pool) = 0; }; Index: trunk/vm/port/include/lil_code_generator_utils.h =================================================================== --- trunk/vm/port/include/lil_code_generator_utils.h (revision 504464) +++ trunk/vm/port/include/lil_code_generator_utils.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,24 +14,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Intel, Evgueni Brevnov, Ivan Volosyuk - * @version $Revision: 1.1.2.1.4.4 $ - */ - #ifndef _LIL_CODE_GENERATOR_UTILS_H_ #define _LIL_CODE_GENERATOR_UTILS_H_ #include "lil.h" #include "vm_core_types.h" -// This module provides some common utilities for generating native code from LIL code stubs - -//*** The following is for managing label to address translation and back patching - -// Patch types have to be the union of the various cases of the various architectures, -// so unfortunately are somewhat platform specific. + /** + * @file + * This module provides some common utilities for generating native code from + * LIL code stubs. + * + * The following is for managing label to address translation and back patching. + * + * Patch types have to be the union of the various cases of the various + * architectures, so unfortunately are somewhat platform specific.*/ typedef enum LilCguPatchType { LPT_Rel8, LPT_Rel32, LPT_Abs32 } LilCguPatchType; @@ -51,27 +49,31 @@ }LilCguLabelAddress; -// This class mantains a mapping between labels and addresses, and ensures the references to -// labels eventually point to those labels. -// Clients should call define_label to set a label's address, and patch_to_label to ensure references -// correct point to a label; the class will make sure that a reference points to its label once both -// functions have been called. + /** This class mantains a mapping between labels and addresses, and ensures the + * references to labels eventually point to those labels. Clients should call + * define_label to set a label's address, and patch_to_label + * to ensure references correct point to a label; the class will make sure that + * a reference points to its label once both functions have been called.*/ class LilCguLabelAddresses { public: - // Create a label to address mapping with back patching - LilCguLabelAddresses(tl::MemoryPool*, char * b); + /** Create a label to address mapping with back patching.*/ + LilCguLabelAddresses(tl::MemoryPool*, char * b); // void change_base(char * new_base); - // Label l should have addres code - void define_label(LilLabel l, void * code, bool base_relative); - // The contents of address patch_address should point to label l according to patch_type + + /** Label l should have addres code.*/ + void define_label(LilLabel l, void * code, bool base_relative); + + /** The contents of address patch_address should point to label + * l according to patch_type.*/ void add_patch_to_label(LilLabel l, void * patch_address, LilCguPatchType patch_type); private: void add_new_label_adress(LilLabel l, void * code, bool base_relative); - // Apply all patches associated with the current label + /** Apply all patches associated with the current label.*/ void apply_patches(LilCguLabelAddress * label_adress); - // Actually apply a patch + + /** Actually apply a patch.*/ void apply_patch(LilCguLabelAddress * label_adress, LilCguPatch * patch); LilCguLabelAddress * first; Index: trunk/vm/port/include/log_macro.h =================================================================== --- trunk/vm/port/include/log_macro.h (revision 504464) +++ trunk/vm/port/include/log_macro.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,60 +14,42 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Alexey V. Varlamov, Evgueni Brevnov - * @version $Revision: 1.1.2.1.4.4 $ - */ + #ifndef _UTIL_LOG_MACRO_H #define _UTIL_LOG_MACRO_H #include #include + /** + * @file + * Basic logging is used during startup. + * + * Macro expansion. It is used, for example, to combine + * a filename and a line number in __FILELINE__ macro.*/ -/** - * @file - * - * Basic logging is used during startup. - */ - - -/** - * Macro expansion. It is used, for example, to combine - * a filename and a line number in - * __FILELINE__ macro. - */ #define EXPAND_(a) # a #define EXPAND(a) EXPAND_(a) -/** - * Concatenate the file name and the line number. - */ + /** Concatenate the file name and the line number.*/ #define LOG_FILELINE __FILE__ ":" EXPAND(__LINE__) -/** - * Create a log message header. - */ + /** Create a log message header.*/ #define LOG_HEAD ":" LOG_FILELINE ": " -/** - * @def ABORT(message) - * @brief Lightweight implementation for error handling. - * - * It prints a simple string message to stderr - * and exits the program. This macro call should be - * used when logging subsystem is not yet fully initialized. - */ + /** @def ABORT(message) + * @brief Lightweight implementation for error handling. + * + * It prints a simple string message to stderr + * and exits the program. This macro call should be + * used when logging subsystem is not yet fully initialized.*/ #define ABORT(message) { \ fprintf(stderr, "Internal error" LOG_HEAD message); \ fflush(stderr); \ abort(); \ } -/** - * Lightweight macro to replace a standard C - * assert(). - */ + /** Lightweight macro to replace a standard C assert().*/ #ifdef NDEBUG # define LOG_ASSERT(assertion, message) /* Asserts are disabled, \ * reset NDEBUG macro to turn them on. */ Index: trunk/vm/port/include/logger.h =================================================================== --- trunk/vm/port/include/logger.h (revision 504464) +++ trunk/vm/port/include/logger.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,10 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** -* @author Roman S. Bushmanov, Dmitry B. Yershov -* @version $Revision: 1.1.2.2.4.3 $ -*/ #ifndef LOGGER_H #define LOGGER_H @@ -31,9 +27,7 @@ extern "C" { #endif -/** - * Enum of logging levels - */ + /** Enum of logging levels.*/ typedef enum { DIE = 0, WARN, @@ -42,9 +36,7 @@ TRACE } LoggingLevel; -/** - * Header format flags. Binary AND operation should be used to combine flags. - */ + /** Header format flags. Binary AND operation should be used to combine flags.*/ typedef unsigned HeaderFormat; #define HEADER_EMPTY 0 #define HEADER_TIMESTAMP 1 @@ -65,36 +57,26 @@ #endif -/** -* Inits log system. -*/ + /** Inits log system.*/ VMEXPORT void init_log_system(); -/** -* shutdown log system. -*/ + /** Shutdown log system.*/ VMEXPORT void shutdown_log_system(); -/** -* Sets loggers logging levels from file -*/ + /** Sets loggers logging levels from file.*/ VMEXPORT void set_logging_level_from_file(const char* filename); -/** - * Passes the message specified with level assigned to the category specified for logging. - */ + + /** Passes the message specified with level assigned to the category specified + * for logging.*/ VMEXPORT void log4cxx_from_c(const char *category, LoggingLevel level, const char* message, const char* file, const char* func, int line); -/** - * Assigns threshold to a category. All the messages having a lower logging level will - * be ignored by the category. - */ -VMEXPORT void set_threshold(const char *category, LoggingLevel level); + /** Assigns threshold to a category. All the messages having a lower logging + * level will be ignored by the category.*/ -/** - * Checks if the logging level specified is enabled for the category given. - */ +VMEXPORT void set_threshold(const char *category, LoggingLevel level); + /** Checks if the logging level specified is enabled for the category given.*/ VMEXPORT unsigned is_enabled(const char *category, LoggingLevel level); VMEXPORT unsigned is_warn_enabled(const char *category); @@ -116,29 +98,22 @@ VMEXPORT unsigned is_log_enabled(const char *category, LogSite *site); VMEXPORT unsigned is_trace_enabled(const char *category, LogSite *site); -/** -* Redirects category (and all subcategories) output to a file. -* If the file is NULL, removes previously assigned redirection (if any). -*/ + /** Redirects category (and all subcategories) output to a file. + * If the file is NULL, removes previously assigned redirection + * (if any).*/ VMEXPORT void set_out(const char *category, const char* file); -/** - * Sets the header format for the category specified. Use HeaderFormat - * flags combined by AND operation to configure format. - */ + /** Sets the header format for the category specified. Use HeaderFormat + * flags combined by AND operation to configure format.*/ VMEXPORT void set_header_format(const char *category, HeaderFormat format); -/** - * Sets the log file path pattern to use for thread specific logging. - * Specify NULL pattern to turn off per-thread output. - * Use %t specifier to be replaced by a thread id. - */ + /** Sets the log file path pattern to use for thread specific logging. + * Specify NULL pattern to turn off per-thread output. + * Use %t specifier to be replaced by a thread id.*/ VMEXPORT void set_thread_specific_out(const char* category, const char* pattern); -/** - * Write formatted data to a newly allocated string. - * Use STD_FREE to release allocated memory. - */ + /** Write formatted data to a newly allocated string. Use STD_FREE + * to release allocated memory.*/ VMEXPORT const char* log_printf(const char* format, ...); #ifdef __cplusplus Index: trunk/vm/port/include/loggerstring.h =================================================================== --- trunk/vm/port/include/loggerstring.h (revision 504464) +++ trunk/vm/port/include/loggerstring.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,10 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** -* @author Dmitry B. Yershov -* @version $Revision: 1.1.2.1.4.3 $ -*/ #ifndef LOGGER_STRING_H #define LOGGER_STRING_H Index: trunk/vm/port/include/m2n.h =================================================================== --- trunk/vm/port/include/m2n.h (revision 504464) +++ trunk/vm/port/include/m2n.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,10 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Intel, Evgueni Brevnov, Ivan Volosyuk - * @version $Revision: 1.1.2.1.4.4 $ - */ #ifndef _M2N_H_ #define _M2N_H_ @@ -26,19 +22,21 @@ #include "open/types.h" #include "vm_core_types.h" -// This module is for the "managed to native frame" abstraction, M2nFrame. -// An M2nFrame sits on the activation stack immediately above a managed -// frame and immediately below a native frame. All managed to native code -// transitions should involve pushing an M2nFrame with the following exceptions: -// Code that does not enable GC (note that calling managed code enables GC), -// throw exceptions, or inspects the stack does not need to push an M2nFrame. -// All other code must. -// M2nFrames are linked together in the order they are pushed onto the -// activation stack, and each thread has a pointer to the most recent M2nFrame. -// Each M2nFrame contains a list of local object handles, can identify the -// location of the return address into the managed frame that preceeds it, -// and is optionally associated with a native method. - + /** + * @file + * This module is for the "managed to native frame" abstraction, M2nFrame. + * An M2nFrame sits on the activation stack immediately above a managed + * frame and immediately below a native frame. All managed to native code + * transitions should involve pushing an M2nFrame with the following exceptions: + * Code that does not enable GC (note that calling managed code enables GC), + * throw exceptions, or inspects the stack does not need to push an M2nFrame. + * All other code must. + * M2nFrame-s are linked together in the order they are pushed onto the + * activation stack, and each thread has a pointer to the most recent M2nFrame. + * Each M2nFrame contains a list of local object handles, can identify the + * location of the return address into the managed frame that preceeds it, + * and is optionally associated with a native method. + */ struct M2nFrame; enum frame_type { @@ -59,95 +57,95 @@ FRAME_MODIFIED_STACK = 0x1000 }; -// The pushing and popping of native frames is done only by stubs that -// implement the managed to native transitions. These stubs use code that is -// necessarily architecture specific and some facilities that are not needed -// by other clients of this code, so this part of the interface is described -// elsewhere. + /** The pushing and popping of native frames is done only by stubs that + * implement the managed to native transitions. These stubs use code that is + * necessarily architecture specific and some facilities that are not needed + * by other clients of this code, so this part of the interface is described + * elsewhere.*/ // fill m2n frame as empty void m2n_null_init(M2nFrame *); -// Get the most recent M2nFrame of the current thread + /** Get the most recent M2nFrame of the current thread.*/ VMEXPORT // temporary solution for interpreter unplug -M2nFrame* m2n_get_last_frame(); -// Set the most recent M2nFrame of the current thread -// The caller must ensure the frame is on the current thread's activation stack -VMEXPORT // temporary solution for interpreter unplug + /** Set the most recent M2nFrame of the current thread. + * The caller must ensure the frame is on the current thread's activation stack.*/ + VMEXPORT // temporary solution for interpreter unplug void m2n_set_last_frame(M2nFrame *); -// Set the most recent M2nFrame of given thread -// The caller must ensure the frame is on the thread's activation stack -VMEXPORT + /** Set the most recent M2nFrame of given thread. + * The caller must ensure the frame is on the thread's activation stack.*/ + VMEXPORT void m2n_set_last_frame(VM_thread *, M2nFrame *); -// Get the most recent M2nFrame of the given thread -VMEXPORT // temporary solution for interpreter unplug + /** Get the most recent M2nFrame of the given thread.*/ + VMEXPORT // temporary solution for interpreter unplug M2nFrame* m2n_get_last_frame(VM_thread *); -// Get the previous M2nFrame to the given one -VMEXPORT // temporary solution for interpreter unplug + /** Get the previous M2nFrame to the given one.*/ + VMEXPORT // temporary solution for interpreter unplug M2nFrame* m2n_get_previous_frame(M2nFrame *); -// Get the local object handles for the M2nFrame -VMEXPORT // temporary solution for interpreter unplug + /** Get the local object handles for the M2nFrame.*/ + VMEXPORT // temporary solution for interpreter unplug ObjectHandles* m2n_get_local_handles(M2nFrame *); -// Set the local object handles -// Note that this just updates the list, it does not free the old list -VMEXPORT // temporary solution for interpreter unplug + /** Set the local object handles. + * + * @note This just updates the list, it does not free the old list.*/ + VMEXPORT // temporary solution for interpreter unplug void m2n_set_local_handles(M2nFrame *, ObjectHandles *); -// Get the return address into the preceding managed frame -NativeCodePtr m2n_get_ip(M2nFrame *); + /** Get the return address into the preceding managed frame.*/ + NativeCodePtr m2n_get_ip(M2nFrame *); -// ? 20040708 New function - needs proper implementation. -// Set the return address into the preceding managed frame -void m2n_set_ip(M2nFrame *, NativeCodePtr); + /** ? 20040708 New function - needs proper implementation. + * Set the return address into the preceding managed frame.*/ + void m2n_set_ip(M2nFrame *, NativeCodePtr); -// Get the native method associated with the transition to native code -// or NULL if no such association. -Method_Handle m2n_get_method(M2nFrame *); + /** Get the native method associated with the transition to native code + * or NULL if no such association.*/ + Method_Handle m2n_get_method(M2nFrame *); -// Returns type of noted m2n frame + /** Returns type of noted m2n frame.*/ frame_type m2n_get_frame_type(M2nFrame *); -// Sets type of noted m2n frame -void m2n_set_frame_type(M2nFrame *, frame_type); + /** Sets type of noted m2n frame.*/ + void m2n_set_frame_type(M2nFrame *, frame_type); -// Returns size of m2n frame + /** Returns size of m2n frame.*/ size_t m2n_get_size(); -// Push a special M2nFrame for managed code suspended by the OS in say -// a signal handler or exception filter. -// The frame can be popped by setting the last frame to a prior frame -void m2n_push_suspended_frame(M2nFrame* m2nf, Registers* regs); + /** Push a special M2nFrame for managed code suspended by the OS in say a signal + * handler or exception filter. + * The frame can be popped by setting the last frame to a prior frame.*/ + void m2n_push_suspended_frame(M2nFrame* m2nf, Registers* regs); -// Push a special M2nFrame for managed code suspended by the OS in say -// a signal handler or exception filter. -// The frame can be popped by setting the last frame to a prior frame -void m2n_push_suspended_frame(VM_thread* thread, M2nFrame* m2nf, Registers* regs); + /** Push a special M2nFrame for managed code suspended by the OS in say + * a signal handler or exception filter. + * The frame can be popped by setting the last frame to a prior frame.*/ + void m2n_push_suspended_frame(VM_thread* thread, M2nFrame* m2nf, Registers* regs); -// Push a special M2nFrame for managed code suspended by the OS in say -// a signal handler or exception filter. The frame is allocated in the heap. -// It can be popped by setting the last frame to a prior frame -// and then calling free on the frame pointer. -M2nFrame* m2n_push_suspended_frame(Registers *); + /** Push a special M2nFrame for managed code suspended by the OS in say + * a signal handler or exception filter. The frame is allocated in the heap. + * It can be popped by setting the last frame to a prior frame + * and then calling free on the frame pointer.*/ + M2nFrame* m2n_push_suspended_frame(Registers *); -// Push a special M2nFrame for managed code suspended by the OS in -// signal handler or exception filter. The frame is allocated in the heap. -// The frame can be popped by setting the last frame to a prior frame -// and then calling free on the frame. -M2nFrame* m2n_push_suspended_frame(VM_thread *, Registers *); + /** Push a special M2nFrame for managed code suspended by the OS in signal + * handler or exception filter. The frame is allocated in the heap. The frame + * can be popped by setting the last frame to a prior frame and then calling + * free on the frame.*/ + M2nFrame* m2n_push_suspended_frame(VM_thread *, Registers *); -// answers true if passed in m2n frame represents suspended frame + /** Answers TRUE if passed in m2n frame represents a suspended frame.*/ bool m2n_is_suspended_frame(M2nFrame *); -// returns pointer to the registers used for jvmti PopFrame + /** Returns pointer to the registers used for jvmti PopFrame.*/ Registers* get_pop_frame_registers(M2nFrame* ); -// sets pointer to the registers used for jvmti PopFrame + /** Sets pointer to the registers used for jvmti PopFrame.*/ void set_pop_frame_registers(M2nFrame* , Registers*); #endif //!_M2N_H_ Index: trunk/vm/port/include/platform_core_natives.h =================================================================== --- trunk/vm/port/include/platform_core_natives.h (revision 504464) +++ trunk/vm/port/include/platform_core_natives.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,10 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Euguene Ostrovsky - * @version $Revision: 1.1.2.1.4.5 $ - */ #ifndef _PLATFORM_CORE_NATIVES_H_ #define _PLATFORM_CORE_NATIVES_H_ @@ -25,7 +21,9 @@ #include "jni.h" -// TIME +/** + * TIME + */ jlong get_current_time(); #endif // _PLATFORM_CORE_NATIVES_H_ Index: trunk/vm/port/include/port_atomic.h =================================================================== --- trunk/vm/port/include/port_atomic.h (revision 504464) +++ trunk/vm/port/include/port_atomic.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,10 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** -* @author Intel, Evgueni Brevnov -* @version $Revision: 1.1.2.1.4.3 $ -*/ #ifndef _PORT_ATOMIC_H_ #define _PORT_ATOMIC_H_ @@ -37,41 +33,33 @@ #define INLINE static #endif #endif -/** - * All atomic operrations are perfomance critical, - * thus they are defined as inlined for most platforms in this file - */ + + /** All atomic operrations are perfomance critical, + * thus they are defined as inlined for most platforms in this file.*/ #if defined(_IPF_) - -/** -* Atomic compare and exchange operation -* @data[in, out] -* @value[in] new value -* @comp[in] value to compare with -* return old value -*/ + /** Atomic compare and exchange operation. + * @data [in, out] + * @value[in] new value + * @comp [in] value to compare with + * @return Old value.*/ APR_DECLARE(uint8) port_atomic_cas8(volatile uint8 * data, - uint8 value, uint8 comp); + uint8 value, uint8 comp); -/** -* Atomic compare and exchange operation -* @data[in, out] -* @value[in] new value -* @comp[in] value to compare with -* return old value -*/ + /** Atomic compare and exchange operation. + * @data [in, out] + * @value[in] new value + * @comp [in] value to compare with + * @return Old value.*/ APR_DECLARE(uint16) port_atomic_cas16(volatile uint16 * data, uint16 value, uint16 comp); -/** -* Atomic compare and exchange operation -* @data[in, out] -* @value[in] new value -* @comp[in] value to compare with -* return old value -*/ + /** Atomic compare and exchange operation. + * @data[in, out] + * @value[in] new value + * @comp[in] value to compare with + * @return Old value.*/ APR_DECLARE(uint64) port_atomic_cas64(volatile uint64 * data, uint64 value, uint64 comp); Index: trunk/vm/port/include/port_disasm.h =================================================================== --- trunk/vm/port/include/port_disasm.h (revision 504464) +++ trunk/vm/port/include/port_disasm.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,10 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Evgueni Brevnov - * @version $Revision: 1.1.2.1.4.4 $ - */ #ifndef _DISASM_H_ #define _DISASM_H_ @@ -39,57 +35,54 @@ } port_disasm_info_t; -/** - * Initializes disasm module - * - * @remark It's safe to call it several times. - */ + /** Initializes disasm module. + * + * @remark It's safe to call it several times.*/ APR_DECLARE(apr_status_t) port_disasm_initialize(); -/** - * Creates disassembler - * - * @param disassembler The created disassembler - * @param pool The pool to use - * @remark It's safe to call this function by multiple threads with different pools - */ + /** Creates disassembler. + * + * @param disassembler - the created disassembler + * @param pool - the pool to use + * + * @remark It's safe to call this function by multiple threads with different + * pools.*/ APR_DECLARE(apr_status_t) port_disassembler_create(port_disassembler_t ** disassembler, apr_pool_t * pool); -/** - * @param new_info The info to set up - * @param old_info Should point to the memory to store old info in. - * NULL value should be specified if no interest for the old info. - * @remark Not thread safe. Only one thread may change the info for the specified - disassembler - */ + + /** @param new_info - the info to set up + * @param old_info - should point to the memory to store old info in + * NULL value should be specified if no interest + * for the old info + * + * @remark Not thread safe. Only one thread may change the info for the specified + * disassembler.*/ APR_DECLARE(apr_status_t) port_disasm_set_info(port_disassembler_t * disassembler, const port_disasm_info_t new_info, port_disasm_info_t * old_info); -/** - * Translates from machine native to human readable code. - * - * @param disassembler The disassembler - * @param code Assembler code to translate - * @param len Number of bytes to be translated - * @param disasm_code Points to pointer to the disassembled code at exit. - * The pointer is valid until the disassembler is valid. - * @warning Not thread safe. Only one thread can use the specified disassembler - */ + /** Translates from machine native to human readable code. + * + * @param disassembler - the disassembler + * @param code - assembler code to translate + * @param len - number of bytes to be translated + * @param disasm_code - points to pointer to the disassembled code at exit; + * the pointer is valid until the disassembler is valid + * + * @warning Not thread safe. Only one thread can use the specified disassembler.*/ APR_DECLARE(apr_status_t) port_disasm(port_disassembler_t * disassembler, const char * code, unsigned int len, char ** disasm_code); -/** - * Translates from machine native to human readable code. - * - * @param code Assembler code to translate - * @param len Number of bytes to be translated - * @param thefile Destination file - * @warning Not thread safe. Only one thread can use the specified disassembler - */ + /** Translates from machine native to human readable code. + * + * @param code - assembler code to translate + * @param len - number of bytes to be translated + * @param thefile - destination file + * + * @warning Not thread safe. Only one thread can use the specified disassembler.*/ APR_DECLARE(apr_status_t) port_disasm_to_file(port_disassembler_t * disassembler, const char * code, unsigned int len, Index: trunk/vm/port/include/port_dso.h =================================================================== --- trunk/vm/port/include/port_dso.h (revision 504464) +++ trunk/vm/port/include/port_dso.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,10 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** -* @author Alexey V. Varlamov -* @version $Revision: 1.1.2.1.4.3 $ -*/ #ifndef _PORT_DSO_H_ #define _PORT_DSO_H_ @@ -31,11 +27,10 @@ extern "C" { #endif -/** - * Decorate shared library name (.dll <-> lib*.so). - * The "name" parameter should be double-quoted string. - * @non_apr - */ + /** Decorate shared library name (.dll <-> lib*.so). + * The name parameter should be double-quoted string. + * + * @non_apr */ #ifdef PLATFORM_POSIX # define PORT_DSO_NAME(name) "lib" name ".so" #elif PLATFORM_NT @@ -46,25 +41,19 @@ #define PORT_DSO_BIND_NOW 0x1 #define PORT_DSO_BIND_DEFER 0x2 -/** -* Loads shared binary (executable or library). -*/ + /** Loads shared binary (executable or library).*/ APR_DECLARE(apr_status_t) port_dso_load_ex(apr_dso_handle_t** handle, const char* path, uint32 mode, apr_pool_t* pool); - -/** -* Returns list of directories in which OS searches for libraries. -*/ + /** Returns list of directories in which OS searches for libraries.*/ APR_DECLARE(apr_status_t) port_dso_search_path(char** path, apr_pool_t* pool); -/** - * Decorate shared library name (.dll <-> lib*.so). - * @non_apr - */ + /** Decorate shared library name (.dll <-> lib*.so). + * + * @non_apr*/ APR_DECLARE(char *) port_dso_name_decorate(const char* dl_name, apr_pool_t* pool); Index: trunk/vm/port/include/port_env.h =================================================================== --- trunk/vm/port/include/port_env.h (revision 504464) +++ trunk/vm/port/include/port_env.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with +* contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at +* the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,10 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** -* @author Alexey V. Varlamov -* @version $Revision$ -*/ + #ifndef _PORT_ENV_H_ #define _PORT_ENV_H_ @@ -28,9 +25,8 @@ extern "C" { #endif - /** - * Returns all environment variable mappings as an array of KEY=VALUE strings. - */ + /** Returns all environment variable mappings as an array of + * KEY=VALUE strings.*/ APR_DECLARE(char **) port_env_all(apr_pool_t* pool); #ifdef __cplusplus Index: trunk/vm/port/include/port_filepath.h =================================================================== --- trunk/vm/port/include/port_filepath.h (revision 504464) +++ trunk/vm/port/include/port_filepath.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,11 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** -* @author Alexey V. Varlamov -* @version $Revision: 1.1.2.1.4.3 $ -*/ + #ifndef _PORT_FILEPATH_H_ #define _PORT_FILEPATH_H_ @@ -29,10 +26,8 @@ extern "C" { #endif -/** - * File system separators definitions. - * @non_apr - */ + /** File system separators definitions. + * @non_apr*/ #ifdef PLATFORM_POSIX # define PORT_FILE_SEPARATOR '/' # define PORT_PATH_SEPARATOR ':' @@ -44,19 +39,17 @@ # define PORT_FILE_SEPARATOR_STR "\\" # define PORT_PATH_SEPARATOR_STR ";" #endif -/** -* Sticks together filepath parts. -* @non_apr -*/ + + /** Sticks together filepath parts. + * + * @non_apr*/ APR_DECLARE(char *) port_filepath_merge(const char* root, const char* trail, apr_pool_t* pool); - -/** -* Returns canonical form of the specified path. -* @non_apr -*/ + /** Returns canonical form of the specified path. + * + * @non_apr*/ APR_DECLARE(char*) port_filepath_canonical(const char* original, apr_pool_t* pool); Index: trunk/vm/port/include/port_general.h =================================================================== --- trunk/vm/port/include/port_general.h (revision 504464) +++ trunk/vm/port/include/port_general.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,10 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** -* @author Alexey V. Varlamov -* @version $Revision: 1.1.2.1.4.3 $ -*/ #ifndef _PORT_GENERAL_H_ #define _PORT_GENERAL_H_ Index: trunk/vm/port/include/port_malloc.h =================================================================== --- trunk/vm/port/include/port_malloc.h (revision 504464) +++ trunk/vm/port/include/port_malloc.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,10 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Evgueni Brevnov - * @version $Revision: 1.1.2.1.4.4 $ - */ + #ifndef _PORT_MALLOC_H_ #define _PORT_MALLOC_H_ Index: trunk/vm/port/include/port_sysinfo.h =================================================================== --- trunk/vm/port/include/port_sysinfo.h (revision 504464) +++ trunk/vm/port/include/port_sysinfo.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,10 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** -* @author Alexey V. Varlamov -* @version $Revision: 1.1.2.1.4.3 $ -*/ #ifndef _PORT_SYSINFO_H_ #define _PORT_SYSINFO_H_ @@ -30,43 +26,29 @@ extern "C" { #endif -/** - * Determines absolute path of the executing process. - */ + /** Determines absolute path of the executing process.*/ APR_DECLARE(apr_status_t) port_executable_name(char** self_name, apr_pool_t* pool); -/** -* Returns number of processors in the system. -*/ + /** Returns number of processors in the system.*/ APR_DECLARE(int) port_CPUs_number(void); -/** -* Returns name of CPU architecture. -*/ + /** Returns name of CPU architecture.*/ APR_DECLARE(const char *) port_CPU_architecture(void); -/** -* Returns OS name and version. -*/ + /** Returns OS name and version.*/ APR_DECLARE(apr_status_t) port_OS_name_version(char** os_name, char** os_ver, apr_pool_t* pool); -/** -* Returns name of active account. -*/ + /** Returns name of active account.*/ APR_DECLARE(apr_status_t) port_user_name(char** account, apr_pool_t* pool); -/** -* Returns home path of active account. -*/ + /** Returns home path of active account.*/ APR_DECLARE(apr_status_t) port_user_home(char** path, apr_pool_t* pool); -/** - * Returns name of current system time zone. - */ + /** Returns name of current system time zone.*/ APR_DECLARE(apr_status_t) port_user_timezone(char** tzname, apr_pool_t* pool); Index: trunk/vm/port/include/port_timer.h =================================================================== --- trunk/vm/port/include/port_timer.h (revision 504464) +++ trunk/vm/port/include/port_timer.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with +* contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at +* the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,10 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** -* @author Alexey V. Varlamov -* @version $Revision$ -*/ + #ifndef _PORT_TIMER_H_ #define _PORT_TIMER_H_ @@ -27,16 +24,12 @@ extern "C" { #endif - /** - * High resolution timer, in nanoseconds. - */ + /** High resolution timer, in nanoseconds.*/ typedef apr_int64_t apr_nanotimer_t; - /** - * Returns the value of the system timer with the best possible accuracy. - * This value is not tied to the absolute time, but intended for precise - * measuring of elapsed time intervals. - */ + /** Returns the value of the system timer with the best possible accuracy. + * This value is not tied to the absolute time, but intended for precise + * measuring of elapsed time intervals.*/ APR_DECLARE(apr_nanotimer_t) port_nanotimer(); #ifdef __cplusplus Index: trunk/vm/port/include/port_vmem.h =================================================================== --- trunk/vm/port/include/port_vmem.h (revision 504464) +++ trunk/vm/port/include/port_vmem.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,10 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Alexey V. Varlamov - * @version $Revision: 1.1.2.1.4.3 $ - */ #ifndef _PORT_VMEM_H_ #define _PORT_VMEM_H_ @@ -36,62 +32,56 @@ #define PORT_VMEM_PAGESIZE_DEFAULT 0 #define PORT_VMEM_PAGESIZE_LARGE 1 -/** - * Virtual memory block descriptor. Incomplete type, - * runtime instance should be obtained via port_vmem_reserve() call - */ + /** Virtual memory block descriptor. Incomplete type, runtime instance should + * be obtained via port_vmem_reserve() call.*/ typedef struct port_vmem_t port_vmem_t; -/** - * Reserves a continuous memory region in the virtual address space - * of the calling process. - * @param[in,out] block descriptor for the reserved memory, required for - * further operations with the memory - * @param[in,out] address starting address of the region to allocate. If null, - * system will determine appropriate location. Actual allocated address is - * returned on success - * @param amount size of the region in bytes. For large pages, size must be - * multiply of page size. See port_vmem_page_sizes() - * @param protectionMode bit mask of PORT_VMEM_MODE_* values - * @param pageSize desired size of memory page. Value should be either - * any of PORT_VMEM_PAGESIZE_* flags or actual size in bytes. - * @param pool auxiliary pool - */ + /** Reserves a continuous memory region in the virtual address space + * of the calling process. + * + * @param[in,out] block - descriptor for the reserved memory, required for + * further operations with the memory + * @param[in,out] address - starting address of the region to allocate. If + * NULL system will determine appropriate + * location. Actual allocated address is returned on + * success + * @param amount - size of the region in bytes. For large pages, size + * must be multiply of page size. See + * port_vmem_page_sizes() + * @param protectionMode - bit mask of PORT_VMEM_MODE_* values + * @param pageSize - desired size of memory page. Value should be either + * any of PORT_VMEM_PAGESIZE_* flags or + * actual size in bytes + * @param pool - auxiliary pool*/ + APR_DECLARE(apr_status_t) port_vmem_reserve(port_vmem_t **block, void **address, size_t amount, unsigned int protectionMode, size_t pageSize, apr_pool_t *pool); -/** -* Commits (part of) previously reserved memory region. -* @param[in,out] address starting address of the region to commit. Returned value -* may differ due to page-alignment. -* @param amount size of the region in bytes -* @param block descriptor to the reserved virtual memory -*/ + /** Commits (part of) previously reserved memory region. + * + * @param[in,out] address - starting address of the region to commit. Returned + * value may differ due to page-alignment. + * @param amount - size of the region in bytes + * @param block - descriptor to the reserved virtual memory*/ APR_DECLARE(apr_status_t) port_vmem_commit(void **address, size_t amount, port_vmem_t *block); -/** -* Decommits the specified region of committed memory. It is safe to -* decommit reserved (but not committed) region. -*/ + /** Decommits the specified region of committed memory. It is safe to + * decommit reserved (but not committed) region.*/ APR_DECLARE(apr_status_t) port_vmem_decommit(void *address, size_t amount, port_vmem_t *block); -/** -* Releases previously reserved virtual memory region as a whole. -* If the region was committed, function first decommits it. -*/ + /** Releases previously reserved virtual memory region as a whole. + * If the region was committed, function first decommits it.*/ APR_DECLARE(apr_status_t) port_vmem_release(/*void *address, size_t amount,*/ port_vmem_t *block); -/** -* Returns zero-terminated array of supported memory page sizes. -* The first element refers to system default size and is guaranteed -* to be non-zero. Subsequent elements (if any) provide large page -* sizes. -*/ + /** Returns zero-terminated array of supported memory page sizes. + * The first element refers to system default size and is guaranteed + * to be non-zero. Subsequent elements (if any) provide large page + * sizes.*/ APR_DECLARE(size_t *) port_vmem_page_sizes(); Index: trunk/vm/port/include/stack_iterator.h =================================================================== --- trunk/vm/port/include/stack_iterator.h (revision 504464) +++ trunk/vm/port/include/stack_iterator.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,33 +14,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Intel, Pavel Afremov - * @version $Revision: 1.1.2.1.4.3 $ - */ -/** - *@file - * Mechanism for iterating over stack frames - * of Java and native code. - * - * This stack iterator handle is a black box. - * - * The iteractor supports iterating over: - *
      - *
    • Managed code frames corresponding to Java - * code - *
    • Managed-to-native frames (M2N) for transferring - * data and control between managed and native frames - * - * Native frames iteration is not currently supported. To iterate over - * native frames, use OS-provided tools. - *
    - * This iterator uses the order from the most recently pushed frame - * to the first frame pushed. - * With the stack iterator, you can also resume a frame in the current thread and - * transfer execution and control to this frame. - */ + /** + * @file + * Mechanism for iterating over stack frames + * of Java and native code. + * + * This stack iterator handle is a black box. + * The iteractor supports iterating over: + *
      + *
    • Managed code frames corresponding to Java + * code/
    • + *
    • Managed-to-native frames (M2N) for transferring + * data and control between managed and native frames/
    • + *
    • Native frames iteration is not currently supported. To iterate over + * native frames, use OS-provided tools.
    • + *
    + * This iterator uses the order from the most recently pushed frame + * to the first frame pushed. + * With the stack iterator, you can also resume a frame in the current thread and + * transfer execution and control to this frame.*/ #ifndef _STACK_ITERATOR_H_ #define _STACK_ITERATOR_H_ @@ -51,251 +44,202 @@ struct StackIterator; -/** - * Creates a new stack iterator for the given thread. - * - * @note The function assumes that the thread is currently in native code. - */ + /** Creates a new stack iterator for the given thread. + * + * @note The function assumes that the thread is currently in native code.*/ StackIterator* si_create_from_native(); -/** - * Creates a new stack iterator for the given thread. - * - * The thread can run concurrently with the stack iterator, - * but it must not pop (return past) the most recent M2N frame when the iterator is called. - * - * Creation is not atomic with respect to pushing/popping of M2N frames. - * The client code must ensure that such operations are serialized. - * - * @param[in] thread - the pointer to the thread, the stack of which must be enumerated - * - * @note The function assumes that the given thread is currently in native code. - */ + /** Creates a new stack iterator for the given thread. + * + * The thread can run concurrently with the stack iterator, + * but it must not pop (return past) the most recent M2N frame + * when the iterator is called. + * Creation is not atomic with respect to pushing/popping of M2N frames. + * The client code must ensure that such operations are serialized. + * + * @param[in] thread - the pointer to the thread, the stack of which must be enumerated + * + * @note The function assumes that the given thread is currently in native code.*/ StackIterator* si_create_from_native(VM_thread* thread); -/** - * Creates a new stack iterator for the suspended thread. - * - * The thread can run concurrently with the stack iterator, - * but it must not pop (return past) the most recent M2N frame when the iterator is called. - * - * Creation is not atomic with respect to pushing/popping of M2N frames. - * The client code must ensure that such operations are serialized. - * - * @param[in] regs - values of the registers at the point of suspension - * @param[in] is_ip_past - indicate is ip past or not - * @param[in] m2nf - the pointer to the M2N frame that must be the one immediately - * prior to the suspended frame - * - * @note The function assumes that iterated thread is currently suspended from managed code. - */ + /** Creates a new stack iterator for the suspended thread. + * The thread can run concurrently with the stack iterator, + * but it must not pop (return past) the most recent M2N frame when + * the iterator is called. + * Creation is not atomic with respect to pushing/popping of M2N frames. + * The client code must ensure that such operations are serialized. + * + * @param[in] regs - values of the registers at the point of suspension + * @param[in] is_ip_past - indicate is ip past or not + * @param[in] m2nf - the pointer to the M2N frame that must be the one + * immediately prior to the suspended frame + * + * @note The function assumes that iterated thread is currently suspended from managed code.*/ StackIterator* si_create_from_registers(Registers* regs, bool is_ip_past, M2nFrame* m2nf); -/** - * Makes a copy of the given stack iterator. - * - * @param[in] si - the pointer to the stack iterator to be copied - */ + /** Makes a copy of the given stack iterator. + * + * @param[in] si - the pointer to the stack iterator to be copied*/ StackIterator* si_dup(StackIterator* si); -/** - * Frees the stack iterator. - * - * @param[in] si - the pointer to the stack iterator to be freed - */ + /** Frees the stack iterator. + * + * @param[in] si - the pointer to the stack iterator to be freed*/ void si_free(StackIterator* si); -/** - * Ensures that all preserved registers are transferred from the M2N frame - * to the iterator. - * - * Depending on the platform, the implementation of stack iterators and M2N frames - * may not track all preserved registers required for resuming a frame, but may instead track - * enough for root set enumeration and stack walking. - * - * This function and the corresponding additional stub generator for M2N frames - * allow all registers to be tracked for exception propagation. - * - * @param[in] si - the poiter to the stack iterator that will contain all preserved - * registers - * - * @note Only call the function when the iterator is at an M2N frame - * that has all preserved registers saved. - */ + /** Ensures that all preserved registers are transferred from the M2N frame + * to the iterator. + * Depending on the platform, the implementation of stack iterators and M2N frames + * may not track all preserved registers required for resuming a frame, but may instead track + * enough for root set enumeration and stack walking. + * This function and the corresponding additional stub generator for M2N frames + * allow all registers to be tracked for exception propagation. + * + * @param[in] si - the poiter to the stack iterator that will contain all preserved + * registers + * + * @note Only call the function when the iterator is at an M2N frame + * that has all preserved registers saved.*/ void si_transfer_all_preserved_registers(StackIterator* si); -/** - * Checks whether the stack iterator has passed all the frames. - * - * @param[in] si - the poiter to a StackIterator which should be tested is past all - * the frames or not. - * @return TRUE if the transferred stack iterator has passed all the frames; - * otherwise, FALSE. - */ + /** Checks whether the stack iterator has passed all the frames. + * + * @param[in] si - the poiter to a StackIterator which should be tested is past all + * the frames or not. + * @return TRUE if the transferred stack iterator has passed all the frames; + * otherwise, FALSE.*/ bool si_is_past_end(StackIterator* si ); -/** - * Goes to the frame previous to the current one. - * - * @param[in] si - the pointer to the stack iterator that will be iterated to the previous - * frame - * @param[in] over_popped - take into account the intermediate result of pop frame operation. - */ + /** Goes to the frame previous to the current one. + * + * @param[in] si - the pointer to the stack iterator that will be iterated to the previous + * frame + * @param[in] over_popped - take into account the intermediate result of pop frame operation.*/ void si_goto_previous(StackIterator* si, bool over_popped = true); -/** - * Gets the instruction pointer for the current frame. - * - * @param[in] si - the pointer to the stack iterator indicating the current frame - * - * @return The instruction pointer for the current frame. - */ + /** Gets the instruction pointer for the current frame. + * + * @param[in] si - the pointer to the stack iterator indicating the current frame + * + * @return The instruction pointer for the current frame.*/ NativeCodePtr si_get_ip(StackIterator* si); -/** - * Sets the instruction pointer for the current frame. - * - * @param[in] si - the pointer to the stack iterator indicating - * the current frame - * @param[in] ip - the instruction pointer for the current frame - * @param[in] also_update_stack_itself - the flag indicating whether the function must update - * data on the stack or only in the iterator - * - * @return If also_update_stack_itself is TRUE, - * updates the instruction pointer in the stack; otherwise, the new - * value stored in the stack iterator only. - */ + /** Sets the instruction pointer for the current frame. + * + * @param[in] si - the pointer to the stack iterator indicating + * the current frame + * @param[in] ip - the instruction pointer for the current frame + * @param[in] also_update_stack_itself - the flag indicating whether the function must update + * data on the stack or only in the iterator + * + * @return If also_update_stack_itself is TRUE, + * updates the instruction pointer in the stack; otherwise, the new + * value stored in the stack iterator only.*/ void si_set_ip(StackIterator* si, NativeCodePtr ip, bool also_update_stack_itself = false); -/** - * Sets the code chunk for the current frame of the stack indicated by the iterator. - * - * @param[in] si - the pointer to the stack iterator indicating the current frame - * @param[in] cci - the pointer to CodeChunkInfo to be set for the current frame - * - * @note The function assumes that the thread is iterated in a managed frame. - */ + /** Sets the code chunk for the current frame of the stack indicated by the iterator. + * + * @param[in] si - the pointer to the stack iterator indicating the current frame + * @param[in] cci - the pointer to CodeChunkInfo to be set for the current frame + * + * @note The function assumes that the thread is iterated in a managed frame.*/ void si_set_code_chunk_info(StackIterator* si, CodeChunkInfo* cci); -/** - * Gets the code chunk information for the current frame. - * - * @param[in] si - the pointer to the stack iterator indicating the current frame - * - * @return The pointer to the code chunk information for managed frames and NULL - * for M2N frames. - */ + /** Gets the code chunk information for the current frame. + * + * @param[in] si - the pointer to the stack iterator indicating the current frame + * + * @return The pointer to the code chunk information for managed frames and NULL + * for M2N frames.*/ CodeChunkInfo* si_get_code_chunk_info(StackIterator* si); -/** - * Gets the JIT frame context for the current frame. - * - * @param[in] si - the pointer to the stack iterator indicating the current frame - * - * @return The JIT frame context for the current frame. - */ + /** Gets the JIT frame context for the current frame. + * + * @param[in] si - the pointer to the stack iterator indicating the current frame + * + * @return The JIT frame context for the current frame.*/ JitFrameContext* si_get_jit_context(StackIterator* si); -/** - * Checks whether the current frame is an M2N frame. - * - * @param[in] si - the pointer to the stack iterator indicating the current frame - * - * @return TRUE if the current thread is an M2N frame; - * otherwise, FALSE. - */ + /** Checks whether the current frame is an M2N frame. + * + * @param[in] si - the pointer to the stack iterator indicating the current frame + * + * @return TRUE if the current thread is an M2N frame; + * otherwise, FALSE.*/ bool si_is_native(StackIterator* si); -/** - * Gets the pointer to the M2N frame if the current frame is M2N. - * - * @param[in] si - the pointer to the stack iterator indicating the current frame - * - * @return The pointer to the the M2N frame if the current frame is M2N; otherwise, - * NULL. - */ + /** Gets the pointer to the M2N frame if the current frame is M2N. + * + * @param[in] si - the pointer to the stack iterator indicating the current frame + * + * @return The pointer to the the M2N frame if the current frame is M2N; otherwise, + * NULL.*/ M2nFrame* si_get_m2n(StackIterator* si); -/** - * Gets the pointer to the value of the return register. - * - * If transfer control is called, the resumed frame will see this value. - * - * @param[in] si - the pointer to the stack iterator indicating the current frame - * - * @return the pointer to the pointer to the return value. - */ + /** Gets the pointer to the value of the return register. + * + * If transfer control is called, the resumed frame will see this value. + * + * @param[in] si - the pointer to the stack iterator indicating the current frame + * + * @return the pointer to the pointer to the return value.*/ void** si_get_return_pointer(StackIterator* si); -/** - * Sets the pointer to the value of the return register. - * - * If the transfer control is subsequently called, the resumed frame has data on this change. - * - * @param[in] si - the pointer to the stack iterator indicating the current frame - * @param[in] return_value - the pointer to the pointer to the return value that will be set - */ + /** Sets the pointer to the value of the return register. + * + * If the transfer control is subsequently called, the resumed frame has data on this change. + * + * @param[in] si - the pointer to the stack iterator indicating the current frame + * @param[in] return_value - the pointer to the pointer to the return value that will be set*/ void si_set_return_pointer(StackIterator* si, void** return_value); -/** - * Thransfers control and resumes execution in the current frame of the iterator. - * Returns no values and frees the stack iterator. - * - * @param[in] si - the pointer to the stack iterator indicating the current frame - * - * @note This function must only be called for the iterator on the current thread's frames. - */ + /** Thransfers control and resumes execution in the current frame of the iterator. + * Returns no values and frees the stack iterator. + * + * @param[in] si - the pointer to the stack iterator indicating the current frame + * + * @note This function must only be called for the iterator on the current thread's frames.*/ void si_transfer_control(StackIterator* si); -/** - * Copies the value of the stack iterators' current frame into the given registers. - * - * This way, resuming these registers transfers control to the current frame. - * - * @param[in] si - the pointer to the stack iterator indicating the current frame - * @param[out] regs - the pointer to the registers where the registers' values - * from the stack iterator will be copied - */ + /** + * Copies the value of the stack iterators' current frame into the given registers. + * + * This way, resuming these registers transfers control to the current frame. + * + * @param[in] si - the pointer to the stack iterator indicating the current frame + * @param[out] regs - the pointer to the registers where the registers' values + * from the stack iterator will be copied*/ void si_copy_to_registers(StackIterator* si, Registers* regs); -/** - * Reloads registers from the register stack. - * - * - * @note On architectures with register stacks, ensure that the register stack of - * the current thread is consistent with its backing store. This is done because the backing - * store might have been modified by the stack walking code. - */ + /** Reloads registers from the register stack. + * + * @note On architectures with register stacks, ensure that the register stack of + * the current thread is consistent with its backing store. This is done + * because the backing store might have been modified by the stack walking code.*/ void si_reload_registers(); -/** - * Gets the method handle for the frame iterated by the stack iterator. - * - * @param[in] si - the pointer to the stack iterator indicating the current frame - * - * @return The method handle corresponding to the given stack iterator. - */ + /** Gets the method handle for the frame iterated by the stack iterator. + * + * @param[in] si - the pointer to the stack iterator indicating the current frame + * + * @return The method handle corresponding to the given stack iterator.*/ Method_Handle si_get_method(StackIterator* si); -/** - * Gets the number of inlined methods corresponding to the current frame - * iterated by stack iterator. - * - * @param[in] si - the pointer to the stack iterator indicating the current frame - * - * @return The number of inlined methods. - */ + /** Gets the number of inlined methods corresponding to the current frame + * iterated by stack iterator. + * + * @param[in] si - the pointer to the stack iterator indicating the current frame + * + * @return The number of inlined methods.*/ uint32 si_get_inline_depth(StackIterator* si); -/** - * Gets the method handle for the frame iterated by the stack iterator. - * - * @param[in] si - the pointer to the stack iterator indicating the frame, - * from which control will be transfered - * @param[in] callback - pointer to the native cose adress which should be - * called, after transfer control - */ + /** Gets the method handle for the frame iterated by the stack iterator. + * + * @param[in] si - the pointer to the stack iterator indicating the frame, + * from which control will be transfered + * @param[in] callback - pointer to the native cose adress which should be + * called, after transfer control*/ void si_set_callbak(StackIterator* si, NativeCodePtr* callback); #endif //!_STACK_ITERATOR_H_ Index: trunk/vm/port/include/tl/allocator.h =================================================================== --- trunk/vm/port/include/tl/allocator.h (revision 504464) +++ trunk/vm/port/include/tl/allocator.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,10 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Intel, Evgueni Brevnov - * @version $Revision: 1.1.2.1.4.3 $ - */ + #ifndef TL_ALLOCATOR_H #define TL_ALLOCATOR_H @@ -26,23 +23,23 @@ namespace tl { - /** - * An allocator based on the basic memory allocation primitives. - */ + /** + * An allocator based on the basic memory allocation primitives.*/ template class BasicAllocator { public: - // Default constructor. + + /** Default constructor.*/ BasicAllocator() {} - // Copy constructor. + /** Copy constructor.*/ template BasicAllocator(const BasicAllocator& allocator) {} - // Destructor. + /** Destructor.*/ ~BasicAllocator() {} - // Underlying pointer, reference, etc types for this allocator. + /** Underlying pointer, reference, etc types for this allocator.*/ typedef T* pointer; typedef const T* const_pointer; typedef T& reference; @@ -51,11 +48,11 @@ typedef size_t size_type; typedef ptrdiff_t difference_type; - // Pointer/reference conversion. + /** Pointer/reference conversion.*/ pointer address(reference x) const { return &x; } const_pointer address(const_reference x) const { return &x; } - // Allocation/deallocation operations. + /** Allocation/deallocation operations.*/ pointer allocate(size_type n, const void* = 0) { pointer p = (pointer) STD_MALLOC(n * sizeof(T)); @@ -67,43 +64,39 @@ //STD_FREE(p); } - // Maximum allocatable size based upon size_type. + /** + * Maximum allocatable size based upon size_type.*/ size_type max_size() const { return ((size_type) -1) / sizeof(value_type); } - // Initialization/finalization operations. + /** Initialization/finalization operations.*/ void construct(pointer p, const value_type& x) { new (p) value_type(x); } void destroy(pointer p) { p->~value_type(); } - // Allocator equality tests + /** Allocator equality tests*/ template bool operator==(const BasicAllocator& allocator) { return TRUE; } template bool operator!=(const BasicAllocator& allocator) { return FALSE; } - // Type conversion utility to obtain BasicAllocator for different underlying type. + /** Type conversion utility to obtain BasicAllocator for different underlying type.*/ template struct rebind { typedef BasicAllocator other; }; - }; - - - /** - * A MemoryPool based STL allocator. - */ + /** A MemoryPool based STL allocator.*/ template class MPAllocator { public: - // Standard constructor + /** Standard constructor.*/ MPAllocator(MemoryPool& mp) : pmp(&mp) {} - // Copy constructor. + /** Copy constructor.*/ template MPAllocator(const MPAllocator& allocator) : pmp(&allocator.getMemoryPool()) {} - // Destructor. + /** Destructor.*/ ~MPAllocator() {} - // Underlying pointer, reference, etc types for this allocator. + /** Underlying pointer, reference, etc types for this allocator.*/ typedef T* pointer; typedef const T* const_pointer; typedef T& reference; @@ -112,14 +105,14 @@ typedef size_t size_type; typedef ptrdiff_t difference_type; - // Pointer/reference conversion. + /** Pointer/reference conversion. */ pointer address(reference x) const { return &x; } const_pointer address(const_reference x) const { return &x; } - // Underlying MemoryPool. + /** Underlying MemoryPool.*/ MemoryPool& getMemoryPool() const { return *pmp; } - // Allocation/deallocation operations. + /** Allocation/deallocation operations.*/ pointer allocate(size_type n, const void* = 0) { pointer p = (pointer) pmp->alloc(n * sizeof(T)); @@ -128,24 +121,25 @@ } void deallocate(void *p, size_type) {} - // Maximum allocatable size based upon size_type. + /** Maximum allocatable size based upon size_type.*/ size_type max_size() const { return ((size_type) -1) / sizeof(value_type); } - // Initialization/finalization operations. + /** Initialization/finalization operations.*/ void construct(pointer p, const value_type& x) { new (p) value_type(x); } void destroy(pointer p) { p->~value_type(); } - // Allocator equality tests + /** Allocator equality tests.*/ template bool operator==(const MPAllocator& allocator) { return pmp == allocator.pmp; } template bool operator!=(const MPAllocator& allocator) { return pmp != allocator.pmp; } - // Type conversion utility to obtain MPAllocator for different underlying type. + /** Type conversion utility to obtain MPAllocator for different + * underlying type.*/ template struct rebind { typedef MPAllocator other; }; private: - // Disable. Cannot be instantiated without a MemoryPool. + /** Disable. Cannot be instantiated without a MemoryPool.*/ MPAllocator(); MemoryPool* pmp; Index: trunk/vm/port/include/tl/list_mt.h =================================================================== --- trunk/vm/port/include/tl/list_mt.h (revision 504464) +++ trunk/vm/port/include/tl/list_mt.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,18 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Intel, Evgueni Brevnov - * @version $Revision: 1.1.2.1.4.3 $ - */ -/** - * This file is a part of tool library. - */ + + /** + * @file + * This file is a part of tool library.*/ namespace tl { - /** - * Linked list interface. - */ + /** Linked list interface.*/ template @@ -58,11 +53,8 @@ } bool Contains(_Key _key); - /** - * Return an iterator. Collection should be locked - * to iterate over the iterator. - * Destruction of iterator unlocks collecton. - */ + /** Return an iterator. Collection should be locked to iterate over the iterator. + * Destruction of iterator unlocks collecton.*/ Iterator GetIterator(); } // ListElement } // tl Index: trunk/vm/port/include/tl/memory_pool.h =================================================================== --- trunk/vm/port/include/tl/memory_pool.h (revision 504464) +++ trunk/vm/port/include/tl/memory_pool.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,10 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Evgueni Brevnov - * @version $Revision: 1.1.2.1.4.4 $ - */ #ifndef TL_MEMORY_POOL_H #define TL_MEMORY_POOL_H @@ -59,14 +55,10 @@ MemoryPoolMT(const MemoryPoolMT* parent); ~MemoryPoolMT(); - /** - * Thread safe memory allocation. - */ + /** Thread safe memory allocation.*/ void *alloc(size_t size); - /** - * Thread safe mutex allocation / creation. - */ + /** Thread safe mutex allocation / creation.*/ apr_status_t create_mutex(apr_thread_mutex_t**, unsigned int flags); }; Index: trunk/vm/port/include/tl/set.h =================================================================== --- trunk/vm/port/include/tl/set.h (revision 504464) +++ trunk/vm/port/include/tl/set.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,25 +14,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Intel, Evgueni Brevnov - * @version $Revision: 1.1.2.1.4.3 $ - */ + #ifndef STL_VECTOR_MT_H #define STL_VECTOR_MT_H -// FIXME this should be thread safe vector implementation with -// custom memory allocator. -// But now this is just wrapper for the current STL vector implementation +/** + * FIXME this should be thread safe vector implementation with + * custom memory allocator. + * But now this is just wrapper for the current STL vector implementation. + */ #include #include "tl/allocator.h" namespace tl { - /** - * A MemoryManager-based STL sorted vector container to use as a set. - **/ + /** A MemoryManager-based STL sorted vector container to use as a set.*/ template > class vector_set : public ::std::vector { Index: trunk/vm/port/include/tl/set_mt.h =================================================================== --- trunk/vm/port/include/tl/set_mt.h (revision 504464) +++ trunk/vm/port/include/tl/set_mt.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -13,17 +13,15 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ -/** - * @author Intel, Evgueni Brevnov - * @version $Revision: 1.1.2.1.4.3 $ - */ + */ #ifndef TL_SET_MT_H #define TL_SET_MT_H -// FIXME this should be thread safe vector implementation with -// custom memory allocator. -// But now this is just wrapper for the current STL vector implementation +/** + * FIXME this should be thread safe vector implementation with + * custom memory allocator. + * But now this is just wrapper for the current STL vector implementation. + */ #include #include // strangely VC defines equal_range here @@ -35,10 +33,8 @@ namespace tl { - /** - * A MemoryManager-based STL sorted vector container to use - * as a set. - */ + /** A MemoryManager-based STL sorted vector container to use + * as a set.*/ template > class vector_set_mt : public ::std::vector { @@ -49,15 +45,11 @@ MemoryPool mem_pool; public: - /** - * Lock container access. Use it before accessing iterators. - */ + /** Lock container access. Use it before accessing iterators.*/ void lock() { apr_thread_mutex_lock(mutex); } - /** - * Unock container access. - */ + /** Unock container access.*/ void unlock() { apr_thread_mutex_unlock(mutex); } Index: trunk/vm/port/include/tl/vector.h =================================================================== --- trunk/vm/port/include/tl/vector.h (revision 504464) +++ trunk/vm/port/include/tl/vector.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,26 +14,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Intel, Evgueni Brevnov - * @version $Revision: 1.1.2.1.4.3 $ - */ + #ifndef TL_VECTOR_H #define TL_VECTOR_H -/** - * This is just wrapper for the current STL vector - * implementation - * with default memory allocator replaced. - */ + /** + * @file + * This is just wrapper for the current STL vector + * implementation with default memory allocator replaced.*/ #include "tl/allocator.h" #include namespace tl { - /** - * A MemoryManager-based STL vector container. - */ + /** A MemoryManager-based STL vector container.*/ template > class vector : public ::std::vector { Index: trunk/vm/port/include/tl/vector_mt.h =================================================================== --- trunk/vm/port/include/tl/vector_mt.h (revision 504464) +++ trunk/vm/port/include/tl/vector_mt.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,17 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Intel, Evgueni Brevnov - * @version $Revision: 1.1.2.1.4.3 $ - */ + #ifndef TL_VECTOR_MT_H #define TL_VECTOR_MT_H -// FIXME this should be thread safe vector implementation with -// custom memory allocator. -// But now this is just wrapper for the current STL vector -// implementation + /** + * FIXME this should be thread safe vector implementation with + * custom memory allocator. + * But now this is just wrapper for the current STL vector + * implementation.*/ #include "tl/vector.h" #include "log_macro.h" @@ -34,9 +32,7 @@ namespace tl { - /** - * Thread safe vector. - */ + /** Thread safe vector.*/ template > class vector_mt : public ::std::vector { @@ -57,27 +53,20 @@ ABORT("Couldn't create mutex"); } } - /** - * Lock container access. Use it before accessing iterators. - */ + /** Lock container access. Use it before accessing iterators.*/ void lock() { apr_thread_mutex_lock(mutex); } - /** - * Unock container access. - */ + /** Unock container access.*/ void unlock() { apr_thread_mutex_unlock(mutex); } - /** - * Add an element to the end of the vector. - */ + /** Add an element to the end of the vector.*/ void push_back(const T& val) { lock(); std_vector::push_back(val); unlock(); } - }; } // tl Index: trunk/vm/port/src/encoder/ia32_em64t/dec_base.h =================================================================== --- trunk/vm/port/src/encoder/ia32_em64t/dec_base.h (revision 504464) +++ trunk/vm/port/src/encoder/ia32_em64t/dec_base.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,17 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Alexander V. Astapchuk - * @version $Revision: $ - */ /** * @file * @brief Main decoding (disassembling) routines and structures. * - * @note Quick and rough implementation, subject for a change. - */ + * @note Quick and rough implementation, subject for a change.*/ #ifndef __DEC_BASE_H_INCLUDED__ #define __DEC_BASE_H_INCLUDED__ @@ -50,32 +45,25 @@ //direct_addr = NULL; argc = 0; } - /** - * Mnemonic of the instruction.s - */ + /** Mnemonic of the instructions.*/ Mnemonic mn; - /** - * Size, in bytes, of the instruction. - */ + /** Size, in bytes, of the instruction.*/ + unsigned size; - /** - * Flags of the instruction. - * @see MF_ - */ + /** Flags of the instruction. + * @see MF_ */ + unsigned flags; - /** - * An offset of target address, in case of 'CALL offset', - * 'JMP/Jcc offset'. - */ + /** An offset of target address, in case of CALL offset, + * JMP/Jcc offset.*/ + //int offset; - /** - * Direct address of the target (on Intel64/IA-32 is 'instruction IP' + - * 'instruction length' + offset). - */ + + /** Direct address of the target (on Intel64/IA-32 is 'instruction IP' + + * 'instruction length' + offset).*/ //void * direct_addr; - /** - * Number of arguments of the instruction. - */ + + /** Number of arguments of the instruction.*/ unsigned argc; // EncoderBase::Operand operands[3]; Index: trunk/vm/port/src/encoder/ia32_em64t/enc_base.h =================================================================== --- trunk/vm/port/src/encoder/ia32_em64t/enc_base.h (revision 504464) +++ trunk/vm/port/src/encoder/ia32_em64t/enc_base.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,15 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + /** - * @author Alexander V. Astapchuk - * @version $Revision: 1.1.2.3.4.4 $ - */ - -/** * @file - * @brief Main encoding routines and structures. - */ + * Main encoding routines and structures.*/ #ifndef __ENC_BASE_H_INCLUDED__ #define __ENC_BASE_H_INCLUDED__ @@ -43,19 +38,16 @@ * @brief Basic facilities for generation of processor's instructions. * * The class EncoderBase represents the basic facilities for the encoding of - * processor's instructions on IA32 and EM64T platforms. - * + * processor's instructions on IA32 and EM64T platforms.
    * The class provides general interface to generate the instructions as well * as to retrieve some static data about instructions (number of arguments, - * their roles, etc). - * - * Currently, the EncoderBase class is used for both LIL and Jitrino code - * generators. Each of these code generators has its own wrapper to adapt + * their roles, etc).
    + * Currently, the EncoderBase class is used for both LIL and Jitrino + * code generators. Each of these code generators has its own wrapper to adapt * this general interface for specific needs - see encoder.h for LIL wrappers - * and Ia32Encoder.h for Jitrino's adapter. - * - * Interface is provided through static methods, no instances of EncoderBase - * to be created. + * and Ia32Encoder.h for Jitrino's adapter.
    + * Interface is provided through static methods, no instances of + * EncoderBase to be created. * * @todo RIP-based addressing on EM64T - it's not yet supported currently. */ @@ -63,66 +55,63 @@ public: class Operands; struct MnemonicDesc; - /** - * @brief Generates processor's instruction. - * - * @param stream - a buffer to generate into - * @param mn - \link Mnemonic mnemonic \endlink of the instruction - * @param opnds - operands for the instruction - * @returns (stream + length of the just generated instruction) - */ + /** + * @brief Generates processor's instruction. + * + * @param stream - a buffer to generate into + * @param mn - \link Mnemonic mnemonic \endlink of the instruction + * @param opnds - operands for the instruction + * + * @returns (stream + length of the just generated instruction)*/ static char * encode(char * stream, Mnemonic mn, const Operands& opnds); - /** - * @brief Generates the smallest possible number of NOP-s. - * - * Effectively generates the smallest possible number of instructions, - * which are NOP-s for CPU. Normally used to make a code alignment. - * - * The method inserts exactly number of bytes specified. It's a caller's - * responsibility to make sure the buffer is big enough. - * - * @param stream - buffer where to generate code into, can not be NULL - * @param howMany - how many bytes to fill with NOP-s - * @return \c (stream+howMany) - */ + /** + * @brief Generates the smallest possible number of NOP-s. + * + * Effectively generates the smallest possible number of instructions, which are + * NOP-s for CPU. Normally used to make a code alignment.
    + * The method inserts exactly number of bytes specified. It's a caller's + * responsibility to make sure the buffer is big enough. + * + * @param stream - buffer where to generate code into, can not be NULL + * @param howMany - how many bytes to fill with NOP-s + * + * @return \c (stream+howMany)*/ static char * nops(char * stream, unsigned howMany); - /** - * @brief Inserts a prefix into the code buffer. - * - * The method writes no more than one byte into the buffer. This is a - * caller's responsibility to make sure the buffer is big enough. - * - * @param stream - buffer where to insert the prefix - * @param pref - prefix to be inserted. If it's InstPrefix_Null, then - * no action performed and return value is \c stream. - * @return \c (stream+1) if pref is not InstPrefix_Null, or \c stream - * otherwise - */ + /** + * @brief Inserts a prefix into the code buffer. + * + * The method writes no more than one byte into the buffer. This is a + * caller's responsibility to make sure the buffer is big enough. + * + * @param stream - buffer where to insert the prefix + * @param pref - prefix to be inserted. If it's InstPrefix_Null, + * then no action performed and return value is \c stream. + * + * @return \c (stream+1) if pref is not InstPrefix_Null, or \c stream + * otherwise*/ static char * prefix(char* stream, InstPrefix pref); - /** - * @brief Returns #MnemonicDesc by the given Mnemonic. - */ + /** + * @brief Returns MnemonicDesc by given Mnemonic.*/ static const MnemonicDesc * getMnemonicDesc(Mnemonic mn) { assert(mn < Mnemonic_Count); return mnemonics + mn; } - /** - * @brief Returns a Mnemonic for the given name. - * - * The lookup is case insensitive, if no mnemonic found for the given - * string, then Mnemonic_Null returned. - */ + /** + * @brief Returns Mnemonic for the given name. + * + * The lookup is case insensitive, if no Mnemonic found for the given + * string, then Mnemonic_Null returned.*/ static Mnemonic str2mnemonic(const char * mn_name); /** - * @brief Returns a string representation of the given Mnemonic. + * @brief Returns a string representation of the given Mnemonic. * - * If invalid mnemonic passed, then the behavior is unpredictable. + * If invalid Mnemonic passed, then the behavior is unpredictable. */ static const char * getMnemonicString(Mnemonic mn) { @@ -133,191 +122,148 @@ { return getMnemonicDesc(mn)->name; } - - - /** - * @brief Description of operand. - * - * Description of an operand in opcode - its kind, size or RegName if - * operand must be a particular register. - */ + /** + * @brief Description of operand. + * + * Description of an operand in opcode - its kind, size or + * RegName if operand must be a particular register.*/ struct OpndDesc { - /** - * @brief Location of the operand. - * - * May be a mask, i.e. OpndKind_Imm|OpndKind_Mem. - */ + /** + * @brief Location of the operand. + * + * May be a mask, i.e. OpndKind_Imm|OpndKind_Mem.*/ OpndKind kind; - /** - * @brief Size of the operand. - */ + /** + * @brief Size of the operand.*/ OpndSize size; - /** - * @brief Appropriate RegName if operand must reside on a particular - * register (i.e. CWD/CDQ instructions), RegName_Null - * otherwise. - */ + /** + * @brief Appropriate RegName if operand must reside on a + * particular register (i.e. CWD/CDQ instructions), + * RegName_Null otherwise.*/ RegName reg; }; - - /** - * @brief Description of operands' roles in instruction. - */ + /** + * @brief Description of operands' roles in instruction.*/ struct OpndRolesDesc { - /** - * @brief Total number of operands in the operation. - */ + /** + * @brief Total number of operands in the operation.*/ unsigned count; - /** - * @brief Number of defs in the operation. - */ + /** + * @brief Number of defs in the operation.*/ unsigned defCount; - /** - * @brief Number of uses in the operation. - */ + /** + * @brief Number of uses in the operation.*/ unsigned useCount; - /** - * @brief Operand roles, bit-packed. - * - * A bit-packed info about operands' roles. Each operand's role is - * described by two bits, counted from right-to-left - the less - * significant bits (0,1) represent operand#0. - * - * The mask is build by ORing #OpndRole_Def and #OpndRole_Use - * appropriately and shifting left, i.e. operand#0's role would be - * - '(OpndRole_Def|OpndRole_Use)' - * - opnd#1's role would be 'OpndRole_Use<<2' - * - and operand#2's role would be, say, 'OpndRole_Def<<4'. - */ + /** + * @brief Operand roles, bit-packed. + * + * A bit-packed info about operands roles. Each operand role is described by two + * bits, counted from right-to-left - the less significant bits (0,1) represent + * operand#0.
    + * The mask is build by ORing #OpndRole_Def and #OpndRole_Use appropriately and + * shifting left, i.e. operand#0's role would be + *
    • OpndRole_Def|OpndRole_Use
    • + *
    • opnd#1's role would be OpndRole_Use<<2
    • + *
    • operand#2's role would be, say, OpndRole_Def<<4
    • + *
    */ unsigned roles; }; - - /** - * @brief Extracts appropriate OpndRole for a given operand. - * - * The order of operands is left-to-right, i.e. for MOV, it - * would be 'MOV op0, op1' - */ + /** + * @brief Extracts appropriate OpndRole for a given operand. + * + * The order of operands is left-to-right, i.e. for MOV, it would be MOV op0, op1*/ static OpndRole getOpndRoles(OpndRolesDesc ord, unsigned idx) { assert(idx < ord.count); return (OpndRole)(ord.roles>>((ord.count-1-idx)*2) & 0x3); } - - /** - * @brief Info about single opcode - its opcode bytes, operands, - * operands' roles. - */ + /** + * @brief Info about single opcode - its opcode bytes, operands, operands' roles.*/ struct OpcodeDesc { - /** - * @brief Raw opcode bytes. - * - * 'Raw' opcode bytes which do not require any analysis and are - * independent from arguments/sizes/etc (may include opcode size - * prefix). - */ + /** + * @brief Raw opcode bytes. + * + * Raw opcode bytes which do not require any analysis and are independent + * from arguments/sizes/etc (may include opcode size prefix).*/ char opcode[5]; // 4 bytes unsigned opcode_len; // 4 unsigned aux0; // 4 unsigned aux1; // 4 - /** - * @brief Info about opcode's operands. - * - * The [3] mostly comes from IDIV/IMUL which both may have up to 3 - * operands. - */ + /** + * @brief Info about opcode's operands. + * + * The [3] mostly comes from IDIV/IMUL which both may have up to 3 operands.*/ OpndDesc opnds[3]; // 12*3 = 36 unsigned first_opnd; // 4 - /** - * @brief Info about operands - total number, number of uses/defs, - * operands' roles. - */ + /** + * @brief Info about operands - total number, number of uses/defs, operands' roles.*/ OpndRolesDesc roles; // 16 - /** - * @brief If not zero, then this is final OpcodeDesc structure in - * the list of opcodes for a given mnemonic. - */ + /** + * @brief If not zero, then this is final OpcodeDesc structure in + * the list of opcodes for a given Mnemonic.*/ char last; // 1 // total: 74 - /** - * @brief Padding to make structure's size a power of 2. - */ + /** + * @brief Padding to make structure's size a power of 2.*/ char padding[128-74]; }; public: - /** - * @brief General info about mnemonic. - */ + /** + * @brief General info about Mnemonic.*/ struct MnemonicDesc { - /** - * @brief The mnemonic itself. - */ + /** + * @brief Mnemonic itself.*/ Mnemonic mn; - /** - * Various characteristics of mnemonic. - * @see MF_ - */ + /** Various characteristics of Mnemonic. + * @see MF_*/ unsigned flags; - /** - * @brief Operation's operand's count and roles. - * - * For the operations whose opcodes may use different number of - * operands (i.e. IMUL/SHL) either most common value used, or empty - * value left. - */ + /** + * @brief Operation's operand's count and roles. + * + * For the operations whose opcodes may use different number of operands + * (i.e. IMUL/SHL) either most common value used, or empty value left.*/ OpndRolesDesc roles; - /** - * @brief Print name of the mnemonic. - */ + /** + * @brief Print name of Mnemonic.*/ const char * name; }; - - - /** - * @brief Magic number, shows a maximum value a hash code can take. - * - * For meaning and arithmetics see enc_tabl.cpp. - * - * The value was increased from '5155' to '8192' to make it aligned - * for faster access in EncoderBase::lookup(). - */ + /** + * @brief Magic number, shows a maximum value a hash code can take. + * + * For meaning and arithmetics see enc_tabl.cpp. + * + * The value was increased from 5155 to 8192 to make it aligned + * for faster access in EncoderBase::lookup().*/ static const unsigned int HASH_MAX = 8192; //5155; - /** - * @brief Empty value, used in hash-to-opcode map to show an empty slot. - */ + /** + * @brief Empty value, used in hash-to-opcode map to show an empty slot.*/ static const unsigned char NOHASH = 0xFF; - /** - * @brief The name says it all. - */ + /** + * @brief The name says it all.*/ static const unsigned char HASH_BITS_PER_OPERAND = 5; - /** - * @brief Contains info about a single instructions's operand - its - * location, size and a value for immediate or RegName for - * register operands. - */ + /** + * @brief Contains info about a single instructions's operand - its location, + * size and a value for immediate or RegName for register operands.*/ class Operand { public: - /** - * @brief Initializes the instance with empty size and kind. - */ + /** + * @brief Initializes the instance with empty size and kind.*/ Operand() : m_kind(OpndKind_Null), m_size(OpndSize_Null), m_need_rex(false) {} - /** - * @brief Creates register operand from given RegName. - */ + /** + * @brief Creates register operand from given RegName.*/ Operand(RegName reg) : m_kind(getRegKind(reg)), m_size(getRegSize(reg)), m_reg(reg) { hash_it(); } - /** - * @brief Creates register operand from given RegName and with the - * specified size and kind. - * - * Used to speedup Operand creation as there is no need to extract - * size and kind from the RegName. - * The provided size and kind must match the RegName's ones though. - */ + /** + * @brief Creates register operand from given RegName and with the + * specified size and kind. + * + * Used to speedup Operand creation as there is no need to extract size and + * kind from the RegName.
    + * The provided size and kind must match the RegName's ones though.*/ Operand(OpndSize sz, OpndKind kind, RegName reg) : m_kind(kind), m_size(sz), m_reg(reg) @@ -326,43 +272,36 @@ assert(m_kind == getRegKind(reg)); hash_it(); } - /** - * @brief Creates immediate operand with the given size and value. - */ + /** + * @brief Creates immediate operand with the given size and value.*/ Operand(OpndSize size, long long ival) : m_kind(OpndKind_Imm), m_size(size), m_imm64(ival) { hash_it(); } - /** - * @brief Creates immediate operand of OpndSize_32. - */ + /** + * @brief Creates immediate operand of OpndSize_32.*/ Operand(int ival) : m_kind(OpndKind_Imm), m_size(OpndSize_32), m_imm64(ival) { hash_it(); } - /** - * @brief Creates immediate operand of OpndSize_16. - */ + /** + * @brief Creates immediate operand of OpndSize_16.*/ Operand(short ival) : m_kind(OpndKind_Imm), m_size(OpndSize_16), m_imm64(ival) { hash_it(); } - - /** - * @brief Creates immediate operand of OpndSize_8. - */ + /** + * @brief Creates immediate operand of OpndSize_8.*/ Operand(char ival) : m_kind(OpndKind_Imm), m_size(OpndSize_8), m_imm64(ival) { hash_it(); } - - /** - * @brief Creates memory operand. - */ + /** + * @brief Creates memory operand.*/ Operand(OpndSize size, RegName base, RegName index, unsigned scale, int disp) : m_kind(OpndKind_Mem), m_size(size) { @@ -372,10 +311,8 @@ m_disp = disp; hash_it(); } - - /** - * @brief Creates memory operand with only base and displacement. - */ + /** + * @brief Creates memory operand with only base and displacement.*/ Operand(OpndSize size, RegName base, int disp) : m_kind(OpndKind_Mem), m_size(size) { @@ -388,17 +325,14 @@ // // general info // - /** - * @brief Returns kind of the operand. - */ + /** + * @brief Returns kind of the operand.*/ OpndKind kind(void) const { return m_kind; } - /** - * @brief Returns size of the operand. - */ + /** + * @brief Returns size of the operand.*/ OpndSize size(void) const { return m_size; } - /** - * @brief Returns hash of the operand. - */ + /** + * @brief Returns hash of the operand.*/ unsigned hash(void) const { return m_hash; } // #ifdef _EM64T_ @@ -406,60 +340,46 @@ #else bool need_rex(void) const { return false; } #endif - /** - * @brief Tests whether operand is memory operand. - */ + /** + * @brief Tests whether operand is memory operand.*/ bool is_mem(void) const { return is_placed_in(OpndKind_Mem); } - /** - * @brief Tests whether operand is immediate operand. - */ + /** + * @brief Tests whether operand is immediate operand.*/ bool is_imm(void) const { return is_placed_in(OpndKind_Imm); } - /** - * @brief Tests whether operand is register operand. - */ + /** + * @brief Tests whether operand is register operand.*/ bool is_reg(void) const { return is_placed_in(OpndKind_Reg); } - /** - * @brief Tests whether operand is general-purpose register operand. - */ + /** + * @brief Tests whether operand is general-purpose register operand.*/ bool is_gpreg(void) const { return is_placed_in(OpndKind_GPReg); } - /** - * @brief Tests whether operand is float-point pseudo-register operand. - */ + /** + * @brief Tests whether operand is float-point pseudo-register operand.*/ bool is_fpreg(void) const { return is_placed_in(OpndKind_FPReg); } - /** - * @brief Tests whether operand is XMM register operand. - */ + /** + * @brief Tests whether operand is XMM register operand.*/ bool is_xmmreg(void) const { return is_placed_in(OpndKind_XMMReg); } #ifdef _HAVE_MMX_ - /** - * @brief Tests whether operand is MMX register operand. - */ + /** + * @brief Tests whether operand is MMX register operand.*/ bool is_mmxreg(void) const { return is_placed_in(OpndKind_MMXReg); } #endif - /** - * @brief Returns base of memory operand (RegName_Null if not memory). - */ + /** + * @brief Returns base of memory operand (RegName_Null if not memory).*/ RegName base(void) const { return is_mem() ? m_base : RegName_Null; } - /** - * @brief Returns index of memory operand (RegName_Null if not memory). - */ + /** + * @brief Returns index of memory operand (RegName_Null if not memory).*/ RegName index(void) const { return is_mem() ? m_index : RegName_Null; } - /** - * @brief Returns scale of memory operand (0 if not memory). - */ + /** @brief Returns scale of memory operand (0 if not memory).*/ unsigned scale(void) const { return is_mem() ? m_scale : 0; } - /** - * @brief Returns displacement of memory operand (0 if not memory). - */ + /** + * @brief Returns displacement of memory operand (0 if not memory).*/ int disp(void) const { return is_mem() ? m_disp : 0; } - /** - * @brief Returns RegName of register operand (RegName_Null if not - * register). - */ + /** + * @brief Returns RegName of register operand (RegName_Null if not + * register).*/ RegName reg(void) const { return is_reg() ? m_reg : RegName_Null; } - /** - * @brief Returns value of immediate operand (0 if not immediate). - */ + /** + * @brief Returns value of immediate operand (0 if not immediate).*/ long long imm(void) const { return is_imm() ? m_imm64 : 0; } private: bool is_placed_in(OpndKind kd) const @@ -503,9 +423,8 @@ bool m_need_rex; friend class EncoderBase::Operands; }; - /** - * @brief Simple container for up to 3 Operand-s. - */ + /** + * @brief Simple container for up to 3 Operand-s.*/ class Operands { public: Operands(void) @@ -562,37 +481,32 @@ }; public: #ifdef _DEBUG - /** - * Verifies some presumptions about encoding data table. - * Called automagicaly during statics initialization. - */ + /** Verifies some presumptions about encoding data table. Called automagicaly + * during statics initialization.*/ static int verify(void); #endif private: - /** - * @brief Returns found OpcodeDesc by the given Mnemonic and operands. - */ + /** + * @brief Returns found OpcodeDesc by the given Mnemonic and operands.*/ static const OpcodeDesc * lookup(Mnemonic mn, const Operands& opnds); - /** - * @brief Encodes mod/rm byte. - */ + /** + * @brief Encodes mod/rm byte.*/ static char* encodeModRM(char* stream, const Operands& opnds, unsigned idx, const OpcodeDesc * odesc, Rex * prex); - /** - * @brief Encodes special things of opcode description - '/r', 'ib', etc. - */ + /** + * @brief Encodes special things of opcode description - /r, + * ib, etc.*/ static char* encode_aux(char* stream, unsigned aux, const Operands& opnds, const OpcodeDesc * odesc, unsigned * pargsCount, Rex* prex); #ifdef _EM64T_ - /** - * @brief Returns true if the 'reg' argument represents one of the new - * EM64T registers - R8(D)-R15(D). - * - * The 64 bits versions of 'old-fashion' registers, i.e. RAX are not - * considered as 'extra'. - */ + /** + * @brief Returns TRUE if the 'reg' argument represents + * one of the new EM64T registers - R8(D)-R15(D). + * + * The 64 bits versions of 'old-fashion' registers, i.e. RAX are not + * considered as extra.*/ static bool is_em64t_extra_reg(const RegName reg) { if (needs_rex_r(reg)) { @@ -625,14 +539,13 @@ } return false; } - /** - * @brief Returns an 'processor's index' of the register - the index - * used to encode the register in ModRM/SIB bytes. - * - * For the new EM64T registers the 'HW index' differs from the index - * encoded in RegName. For old-fashion registers it's effectively the - * same as ::getRegIndex(RegName). - */ + /** + * @brief Returns an processor's index of the register - the index + * used to encode the register in ModRM/SIB bytes. + * + * For the new EM64T registers the HW index differs from the index + * encoded in RegName. For old-fashion registers it's effectively the + * same as ::getRegIndex(RegName).*/ static unsigned char getHWRegIndex(const RegName reg) { if (getRegKind(reg) != OpndKind_GPReg) { @@ -658,49 +571,40 @@ } #endif public: - /** - * @brief A table used for the fast computation of hash value. - * - * A change must be strictly balanced with hash-related functions and data - * in enc_base.h/.cpp. - */ + /** + * @brief A table used for the fast computation of hash value. + * + * A change must be strictly balanced with hash-related functions and data + * in enc_base.h/.cpp.*/ static const unsigned char size_hash[OpndSize_64+1]; - /** - * @brief A table used for the fast computation of hash value. - * - * A change must be strictly balanced with hash-related functions and data - * in enc_base.h/.cpp. - */ + /** + * @brief A table used for the fast computation of hash value. + * + * A change must be strictly balanced with hash-related functions and data + * in enc_base.h/.cpp.*/ static const unsigned char kind_hash[OpndKind_Mem+1]; - /** - * @brief Maximum number of opcodes used for a single mnemonic. - * - * No arithmetics behind the number, simply estimated. - */ + /** + * @brief Maximum number of opcodes used for a single Mnemonic. + * + * No arithmetics behind the number, simply estimated.*/ static const unsigned int MAX_OPCODES = 32; //20; - /** - * @brief Mapping between operands hash code and operands. - */ + /** + * @brief Mapping between operands hash code and operands.*/ static unsigned char opcodesHashMap[Mnemonic_Count][HASH_MAX]; - /** - * @brief Array of mnemonics. - */ + /** + * @brief Array of Mnemonic-s.*/ static MnemonicDesc mnemonics[Mnemonic_Count]; - /** - * @brief Array of available opcodes. - */ + /** + * @brief Array of available opcodes.*/ static OpcodeDesc opcodes[Mnemonic_Count][MAX_OPCODES]; static int buildTable(void); static void buildMnemonicDesc(const MnemonicInfo * minfo); - /** - * @brief Computes hash value for the given operands. - */ + /** + * @brief Computes hash value for the given operands.*/ static unsigned short getHash(const OpcodeInfo* odesc); - /** - * @brief Dummy variable, for automatic invocation of buildTable() at - * startup. - */ + /** + * @brief Dummy variable, for automatic invocation of buildTable() at startup.*/ static int dummy; }; Index: trunk/vm/port/src/encoder/ia32_em64t/enc_defs.h =================================================================== --- trunk/vm/port/src/encoder/ia32_em64t/enc_defs.h (revision 504464) +++ trunk/vm/port/src/encoder/ia32_em64t/enc_defs.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,16 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Alexander V. Astapchuk - * @version $Revision: 1.1.2.2.4.4 $ - */ + #ifndef _ENCODER_DEFS_H_ #define _ENCODER_DEFS_H_ - -// Used to isolate experimental or being tuned encoder into a separate -// namespace so it can coexist with a stable one in the same bundle. + /** + * @file + * Used to isolate experimental or being tuned encoder into a separate namespace + * so it can coexist with a stable one in the same bundle.*/ #ifdef ENCODER_ISOLATE #define ENCODER_NAMESPACE_START namespace enc_ia32 { #define ENCODER_NAMESPACE_END }; @@ -35,24 +33,16 @@ #include #ifndef COUNTOF - /** - * Number of items in an array. - */ + /** Number of items in an array.*/ #define COUNTOF(a) (sizeof(a)/sizeof(a[0])) #endif #ifdef _EM64T_ - /** - * A stack pointer of default platform's size. - */ + /** A stack pointer of default platform's size.*/ #define REG_STACK RegName_RSP - /** - * A max GP register (with a highest index number) - */ + /** A max GP register (with a highest index number).*/ #define REG_MAX RegName_R15 - /** - * Total number of GP registers including stack pointer. - */ + /** Total number of GP registers including stack pointer.*/ #define MAX_REGS 15 #else #define REG_STACK RegName_ESP @@ -63,41 +53,28 @@ ENCODER_NAMESPACE_START -/** - * 'int_ptr' is a signed integer type which has the - * same size as a pointer on the target platform. - * Luckily, the long type serves as desired. - */ + /** int_ptr is a signed integer type which has the same size as a + * pointer on the target platform. Luckily, the long type serves as desired.*/ typedef long int_ptr; -/** - * A number of bytes 'eaten' by an ordinary PUSH/POP. - */ + /** A number of bytes 'eaten' by an ordinary PUSH/POP.*/ #define STACK_SLOT_SIZE (sizeof(void*)) - - -/** - * A recommended by Intel Arch Manual aligment for instructions that - * are targets for jmps. - */ + /** A recommended by Intel Arch Manual aligment for instructions that are + * targets for jmps.*/ #define JMP_TARGET_ALIGMENT (16) -/** - * A maximum possible size of native instruction. - */ + /** A maximum possible size of native instruction.*/ #define MAX_NATIVE_INST_SIZE (15) -/** - * The enum OpndKind describes an operand's location - memory, immediate or a register. - * It can be used as a bit mask. - */ + /** The enum #OpndKind describes an operand's location - memory, immediate or + * a register. It can be used as a bit mask.*/ enum OpndKind { - /** - * A change must be balanced with at least the following places: - * Ia32::Constraint-s use the OpndKind as a mask - * encoder.cpp & encoder_master_info.cpp uses OpndKind as an index for hashing - * - perhaps there are much more places - * - * NOTE: an MMXReg kind is incompatible with the current constraints framework, - * as it's not encoded as a mask. - */ + /** + * A change must be balanced with at least the following places: + *
    • Ia32::Constraint-s use the #OpndKind as a mask
    • + *
    • encoder.cpp & encoder_master_info.cpp + * uses #OpndKind as an index for hashing
    + * Perhaps there are much more places + * + * @note An MMXReg kind is incompatible with the current + * constraints framework, as it's not encoded as a mask.*/ OpndKind_Null=0, OpndKind_GPReg = 0x01, OpndKind_MinRegKind = OpndKind_GPReg, OpndKind_SReg = 0x02, @@ -125,15 +102,14 @@ OpndKind_XMMReg_Mem = OpndKind_XMMReg|OpndKind_Mem, }; - enum OpndSize { - /** - * A change must be balanced with at least the following places: - * Ia32IRConstants.h :: getByteSize() uses some presumptions about OpndSize_ values - * Ia32::Constraint-s use the OpndSize as a mask - * encoder.cpp & encoder_master_info.cpp uses OpndSize as an index for hashing - * - perhaps there are much more places - */ + /** A change must be balanced with at least the following places: + *
    • Ia32IRConstants.h :: getByteSize() uses some presumptions + * about OpndSize_ values
    • + *
    • Ia32::Constraint-s use the #OpndSize as a mask
    • + *
    • encoder.cpp & encoder_master_info.cpp uses + * #OpndSize as an index for hashing
    + * Perhaps there are much more places.*/ OpndSize_Null = 0, OpndSize_8 = 0x01, OpndSize_16 = 0x02, @@ -148,11 +124,9 @@ OpndSize_Default = OpndSize_Any }; -/** - * enum OpndRole defines the role of an operand in an instruction - * Can be used as mask to combine def and use. The complete def+use - * info can be combined in 2 bits which is used, say in Encoder::OpndRole. - */ + /** enum OpndRole defines the role of an operand in an instruction + * Can be used as mask to combine def and use. The complete def+use + * info can be combined in 2 bits which is used, say in Encoder::OpndRole.*/ //TODO: this duplicates an Role used in the Ia32::Inst. That duplicate enum should be removed. enum OpndRole { OpndRole_Null=0, @@ -162,7 +136,6 @@ OpndRole_All=0xffff, }; - #define REGNAME(k,s,i) ( ((k & OpndKind_Any)<<24) | ((s & OpndSize_Any)<<16) | (i&0xFF) ) enum RegName { @@ -170,13 +143,11 @@ RegName_Null = 0, #ifdef _EM64T_ - /* - An index part of the RegName-s for RAX-RDI, EAX-ESI, AX-SI and AL-BH is - the same as the index used during instructions encoding. The same rule - applies for XMM regsters for IA32. - For new EM64T registers (both GP and XMM) the index need to be corrected to - obtain the index used in processor's instructions. - */ + /** An index part of the RegName-s for RAX-RDI, EAX-ESI, AX-SI and AL-BH is the + * same as the index used during instructions encoding. The same rule applies + * for XMM regsters for IA32.
    + * For new EM64T registers (both GP and XMM) the index need to be corrected to + * obtain the index used in processor's instructions.*/ RegName_RAX = REGNAME(OpndKind_GPReg,OpndSize_64,0), RegName_RCX = REGNAME(OpndKind_GPReg,OpndSize_64,1), RegName_RDX = REGNAME(OpndKind_GPReg,OpndSize_64,2), @@ -368,11 +339,9 @@ #endif // _HAVE_MMX_ }; -/** - * Conditional mnemonics. - * The values match the 'real' (==processor's) values of the appropriate - * condition values used in the opcodes. - */ + /** Conditional mnemonics. + * The values match the 'real' (==processor's) values of the appropriate + * condition values used in the opcodes.*/ enum ConditionMnemonic { ConditionMnemonic_O=0, @@ -617,8 +586,7 @@ #undef CCM /** - * @brief Instruction prefixes, according to arch manual. - */ + * @brief Instruction prefixes, according to arch manual.*/ enum InstPrefix { InstPrefix_Null = 0, // Group 1 @@ -657,97 +625,81 @@ return OpndKind_GPReg<= kind && kind<=OpndKind_MaxRegKind; } -/** - * @brief Returns #RegName for a given name. - * - * Name is case-insensitive. - * @param regname - string name of a register - * @return #RegName for the given name, or #RegName_Null if name is invalid - */ + /** + * @brief Returns #RegName for a given name. + * + * Name is case-insensitive. + * + * @param regname - string name of a register + * + * @return #RegName for the given name, or #RegName_Null if name is invalid.*/ RegName getRegName(const char * regname); -/** - * Constructs RegName from the given OpndKind, size and index. - */ + /** Constructs #RegName from the given #OpndKind, size and index.*/ inline RegName getRegName(OpndKind k, OpndSize s, int idx) { return (RegName)REGNAME(k,s,idx); } -/** - * Extracts a bit mask with a bit set at the position of the register's index. - */ + /** Extracts a bit mask with a bit set at the position of the register's index.*/ inline unsigned getRegMask(RegName reg) { return 1<<(reg&0xff); } -/** - * @brief Extracts #RegKind from the #RegName. - */ + /** + * @brief Extracts RegKind from the #RegName.*/ inline OpndKind getRegKind(RegName reg) { return (OpndKind)(reg>>24); } -/** - * @brief Extracts #OpndSize from #RegName. - */ + /** + * @brief Extracts #OpndSize from #RegName.*/ inline OpndSize getRegSize(RegName reg) { return (OpndSize)((reg>>16)&0xFF); } -/** - * Extracts an index from the given RegName. - */ + /** Extracts an index from the given #RegName.*/ inline unsigned char getRegIndex(RegName reg) { return (unsigned char)(reg&0xFF); } -/** - * Returns a string name of the given RegName. The name returned is in upper-case. - * Returns NULL if invalid RegName specified. - */ + /** @return A string name of the given #RegName. The name returned is in upper-case. + * @return NULL if invalid #RegName specified.*/ const char * getRegNameString(RegName reg); -/** - * Returns string name of a given OpndSize. - * Returns NULL if invalid OpndSize passed. - */ + + /** @return String name of a given #OpndSize. + * @return NULL if invalid #OpndSize passed.*/ const char * getOpndSizeString(OpndSize size); -/** - * Returns OpndSize passed by its string representation (case insensitive). - * Returns OpndSize_Null if invalid string specified. - * The 'sizeString' can not be NULL. - */ + + /** @return #OpndSize passed by its string representation (case insensitive). + * @return #OpndSize_Null if invalid string specified. + * sizeString can not be NULL.*/ OpndSize getOpndSize(const char * sizeString); -/** - * Returns string name of a given OpndKind. - * Returns NULL if the passed kind is invalid. - */ + + /** @return String name of a given #OpndKind. + * @return NULL if the passed kind is invalid.*/ const char * getOpndKindString(OpndKind kind); -/** - * Returns OpndKind found by its string representation (case insensitive). - * Returns OpndKind_Null if the name is invalid. - * The 'kindString' can not be NULL. - */ + + /** @return #OpndKind found by its string representation (case insensitive). + * @return #OpndKind_Null if the name is invalid. + * kindString can not be NULL.*/ OpndKind getOpndKind(const char * kindString); -/** - * - */ + /** + * + */ const char * getConditionString(ConditionMnemonic cm); -/** - * Constructs an RegName with the same index and kind, but with a different size from - * the given RegName (i.e. getRegAlias(EAX, OpndSize_16) => AX; getRegAlias(BL, OpndSize_32) => EBX). - * The constructed RegName is not checked in any way and thus may be invalid. - * Note, that the aliasing does not work for at least AH,BH,CH,DH, ESI, EDI, ESP and EBP regs. - */ + /** Constructs an #RegName with the same index and kind, but with a different size from + * the given #RegName (i.e. getRegAlias(EAX, OpndSize_16) => AX; getRegAlias(BL, + * OpndSize_32) => EBX).
    + * The constructed #RegName is not checked in any way and thus may be invalid. + * + * @note The aliasing does not work for at least AH,BH,CH,DH, ESI, EDI, ESP and EBP regs.*/ inline RegName getAliasReg(RegName reg, OpndSize sz) { return (RegName)REGNAME(getRegKind(reg), sz, getRegIndex(reg)); } - -/** - * brief Tests two RegName-s of the same kind for equality. - * - * @note Does work for 8 bit general purpose registers (AH, AL, BH, BL, etc). - */ + /** @brief Tests two RegName-s of the same kind for equality. + * + * @note Does work for 8 bit general purpose registers (AH, AL, BH, BL, etc).*/ inline bool equals(RegName r0, RegName r1) { return getRegKind(r0) == getRegKind(r1) && Index: trunk/vm/port/src/encoder/ia32_em64t/enc_prvt.h =================================================================== --- trunk/vm/port/src/encoder/ia32_em64t/enc_prvt.h (revision 504464) +++ trunk/vm/port/src/encoder/ia32_em64t/enc_prvt.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,22 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Alexander V. Astapchuk - * @version $Revision: 1.1.2.2.4.4 $ - */ + #ifndef __ENC_PRVT_H_INCLUDED__ #define __ENC_PRVT_H_INCLUDED__ #include "enc_base.h" ENCODER_NAMESPACE_START -/* +/** * @file + * * @brief Contains some definitions/constants and other stuff used by the - * Encoder internally. - */ - + * Encoder internally.*/ + enum OpcodeByteKind { //OpcodeByteKind_Opcode = 0x0000, OpcodeByteKind_ZeroOpcodeByte = 0x0100, @@ -62,31 +59,22 @@ OpcodeByteKind_REX_W = 0x1300, #endif OpcodeByteKind_plus_i = 0x1400, - /** - * a special marker, means 'no opcode on the given position' - * used in opcodes array, to specify the empty slot, say - * to fill an em64t-specific opcode on ia32. - * last 'e' made lowercase to avoid a mess with 'F' in - * OpcodeByteKind_LAST . - */ + /** A special marker, means 'no opcode on the given position' used in opcodes + * array, to specify the empty slot, say to fill an em64t-specific opcode on ia32. + * Last 'e' made lowercase to avoid a mess with 'F' in OpcodeByteKind_LAST.*/ OpcodeByteKind_EMPTY = 0xFFFE, - /** - * a special marker, means 'no more opcodes in the array' - * used in in opcodes array to show that there are no more - * opcodes in the array for a given mnemonic. - */ + + /** A special marker, means 'no more opcodes in the array' used in in opcodes + * array to show that there are no more opcodes in the array for a given mnemonic.*/ OpcodeByteKind_LAST = 0xFFFF, - /** - * a mask to extract the OpcodeByteKind - */ + + /** A mask to extract the OpcodeByteKind.*/ OpcodeByteKind_KindMask = 0xFF00, - /** - * a mask to extract the opcode byte when presented - */ + + /** A mask to extract the opcode byte when presented.*/ OpcodeByteKind_OpcodeMask = 0x00FF }; - #define N {0, 0, 0, 0 } #define U {1, 0, 1, OpndRole_Use } #define D {1, 1, 0, OpndRole_Def } @@ -171,8 +159,11 @@ #define r_m16 {(OpndKind)(OpndKind_GPReg|OpndKind_Mem), OpndSize_16, RegName_Null} #define r_m32 {(OpndKind)(OpndKind_GPReg|OpndKind_Mem), OpndSize_32, RegName_Null} -//'m' was only used in LEA mnemonic, but is replaced with -// set of exact sizes. See more comments for LEA instruction in TheTable. + /** m was only used in LEA mnemonic, but is replaced with + * set of exact sizes. + * + * @sa TheTable.*/ + //#define m {OpndKind_Mem, OpndSize_Null, RegName_Null} #define m8 {OpndKind_Mem, OpndSize_8, RegName_Null} #define m16 {OpndKind_Mem, OpndSize_16, RegName_Null} @@ -213,9 +204,8 @@ #endif -/** - * @brief Represents the REX part of instruction. - */ + /** + * @brief Represents the REX part of instruction.*/ struct Rex { unsigned char b : 1; unsigned char x : 1; @@ -225,9 +215,8 @@ unsigned int :24; }; -/** - * @brief Describes SIB (scale,index,base) byte. - */ + /** + * @brief Describes SIB (scale,index,base) byte.*/ struct SIB { unsigned char base:3; unsigned char index:3; @@ -235,8 +224,7 @@ unsigned int padding:24; }; /** - * @brief Describes ModRM byte. - */ + * @brief Describes ModRM byte.*/ struct ModRM { unsigned char rm:3; @@ -245,12 +233,8 @@ unsigned int padding:24; }; - - -/** -* exactly the same as EncoderBase::OpcodeDesc, but also holds info about -* platform on which the opcode is applicable. -*/ + /** Exactly the same as EncoderBase::OpcodeDesc, but also holds info about + * platform on which the opcode is applicable.*/ struct OpcodeInfo { enum platform { all, em64t, ia32 }; platform platf; @@ -259,72 +243,57 @@ EncoderBase::OpndRolesDesc roles; }; -/** - * @defgroup MF_ Mnemonic flags -*/ + /** + * @defgroup MF_ Mnemonic flags*/ - /** - * Operation has no special properties. - */ + /** Operation has no special properties.*/ #define MF_NONE (0x00000000) - /** - * Operation affects flags - */ + + /** Operation affects flags.*/ #define MF_AFFECTS_FLAGS (0x00000001) - /** - * Operation uses flags - conditional operations, ADC/SBB/ETC - */ + + /** Operation uses flags - conditional operations, ADC/SBB/ETC.*/ #define MF_USES_FLAGS (0x00000002) - /** - * Operation is conditional - MOVcc/SETcc/Jcc/ETC - */ + + /** Operation is conditional - MOVcc/SETcc/Jcc/ETC.*/ #define MF_CONDITIONAL (0x00000004) -/** - * Operation is symmetric - its args can be swapped (ADD/MUL/etc). - */ + + /** Operation is symmetric - its args can be swapped (ADD/MUL/etc).*/ #define MF_SYMMETRIC (0x00000008) -/** - * Operation is XOR-like - XOR, SUB - operations of 'arg,arg' is pure def, - * without use. - */ + + /** Operation is XOR-like - XOR, SUB - operations of 'arg,arg' is pure def, + * without use.*/ #define MF_SAME_ARG_NO_USE (0x00000010) ///@} // ~MNF -/** - * @see same structure as EncoderBase::MnemonicDesc, but carries - * MnemonicInfo::OpcodeInfo[] instead of OpcodeDesc[]. - * Only used during prebuilding the encoding tables, thus it's hidden under - * the appropriate define. - */ + /** + * @see Same structure as EncoderBase::MnemonicDesc, but carries + * MnemonicInfo::OpcodeInfo[] instead of OpcodeDesc[]. + * Only used during prebuilding the encoding tables, thus it's hidden under + * the appropriate define.*/ struct MnemonicInfo { - /** - * The mnemonic itself - */ + + /** The mnemonic itself.*/ Mnemonic mn; - /** - * Various characteristics of mnemonic. - * @see MF_ - */ + + /** Various characteristics of mnemonic. + * @see MF_*/ unsigned flags; - /** - * Number of args/des/uses/roles for the operation. For the operations - * which may use different number of operands (i.e. IMUL/SHL) use the - * most common value, or leave '0' if you are sure this info is not - * required. - */ + + /** Number of args/des/uses/roles for the operation. For the operations + * which may use different number of operands (i.e. IMUL/SHL) use the + * most common value, or leave '0' if you are sure this info is not required.*/ EncoderBase::OpndRolesDesc roles; - /** - * Print name of the mnemonic - */ + + /** Print name of the mnemonic.*/ const char * name; - /** - * Array of opcodes. - * The terminating opcode description always have OpcodeByteKind_LAST - * at the opcodes[i].opcode[0]. - * The size of '20' has nothing behind it, just counted the max - * number of opcodes currently used. - */ + + /** Array of opcodes.
    + * The terminating opcode description always have OpcodeByteKind_LAST + * at the opcodes[i].opcode[0]. + * The size of '20' has nothing behind it, just counted the max + * number of opcodes currently used.*/ OpcodeInfo opcodes[20]; }; Index: trunk/vm/port/src/encoder/ia32_em64t/encoder.h =================================================================== --- trunk/vm/port/src/encoder/ia32_em64t/encoder.h (revision 504464) +++ trunk/vm/port/src/encoder/ia32_em64t/encoder.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,25 +14,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + /** - * @author Alexander V. Astapchuk - * @version $Revision: 1.1.2.2.4.5 $ - */ -/** * @file + * * @brief Simple interface for generating processor instructions. * * The interface works for both IA32 and EM64T. By default, only IA32 - * capabilities are presented. To enable EM64T feature, the _EM64T_ macro - * must be defined (and, of course, a proper library version to be used). - * - * The interface is based on the original ia32.h encoder interface, - * with some simplifications and add-ons - EM64T-specific, SSE and SSE2. - * + * capabilities are presented. To enable EM64T feature, the _EM64T_ + * macro must be defined (and, of course, a proper library version to be used).
    + * The interface is based on the original ia32.h encoder interface, + * with some simplifications and add-ons - EM64T-specific, SSE and SSE2.
    * The interface mostly intended for existing legacy code like LIL code * generator. From the implementation point of view, it's just a wrapper - * around the EncoderBase functionality. - */ + * around the EncoderBase functionality.*/ #ifndef _VM_ENCODER_H_ #define _VM_ENCODER_H_ @@ -42,9 +37,10 @@ #include "open/types.h" #ifdef _EM64T_ -// size of general-purpose value on the stack in bytes + /** Size of general-purpose value on the stack in bytes.*/ #define GR_STACK_SIZE 8 -// size of floating-point value on the stack in bytes + + /** Size of floating-point value on the stack in bytes.*/ #define FR_STACK_SIZE 8 #else #define GR_STACK_SIZE 4 @@ -70,7 +66,9 @@ xmm4_reg, xmm5_reg, xmm6_reg, xmm7_reg, fs_reg, #endif - /** @brief Total number of registers.*/ + /** + * @brief Total number of registers. + */ n_reg }; // @@ -89,18 +87,16 @@ #endif }; -// -// opcodes for alu instructions -// + /** Opcodes for alu instructions.*/ + enum ALU_Opcode { add_opc = 0,or_opc, adc_opc, sbb_opc, and_opc, sub_opc, xor_opc, cmp_opc, n_alu }; -// -// opcodes for shift instructions -// + /** Opcodes for shift instructions.*/ + enum Shift_Opcode { shld_opc, shrd_opc, shl_opc, shr_opc, sar_opc, ror_opc, max_shift_opcode=6, n_shift = 6 @@ -141,9 +137,8 @@ Condition_Count = 16 }; -// -// prefix code -// + /** Prefix code.*/ + enum InstrPrefix { no_prefix, lock_prefix = 0xF0, @@ -162,10 +157,8 @@ prefix_gs = 0x65 }; + /** An instruction operand.*/ -// -// an instruction operand -// class Opnd { protected: @@ -293,10 +286,9 @@ R_Opnd(const R_Opnd &): RM_Opnd(Reg) { assert(false); } }; -// -// a memory operand with displacement -// Can also serve as a full memory operand with base,index, displacement and scale. -// Use n_reg to specify 'no register', say, for index. + /** A memory operand with displacement. Can also serve as a full memory operand + * with base, index, displacement and scale. Use n_reg to specify + * 'no register', say, for index.*/ class M_Opnd: public RM_Opnd { protected: @@ -324,9 +316,7 @@ inline const Imm_Opnd & disp(void) const { return m_disp; } }; -// -// a memory operand with base register and displacement -// + /** A memory operand with base register and displacement.*/ class M_Base_Opnd: public M_Opnd { public: @@ -337,10 +327,8 @@ // M_Base_Opnd(const M_Base_Opnd &): M_Opnd(0) { assert(false); } }; -// -// a memory operand with base register, scaled index register -// and displacement. -// + /** A memory operand with base register, scaled index register and displacement.*/ + class M_Index_Opnd : public M_Opnd { public: @@ -366,9 +354,7 @@ XMM_Opnd(const XMM_Opnd &): Opnd(XMM) { assert(false); } }; -// -// operand structures for ia32 registers -// + /** Operand structures for ia32 registers.*/ #ifdef _EM64T_ extern R_Opnd rax_opnd; @@ -426,19 +412,20 @@ #include "encoder.inl" #endif -// prefix + /** Prefix.*/ ENCODER_DECLARE_EXPORT char * prefix(char * stream, InstrPrefix p); -// stack push and pop instructions + /** Stack push and pop instructions.*/ ENCODER_DECLARE_EXPORT char * push(char * stream, const RM_Opnd & rm, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * push(char * stream, const Imm_Opnd & imm); ENCODER_DECLARE_EXPORT char * pop(char * stream, const RM_Opnd & rm, Opnd_Size sz = size_platf); -// cmpxchg or xchg + /** cmpxchg or xchg*/ ENCODER_DECLARE_EXPORT char * cmpxchg(char * stream, const RM_Opnd & rm, const R_Opnd & r, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * xchg(char * stream, const RM_Opnd & rm, const R_Opnd & r, Opnd_Size sz = size_platf); -// inc(rement), dec(rement), not, neg(ate) instructions + /** inc(rement), dec(rement), not, + * neg(ate) instructions.*/ ENCODER_DECLARE_EXPORT char * inc(char * stream, const RM_Opnd & rm, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * dec(char * stream, const RM_Opnd & rm, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * _not(char * stream, const RM_Opnd & rm, Opnd_Size sz = size_platf); @@ -446,31 +433,31 @@ ENCODER_DECLARE_EXPORT char * nop(char * stream); ENCODER_DECLARE_EXPORT char * int3(char * stream); -// alu instructions: add, or, adc, sbb, and, sub, xor, cmp + /** alu instructions: add, or, adc, sbb, and, sub, xor, cmp.*/ ENCODER_DECLARE_EXPORT char * alu(char * stream, ALU_Opcode opc, const RM_Opnd & rm, const Imm_Opnd & imm, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * alu(char * stream, ALU_Opcode opc, const M_Opnd & m, const R_Opnd & r, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * alu(char * stream, ALU_Opcode opc, const R_Opnd & r, const RM_Opnd & rm, Opnd_Size sz = size_platf); -// test instruction + /** Test instruction.*/ ENCODER_DECLARE_EXPORT char * test(char * stream, const RM_Opnd & rm, const Imm_Opnd & imm, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * test(char * stream, const RM_Opnd & rm, const R_Opnd & r, Opnd_Size sz = size_platf); -// shift instructions: shl, shr, sar, shld, shrd, ror + /** Shift instructions: shl, shr, sar, shld, shrd, ror.*/ ENCODER_DECLARE_EXPORT char * shift(char * stream, Shift_Opcode opc, const RM_Opnd & rm, const Imm_Opnd & imm, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * shift(char * stream, Shift_Opcode opc, const RM_Opnd & rm, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * shift(char * stream, Shift_Opcode opc, const RM_Opnd & rm, const R_Opnd & r, const Imm_Opnd & imm, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * shift(char * stream, Shift_Opcode opc, const RM_Opnd & rm, const R_Opnd & r, Opnd_Size sz = size_platf); -// multiply instructions: mul, imul + /** Multiply instructions: mul, imul.*/ ENCODER_DECLARE_EXPORT char * mul(char * stream, const RM_Opnd & rm, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * imul(char * stream, const R_Opnd & r, const RM_Opnd & rm, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * imul(char * stream, const R_Opnd & r, const Imm_Opnd & imm, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * imul(char * stream, const R_Opnd & r, const RM_Opnd & rm, const Imm_Opnd& imm, Opnd_Size sz = size_platf); -// divide instructions: div, idiv + /** Divide instructions: div, idiv.*/ ENCODER_DECLARE_EXPORT char * idiv(char * stream, const RM_Opnd & rm, Opnd_Size sz = size_platf); -// data movement: mov + /** Data movement: mov.*/ ENCODER_DECLARE_EXPORT char * mov(char * stream, const M_Opnd & m, const R_Opnd & r, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * mov(char * stream, const R_Opnd & r, const RM_Opnd & rm, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * mov(char * stream, const RM_Opnd & rm, const Imm_Opnd & imm, Opnd_Size sz = size_platf); @@ -483,12 +470,12 @@ ENCODER_DECLARE_EXPORT char * movq(char * stream, const RM_Opnd & rm, const XMM_Opnd & xmm); ENCODER_DECLARE_EXPORT char * movq(char * stream, const XMM_Opnd & xmm, const RM_Opnd & rm); -// sse mov + /** sse mov*/ ENCODER_DECLARE_EXPORT char * sse_mov(char * stream, const XMM_Opnd & xmm, const M_Opnd & mem, bool dbl); ENCODER_DECLARE_EXPORT char * sse_mov(char * stream, const M_Opnd & mem, const XMM_Opnd & xmm, bool dbl); ENCODER_DECLARE_EXPORT char * sse_mov(char * stream, const XMM_Opnd & xmm0, const XMM_Opnd & xmm1, bool dbl); -// sse add, sub, mul, div + /** sse add, sub, mul, div*/ ENCODER_DECLARE_EXPORT char * sse_add(char * stream, const XMM_Opnd & xmm, const M_Opnd & mem, bool dbl); ENCODER_DECLARE_EXPORT char * sse_add(char * stream, const XMM_Opnd & xmm0, const XMM_Opnd & xmm1, bool dbl); @@ -501,13 +488,13 @@ ENCODER_DECLARE_EXPORT char * sse_div(char * stream, const XMM_Opnd & xmm, const M_Opnd & mem, bool dbl); ENCODER_DECLARE_EXPORT char * sse_div(char * stream, const XMM_Opnd & xmm0, const XMM_Opnd & xmm1, bool dbl); -// xor, compare + /** xor, compare*/ ENCODER_DECLARE_EXPORT char * sse_xor(char * stream, const XMM_Opnd & xmm0, const XMM_Opnd & xmm1); ENCODER_DECLARE_EXPORT char * sse_compare(char * stream, const XMM_Opnd & xmm0, const XMM_Opnd & xmm1, bool dbl); ENCODER_DECLARE_EXPORT char * sse_compare(char * stream, const XMM_Opnd & xmm0, const M_Opnd & mem, bool dbl); -// sse conversions + /** sse conversions*/ ENCODER_DECLARE_EXPORT char * sse_cvt_si(char * stream, const XMM_Opnd & xmm, const M_Opnd & mem, bool dbl); ENCODER_DECLARE_EXPORT char * sse_cvtt2si(char * stream, const R_Opnd & reg, const M_Opnd & mem, bool dbl); ENCODER_DECLARE_EXPORT char * sse_cvtt2si(char * stream, const R_Opnd & reg, const XMM_Opnd & xmm, bool dbl); @@ -518,65 +505,65 @@ ENCODER_DECLARE_EXPORT char * sse_s2d(char * stream, const XMM_Opnd & xmm0, const M_Opnd & mem32); ENCODER_DECLARE_EXPORT char * sse_s2d(char * stream, const XMM_Opnd & xmm0, const XMM_Opnd & xmm1); -// condition operations + /** Condition operations.*/ ENCODER_DECLARE_EXPORT char * cmov(char * stream, ConditionCode cc, const R_Opnd & r, const RM_Opnd & rm, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * setcc(char * stream, ConditionCode cc, const RM_Opnd & rm8); -// load effective address: lea + /** Load effective address: lea.*/ ENCODER_DECLARE_EXPORT char * lea(char * stream, const R_Opnd & r, const M_Opnd & m, Opnd_Size sz = size_platf); ENCODER_DECLARE_EXPORT char * cdq(char * stream); ENCODER_DECLARE_EXPORT char * wait(char * stream); -// control-flow instructions + /** Control-flow instructions.*/ ENCODER_DECLARE_EXPORT char * loop(char * stream, const Imm_Opnd & imm); -// jump with 8-bit relative + /** Jump with 8-bit relative.*/ ENCODER_DECLARE_EXPORT char * jump8(char * stream, const Imm_Opnd & imm); -// jump with 32-bit relative + /** Jump with 32-bit relative.*/ ENCODER_DECLARE_EXPORT char * jump32(char * stream, const Imm_Opnd & imm); -// register indirect jump + /** Register indirect jump.*/ ENCODER_DECLARE_EXPORT char * jump(char * stream, const RM_Opnd & rm, Opnd_Size sz = size_platf); -// jump to target address + /** Jump to target address.*/ ENCODER_DECLARE_EXPORT char *jump(char * stream, char *target); -// jump with displacement + /** Jump with displacement.*/ //char * jump(char * stream, int32 disp); -// conditional branch with 8-bit branch offset + /** Conditional branch with 8-bit branch offset.*/ ENCODER_DECLARE_EXPORT char * branch8(char * stream, ConditionCode cc, const Imm_Opnd & imm, InstrPrefix prefix = no_prefix); -// conditional branch with 32-bit branch offset + /** Conditional branch with 32-bit branch offset.*/ ENCODER_DECLARE_EXPORT char * branch32(char * stream, ConditionCode cc, const Imm_Opnd & imm, InstrPrefix prefix = no_prefix); -// conditional branch with target label address + /** Conditional branch with target label address.*/ //char * branch(char * stream, ConditionCode cc, const char * target, InstrPrefix prefix = no_prefix); -// conditional branch with displacement immediate + /** Conditional branch with displacement immediate.*/ ENCODER_DECLARE_EXPORT char * branch(char * stream, ConditionCode cc, int32 disp, InstrPrefix prefix = no_prefix); -// call with displacement + /** Call with displacement.*/ ENCODER_DECLARE_EXPORT char * call(char * stream, const Imm_Opnd & imm); -// indirect call through register or memory location + /** Indirect call through register or memory location.*/ ENCODER_DECLARE_EXPORT char * call(char * stream, const RM_Opnd & rm, Opnd_Size sz = size_platf); -// call target address + /** Call target address.*/ ENCODER_DECLARE_EXPORT char * call(char * stream, const char * target); -// return instruction + /** Return instruction.*/ ENCODER_DECLARE_EXPORT char * ret(char * stream); ENCODER_DECLARE_EXPORT char * ret(char * stream, unsigned short pop); ENCODER_DECLARE_EXPORT char * ret(char * stream, const Imm_Opnd & imm); -// string operations + /** String operations.*/ ENCODER_DECLARE_EXPORT char * set_d(char * stream, bool set); ENCODER_DECLARE_EXPORT char * scas(char * stream, unsigned char prefix); ENCODER_DECLARE_EXPORT char * stos(char * stream, unsigned char prefix); -// floating-point instructions + /** Floating-point instructions.*/ // st(0) = st(0) fp_op m{32,64}real //!char * fp_op_mem(char * stream, FP_Opcode opc,const M_Opnd& mem,int is_double); Index: trunk/vm/port/src/lil/em64t/pim/m2n_em64t_internal.h =================================================================== --- trunk/vm/port/src/lil/em64t/pim/m2n_em64t_internal.h (revision 504464) +++ trunk/vm/port/src/lil/em64t/pim/m2n_em64t_internal.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -15,19 +15,15 @@ * limitations under the License. */ -/** - * @author Evgueni Brevnov - * @version $Revision$ - */ - #ifndef _M2N_EM64T_INTERNAL_H_ #define _M2N_EM64T_INTERNAL_H_ -// This file describes the internal EM64T interface of m2n frames. -// It can be used by stubs to generate code to push and pop m2n frames, to update object handles fields, and -// to access the arguments from managed to native code. -// It is also used by stack iterators. - +/** + * @file + * This file describes the internal EM64T interface of m2n frames. + * It can be used by stubs to generate code to push and pop m2n frames, + * to update object handles fields, and to access the arguments from managed to + * native code. It is also used by stack iterators.*/ #include "m2n.h" #include "open/types.h" #include "encoder.h" @@ -36,19 +32,18 @@ typedef struct M2nFrame M2nFrame; -/** - * There are two types of M2nFrames: those that result from managed code calling a stub, - * and those that represent suspended managed code. The second type is needed to deal with - * throwing exceptions from OS contexts with the exception filter or signal mechanisms. - * For the first type: - * rip points to the instruction past the one in question - * the bottom two bits of p_lm2nf are zero - * regs is not present, and is implicitly the address of the word above rip - * For the second type: - * rip points to the instruction in question - * p_lm2nf==1 - * regs is present - */ + /** There are two types of M2nFrames: those that result from managed code calling + * a stub, and those that represent suspended managed code. The second type is + * needed to deal with throwing exceptions from OS contexts with the exception + * filter or signal mechanisms.
    + * For the first type: + *
    • rip points to the instruction past the one in question + *
    • the bottom two bits of p_lm2nf are zero + *
    • regs is not present, and is implicitly the address of the word above rip
    + * For the second type: + *
    • rip points to the instruction in question + *
    • p_lm2nf==1 + *
    • regs is present
    */ struct M2nFrame { M2nFrame * prev_m2nf; M2nFrame ** p_lm2nf; @@ -66,57 +61,52 @@ Registers * regs; }; -/** - * returns size of m2n frame in bytes - */ + /** Returns size of m2n frame in bytes.*/ inline size_t m2n_get_size() { // omit regs return sizeof(M2nFrame) - 16; } -/** - * Generate code to put the thread local storage pointer into a given register. - * It destroys outputs. - */ + /** Generate code to put the thread local storage pointer into a given register. + * It destroys outputs.*/ char * m2n_gen_ts_to_register(char * buf, const R_Opnd * reg, unsigned num_callee_saves_used, unsigned num_callee_saves_max, unsigned num_std_need_to_save, unsigned num_ret_need_to_save); -/** - * Generate code to set the local handles of an M2nFrame. - * The M2nFrame is located bytes_to_m2n above rsp, and src_reg has the address of the frames. - */ + /** Generate code to set the local handles of an M2nFrame. + * The M2nFrame is located bytes_to_m2n above rsp, + * and src_reg has the address of the frames.*/ char * m2n_gen_set_local_handles_r(char * buf, unsigned bytes_to_m2n, const R_Opnd * src_reg); char * m2n_gen_set_local_handles_imm(char * buf, unsigned bytes_to_m2n, const Imm_Opnd * imm); -/** - * Generate code to push an M2nFrame onto the stack. - * It assumes that num_callee_saves registers have already been saved and the rest have been preserved, - * that the saved registers are immediately below the return address, and that rsp points to the last one saved. - * The order for callee saves is r12, r13, r14, r15, rbp, rbx. - * It destroys returns (rax) and outputs. - * After the sequence, rsp points to the M2nFrame. - * - * @param handles Indicates whether the stub will want local handles or not - * @param bytes_to_m2n_top Number of bytes to the beginning of m2n frame relative to the current rsp value. - Negative value means that current rsp is above m2n bottom. - */ + /** Generate code to push an M2nFrame onto the stack. It assumes that + * num_callee_saves registers have already been saved and the + * rest have been preserved, that the saved registers are immediately below + * the return address, and that rsp points to the last one saved. + * The order for callee saves is r12, r13, r14, r15, rbp, rbx. + * It destroys returns (rax) and outputs. + * After the sequence, rsp points to the M2nFrame. + * + * @param handles - indicates whether the stub will want local handles or not + * @param bytes_to_m2n_top - Number of bytes to the beginning of m2n + * frame relative to the current rsp value. + * Negative value means that current rsp is above + * m2n bottom.*/ char * m2n_gen_push_m2n(char * buf, Method_Handle method, frame_type current_frame_type, bool handles, unsigned num_callee_saves, unsigned num_std_need_to_save, int32 bytes_to_m2n_top); -/** - * Generate code to pop an M2nFrame off the stack. - * @param num_callee_saves Number of callee saves registers to leave - * on the stack as at the entry to push_m2n. - * @param bytes_to_m2n_bottom Number of bytes between rsp and the bottom of the M2nFrame. - * @param preserve_ret Number of return registers to preserve, 0 means none, - * 1 means rax, 2 means rax & rdx. - * @param handles As for push_m2n, frees the handles if true. - */ + /** Generate code to pop an M2nFrame off the stack. + * + * @param num_callee_saves - number of callee saves registers to leave + * on the stack as at the entry to push_m2n + * @param bytes_to_m2n_bottom - number of bytes between rsp and the bottom of the M2nFrame + * @param preserve_ret - number of return registers to preserve, 0 means none, + * 1 means rax, 2 means rax & rdx. + * @param handles - as for push_m2n, frees the handles if TRUE*/ char * m2n_gen_pop_m2n(char * buf, bool handles, unsigned num_callee_saves, int32 bytes_to_m2n_bottom, unsigned preserve_ret); -// returns top of the specified frame on the stack (it should point to return ip) + /** @return Top of the specified frame on the stack (it should point to return ip).*/ void * m2n_get_frame_base(M2nFrame *); #endif // _M2N_EM64T_INTERNAL_H_ Index: trunk/vm/port/src/lil/ia32/pim/m2n_ia32_internal.h =================================================================== --- trunk/vm/port/src/lil/ia32/pim/m2n_ia32_internal.h (revision 504464) +++ trunk/vm/port/src/lil/ia32/pim/m2n_ia32_internal.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,19 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Intel, Evgueni Brevnov, Ivan Volosyuk - * @version $Revision: 1.1.2.1.4.4 $ - */ - #ifndef _M2N_IA32_INTERNAL_H_ #define _M2N_IA32_INTERNAL_H_ -// This file describes the internal IPF interface of m2n frames. -// It can be used by stubs to generate code to push and pop m2n frames, to update object handles fields, and -// to access the arguments from managed to native code. -// It is also used by stack iterators. + /** + * @file + * This file describes the internal IPF interface of m2n frames. + * It can be used by stubs to generate code to push and pop m2n frames, to + * update object handles fields, and to access the arguments from managed to + * native code. It is also used by stack iterators.*/ #include "m2n.h" #include "vm_threads.h" @@ -34,58 +31,91 @@ class R_Opnd; -// Return a pointer to the argument just above the return address of an M2nFrame + /** + * @return A pointer to the argument just above the return address of an M2nFrame.*/ uint32* m2n_get_args(M2nFrame*); -// An M2nFrame is a structure that resides on the stack. -// It takes up space below and including the return address to the managed code, and thus is immediately below the arguments. - -// This is the size of the structure that goes on the stack. + /** + * An M2nFrame is a structure that resides on the stack. + * It takes up space below and including the return address to the managed code, + * and thus is immediately below the arguments. + * + * This is the size of the structure that goes on the stack. + */ const unsigned m2n_sizeof_m2n_frame = 44; -// Generate code to put the thread local storage pointer into a given register +/** + * Generate code to put the thread local storage pointer into a given register. + */ unsigned m2n_ts_to_register_size(); char* m2n_gen_ts_to_register(char* buf, R_Opnd* reg); -// Generate code to push an M2nFrame onto the stack. -// It assumes that num_callee_saves registers have already been saved and the rest have been preserved, that the saved registers are immediately -// below the return address, and that esp points to the last one saved. The order for callee saves is ebp, ebx, esi, edi. -// It destroys eax. -// After the sequence, esp points to the M2nFrame. -// handles: will the stub want local handles or not +/** + * Generate code to push an M2nFrame onto the stack. + * It assumes that num_callee_saves registers have already been + * saved and the rest have been preserved, that the saved registers are immediately + * below the return address, and that esp points to the last one saved. + * The order for callee saves is ebp, ebx, esi, edi. + * + * It destroys eax. + * + * After the sequence, esp points to the M2nFrame. + * + * Handles: will the stub want local handles or not. + */ unsigned m2n_push_m2n_size(bool handles, unsigned num_callee_saves); char* m2n_gen_push_m2n(char* buf, Method_Handle method, frame_type current_frame_type, bool handles, unsigned num_callee_saves); -// Generate code to set the local handles of an M2nFrame -// The M2nFrame is located bytes_to_m2n above esp, and src_reg has the address of the frames. +/** + * Generate code to set the local handles of an M2nFrame. + * The M2nFrame is located bytes_to_m2n above esp, + * and src_reg has the address of the frames. + */ unsigned m2n_set_local_handles_size(unsigned bytes_to_m2n); char* m2n_gen_set_local_handles(char* buf, unsigned bytes_to_m2n, R_Opnd* src_reg); -// Generate code to pop an M2nFrame off the stack. -// num_callee_saves: the number of callee saves registers to leave on the stack as at the entry to push_m2n. -// extra_on_stack: the number of bytes between esp and the bottom of the M2nFrame. -// preserve_ret: the number of return registers to preserve, 0 means none, 1 means eax, 2 means eax & edx; st(0) is always preserved. -// handles: as for push_m2n, frees the handles if true. +/** + * Generate code to pop an M2nFrame off the stack. + * + * @param num_callee_saves - the number of callee saves registers to leave on + * the stack as at the entry to push_m2n + * @param extra_on_stack: - the number of bytes between esp and the + * bottom of the M2nFrame + * @param preserve_ret - the number of return registers to preserve, 0 means none, + * 1 means eax, 2 means eax and + * edx; st(0) is always preserved. + * @param handles - as for push_m2n, frees the handles if true. + */ unsigned m2n_pop_m2n_size(bool handles, unsigned num_callee_saves, unsigned extra_on_stack, unsigned preserve_ret); char* m2n_gen_pop_m2n(char* buf, bool handles, unsigned num_callee_saves, unsigned extra_on_stack, unsigned preserve_ret); -////////////////////////////////////////////////////////////////////////// -// Implementation details +/** + * Implementation Details + * + * This information is used by the m2n implementation and the stack + * iterator implementation. It may not be used by any other module. + * + * There are two types of M2nFrames: those that result from managed code calling a stub, + * and those that represent suspended managed code. The second type is needed to deal + * with throwing exceptions from OS contexts with the exception filter or signal mechanisms. + * + * For the first type: + *
      + *
    • eip points to the instruction past the one in question (ie + * is the return address into managed code)
    • + *
    • the bottom two bits of p_lm2nf are zero
    • + *
    • regs is not present, and is implicitly the address of the word + * above eip
    • + *
    + * + * For the second type: + *
      + *
    • eip points to the instruction in question
    • + *
    • p_lm2nf==1
    • + *
    • regs is present
    • + *
    + */ -// This information is used by the m2n implementation and the stack iterator implementation. -// It may not be used by any other module. - -// There are two types of M2nFrames: those that result from managed code calling a stub, and those that represent suspended managed code. -// The second type is needed to deal with throwing exceptions from OS contexts with the exception filter or signal mechanisms. -// For the first type: -// eip points to the instruction past the one in question (ie is the return address into managed code) -// the bottom two bits of p_lm2nf are zero -// regs is not present, and is implicitly the address of the word above eip -// For the second type: -// eip points to the instruction in question -// p_lm2nf==1 -// regs is present - #ifdef _EM64T_ #error Wrong header file. #endif Index: trunk/vm/port/src/lil/ipf/pim/m2n_ipf_internal.h =================================================================== --- trunk/vm/port/src/lil/ipf/pim/m2n_ipf_internal.h (revision 504464) +++ trunk/vm/port/src/lil/ipf/pim/m2n_ipf_internal.h (working copy) @@ -1,10 +1,10 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,100 +14,136 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Intel, Evgueni Brevnov, Ivan Volosyuk - * @version $Revision: 1.1.2.1.4.4 $ - */ - #ifndef _M2N_IPF_INTERNAL_H_ #define _M2N_IPF_INTERNAL_H_ -// This file describes the internal IPF interface of m2n frames. -// It can be used by stubs to generate code to push and pop m2n frames and to update object handles fields. -// It is also used by stack iterators. + /** + * @file + * This file describes the internal IPF interface of m2n frames. + * It can be used by stubs to generate code to push and pop m2n frames and + * to update object handles fields. It is also used by stack iterators.*/ #include "Code_Emitter.h" #include "m2n.h" #include "open/types.h" -// Generate code to push an M2nFrame onto the stack -// The activation frame of the stub is used for the M2nFrame as are certain registers in this frame. -// The stub must preserve all preserved registers including pfs, gp, and b0 from entry to the stub to the time of push_m2n. -// The stub may use up to 8 inputs, the requested number of locals, and the requested number of outputs after push_m2n. -// method: the method to be associated with the M2nFrame or NULL for no association -// handles: does the stub want local handles or not -// num_on_stack: this number plus the current sp is the sp at entry to the stub (should be positive as stack grows down) -// num_local: the number of local registers above the M2N registers required by the stub -// num_outputs: the number of output registers required by the stub -// do_alloc: if false, the function should assume that the stacked register -// frame has been allocated, and no alloc instruction needs to be executed; it should also assume that ar.pfs is already saved at its proper place -// return: the register number for the first local, the outputs immediately follow the locals -// Note, the stub may use some of the 8 inputs as locals if it wants to -unsigned m2n_gen_push_m2n(Merced_Code_Emitter*, Method_Handle method, frame_type current_frame_type, bool handles, unsigned num_on_stack, unsigned num_locals, - unsigned num_outputs, bool do_alloc=true); - + /** Generate code to push an M2nFrame onto the stack. + * The activation frame of the stub is used for the M2nFrame as are certain + * registers in this frame. The stub must preserve all preserved registers + * including pfs, gp, and b0 from entry + * to the stub to the time of push_m2n.
    + * The stub may use up to 8 inputs, the requested number of locals, and the + * requested number of outputs after push_m2n. + * + * @param method - the method to be associated with the M2nFrame or + * NULL for no association + * @param handles - does the stub want local handles or not + * @param num_on_stack - this number plus the current sp is the sp at entry + * to the stub (should be positive as stack grows down) + * @param num_local - the number of local registers above the M2N + * registers required by the stub + * @param num_outputs - the number of output registers required by the stub + * @param do_alloc - if false, the function should assume that the stacked register + * frame has been allocated, and no alloc instruction needs + * to be executed; it should also assume that ar.pfs + * is already saved at its proper place + * + * @return The register number for the first local, the outputs immediately + * follow the locals. + * + * @note The stub may use some of the 8 inputs as locals if it wants to + * unsigned m2n_gen_push_m2n(Merced_Code_Emitter*, Method_Handle method, + * frame_type current_frame_type, bool handles, unsigned num_on_stack, + * unsigned num_locals, unsigned num_outputs, bool do_alloc=true);*/ enum M2nPreserveRet { MPR_None, MPR_Gr, MPR_Fr }; -// Generate code to pop the M2nFrame from the stack. -// This should be matched by a preceeding push_m2n in the stub. -// handles: should match the push_m2n handles argument, if true the generated code will free the handles. -// preserve_ret_regs: the number of return registers to preserve (starting with r8). -// Note that the pop restores the callee saves gp registers, pfs, gp, and b0 to the values that had at the push m2n; it does not restore sp. -// do_alloc: must have the same value as the corresponding m2n_gen_push_m2n() parameter -// target: if handles==true and the vm property vm.free_local_object_handles -// is also true, m2n_gen_pop_m2n will need to set a target in the emitter; -// target will be the number used. Otherwise, this parameter is ignored. -// out_reg: if handles==true and the vm property vm.free_local_object_handles -// is also true, m2n_gen_pop_m2n needs to know the first output register; out_reg is this register. Otherwise this parameter is ignored + /** Generate code to pop the M2nFrame from the stack. + * This should be matched by a preceeding push_m2n in the stub. + * + * @param handles - should match the push_m2n handles + * argument, if true the generated code will free + * the handles + * @param preserve_ret_regs - the number of return registers to preserve + * (starting with r8) + * + * @note The pop restores the callee saves gp registers, pfs, + * gp, and b0 to the values that had at the + * push m2n; it does not restore sp. + * + * @param do_alloc - must have the same value as the corresponding + * m2n_gen_push_m2n() parameter + * @param target - if handles is TRUE and the vm property + * vm.free_local_object_handles is also + * TRUE, m2n_gen_pop_m2n will need + * to set a target in the emitter; target will be the number used. + * Otherwise, this parameter is ignored. + * @param out_reg - if handles is TRUE and the vm property + * vm.free_local_object_handles is also TRUE, + * m2n_gen_pop_m2n needs to know the first output + * register; out_reg is this register. Otherwise this parameter + * is ignored.*/ + void m2n_gen_pop_m2n(Merced_Code_Emitter*, bool handles, M2nPreserveRet preserve_ret_regs, bool do_alloc=true, unsigned out_reg=0, int target=-1); -// Generate code to set the local handles of the M2nFrame that is also the current frame. -// Preserves all registers that are not used to store M2nFrame information. + /** Generate code to set the local handles of the M2nFrame that is also the + * current frame. Preserves all registers that are not used to store M2nFrame + * information.*/ void m2n_gen_set_local_handles(Merced_Code_Emitter*, unsigned src_reg); -// Generate code to set the local handles of the M2nFrame that is also the current frame. -// Preserves all registers that are not used to store M2nFrame information. + /** Generate code to set the local handles of the M2nFrame that is also the + * current frame. Preserves all registers that are not used to store M2nFrame + * information.*/ void m2n_gen_set_local_handles_imm(Merced_Code_Emitter*, uint64 imm_val); -// Generate code to save additional preserved registers not normally saved by push_m2n. -// The combination of push_m2n and save_extra_preserved_registers will save all preserved registers as needed by exception propogation. -// The code generated by this function must follow that of push_m2n. -// Note that this function uses the memory stack, expects the scratch area above sp, and leaves a scratch area above sp. + /** Generate code to save additional preserved registers not normally saved by + * push_m2n. + * The combination of push_m2n and save_extra_preserved_registers + * will save all preserved registers as needed by exception propogation. + * The code generated by this function must follow that of push_m2n. + * + * @note This function uses the memory stack, expects the scratch area above + * sp, and leaves a scratch area above sp.*/ void m2n_gen_save_extra_preserved_registers(Merced_Code_Emitter* emitter); - -// returns the number of the last GR that the M2N frame uses + /** + * @return The number of the last GR that the M2N + * frame uses.*/ unsigned m2n_get_last_m2n_reg(); -// the following functions return the GR numbers where various things should be saved + /** The following functions return the GR numbers where various things should + * be saved.*/ unsigned m2n_get_pfs_save_reg(); unsigned m2n_get_return_save_reg(); unsigned m2n_get_gp_save_reg(); -// The IPF calling convention defines how to layout the arguments into words and then how to place -// these into gp registers, fp registers, or memory stack. This function returns a pointer to the -// nth word assuming it is either in a gp register or on the memory stack. + /** The IPF calling convention defines how to layout the arguments into words and + * then how to place these into gp registers, fp + * registers, or memory stack. This function returns a pointer to the + * nth word assuming it is either in a gp register or + * on the memory stack.*/ uint64* m2n_get_arg_word(M2nFrame*, unsigned n); -////////////////////////////////////////////////////////////////////////// -// Implementation details + /** Implementation details + * + * An M2nFrame is always represented using the bsp value for register 32 of the + * frame. The information needed for the frame is stored in stacked local registers or + * on the memory stack. It can be accessed by computing the spill location from + * the bsp value or by retrieving the sp value.*/ -// An M2nFrame is always represented using the bsp value for register 32 of the frame -// The information needed for the frame is stored in stacked local registers or on the memory stack. -// It can be accessed by computing the spill location from the bsp value or by retrieving the sp value and - uint64* m2n_get_bsp(M2nFrame*); uint64* m2n_get_extra_saved(M2nFrame*); -// An M2nFrame will always have 8 input registers, some local stacked registers to save stuff, and some outputs + /** An M2nFrame will always have 8 input registers, some local stacked registers + * to save stuff, and some outputs.*/ #define M2N_NUMBER_ALIGNS 2 #define M2N_NUMBER_INPUTS 8 #define M2N_NUMBER_LOCALS 14 -// The following registers are used in M2nFrames to hold the indicated values -// The register numbers must be distinct, at least 40 (so they don't conflict with inputs), and less than 40+M2N_NUMBER_LOCALS + /** The following registers are used in M2nFrames to hold the indicated values. + * The register numbers must be distinct, at least 40 (so they don't conflict + * with inputs), and less than 40+M2N_NUMBER_LOCALS.*/ #define M2N_SAVED_PFS 40 #define M2N_SAVED_RETURN_ADDRESS 41 @@ -124,27 +160,29 @@ #define M2N_METHOD 52 #define M2N_FRAME_TYPE 53 -// Only the callee saves general registers are normally saved in the M2nFrame along with special things like pfs, return address, etc. -// The full set of preserved registers includes callee saves floating point and branch registers as well. -// These are saved, if requested, onto the memory stack as follows: -// +-------------------------+ -// | Saved f2 | -// Extra Saved ---> +-------------------------+ -// | Saved f3..f5 | -// +-------------------------+ -// | Saved f16..f31 | -// +-------------------------+ -// | Scratch area (8 bytes) | -// +-------------------------+ -// | Saved b1..b5 | -// +-------------------------+ -// | Saved ar.fpsr | -// +-------------------------+ -// | Saved ar.unat | -// +-------------------------+ -// | Saved ar.lc | -// +-------------------------+ - + /** Only the callee saves general registers are normally saved in the M2nFrame + * along with special things like pfs, return address, etc. + * The full set of preserved registers includes callee saves floating point + * and branch registers as well.
    + * These are saved, if requested, onto the memory stack as follows:
    + *
                      +-------------------------+
    +  *                  | Saved f2                |
    +  * Extra Saved ---> +-------------------------+
    +  *                  | Saved f3..f5            |
    +  *                  +-------------------------+
    +  *                  | Saved f16..f31          |
    +  *                  +-------------------------+
    +  *                  | Scratch area (8 bytes)  |
    +  *                  +-------------------------+
    +  *                  | Saved b1..b5            |
    +  *                  +-------------------------+
    +  *                  | Saved ar.fpsr           |
    +  *                  +-------------------------+
    +  *                  | Saved ar.unat           |
    +  *                  +-------------------------+
    +  *                  | Saved ar.lc             |
    +  *                  +-------------------------+
    +  * 
    */ #define M2N_EXTRA_SAVES_SPACE 400 #ifdef _EM64T_