< prev index next >

src/java.base/share/native/libverify/check_code.c

Print this page
rev 12879 : 8136556: Add the ability to perform static builds of MacOSX x64 binaries
Reviewed-by: ihse, bdelsart, gadams, lfoltan, rriggs, hseigel, twisti


  69    JVM_GetCPMethodNameUTF
  70    JVM_GetCPFieldSignatureUTF
  71    JVM_GetCPMethodSignatureUTF
  72    JVM_GetCPFieldClassNameUTF
  73    JVM_GetCPMethodClassNameUTF
  74    JVM_GetCPFieldModifiers
  75    JVM_GetCPMethodModifiers
  76 
  77    JVM_ReleaseUTF
  78    JVM_IsSameClassPackage
  79 
  80  */
  81 
  82 #include <string.h>
  83 #include <setjmp.h>
  84 #include <assert.h>
  85 #include <limits.h>
  86 #include <stdlib.h>
  87 
  88 #include "jni.h"

  89 #include "jvm.h"
  90 #include "classfile_constants.h"
  91 #include "opcodes.in_out"
  92 
  93 /* On AIX malloc(0) and calloc(0, ...) return a NULL pointer, which is legal,
  94  * but the code here does not handles it. So we wrap the methods and return non-NULL
  95  * pointers even if we allocate 0 bytes.
  96  */
  97 #ifdef _AIX
  98 static int aix_dummy;
  99 static void* aix_malloc(size_t len) {
 100   if (len == 0) {
 101     return &aix_dummy;
 102   }
 103   return malloc(len);
 104 }
 105 
 106 static void* aix_calloc(size_t n, size_t size) {
 107   if (n == 0) {
 108     return &aix_dummy;


 463 
 464 static void CCerror (context_type *, char *format, ...);
 465 static void CFerror (context_type *, char *format, ...);
 466 static void CCout_of_memory (context_type *);
 467 
 468 /* Because we can longjmp any time, we need to be very careful about
 469  * remembering what needs to be freed. */
 470 
 471 static void check_and_push(context_type *context, const void *ptr, int kind);
 472 static void pop_and_free(context_type *context);
 473 
 474 static int signature_to_args_size(const char *method_signature);
 475 
 476 #ifdef DEBUG
 477 static void print_stack (context_type *, stack_info_type *stack_info);
 478 static void print_registers(context_type *, register_info_type *register_info);
 479 static void print_flags(context_type *, flag_type, flag_type);
 480 static void print_formatted_fieldname(context_type *context, int index);
 481 static void print_formatted_methodname(context_type *context, int index);
 482 #endif





 483 
 484 void initialize_class_hash(context_type *context)
 485 {
 486     hash_table_type *class_hash = &(context->class_hash);
 487     class_hash->buckets = (hash_bucket_type **)
 488         calloc(MAX_HASH_ENTRIES / HASH_ROW_SIZE, sizeof(hash_bucket_type *));
 489     class_hash->table = (unsigned short *)
 490         calloc(HASH_TABLE_SIZE, sizeof(unsigned short));
 491     if (class_hash->buckets == 0 ||
 492         class_hash->table == 0)
 493         CCout_of_memory(context);
 494     class_hash->entries_used = 0;
 495 }
 496 
 497 static void finalize_class_hash(context_type *context)
 498 {
 499     hash_table_type *class_hash = &(context->class_hash);
 500     JNIEnv *env = context->env;
 501     int i;
 502     /* 4296677: bucket index starts from 1. */




  69    JVM_GetCPMethodNameUTF
  70    JVM_GetCPFieldSignatureUTF
  71    JVM_GetCPMethodSignatureUTF
  72    JVM_GetCPFieldClassNameUTF
  73    JVM_GetCPMethodClassNameUTF
  74    JVM_GetCPFieldModifiers
  75    JVM_GetCPMethodModifiers
  76 
  77    JVM_ReleaseUTF
  78    JVM_IsSameClassPackage
  79 
  80  */
  81 
  82 #include <string.h>
  83 #include <setjmp.h>
  84 #include <assert.h>
  85 #include <limits.h>
  86 #include <stdlib.h>
  87 
  88 #include "jni.h"
  89 #include "jni_util.h"
  90 #include "jvm.h"
  91 #include "classfile_constants.h"
  92 #include "opcodes.in_out"
  93 
  94 /* On AIX malloc(0) and calloc(0, ...) return a NULL pointer, which is legal,
  95  * but the code here does not handles it. So we wrap the methods and return non-NULL
  96  * pointers even if we allocate 0 bytes.
  97  */
  98 #ifdef _AIX
  99 static int aix_dummy;
 100 static void* aix_malloc(size_t len) {
 101   if (len == 0) {
 102     return &aix_dummy;
 103   }
 104   return malloc(len);
 105 }
 106 
 107 static void* aix_calloc(size_t n, size_t size) {
 108   if (n == 0) {
 109     return &aix_dummy;


 464 
 465 static void CCerror (context_type *, char *format, ...);
 466 static void CFerror (context_type *, char *format, ...);
 467 static void CCout_of_memory (context_type *);
 468 
 469 /* Because we can longjmp any time, we need to be very careful about
 470  * remembering what needs to be freed. */
 471 
 472 static void check_and_push(context_type *context, const void *ptr, int kind);
 473 static void pop_and_free(context_type *context);
 474 
 475 static int signature_to_args_size(const char *method_signature);
 476 
 477 #ifdef DEBUG
 478 static void print_stack (context_type *, stack_info_type *stack_info);
 479 static void print_registers(context_type *, register_info_type *register_info);
 480 static void print_flags(context_type *, flag_type, flag_type);
 481 static void print_formatted_fieldname(context_type *context, int index);
 482 static void print_formatted_methodname(context_type *context, int index);
 483 #endif
 484 
 485 /*
 486  * Declare library specific JNI_Onload entry if static build
 487  */
 488 DEF_STATIC_JNI_OnLoad
 489 
 490 void initialize_class_hash(context_type *context)
 491 {
 492     hash_table_type *class_hash = &(context->class_hash);
 493     class_hash->buckets = (hash_bucket_type **)
 494         calloc(MAX_HASH_ENTRIES / HASH_ROW_SIZE, sizeof(hash_bucket_type *));
 495     class_hash->table = (unsigned short *)
 496         calloc(HASH_TABLE_SIZE, sizeof(unsigned short));
 497     if (class_hash->buckets == 0 ||
 498         class_hash->table == 0)
 499         CCout_of_memory(context);
 500     class_hash->entries_used = 0;
 501 }
 502 
 503 static void finalize_class_hash(context_type *context)
 504 {
 505     hash_table_type *class_hash = &(context->class_hash);
 506     JNIEnv *env = context->env;
 507     int i;
 508     /* 4296677: bucket index starts from 1. */


< prev index next >