You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2007/10/12 16:42:23 UTC
svn commit: r584170 [7/7] - in
/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363: base/ java5/
java6/
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.cpp?rev=584170&r1=584169&r2=584170&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.cpp Fri Oct 12 07:42:03 2007
@@ -1,441 +1,441 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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 Mikhail Loenko, Vladimir Molotkov
- */
-
-#include "context_6.h"
-namespace CPVerifier_6 {
-
- /*
- * Do Java6 verification of a method
- */
- vf_Result vf_Context_6::verify_method(method_handler method) {
- vf_Result tcr;
-
- //nothing to verify
- if( !method_get_code_length( m_method ) ) {
- return VF_OK;
- }
-
- //load memory storage, read variable like max_stack, etc
- init(method);
-
- //create workmap for zero instruction from method arguments
- if((tcr = create_method_initial_workmap()) != VF_OK ) {
- return tcr;
- }
-
- //parse stackmaptable, create Stackmaps for jump targets and exception handlers (catch block starts)
- if((tcr = load_stackmaptable()) != VF_OK ) {
- return tcr;
- }
-
- //////////////////////////// Check Exception Handlers (catch block starts) /////////////////////////
-
- for( unsigned short idx = 0; idx < m_handlecount; idx++ ) {
- unsigned short start_pc;
- unsigned short end_pc;
- unsigned short handler_pc;
- unsigned short handler_cp_index;
-
- method_get_exc_handler_info( m_method, idx, &start_pc, &end_pc,
- &handler_pc, &handler_cp_index );
-
- //just in case: it has been checked in classloader
- if( start_pc >= end_pc || end_pc > m_code_length ) {
- return error(VF_ErrorHandler, "start_pc >= end_pc OR end_pc > code_length");
- }
-
- SmConstant handler_type;
- if( handler_cp_index ) {
- //check that expected exception is of type throwable
- if( !tpool.cpool_get_class(handler_cp_index, &handler_type) ||
- !tpool.mustbe_assignable(handler_type, tpool.sm_get_const_throwable()) )
- {
- return error(VF_ErrorHandler, "incorrect constantpool entry");
- }
- } else {
- handler_type = tpool.sm_get_const_throwable();
- }
-
- //check stackmap at the point of exception handler
- if((tcr = checkHandlerStackmap(handler_pc, handler_type)) != VF_OK ) {
- return tcr;
- }
- }
-
- //use Java5 method to find first applicable try block
- next_start_pc = 0;
-
- //////////////////////////// Dataflow Pass /////////////////////////
-
- Address instr = 0;
- int afterJump = false;
- while( instr < m_code_length ) {
-
- OpCode opcode = (OpCode)m_bytecode[instr];
- processed_instruction = instr;
-
- // does code correspond to any valid instruction?
- if( !instr_is_valid_bytecode(opcode) || instr_is_jsr(opcode) ) {
- //to check WIDE RET we need to check m_code_length
- //anyway check for JSR is enough
- return error(VF_ErrorInstruction, "invalid opcode");
- }
-
- // keep all nessesary information about instruction
- ParseInfo &pi = instr_get_parse_info(opcode);
-
- // get MINIMAL length of the instruction with operands
- unsigned instr_len = instr_get_minlen(pi);
-
- // code does not correspond to any valid instruction or method length is less than required
- if( instr + instr_len > m_code_length ) {
- return error(VF_ErrorInstruction, "method length is less than required");
- }
-
- if( instr_is_compound(opcode, pi) ) {
- // get ACTUAL length for variable length insgtructions
- instr_len = instr_get_len_compound(instr, opcode);
-
- // method length is less than required
- if( instr + instr_len > m_code_length ) {
- return error(VF_ErrorInstruction, "compound instruction: method length is less than required");
- }
- }
-
- // check that no other instruction jumps to the middle of the current instruction
- for( Address i = instr + 1; i < instr + instr_len; i++ ) {
- if( props.getInstrProps(i) ) {
- //there is a stack map recorded for this instruction
- return error(VF_ErrorStackmap, "StackMapTable at the middle of instruction");
- }
- }
-
-
- /////////////////////////////////////////////////////////////////////////
-
- if( props.getInstrProps(instr) ) {
- //if instruction has a stackmap
- if( !afterJump && (tcr=new_generic_vector_constraint(instr)) != VF_OK ) {
- return tcr;
- }
-
- fill_workmap(instr);
- } else {
- if( afterJump ) return error(VF_ErrorBranch, "Stackmap expected");
- }
- afterJump = false;
-
- //check IN types, create OUT types, check exception
- if( (tcr=dataflow_instruction(instr)) != VF_OK ) {
- return tcr;
- }
-
- if( instr_is_jump(pi) ) {
- afterJump = instr_direct(pi, opcode, m_bytecode, instr);
-
- Address target = instr_get_jump_target(pi, m_bytecode, instr);
-
- if( (tcr=new_generic_vector_constraint(target)) != VF_OK ) {
- return tcr;
- }
- } else if( instr_direct(pi, opcode, m_bytecode, instr) ) {
- // it is not a jump ==> it is ret, return or throw
- afterJump = true;
- } else if( instr_is_switch(pi) ) {
- afterJump = true;
-
- Address next_target_adr = (instr & (~3) ) + 4;
-
- //default target
- Address target = instr + read_int32(m_bytecode + next_target_adr);
- new_generic_vector_constraint(target);
-
- // in tableswitch instruction target offsets are stored with shift = 4,
- // in lookupswitch with shift = 8
- int shift = (opcode == OP_TABLESWITCH) ? 4 : 8;
-
- // process conditional jump target
- for (next_target_adr += 12;
- next_target_adr < instr + instr_len;
- next_target_adr += shift)
- {
- target = instr + read_int32(m_bytecode + next_target_adr);
- new_generic_vector_constraint(target);
- }
- } else {
- assert( instr_is_regular(pi) );
- }
- instr += instr_len;
- }
-
- // control went out of method bounds
- return afterJump ? VF_OK : error(VF_ErrorCodeEnd, "control went out of method bounds");
- }
-
-
- /*
- * parse StackMapTable attribute and store Stackmap vectors for the instructions
- */
- vf_Result vf_Context_6::load_stackmaptable() {
- vf_Result tcr;
-
- uint8* stackmaptable = method_get_stackmaptable(m_method);
-
- if(!stackmaptable) return VF_OK;
-
- uint8* read_ptr = stackmaptable;
-
- read_ptr+=2; //skip uint16 attribute_name_index
-
- uint32 attribute_length = read_int32(read_ptr);
- read_ptr+=4;
- uint8 *attribute_end = stackmaptable + attribute_length + 6;
-
- if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
- uint16 number_of_entries = read_int16(read_ptr);
- read_ptr+=2;
-
- //create working copy fr previous stackmap frame, offeset, and number of locals
- WorkmapHead *lastWorkmap = newWorkmap(m_stack_start + m_max_stack);
- tc_memcpy(lastWorkmap, workmap, sizeof(WorkmapHead) + sizeof(WorkmapElement) * (m_stack_start + workmap->depth));
-
- unsigned last_maxlocals = m_max_locals;
- while( last_maxlocals > 0 ) {
- if( workmap->elements[last_maxlocals - 1].const_val != SM_BOGUS )
- {
- break;
- }
- last_maxlocals--;
- }
-
- int last_offset = -1;
-
- for( unsigned entry = 0; entry < number_of_entries; entry++) {
- if( read_ptr + 1 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-
- uint8 frame_type = (*read_ptr++);
- unsigned offset;
- if( frame_type <= 63 ) { // 0-63
- //same locals as previous, stack is empty. offset calculated from frame_type
- offset = frame_type;
- lastWorkmap->depth = 0;
-
- } else if (frame_type <= 127 ) { //64-127
- //same locals as previous, stack contains single element specified here. offset calculated from frame_type
- offset = frame_type - 64;
-
- unsigned k = 1; // k may change in read_types(): if it's LONG or DOUBLE stack size will be '2'
- if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[m_stack_start], &k, m_max_stack)) != VF_OK ) {
- return tcr;
- }
- lastWorkmap->depth = k;
-
- } else if (frame_type <= 246 ) {
- //reserved
- error(VF_ErrorStackmap, "corrupted StackMapTable");
-
- } else if (frame_type == 247 ) {
- //same locals as previous, stack contains single element specified here. offset is explicitely specified
- if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
- offset = read_int16(read_ptr);
- read_ptr+=2;
-
- unsigned k = 1; // k may change in read_types(): if it's LONG or DOUBLE stack size will be '2'
- if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[m_stack_start], &k, m_max_stack)) != VF_OK ) {
- return tcr;
- }
- lastWorkmap->depth = k;
-
- } else if (frame_type <= 250) { // 248-250
- //stack is empty, locals the same (tail is cut)
- unsigned k = 251 - frame_type; // last k locals are missing (k may change if there are LONG or DOUBLE there)
-
- while ( k ) {
- if( 0 == last_maxlocals-- ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-
- if( lastWorkmap->elements[last_maxlocals].const_val == SM_HIGH_WORD) {
- ++k;
- }
-
- lastWorkmap->elements[last_maxlocals].const_val = SmConstant(SM_BOGUS);
- --k;
- }
-
- if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
- offset = read_int16(read_ptr);
- read_ptr+=2;
-
- lastWorkmap->depth = 0;
- } else if (frame_type == 251 ) { // 251
- //same locals as previous, stack is empty. offset is explicitely specified
- if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
- offset = read_int16(read_ptr);
- read_ptr+=2;
-
- lastWorkmap->depth = 0;
- } else if (frame_type <= 254 ) { // 252-254
- //stack is empty, locals are extended
- if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
- offset = read_int16(read_ptr);
- read_ptr+=2;
-
- unsigned k = frame_type - 251; //may change in read_types()
- if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[last_maxlocals], &k, m_max_locals - last_maxlocals)) != VF_OK ) {
- return tcr;
- }
- last_maxlocals += k;
-
- lastWorkmap->depth = 0;
- } else {
- //all entries are specified explicitely
- assert(frame_type == 255);
-
- if( read_ptr + 4 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
- offset = read_int16(read_ptr);
- read_ptr+=2;
-
- last_maxlocals = read_int16(read_ptr); //may change in read_types()
- read_ptr+=2;
-
- if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[0], &last_maxlocals, m_max_locals)) != VF_OK ) {
- return tcr;
- }
-
- for( unsigned i = last_maxlocals; i < m_stack_start; i++ ) {
- lastWorkmap->elements[i].const_val = SmConstant(SM_BOGUS);
- }
-
- if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
- unsigned depth = read_int16(read_ptr); //may change in read_types()
- read_ptr+=2;
-
- if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[m_stack_start], &depth, m_max_stack)) != VF_OK ) {
- return tcr;
- }
- lastWorkmap->depth = depth;
- }
-
- //calculate instruction address
- last_offset = last_offset == -1 ? offset : last_offset + offset + 1;
-
- //record stackmap for the instruction
- PropsHead *pro = newStackmap(m_stack_start + lastWorkmap->depth);
- props.setInstrProps(last_offset, pro);
- StackmapHead *sm = pro->getStackmap();
-
- //set stack depth
- sm->depth = lastWorkmap->depth;
-
- unsigned i = 0;
- SmConstant flag_element = tpool.sm_get_const_this();
- //copy obtained data to stackmap of the instruction, check whether there is SM_THISUNINIT on stack or in locals
- for( ; i < m_max_locals; i++ ) {
- sm->elements[i].const_val = lastWorkmap->elements[i].const_val;
- if( sm->elements[i].const_val == SM_THISUNINIT ) flag_element = SmConstant(SM_THISUNINIT);
- }
-
- //skip copying workmap->elements[m_max_locals] that in case of constructor contains flags
-
- for( ; i < m_stack_start + lastWorkmap->depth; i++ ) {
- sm->elements[i].const_val = lastWorkmap->elements[i].const_val;
- if( sm->elements[i].const_val == SM_THISUNINIT ) flag_element = SmConstant(SM_THISUNINIT);
- }
-
- //initialize the flags
- if( m_is_constructor ) sm->elements[m_max_locals].const_val = flag_element;
-
- }
-
- if( read_ptr < attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
- return VF_OK;
- }
-
- /*
- * Read cnt types from a row bytearray representing StackMapTable and record to workmap starting at
- * the specified element. If Long or Double happens in StackMapTable, record SM_HIGH_WORD after SM_LONG or SM_DOUBLE
- * to the workmap and increase cnt. Check space_available when record to the workmap
- */
- vf_Result vf_Context_6::read_types(uint8 **attr, uint8 *end, WorkmapElement* element, unsigned *cnt, unsigned space_available) {
- uint16 idx = 0;
- //read (*cnt) types
- while( idx < *cnt ) {
-
- //attribute truncated?
- if( (*attr) > end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-
- //more elemens than max_locals or max_stack
- if( idx >= space_available ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-
- uint8 tag = *((*attr)++);
- switch (tag) {
- case ITEM_TOP:
- element[idx++].const_val = SmConstant(SM_BOGUS);
- break;
- case ITEM_INTEGER:
- element[idx++].const_val = SmConstant(SM_INTEGER);
- break;
- case ITEM_FLOAT:
- element[idx++].const_val = SmConstant(SM_FLOAT);
- break;
- case ITEM_DOUBLE:
- element[idx++].const_val = SmConstant(SM_DOUBLE);
- if( idx >= space_available ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
- (*cnt)++;
- element[idx++].const_val = SmConstant(SM_HIGH_WORD);
- break;
- case ITEM_LONG:
- element[idx++].const_val = SmConstant(SM_LONG);
- if( idx >= space_available ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
- (*cnt)++;
- element[idx++].const_val = SmConstant(SM_HIGH_WORD);
- break;
- case ITEM_NULL:
- element[idx++].const_val = SmConstant(SM_NULL);
- break;
- case ITEM_UNINITIALIZEDTHIS:
- element[idx++].const_val = SmConstant(SM_THISUNINIT);
- break;
- case ITEM_OBJECT: {
- if( (*attr) + 2 > end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
- uint16 cp_idx = read_int16(*attr);
- (*attr)+=2;
-
- SmConstant c;
- if( !tpool.cpool_get_class(cp_idx, &c) ) return error(VF_ErrorStackmap, "incorrect constantpool entry");
- element[idx++].const_val = c;
-
- break;
- }
- case ITEM_UNINITIALIZED: {
- if( (*attr) + 2 > end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
- uint16 address = read_int16(*attr);
- (*attr)+=2;
-
- element[idx++].const_val = SmConstant::getNewObject(address);
- break;
- }
- default:
- return error(VF_ErrorStackmap, "corrupted StackMapTable");
- }
- }
- return VF_OK;
- }
-
-} // namespace CPVerifier
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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 Mikhail Loenko, Vladimir Molotkov
+ */
+
+#include "context_6.h"
+namespace CPVerifier_6 {
+
+ /*
+ * Do Java6 verification of a method
+ */
+ vf_Result vf_Context_6::verify_method(method_handler method) {
+ vf_Result tcr;
+
+ //nothing to verify
+ if( !method_get_code_length( m_method ) ) {
+ return VF_OK;
+ }
+
+ //load memory storage, read variable like max_stack, etc
+ init(method);
+
+ //create workmap for zero instruction from method arguments
+ if((tcr = create_method_initial_workmap()) != VF_OK ) {
+ return tcr;
+ }
+
+ //parse stackmaptable, create Stackmaps for jump targets and exception handlers (catch block starts)
+ if((tcr = load_stackmaptable()) != VF_OK ) {
+ return tcr;
+ }
+
+ //////////////////////////// Check Exception Handlers (catch block starts) /////////////////////////
+
+ for( unsigned short idx = 0; idx < m_handlecount; idx++ ) {
+ unsigned short start_pc;
+ unsigned short end_pc;
+ unsigned short handler_pc;
+ unsigned short handler_cp_index;
+
+ method_get_exc_handler_info( m_method, idx, &start_pc, &end_pc,
+ &handler_pc, &handler_cp_index );
+
+ //just in case: it has been checked in classloader
+ if( start_pc >= end_pc || end_pc > m_code_length ) {
+ return error(VF_ErrorHandler, "start_pc >= end_pc OR end_pc > code_length");
+ }
+
+ SmConstant handler_type;
+ if( handler_cp_index ) {
+ //check that expected exception is of type throwable
+ if( !tpool.cpool_get_class(handler_cp_index, &handler_type) ||
+ !tpool.mustbe_assignable(handler_type, tpool.sm_get_const_throwable()) )
+ {
+ return error(VF_ErrorHandler, "incorrect constantpool entry");
+ }
+ } else {
+ handler_type = tpool.sm_get_const_throwable();
+ }
+
+ //check stackmap at the point of exception handler
+ if((tcr = checkHandlerStackmap(handler_pc, handler_type)) != VF_OK ) {
+ return tcr;
+ }
+ }
+
+ //use Java5 method to find first applicable try block
+ next_start_pc = 0;
+
+ //////////////////////////// Dataflow Pass /////////////////////////
+
+ Address instr = 0;
+ int afterJump = false;
+ while( instr < m_code_length ) {
+
+ OpCode opcode = (OpCode)m_bytecode[instr];
+ processed_instruction = instr;
+
+ // does code correspond to any valid instruction?
+ if( !instr_is_valid_bytecode(opcode) || instr_is_jsr(opcode) ) {
+ //to check WIDE RET we need to check m_code_length
+ //anyway check for JSR is enough
+ return error(VF_ErrorInstruction, "invalid opcode");
+ }
+
+ // keep all nessesary information about instruction
+ ParseInfo &pi = instr_get_parse_info(opcode);
+
+ // get MINIMAL length of the instruction with operands
+ unsigned instr_len = instr_get_minlen(pi);
+
+ // code does not correspond to any valid instruction or method length is less than required
+ if( instr + instr_len > m_code_length ) {
+ return error(VF_ErrorInstruction, "method length is less than required");
+ }
+
+ if( instr_is_compound(opcode, pi) ) {
+ // get ACTUAL length for variable length insgtructions
+ instr_len = instr_get_len_compound(instr, opcode);
+
+ // method length is less than required
+ if( instr + instr_len > m_code_length ) {
+ return error(VF_ErrorInstruction, "compound instruction: method length is less than required");
+ }
+ }
+
+ // check that no other instruction jumps to the middle of the current instruction
+ for( Address i = instr + 1; i < instr + instr_len; i++ ) {
+ if( props.getInstrProps(i) ) {
+ //there is a stack map recorded for this instruction
+ return error(VF_ErrorStackmap, "StackMapTable at the middle of instruction");
+ }
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+
+ if( props.getInstrProps(instr) ) {
+ //if instruction has a stackmap
+ if( !afterJump && (tcr=new_generic_vector_constraint(instr)) != VF_OK ) {
+ return tcr;
+ }
+
+ fill_workmap(instr);
+ } else {
+ if( afterJump ) return error(VF_ErrorBranch, "Stackmap expected");
+ }
+ afterJump = false;
+
+ //check IN types, create OUT types, check exception
+ if( (tcr=dataflow_instruction(instr)) != VF_OK ) {
+ return tcr;
+ }
+
+ if( instr_is_jump(pi) ) {
+ afterJump = instr_direct(pi, opcode, m_bytecode, instr);
+
+ Address target = instr_get_jump_target(pi, m_bytecode, instr);
+
+ if( (tcr=new_generic_vector_constraint(target)) != VF_OK ) {
+ return tcr;
+ }
+ } else if( instr_direct(pi, opcode, m_bytecode, instr) ) {
+ // it is not a jump ==> it is ret, return or throw
+ afterJump = true;
+ } else if( instr_is_switch(pi) ) {
+ afterJump = true;
+
+ Address next_target_adr = (instr & (~3) ) + 4;
+
+ //default target
+ Address target = instr + read_int32(m_bytecode + next_target_adr);
+ new_generic_vector_constraint(target);
+
+ // in tableswitch instruction target offsets are stored with shift = 4,
+ // in lookupswitch with shift = 8
+ int shift = (opcode == OP_TABLESWITCH) ? 4 : 8;
+
+ // process conditional jump target
+ for (next_target_adr += 12;
+ next_target_adr < instr + instr_len;
+ next_target_adr += shift)
+ {
+ target = instr + read_int32(m_bytecode + next_target_adr);
+ new_generic_vector_constraint(target);
+ }
+ } else {
+ assert( instr_is_regular(pi) );
+ }
+ instr += instr_len;
+ }
+
+ // control went out of method bounds
+ return afterJump ? VF_OK : error(VF_ErrorCodeEnd, "control went out of method bounds");
+ }
+
+
+ /*
+ * parse StackMapTable attribute and store Stackmap vectors for the instructions
+ */
+ vf_Result vf_Context_6::load_stackmaptable() {
+ vf_Result tcr;
+
+ uint8* stackmaptable = method_get_stackmaptable(m_method);
+
+ if(!stackmaptable) return VF_OK;
+
+ uint8* read_ptr = stackmaptable;
+
+ read_ptr+=2; //skip uint16 attribute_name_index
+
+ uint32 attribute_length = read_int32(read_ptr);
+ read_ptr+=4;
+ uint8 *attribute_end = stackmaptable + attribute_length + 6;
+
+ if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+ uint16 number_of_entries = read_int16(read_ptr);
+ read_ptr+=2;
+
+ //create working copy fr previous stackmap frame, offeset, and number of locals
+ WorkmapHead *lastWorkmap = newWorkmap(m_stack_start + m_max_stack);
+ tc_memcpy(lastWorkmap, workmap, sizeof(WorkmapHead) + sizeof(WorkmapElement) * (m_stack_start + workmap->depth));
+
+ unsigned last_maxlocals = m_max_locals;
+ while( last_maxlocals > 0 ) {
+ if( workmap->elements[last_maxlocals - 1].const_val != SM_BOGUS )
+ {
+ break;
+ }
+ last_maxlocals--;
+ }
+
+ int last_offset = -1;
+
+ for( unsigned entry = 0; entry < number_of_entries; entry++) {
+ if( read_ptr + 1 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+
+ uint8 frame_type = (*read_ptr++);
+ unsigned offset;
+ if( frame_type <= 63 ) { // 0-63
+ //same locals as previous, stack is empty. offset calculated from frame_type
+ offset = frame_type;
+ lastWorkmap->depth = 0;
+
+ } else if (frame_type <= 127 ) { //64-127
+ //same locals as previous, stack contains single element specified here. offset calculated from frame_type
+ offset = frame_type - 64;
+
+ unsigned k = 1; // k may change in read_types(): if it's LONG or DOUBLE stack size will be '2'
+ if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[m_stack_start], &k, m_max_stack)) != VF_OK ) {
+ return tcr;
+ }
+ lastWorkmap->depth = k;
+
+ } else if (frame_type <= 246 ) {
+ //reserved
+ error(VF_ErrorStackmap, "corrupted StackMapTable");
+
+ } else if (frame_type == 247 ) {
+ //same locals as previous, stack contains single element specified here. offset is explicitely specified
+ if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+ offset = read_int16(read_ptr);
+ read_ptr+=2;
+
+ unsigned k = 1; // k may change in read_types(): if it's LONG or DOUBLE stack size will be '2'
+ if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[m_stack_start], &k, m_max_stack)) != VF_OK ) {
+ return tcr;
+ }
+ lastWorkmap->depth = k;
+
+ } else if (frame_type <= 250) { // 248-250
+ //stack is empty, locals the same (tail is cut)
+ unsigned k = 251 - frame_type; // last k locals are missing (k may change if there are LONG or DOUBLE there)
+
+ while ( k ) {
+ if( 0 == last_maxlocals-- ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+
+ if( lastWorkmap->elements[last_maxlocals].const_val == SM_HIGH_WORD) {
+ ++k;
+ }
+
+ lastWorkmap->elements[last_maxlocals].const_val = SmConstant(SM_BOGUS);
+ --k;
+ }
+
+ if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+ offset = read_int16(read_ptr);
+ read_ptr+=2;
+
+ lastWorkmap->depth = 0;
+ } else if (frame_type == 251 ) { // 251
+ //same locals as previous, stack is empty. offset is explicitely specified
+ if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+ offset = read_int16(read_ptr);
+ read_ptr+=2;
+
+ lastWorkmap->depth = 0;
+ } else if (frame_type <= 254 ) { // 252-254
+ //stack is empty, locals are extended
+ if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+ offset = read_int16(read_ptr);
+ read_ptr+=2;
+
+ unsigned k = frame_type - 251; //may change in read_types()
+ if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[last_maxlocals], &k, m_max_locals - last_maxlocals)) != VF_OK ) {
+ return tcr;
+ }
+ last_maxlocals += k;
+
+ lastWorkmap->depth = 0;
+ } else {
+ //all entries are specified explicitely
+ assert(frame_type == 255);
+
+ if( read_ptr + 4 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+ offset = read_int16(read_ptr);
+ read_ptr+=2;
+
+ last_maxlocals = read_int16(read_ptr); //may change in read_types()
+ read_ptr+=2;
+
+ if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[0], &last_maxlocals, m_max_locals)) != VF_OK ) {
+ return tcr;
+ }
+
+ for( unsigned i = last_maxlocals; i < m_stack_start; i++ ) {
+ lastWorkmap->elements[i].const_val = SmConstant(SM_BOGUS);
+ }
+
+ if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+ unsigned depth = read_int16(read_ptr); //may change in read_types()
+ read_ptr+=2;
+
+ if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[m_stack_start], &depth, m_max_stack)) != VF_OK ) {
+ return tcr;
+ }
+ lastWorkmap->depth = depth;
+ }
+
+ //calculate instruction address
+ last_offset = last_offset == -1 ? offset : last_offset + offset + 1;
+
+ //record stackmap for the instruction
+ PropsHead *pro = newStackmap(m_stack_start + lastWorkmap->depth);
+ props.setInstrProps(last_offset, pro);
+ StackmapHead *sm = pro->getStackmap();
+
+ //set stack depth
+ sm->depth = lastWorkmap->depth;
+
+ unsigned i = 0;
+ SmConstant flag_element = tpool.sm_get_const_this();
+ //copy obtained data to stackmap of the instruction, check whether there is SM_THISUNINIT on stack or in locals
+ for( ; i < m_max_locals; i++ ) {
+ sm->elements[i].const_val = lastWorkmap->elements[i].const_val;
+ if( sm->elements[i].const_val == SM_THISUNINIT ) flag_element = SmConstant(SM_THISUNINIT);
+ }
+
+ //skip copying workmap->elements[m_max_locals] that in case of constructor contains flags
+
+ for( ; i < m_stack_start + lastWorkmap->depth; i++ ) {
+ sm->elements[i].const_val = lastWorkmap->elements[i].const_val;
+ if( sm->elements[i].const_val == SM_THISUNINIT ) flag_element = SmConstant(SM_THISUNINIT);
+ }
+
+ //initialize the flags
+ if( m_is_constructor ) sm->elements[m_max_locals].const_val = flag_element;
+
+ }
+
+ if( read_ptr < attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+ return VF_OK;
+ }
+
+ /*
+ * Read cnt types from a row bytearray representing StackMapTable and record to workmap starting at
+ * the specified element. If Long or Double happens in StackMapTable, record SM_HIGH_WORD after SM_LONG or SM_DOUBLE
+ * to the workmap and increase cnt. Check space_available when record to the workmap
+ */
+ vf_Result vf_Context_6::read_types(uint8 **attr, uint8 *end, WorkmapElement* element, unsigned *cnt, unsigned space_available) {
+ uint16 idx = 0;
+ //read (*cnt) types
+ while( idx < *cnt ) {
+
+ //attribute truncated?
+ if( (*attr) > end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+
+ //more elemens than max_locals or max_stack
+ if( idx >= space_available ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+
+ uint8 tag = *((*attr)++);
+ switch (tag) {
+ case ITEM_TOP:
+ element[idx++].const_val = SmConstant(SM_BOGUS);
+ break;
+ case ITEM_INTEGER:
+ element[idx++].const_val = SmConstant(SM_INTEGER);
+ break;
+ case ITEM_FLOAT:
+ element[idx++].const_val = SmConstant(SM_FLOAT);
+ break;
+ case ITEM_DOUBLE:
+ element[idx++].const_val = SmConstant(SM_DOUBLE);
+ if( idx >= space_available ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+ (*cnt)++;
+ element[idx++].const_val = SmConstant(SM_HIGH_WORD);
+ break;
+ case ITEM_LONG:
+ element[idx++].const_val = SmConstant(SM_LONG);
+ if( idx >= space_available ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+ (*cnt)++;
+ element[idx++].const_val = SmConstant(SM_HIGH_WORD);
+ break;
+ case ITEM_NULL:
+ element[idx++].const_val = SmConstant(SM_NULL);
+ break;
+ case ITEM_UNINITIALIZEDTHIS:
+ element[idx++].const_val = SmConstant(SM_THISUNINIT);
+ break;
+ case ITEM_OBJECT: {
+ if( (*attr) + 2 > end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+ uint16 cp_idx = read_int16(*attr);
+ (*attr)+=2;
+
+ SmConstant c;
+ if( !tpool.cpool_get_class(cp_idx, &c) ) return error(VF_ErrorStackmap, "incorrect constantpool entry");
+ element[idx++].const_val = c;
+
+ break;
+ }
+ case ITEM_UNINITIALIZED: {
+ if( (*attr) + 2 > end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+ uint16 address = read_int16(*attr);
+ (*attr)+=2;
+
+ element[idx++].const_val = SmConstant::getNewObject(address);
+ break;
+ }
+ default:
+ return error(VF_ErrorStackmap, "corrupted StackMapTable");
+ }
+ }
+ return VF_OK;
+ }
+
+} // namespace CPVerifier
Propchange: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.cpp
('svn:executable' removed)
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.h?rev=584170&r1=584169&r2=584170&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.h Fri Oct 12 07:42:03 2007
@@ -1,146 +1,146 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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 Mikhail Loenko, Vladimir Molotkov
- */
-
-#ifndef __CONTEXT6_H__
-#define __CONTEXT6_H__
-
-#include <assert.h>
-#include <string.h>
-#include "../base/context_x.h"
-#include "stackmap_6.h"
-
-using namespace CPVerifier;
-
-
-namespace CPVerifier_6 {
-
- //
- // Context - main class of Type Checker
- //
-
- class vf_Context_6 : public vf_Context_x<vf_Context_6, WorkmapElement, _WorkmapElement, StackmapElement> {
- public:
- vf_Context_6(SharedClasswideData &classwide) :
- vf_Context_x<vf_Context_6, WorkmapElement, _WorkmapElement, StackmapElement>(classwide) {}
-
- vf_Result verify_method(method_handler method);
- protected:
- // stackmaps for instructions
- InstrPropsBase props;
-
- //init method-wide data
- void init(method_handler _m_method) {
- vf_Context_x<vf_Context_6, WorkmapElement, _WorkmapElement, StackmapElement>::init(_m_method);
- props.init(mem, m_code_length);
- }
-
- // load derived types previously stored for the given instruction
- void fill_workmap(Address instr) {
- PropsHead *head = (PropsHead*)props.getInstrProps(instr);
- assert(sizeof(StackmapElement) == sizeof(WorkmapElement));
- tc_memcpy(workmap, head->getStackmap(), sizeof(WorkmapHead) + sizeof(WorkmapElement) * (m_stack_start + head->stackmap.depth));
- }
-
- //create a stackmap vector of the given size sz (max_locals <= sz <= max_locals+max_stack)
- PropsHead* newStackmap(int sz) {
- return (PropsHead*)mem.calloc(sizeof(PropsHead) + sizeof(StackmapElement) * sz);
- }
-
- //parse StackMapTable attribute and store Stackmap vectors for the instructions
- vf_Result load_stackmaptable();
-
- //Read cnt types from a row bytearray representing StackMapTable and record to workmap starting at
- //the specified element. If Long or Double happens in StackMapTable, record SM_HIGH_WORD after SM_LONG or SM_DOUBLE
- //to the workmap and increase cnt. Check space_available when record to the workmap
- vf_Result read_types(uint8 **attr, uint8 *end, WorkmapElement* element, unsigned *cnt, unsigned space_available);
-
-
- /////////////////////////////////// "VIRTUAL" METHODS /////////////////////////////////////////////
- public:
- //create constraint vector in case of a branch
- //simple conatraints are created for pairs of both locals and stack (current must be assignable to target)
- vf_Result new_generic_vector_constraint(Address target_instr) {
- StackmapHead *target = getStackmap(target_instr);
- return target ? new_generic_vector_constraint_impl(target) : error(VF_ErrorBranch, "no stackmap at branch target");
- }
-
- //when we hit RET instruction we update the data for the given subroutine with current derived types
- vf_Result new_ret_vector_constraint(Address target_instr) {
- assert(0);
- return error(VF_ErrorInternal, "unexpected JSR/RET instruction");
- }
-
- // Java5 anachronism: push catch-block to the stack of branches to pass, empty in Java6
- void push_handler(Address handler_pc) {
- }
-
- //check stackmap for exception handler start
- vf_Result checkHandlerStackmap(Address handler_pc, SmConstant type) {
- StackmapHead *map = getStackmap(handler_pc);
- if( !map ) {
- return error(VF_ErrorHandler, "no stackmap at catch");
- }
- if( map->depth != 1 ) {
- return error(VF_ErrorHandler, "incorrect stack at catch");
- }
- return add_incoming_value(type, &map->elements[m_stack_start]);
- }
-
- //returns stackmap for the 'instr' instruction or 0 if it does not exist
- StackmapHead *getStackmap(Address instr) {
- PropsHead *pro = (PropsHead*) props.getInstrProps(instr);
- return pro ? pro->getStackmap() : 0;
- }
-
- /////////////// expect some type //////////////
-
- //expect exactly this type
- int workmap_expect_strict( WorkmapElement &el, SmConstant type ) {
- assert(type != SM_BOGUS);
- return type == el.const_val;
- }
-
- int workmap_expect( WorkmapElement &el, SmConstant type ) {
- return tpool.mustbe_assignable(el.const_val, type);
- }
-
- //create simple single constraint: "'from' is assingable to 'to'"
- vf_Result new_scalar_constraint(WorkmapElement *from, StackmapElement *to) {
- return add_incoming_value(from->const_val, to);
- }
-
- //add one more possible value (type) that can come to the given point (local or stack)
- vf_Result add_incoming_value(SmConstant new_value, StackmapElement *destination) {
- return tpool.mustbe_assignable(new_value, destination->const_val) ? VF_OK :
- error(VF_ErrorIncompatibleArgument, "incompatible argument");
- }
-
- //create special type of conatraint: "'from' is an array and it's element is assignable to 'to'"
- vf_Result new_scalar_array2ref_constraint(WorkmapElement *from, WorkmapElement *to) {
- //although new_scalar_conatraint() whould process from constants correctly
- // we just do not need new variable if it is really a constant
- *to = _WorkmapElement( tpool.get_ref_from_array(from->const_val) );
- return VF_OK;
- }
- };
-
-} // namespace CPVerifier
-
-#endif
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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 Mikhail Loenko, Vladimir Molotkov
+ */
+
+#ifndef __CONTEXT6_H__
+#define __CONTEXT6_H__
+
+#include <assert.h>
+#include <string.h>
+#include "../base/context_x.h"
+#include "stackmap_6.h"
+
+using namespace CPVerifier;
+
+
+namespace CPVerifier_6 {
+
+ //
+ // Context - main class of Type Checker
+ //
+
+ class vf_Context_6 : public vf_Context_x<vf_Context_6, WorkmapElement, _WorkmapElement, StackmapElement> {
+ public:
+ vf_Context_6(SharedClasswideData &classwide) :
+ vf_Context_x<vf_Context_6, WorkmapElement, _WorkmapElement, StackmapElement>(classwide) {}
+
+ vf_Result verify_method(method_handler method);
+ protected:
+ // stackmaps for instructions
+ InstrPropsBase props;
+
+ //init method-wide data
+ void init(method_handler _m_method) {
+ vf_Context_x<vf_Context_6, WorkmapElement, _WorkmapElement, StackmapElement>::init(_m_method);
+ props.init(mem, m_code_length);
+ }
+
+ // load derived types previously stored for the given instruction
+ void fill_workmap(Address instr) {
+ PropsHead *head = (PropsHead*)props.getInstrProps(instr);
+ assert(sizeof(StackmapElement) == sizeof(WorkmapElement));
+ tc_memcpy(workmap, head->getStackmap(), sizeof(WorkmapHead) + sizeof(WorkmapElement) * (m_stack_start + head->stackmap.depth));
+ }
+
+ //create a stackmap vector of the given size sz (max_locals <= sz <= max_locals+max_stack)
+ PropsHead* newStackmap(int sz) {
+ return (PropsHead*)mem.calloc(sizeof(PropsHead) + sizeof(StackmapElement) * sz);
+ }
+
+ //parse StackMapTable attribute and store Stackmap vectors for the instructions
+ vf_Result load_stackmaptable();
+
+ //Read cnt types from a row bytearray representing StackMapTable and record to workmap starting at
+ //the specified element. If Long or Double happens in StackMapTable, record SM_HIGH_WORD after SM_LONG or SM_DOUBLE
+ //to the workmap and increase cnt. Check space_available when record to the workmap
+ vf_Result read_types(uint8 **attr, uint8 *end, WorkmapElement* element, unsigned *cnt, unsigned space_available);
+
+
+ /////////////////////////////////// "VIRTUAL" METHODS /////////////////////////////////////////////
+ public:
+ //create constraint vector in case of a branch
+ //simple conatraints are created for pairs of both locals and stack (current must be assignable to target)
+ vf_Result new_generic_vector_constraint(Address target_instr) {
+ StackmapHead *target = getStackmap(target_instr);
+ return target ? new_generic_vector_constraint_impl(target) : error(VF_ErrorBranch, "no stackmap at branch target");
+ }
+
+ //when we hit RET instruction we update the data for the given subroutine with current derived types
+ vf_Result new_ret_vector_constraint(Address target_instr) {
+ assert(0);
+ return error(VF_ErrorInternal, "unexpected JSR/RET instruction");
+ }
+
+ // Java5 anachronism: push catch-block to the stack of branches to pass, empty in Java6
+ void push_handler(Address handler_pc) {
+ }
+
+ //check stackmap for exception handler start
+ vf_Result checkHandlerStackmap(Address handler_pc, SmConstant type) {
+ StackmapHead *map = getStackmap(handler_pc);
+ if( !map ) {
+ return error(VF_ErrorHandler, "no stackmap at catch");
+ }
+ if( map->depth != 1 ) {
+ return error(VF_ErrorHandler, "incorrect stack at catch");
+ }
+ return add_incoming_value(type, &map->elements[m_stack_start]);
+ }
+
+ //returns stackmap for the 'instr' instruction or 0 if it does not exist
+ StackmapHead *getStackmap(Address instr) {
+ PropsHead *pro = (PropsHead*) props.getInstrProps(instr);
+ return pro ? pro->getStackmap() : 0;
+ }
+
+ /////////////// expect some type //////////////
+
+ //expect exactly this type
+ int workmap_expect_strict( WorkmapElement &el, SmConstant type ) {
+ assert(type != SM_BOGUS);
+ return type == el.const_val;
+ }
+
+ int workmap_expect( WorkmapElement &el, SmConstant type ) {
+ return tpool.mustbe_assignable(el.const_val, type);
+ }
+
+ //create simple single constraint: "'from' is assingable to 'to'"
+ vf_Result new_scalar_constraint(WorkmapElement *from, StackmapElement *to) {
+ return add_incoming_value(from->const_val, to);
+ }
+
+ //add one more possible value (type) that can come to the given point (local or stack)
+ vf_Result add_incoming_value(SmConstant new_value, StackmapElement *destination) {
+ return tpool.mustbe_assignable(new_value, destination->const_val) ? VF_OK :
+ error(VF_ErrorIncompatibleArgument, "incompatible argument");
+ }
+
+ //create special type of conatraint: "'from' is an array and it's element is assignable to 'to'"
+ vf_Result new_scalar_array2ref_constraint(WorkmapElement *from, WorkmapElement *to) {
+ //although new_scalar_conatraint() whould process from constants correctly
+ // we just do not need new variable if it is really a constant
+ *to = _WorkmapElement( tpool.get_ref_from_array(from->const_val) );
+ return VF_OK;
+ }
+ };
+
+} // namespace CPVerifier
+
+#endif
Propchange: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.h
('svn:executable' removed)
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/stackmap_6.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/stackmap_6.h?rev=584170&r1=584169&r2=584170&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/stackmap_6.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/stackmap_6.h Fri Oct 12 07:42:03 2007
@@ -1,93 +1,93 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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 Mikhail Loenko, Vladimir Molotkov
- */
-
-#ifndef __STACKMAP6_H__
-#define __STACKMAP6_H__
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include "../base/stackmap_x.h"
-
-using namespace CPVerifier;
-
-namespace CPVerifier_6 {
-
- //Constant for parsing StackMapTable attribute
- enum StackMapTableItems {
- ITEM_TOP = 0,
- ITEM_INTEGER = 1,
- ITEM_FLOAT = 2,
- ITEM_DOUBLE = 3,
- ITEM_LONG = 4,
- ITEM_NULL = 5,
- ITEM_UNINITIALIZEDTHIS = 6,
- ITEM_OBJECT = 7,
- ITEM_UNINITIALIZED = 8
- };
-
-
- //StackMapElement structure represens recorded verification types
- //it's read from class file StackMapTable attribute
- struct StackmapElement {
- //list of IncomingType constraint
- _SmConstant const_val;
- };
-
- //WorkMapElement structure represent an element of the workmap vector -- vector of the derived types
- //in Java6 verification type might be constant (or known) only
- struct WorkmapElement {
- //the value
- _SmConstant const_val; //either a constant (known-type)
-
- //// Java5 anachonisms ////
- void setJsrModified() {};
- int isJsrModified() { return 1;};
- SmConstant getAnyPossibleValue() { return const_val; }
- SmConstant getConst() { return const_val; }
- };
-
- //WorkmapElement type with some constructors
- struct _WorkmapElement : WorkmapElement {
- _WorkmapElement(WorkmapElement other) {
- const_val = other.const_val;
- }
-
- _WorkmapElement(SmConstant c) {
- const_val = c;
- }
- };
-
- //Store stackmap data for the given instruction
- // the list is used to organize storing Props as a HashTable
- struct PropsHead : public PropsHeadBase {
- typedef MapHead<StackmapElement> StackmapHead;
-
- //possible properties
- StackmapHead stackmap;
-
- //get stackmap stored here
- StackmapHead *getStackmap() {
- return &stackmap;
- }
- };
-} // namespace CPVerifier_6
-
-#endif
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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 Mikhail Loenko, Vladimir Molotkov
+ */
+
+#ifndef __STACKMAP6_H__
+#define __STACKMAP6_H__
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include "../base/stackmap_x.h"
+
+using namespace CPVerifier;
+
+namespace CPVerifier_6 {
+
+ //Constant for parsing StackMapTable attribute
+ enum StackMapTableItems {
+ ITEM_TOP = 0,
+ ITEM_INTEGER = 1,
+ ITEM_FLOAT = 2,
+ ITEM_DOUBLE = 3,
+ ITEM_LONG = 4,
+ ITEM_NULL = 5,
+ ITEM_UNINITIALIZEDTHIS = 6,
+ ITEM_OBJECT = 7,
+ ITEM_UNINITIALIZED = 8
+ };
+
+
+ //StackMapElement structure represens recorded verification types
+ //it's read from class file StackMapTable attribute
+ struct StackmapElement {
+ //list of IncomingType constraint
+ _SmConstant const_val;
+ };
+
+ //WorkMapElement structure represent an element of the workmap vector -- vector of the derived types
+ //in Java6 verification type might be constant (or known) only
+ struct WorkmapElement {
+ //the value
+ _SmConstant const_val; //either a constant (known-type)
+
+ //// Java5 anachonisms ////
+ void setJsrModified() {};
+ int isJsrModified() { return 1;};
+ SmConstant getAnyPossibleValue() { return const_val; }
+ SmConstant getConst() { return const_val; }
+ };
+
+ //WorkmapElement type with some constructors
+ struct _WorkmapElement : WorkmapElement {
+ _WorkmapElement(WorkmapElement other) {
+ const_val = other.const_val;
+ }
+
+ _WorkmapElement(SmConstant c) {
+ const_val = c;
+ }
+ };
+
+ //Store stackmap data for the given instruction
+ // the list is used to organize storing Props as a HashTable
+ struct PropsHead : public PropsHeadBase {
+ typedef MapHead<StackmapElement> StackmapHead;
+
+ //possible properties
+ StackmapHead stackmap;
+
+ //get stackmap stored here
+ StackmapHead *getStackmap() {
+ return &stackmap;
+ }
+ };
+} // namespace CPVerifier_6
+
+#endif
Propchange: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/stackmap_6.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/stackmap_6.h
('svn:executable' removed)