src/share/vm/classfile/stackMapTable.hpp

Print this page


   1 /*
   2  * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 


















  25 class StackMapReader;
  26 
  27 // StackMapTable class is the StackMap table used by type checker
  28 class StackMapTable : public StackObj {
  29  private:
  30   // Logically, the _frame_count (as well as many fields in the StackFrame)
  31   // should be a u2, but if we defined the variable as that type it will
  32   // be difficult to detect/recover from overflow or underflow conditions.
  33   // Widening the type and making it signed will help detect these.
  34   int32_t              _code_length;
  35   int32_t              _frame_count;     // Stackmap frame count
  36   StackMapFrame**       _frame_array;
  37 
  38  public:
  39   StackMapTable(StackMapReader* reader, StackMapFrame* init_frame,
  40                 u2 max_locals, u2 max_stack,
  41                 char* code_data, int code_len, TRAPS);
  42 
  43   inline int32_t get_frame_count() const { return _frame_count; }
  44   inline int get_offset(int index) const {


 142     methodHandle m = v->method();
 143     if (m->has_stackmap_table()) {
 144       _cp = constantPoolHandle(THREAD, m->constants());
 145       _frame_count = _stream->get_u2(CHECK);
 146     } else {
 147       // There's no stackmap table present. Frame count and size are 0.
 148       _frame_count = 0;
 149     }
 150   }
 151 
 152   inline int32_t get_frame_count() const                { return _frame_count; }
 153   StackMapFrame* next(StackMapFrame* pre_frame, bool first,
 154                       u2 max_locals, u2 max_stack, TRAPS);
 155 
 156   void check_end(TRAPS) {
 157     if (!_stream->at_end()) {
 158       StackMapStream::stackmap_format_error("wrong attribute size", CHECK);
 159     }
 160   }
 161 };


   1 /*
   2  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CLASSFILE_STACKMAPTABLE_HPP
  26 #define SHARE_VM_CLASSFILE_STACKMAPTABLE_HPP
  27 
  28 #include "classfile/stackMapFrame.hpp"
  29 #include "memory/allocation.hpp"
  30 #include "oops/constantPoolOop.hpp"
  31 #include "oops/methodOop.hpp"
  32 #include "utilities/globalDefinitions.hpp"
  33 #ifdef TARGET_ARCH_x86
  34 # include "bytes_x86.hpp"
  35 #endif
  36 #ifdef TARGET_ARCH_sparc
  37 # include "bytes_sparc.hpp"
  38 #endif
  39 #ifdef TARGET_ARCH_zero
  40 # include "bytes_zero.hpp"
  41 #endif
  42 
  43 class StackMapReader;
  44 
  45 // StackMapTable class is the StackMap table used by type checker
  46 class StackMapTable : public StackObj {
  47  private:
  48   // Logically, the _frame_count (as well as many fields in the StackFrame)
  49   // should be a u2, but if we defined the variable as that type it will
  50   // be difficult to detect/recover from overflow or underflow conditions.
  51   // Widening the type and making it signed will help detect these.
  52   int32_t              _code_length;
  53   int32_t              _frame_count;     // Stackmap frame count
  54   StackMapFrame**       _frame_array;
  55 
  56  public:
  57   StackMapTable(StackMapReader* reader, StackMapFrame* init_frame,
  58                 u2 max_locals, u2 max_stack,
  59                 char* code_data, int code_len, TRAPS);
  60 
  61   inline int32_t get_frame_count() const { return _frame_count; }
  62   inline int get_offset(int index) const {


 160     methodHandle m = v->method();
 161     if (m->has_stackmap_table()) {
 162       _cp = constantPoolHandle(THREAD, m->constants());
 163       _frame_count = _stream->get_u2(CHECK);
 164     } else {
 165       // There's no stackmap table present. Frame count and size are 0.
 166       _frame_count = 0;
 167     }
 168   }
 169 
 170   inline int32_t get_frame_count() const                { return _frame_count; }
 171   StackMapFrame* next(StackMapFrame* pre_frame, bool first,
 172                       u2 max_locals, u2 max_stack, TRAPS);
 173 
 174   void check_end(TRAPS) {
 175     if (!_stream->at_end()) {
 176       StackMapStream::stackmap_format_error("wrong attribute size", CHECK);
 177     }
 178   }
 179 };
 180 
 181 #endif // SHARE_VM_CLASSFILE_STACKMAPTABLE_HPP