< prev index next >

src/hotspot/share/jvmci/jvmciJavaClasses.cpp

Print this page


  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 #include "precompiled.hpp"
  25 #include "classfile/symbolTable.hpp"
  26 #include "jvmci/jvmciJavaClasses.hpp"
  27 #include "memory/resourceArea.hpp"
  28 #include "oops/oop.inline.hpp"
  29 #include "runtime/jniHandles.inline.hpp"

  30 
  31 
  32 // This macro expands for non-inline functions, in class declarations.
  33 
  34 #define START_CLASS(name)                                                                                                                                \
  35     void name::check(oop obj, const char* field_name, int offset) {                                                                                          \
  36       assert(obj != NULL, "NULL field access of %s.%s", #name, field_name);                                                                                  \
  37       assert(obj->is_a(SystemDictionary::name##_klass()), "wrong class, " #name " expected, found %s", obj->klass()->external_name());                       \
  38       assert(offset != 0, "must be valid offset");                                                                                                           \
  39     }
  40 
  41 #define END_CLASS
  42 
  43 #define FIELD(klass, name, type, accessor, cast)                                                                                                                                \
  44     type klass::name(jobject obj)               { check(JNIHandles::resolve(obj), #name, _##name##_offset); return cast JNIHandles::resolve(obj)->accessor(_##name##_offset); }     \
  45     void klass::set_##name(jobject obj, type x) { check(JNIHandles::resolve(obj), #name, _##name##_offset); JNIHandles::resolve(obj)->accessor##_put(_##name##_offset, x); }
  46 
  47 #define EMPTY_CAST
  48 #define CHAR_FIELD(klass, name) FIELD(klass, name, jchar, char_field, EMPTY_CAST)
  49 #define INT_FIELD(klass, name) FIELD(klass, name, jint, int_field, EMPTY_CAST)




  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 #include "precompiled.hpp"
  25 #include "classfile/symbolTable.hpp"
  26 #include "jvmci/jvmciJavaClasses.hpp"
  27 #include "memory/resourceArea.hpp"
  28 #include "oops/oop.inline.hpp"
  29 #include "runtime/jniHandles.inline.hpp"
  30 #include "runtime/fieldDescriptor.inline.hpp"
  31 
  32 
  33 // This macro expands for non-inline functions, in class declarations.
  34 
  35 #define START_CLASS(name)                                                                                                                                \
  36     void name::check(oop obj, const char* field_name, int offset) {                                                                                          \
  37       assert(obj != NULL, "NULL field access of %s.%s", #name, field_name);                                                                                  \
  38       assert(obj->is_a(SystemDictionary::name##_klass()), "wrong class, " #name " expected, found %s", obj->klass()->external_name());                       \
  39       assert(offset != 0, "must be valid offset");                                                                                                           \
  40     }
  41 
  42 #define END_CLASS
  43 
  44 #define FIELD(klass, name, type, accessor, cast)                                                                                                                                \
  45     type klass::name(jobject obj)               { check(JNIHandles::resolve(obj), #name, _##name##_offset); return cast JNIHandles::resolve(obj)->accessor(_##name##_offset); }     \
  46     void klass::set_##name(jobject obj, type x) { check(JNIHandles::resolve(obj), #name, _##name##_offset); JNIHandles::resolve(obj)->accessor##_put(_##name##_offset, x); }
  47 
  48 #define EMPTY_CAST
  49 #define CHAR_FIELD(klass, name) FIELD(klass, name, jchar, char_field, EMPTY_CAST)
  50 #define INT_FIELD(klass, name) FIELD(klass, name, jint, int_field, EMPTY_CAST)


< prev index next >