1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 * This source file is part of SableVM. * 3 * * 4 * See the file "LICENSE" for the copyright information and for * 5 * the terms and conditions for copying, distribution and * 6 * modification of this source file. * 7 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 8 9 #ifndef SVM_SABLEVM_H 10 #define SVM_SABLEVM_H 11 12 /* This file is really at the heart of SableVM. It defines the data 13 structures used in SableVM. When looking at the VM for a first 14 time, you should spend some time reading this file. 15 */ 16 17 /* *INDENT-OFF* */ 18 19 typedef struct _svmt_CONSTANT_Class_info_struct _svmt_CONSTANT_Class_info; 20 typedef struct _svmt_CONSTANT_Double_info_struct _svmt_CONSTANT_Double_info; 21 typedef struct _svmt_CONSTANT_Fieldref_info_struct _svmt_CONSTANT_Fieldref_info; 22 typedef struct _svmt_CONSTANT_Float_info_struct _svmt_CONSTANT_Float_info; 23 typedef struct _svmt_CONSTANT_Integer_info_struct _svmt_CONSTANT_Integer_info; 24 typedef struct _svmt_CONSTANT_InterfaceMethodref_info_struct _svmt_CONSTANT_InterfaceMethodref_info; 25 typedef struct _svmt_CONSTANT_Long_info_struct _svmt_CONSTANT_Long_info; 26 typedef struct _svmt_CONSTANT_Methodref_info_struct _svmt_CONSTANT_Methodref_info; 27 typedef struct _svmt_CONSTANT_NameAndType_info_struct _svmt_CONSTANT_NameAndType_info; 28 typedef struct _svmt_CONSTANT_String_info_struct _svmt_CONSTANT_String_info; 29 typedef struct _svmt_CONSTANT_Utf8_info_struct _svmt_CONSTANT_Utf8_info; 30 typedef struct _svmt_Code_attribute_struct _svmt_Code_attribute; 31 typedef struct _svmt_ConstantValue_attribute_struct _svmt_ConstantValue_attribute; 32 typedef struct _svmt_Deprecated_attribute_struct _svmt_Deprecated_attribute; 33 typedef struct _svmt_Exceptions_attribute_struct _svmt_Exceptions_attribute; 34 typedef struct _svmt_InnerClasses_attribute_struct _svmt_InnerClasses_attribute; 35 typedef struct _svmt_JNIEnv_struct _svmt_JNIEnv; 36 typedef struct _svmt_JavaVM_struct _svmt_JavaVM; 37 typedef struct _svmt_LineNumberTable_attribute_struct _svmt_LineNumberTable_attribute; 38 typedef struct _svmt_LocalVariableTable_attribute_struct _svmt_LocalVariableTable_attribute; 39 typedef struct _svmt_SourceFile_attribute_struct _svmt_SourceFile_attribute; 40 typedef struct _svmt_Synthetic_attribute_struct _svmt_Synthetic_attribute; 41 typedef struct _svmt_arg_preparation_struct _svmt_arg_preparation; 42 typedef struct _svmt_array_info_struct _svmt_array_info; 43 typedef struct _svmt_array_instance_struct _svmt_array_instance; 44 typedef struct _svmt_attribute_info_struct _svmt_attribute_info; 45 typedef struct _svmt_zip_file_struct _svmt_zip_file; 46 typedef struct _svmt_zip_file_entry_struct _svmt_zip_file_entry; 47 typedef struct _svmt_boot_class_path_entry_struct _svmt_boot_class_path_entry; 48 typedef struct _svmt_bootstrap_classloader_struct _svmt_bootstrap_classloader; 49 typedef struct _svmt_branch_preparation_struct _svmt_branch_preparation; 50 typedef struct _svmt_bytecode_info_struct _svmt_bytecode_info; 51 typedef struct _svmt_class_field_data_struct _svmt_class_field_data; 52 typedef struct _svmt_class_file_struct _svmt_class_file; 53 typedef struct _svmt_class_info_struct _svmt_class_info; 54 typedef struct _svmt_class_loader_info_struct _svmt_class_loader_info; 55 typedef struct _svmt_class_loading_struct _svmt_class_loading; 56 typedef struct _svmt_classes_struct _svmt_classes; 57 typedef struct _svmt_cp_info_struct _svmt_cp_info; 58 typedef struct _svmt_exception_table_struct _svmt_exception_table; 59 typedef struct _svmt_fat_lock_struct _svmt_fat_lock; 60 typedef struct _svmt_fat_locks_struct _svmt_fat_locks; 61 typedef struct _svmt_field_info_struct _svmt_field_info; 62 typedef struct _svmt_fieldref_preparation_struct _svmt_fieldref_preparation; 63 typedef struct _svmt_fields_struct _svmt_fields; 64 typedef struct _svmt_free_block_struct _svmt_free_block; 65 typedef struct _svmt_gc_map_node_struct _svmt_gc_map_node; 66 typedef struct _svmt_heap_struct _svmt_heap; 67 typedef struct _svmt_imethodref_preparation_struct _svmt_imethodref_preparation; 68 typedef struct _svmt_initialization_struct _svmt_initialization; 69 typedef struct _svmt_inner_classes_struct _svmt_inner_classes; 70 typedef struct _svmt_instance_field_data_struct _svmt_instance_field_data; 71 typedef struct _svmt_instanceof_info_struct _svmt_instanceof_info; 72 typedef struct _svmt_instances_struct _svmt_instances; 73 typedef struct _svmt_instruction_info_struct _svmt_instruction_info; 74 typedef struct _svmt_instruction_preparation_struct _svmt_instruction_preparation; 75 typedef struct _svmt_interface_class_data_struct _svmt_interface_class_data; 76 typedef struct _svmt_imethod_signature_node_struct _svmt_imethod_signature_node; 77 typedef struct _svmt_internal_method_node_struct _svmt_internal_method_node; 78 typedef struct _svmt_ldc_preparation_struct _svmt_ldc_preparation; 79 typedef struct _svmt_line_number_table_struct _svmt_line_number_table; 80 typedef struct _svmt_local_preparation_struct _svmt_local_preparation; 81 typedef struct _svmt_local_split_struct _svmt_local_split; 82 typedef struct _svmt_local_variable_table_struct _svmt_local_variable_table; 83 typedef struct _svmt_memory_block_struct _svmt_memory_block; 84 typedef struct _svmt_method_frame_info_struct _svmt_method_frame_info; 85 typedef struct _svmt_method_info_struct _svmt_method_info; 86 typedef struct _svmt_method_preparation_struct _svmt_method_preparation; 87 typedef struct _svmt_methodref_preparation_struct _svmt_methodref_preparation; 88 typedef struct _svmt_methods_struct _svmt_methods; 89 typedef struct _svmt_native_globals_struct _svmt_native_globals; 90 typedef struct _svmt_native_library_struct _svmt_native_library; 91 typedef struct _svmt_native_locals_struct _svmt_native_locals; 92 typedef struct _svmt_native_method_data_struct _svmt_native_method_data; 93 typedef struct _svmt_native_ref_struct _svmt_native_ref; 94 typedef struct _svmt_noninterface_class_data_struct _svmt_noninterface_class_data; 95 typedef struct _svmt_object_instance_struct _svmt_object_instance; 96 typedef struct _svmt_sequence_node_struct _svmt_sequence_node; 97 typedef struct _svmt_stack_and_local_map_struct _svmt_stack_and_local_map; 98 typedef struct _svmt_stack_frame_struct _svmt_stack_frame; 99 typedef struct _svmt_stack_struct _svmt_stack; 100 typedef struct _svmt_system_properties_struct _svmt_system_properties; 101 typedef struct _svmt_thread_struct _svmt_thread; 102 typedef struct _svmt_threads_struct _svmt_threads; 103 typedef struct _svmt_type_info_struct _svmt_type_info; 104 typedef struct _svmt_type_node_struct _svmt_type_node; 105 typedef struct _svmt_unknown_attribute_struct _svmt_unknown_attribute; 106 typedef struct _svmt_vtable_struct _svmt_vtable; 107 typedef union _svmt_code_union _svmt_code; 108 typedef union _svmt_stack_native_reference_union _svmt_stack_native_reference; 109 typedef union _svmt_stack_value_union _svmt_stack_value; 110 111 #ifdef _SABLEVM_INLINABILITY_TESTING 112 typedef struct _svmt_inlinability_testing_struct _svmt_inlinability_testing; 113 #endif 114 115 /* *INDENT-ON* */ 116 117 /* 118 ---------------------------------------------------------------------- 119 _svmt_thread 120 ---------------------------------------------------------------------- 121 */ 122 123 struct _svmt_thread_struct 124 { 125 pthread_t pthread; 126 jint id; 127 _svmt_word thinlock_id; 128 jboolean is_daemon; 129 jobject thread_instance; 130 131 /* We need these for Thread.interrupt() implementation. 132 * They are "volatile" because we set/read it from different threads 133 * sometimes w/o help of atomic compare&swap. */ 134 135 /* see SVM_THREAD* flags in constants.h */ 136 volatile _svmt_word interrupted_status; 137 /* if != NULL then thread is sleeping on it */ 138 _svmt_fat_lock *volatile sleeping_on_fat_lock; 139 }; 140 141 /* 142 ---------------------------------------------------------------------- 143 _svmt_native_locals 144 ---------------------------------------------------------------------- 145 */ 146 147 struct _svmt_native_locals_struct 148 { 149 _svmt_native_ref *list; 150 _svmt_native_ref *free_list; 151 }; 152 153 /* 154 ---------------------------------------------------------------------- 155 _svmt_stack 156 ---------------------------------------------------------------------- 157 */ 158 159 struct _svmt_stack_struct 160 { 161 /* each thread has a single contiguous "Java stack", that can grow 162 (thus it can move around) */ 163 void *start; 164 void *end; 165 166 _svmt_stack_frame *current_frame; 167 }; 168 169 /* 170 ---------------------------------------------------------------------- 171 _svmt_inlinability_testing 172 ---------------------------------------------------------------------- 173 */ 174 175 #ifdef _SABLEVM_INLINABILITY_TESTING 176 177 struct _svmt_inlinability_testing_struct 178 { 179 jbyte bytecode_inlinability[SVM_INSTRUCTION_COUNT]; 180 jbyte bytecode_recognizability[SVM_INSTRUCTION_COUNT]; 181 jboolean ever_used; 182 jint last_signal; 183 volatile jint sigsegv_expected; 184 }; 185 186 #endif 187 188 /* 189 ---------------------------------------------------------------------- 190 _svmt_JNIEnv 191 ---------------------------------------------------------------------- 192 */ 193 194 struct _svmt_JNIEnv_struct 195 { 196 const JNINativeInterface *interface; /* This must be first for JNI */ 197 198 _svmt_JavaVM *vm; 199 200 _svmt_JNIEnv *previous; /* for threads (doubly-linked) list */ 201 _svmt_JNIEnv *next; 202 203 jboolean is_alive; 204 205 _svmt_thread thread; 206 _svmt_native_locals native_locals; 207 _svmt_stack stack; 208 209 210 /* "throwable" is a pre-allocated native ref pointing to: 211 - NULL when there's no pending error/exception 212 - a throwable object otherwise. 213 */ 214 jthrowable throwable; 215 216 /* number of time a "critical" JNI function was entered */ 217 jint critical_section_count; 218 219 #if defined(_SABLEVM_SIGNALS_FOR_EXCEPTIONS) || defined(_SABLEVM_INLINABILITY_TESTING) 220 221 /* We maintain a pointer to the innermost exception handler. 222 If an error/exception signal happens, we jump to it. The 223 signal handler DOES NOT create/set "throwable"; it only 224 sets "signal_code" to the appropriate value, and delegates 225 to the exception handler the delicate task of actually 226 creating a throwable object. 227 */ 228 sigjmp_buf *volatile signal_handler; 229 volatile jint signal_code; 230 231 #ifndef NDEBUG 232 233 volatile jint sigsegv_expected; 234 volatile jint sigfpe_expected; 235 236 #endif /* not NDEBUG */ 237 238 #ifdef _SABLEVM_INLINABILITY_TESTING 239 240 _svmt_inlinability_testing inlinability_testing; 241 242 #endif 243 244 #endif /* _SABLEVM_SIGNALS_FOR_EXCEPTIONS || _SABLEVM_INLINABILITY_TESTING */ 245 246 /* fields for "stop_the_world" and "suspend" operations */ 247 volatile _svmt_word thread_status; 248 249 /* flags used to indicate the reason why a thread status is not 250 RUNNING_JAVA or NOT_RUNNING_JAVA_RESUMING_ALLOWED. Access to 251 this variable should be protected by the global mutex. */ 252 jint status_flags; 253 254 /* condition variable used by this thread to wake up from 255 stop_the_world and suspend operations */ 256 pthread_cond_t wakeup_cond; 257 258 struct 259 { 260 /* list of threads that have requested the suspension of this 261 thread. Protected by global mutex. */ 262 _svmt_JNIEnv *suspender_list; 263 264 /* points to the next thread when this thread is in the 265 suspender_list of another thread. */ 266 _svmt_JNIEnv *suspender_list_next; 267 268 /* condition variable used by this thread to receive suspension 269 notifications */ 270 pthread_cond_t cond; 271 } 272 suspension; 273 274 /* fields for dealing with thinlock contention */ 275 struct 276 { 277 struct 278 { 279 pthread_mutex_t mutex; 280 volatile _svmt_word flag; /* 0: no contention, 1: contention */ 281 282 _svmt_JNIEnv *wait_list; 283 } 284 owner; 285 286 struct 287 { 288 pthread_cond_t cond; 289 290 jobject jobject; 291 _svmt_JNIEnv *wait_list_next; 292 } 293 requester; 294 } 295 contention; 296 297 /* we use 1 bit per error type to avoid recursively 298 creating the same error. In other words, we don't like 299 things like an OutOfMemoryError triggering the creation 300 of another OutOfMemoryError. When such a thing happens, 301 we simply return a "pre-instantiated" error object, which 302 stops this nasty type of recursion. 303 304 Of course, we use m4 to nicely generate the stuff for us. Much 305 better than hand coding, for maintenance;-). Who was it that 306 said that m4 can be addictive? I think it was written in the m4 307 "info" pages... 308 */ 309 310 #include "error_bits.h" 311 312 #ifndef NDEBUG 313 314 struct 315 { 316 jint last_index; 317 struct 318 { 319 const char *action; 320 const char *file; 321 const char *func; 322 int line; 323 _svmt_word entry; 324 _svmt_word exit; 325 } info[SVM_STOP_RESUME_TRACE_SIZE]; 326 } stop_resume; 327 328 #endif 329 330 }; 331 332 /* 333 ---------------------------------------------------------------------- 334 _svmt_classes 335 ---------------------------------------------------------------------- 336 */ 337 struct _svmt_classes_struct 338 { 339 _svmt_class_info *jiserializable; 340 _svmt_class_info *jlclass; 341 _svmt_class_info *jlcloneable; 342 _svmt_class_info *jlobject; 343 _svmt_class_info *jlrconstructor; 344 _svmt_class_info *jlrfield; 345 _svmt_class_info *jlrinvocationtargetexception; 346 _svmt_class_info *jlrmethod; 347 _svmt_class_info *jlstacktraceelement; 348 _svmt_class_info *jlvmclass; 349 _svmt_class_info *niobytebuffervm; 350 _svmt_class_info *stringcreator; 351 _svmt_class_info *virtualmachine; 352 353 _svmt_array_info *jlrfield_array; 354 355 /* primitive arrays */ 356 _svmt_array_info *boolean_array; 357 _svmt_array_info *byte_array; 358 _svmt_array_info *short_array; 359 _svmt_array_info *char_array; 360 _svmt_array_info *int_array; 361 _svmt_array_info *long_array; 362 _svmt_array_info *float_array; 363 _svmt_array_info *double_array; 364 365 #include "error_classes.h" 366 367 }; 368 369 /* 370 ---------------------------------------------------------------------- 371 _svmt_methods 372 ---------------------------------------------------------------------- 373 */ 374 375 struct _svmt_methods_struct 376 { 377 _svmt_method_info *jlclass_init; 378 _svmt_method_info *jlclass_init_primitive; 379 _svmt_method_info *jlclass_initialize; 380 _svmt_method_info *jlrconstructor_init; 381 _svmt_method_info *jlrfield_init; 382 _svmt_method_info *jlrinvocationtargetexception_init; 383 _svmt_method_info *jlrmethod_init; 384 _svmt_method_info *jlstacktraceelement_init; 385 _svmt_method_info *stringcreator_createinternedstring; 386 _svmt_method_info *stringcreator_createstring; 387 _svmt_method_info *stringcreator_createstringfromchars; 388 _svmt_method_info *stringcreator_getchars; 389 _svmt_method_info *stringcreator_getlength; 390 _svmt_method_info *stringcreator_getutfchars; 391 _svmt_method_info *stringcreator_getutflength; 392 _svmt_method_info *virtualmachine_createarray; 393 _svmt_method_info *virtualmachine_createclass; 394 _svmt_method_info *virtualmachine_createrootthread; 395 _svmt_method_info *virtualmachine_exceptiondescribe; 396 _svmt_method_info *virtualmachine_exceptiondescription; 397 _svmt_method_info *virtualmachine_exceptiontruncateddescription; 398 _svmt_method_info *virtualmachine_getsystemcl; 399 _svmt_method_info *virtualmachine_runthread; 400 _svmt_method_info *niobytebuffervm_getcapacity; 401 402 #if SVM_WORD_BIT_COUNT == 32 403 _svmt_method_info *niobytebuffervm_newbuffer32; 404 _svmt_method_info *niobytebuffervm_getaddress32; 405 #elif SVM_WORD_BIT_COUNT == 64 406 _svmt_method_info *niobytebuffervm_newbuffer64; 407 _svmt_method_info *niobytebuffervm_getaddress64; 408 #endif 409 410 #include "error_init_methods.h" 411 412 }; 413 414 /* 415 ---------------------------------------------------------------------- 416 _svmt_fields 417 ---------------------------------------------------------------------- 418 */ 419 420 struct _svmt_fields_struct 421 { 422 _svmt_field_info *jlclass_vmdata; 423 _svmt_field_info *jlrfield_vmdata; 424 _svmt_field_info *jlrmethod_vmdata; 425 _svmt_field_info *jlrconstructor_vmdata; 426 _svmt_field_info *jlstacktraceelement_next; 427 _svmt_field_info *jlstacktraceelement_length; 428 }; 429 430 /* 431 ---------------------------------------------------------------------- 432 _svmt_instances 433 ---------------------------------------------------------------------- 434 */ 435 436 struct _svmt_instances_struct 437 { 438 jobject boolean_type; 439 jobject byte_type; 440 jobject short_type; 441 jobject char_type; 442 jobject int_type; 443 jobject long_type; 444 jobject float_type; 445 jobject double_type; 446 jobject void_type; 447 448 #include "error_instances.h" 449 }; 450 451 /* 452 ---------------------------------------------------------------------- 453 _svmt_system_properties 454 ---------------------------------------------------------------------- 455 */ 456 457 struct _svmt_system_properties_struct 458 { 459 jint count; 460 461 char **properties; 462 }; 463 464 /* 465 ---------------------------------------------------------------------- 466 _svmt_class_file 467 ---------------------------------------------------------------------- 468 */ 469 470 struct _svmt_class_file_struct 471 { 472 jint length; 473 jboolean free_bytes_after_use; 474 _svmt_u8 *bytes; 475 }; 476 477 /* 478 ---------------------------------------------------------------------- 479 _svmt_zip_file_struct 480 ---------------------------------------------------------------------- 481 */ 482 483 struct _svmt_zip_file_struct 484 { 485 int fd; 486 char *name; 487 _svmt_u32 file_len; 488 _svmt_u8 *content; /* mmaped */ 489 _svmt_u16 entries_no; 490 _svmt_zip_file_entry *entries; 491 }; 492 493 /* 494 ---------------------------------------------------------------------- 495 _svmt_zip_file_entry_struct 496 ---------------------------------------------------------------------- 497 */ 498 499 struct _svmt_zip_file_entry_struct 500 { 501 char *name; 502 _svmt_u32 local_header_offset; 503 _svmt_u32 size_compressed; 504 _svmt_u32 size_uncompressed; 505 _svmt_u32 compression_method; 506 }; 507 508 /* 509 ---------------------------------------------------------------------- 510 _svmt_boot_class_path_entry 511 ---------------------------------------------------------------------- 512 */ 513 514 struct _svmt_boot_class_path_entry_struct 515 { 516 jboolean is_valid; /* non-existan dir/files, or non-zip files get this flag set */ 517 jboolean is_file; /* class_path should point to a directory or zip/jar file */ 518 char *class_path; 519 _svmt_zip_file *zip_file; /* only if not NULL for non-zip/jar class_path */ 520 }; 521 522 /* 523 ---------------------------------------------------------------------- 524 _svmt_bootstrap_classloader 525 ---------------------------------------------------------------------- 526 */ 527 528 struct _svmt_bootstrap_classloader_struct 529 { 530 char *boot_class_path, *boot_class_path_prepend, *boot_class_path_append; 531 char *boot_library_path; 532 533 /* boot_class_path split in elements separated by ':' */ 534 _svmt_boot_class_path_entry *boot_class_path_entries; 535 jint boot_class_path_entries_no; 536 537 /* system properties received through the VM creation structure. */ 538 _svmt_system_properties system_properties; 539 540 _svmt_classes classes; 541 _svmt_methods methods; 542 _svmt_fields fields; 543 _svmt_instances instances; 544 545 _svmt_type_node *initiated_type_tree; 546 _svmt_type_node *partially_derived_type_tree; 547 548 _svmt_internal_method_node *internal_method_tree; 549 550 _svmt_class_loader_info *class_loader_info; 551 }; 552 553 /* 554 ---------------------------------------------------------------------- 555 _svmt_arg_preparation 556 ---------------------------------------------------------------------- 557 */ 558 559 struct _svmt_arg_preparation_struct 560 { 561 jint index; 562 }; 563 564 /* 565 ---------------------------------------------------------------------- 566 _svmt_branch_preparation 567 ---------------------------------------------------------------------- 568 */ 569 570 struct _svmt_branch_preparation_struct 571 { 572 _svmt_instruction_preparation *target; 573 }; 574 575 /* 576 ---------------------------------------------------------------------- 577 _svmt_ldc_preparation 578 ---------------------------------------------------------------------- 579 */ 580 581 struct _svmt_ldc_preparation_struct 582 { 583 _svmt_CONSTANT_String_info *stringref_info; /* is not NULL if this 584 is an ldc[_w] 585 String */ 586 }; 587 588 /* 589 ---------------------------------------------------------------------- 590 _svmt_fieldref_preparation 591 ---------------------------------------------------------------------- 592 */ 593 594 struct _svmt_fieldref_preparation_struct 595 { 596 _svmt_CONSTANT_Fieldref_info *info; 597 }; 598 599 /* 600 ---------------------------------------------------------------------- 601 _svmt_methodref_preparation 602 ---------------------------------------------------------------------- 603 */ 604 605 struct _svmt_methodref_preparation_struct 606 { 607 _svmt_CONSTANT_Methodref_info *info; 608 }; 609 610 /* 611 ---------------------------------------------------------------------- 612 _svmt_imethodref_preparation 613 ---------------------------------------------------------------------- 614 */ 615 616 struct _svmt_imethodref_preparation_struct 617 { 618 _svmt_CONSTANT_InterfaceMethodref_info *info; 619 }; 620 621 /* 622 ---------------------------------------------------------------------- 623 _svmt_gc_map_node 624 ---------------------------------------------------------------------- 625 */ 626 627 struct _svmt_gc_map_node_struct 628 { 629 jint size; /* number of bits */ 630 _svmt_u8 *bits; /* NULL when size is 0 */ 631 632 _svmt_gc_map_node *parent; 633 _svmt_gc_map_node *left; 634 _svmt_gc_map_node *right; 635 }; 636 637 /* 638 ---------------------------------------------------------------------- 639 _svmt_stack_and_local_map 640 ---------------------------------------------------------------------- 641 */ 642 643 struct _svmt_stack_and_local_map_struct 644 { 645 jint stack_size; 646 jint *stack; 647 jint *locals; 648 _svmt_stack_and_local_map *free_list_next; 649 }; 650 651 /* 652 ---------------------------------------------------------------------- 653 _svmt_code 654 ---------------------------------------------------------------------- 655 */ 656 657 union _svmt_code_union 658 { 659 #if defined (_SABLEVM_INLINED_THREADED_INTERPRETER) || defined (_SABLEVM_DIRECT_THREADED_INTERPRETER) 660 const void *implementation; 661 #endif 662 663 _svmt_CONSTANT_Class_info *classref_info; 664 _svmt_CONSTANT_String_info *stringref_info; 665 _svmt_CONSTANT_Fieldref_info *fieldref_info; 666 _svmt_CONSTANT_Methodref_info *methodref_info; 667 _svmt_CONSTANT_InterfaceMethodref_info *imethodref_info; 668 _svmt_gc_map_node *stack_gc_map; 669 670 _svmt_method_info *method_info; 671 _svmt_type_info *type_info; 672 _svmt_class_info *class_info; 673 _svmt_array_info *array_info; 674 675 _svmt_code *addr; 676 size_t offset; 677 678 jint jint; 679 jfloat jfloat; 680 681 jlong *pjlong; 682 jdouble *pjdouble; 683 684 jvalue *pvalue; 685 686 jobject jobject; 687 }; 688 689 /* 690 ---------------------------------------------------------------------- 691 _svmt_instruction_preparation 692 ---------------------------------------------------------------------- 693 */ 694 695 struct _svmt_instruction_preparation_struct 696 { 697 unsigned reaches_gc_site:1; /* true if instruction is 698 unconditionally followed by a gc 699 check */ 700 701 unsigned reachable:1; /* true if there is a path that 702 reaches this instruction */ 703 704 unsigned addr_stack_top:1; /* true if this is an "astore" and 705 stack top holds an address */ 706 707 unsigned is_backward_branch_target:1; 708 unsigned is_backward_switch_target:1; 709 unsigned has_backward_target:1; 710 711 #if defined (_SABLEVM_INLINED_THREADED_INTERPRETER) 712 unsigned is_sequence_head:1; 713 unsigned is_sequence_tail:1; 714 unsigned sequence_contains_resolution:1; 715 unsigned is_sequence_last_resolution:1; 716 #endif 717 718 jint bc_pc; /* position in the bytecode array */ 719 jint bc_length; /* length in the bytecode array */ 720 721 size_t code_offset; /* offset of instruction in code 722 array */ 723 size_t code_length; /* length of instruction in code 724 array */ 725 726 #if defined (_SABLEVM_INLINED_THREADED_INTERPRETER) 727 size_t sequence_length; /* number of instructions in sequence */ 728 size_t sequence_size; /* implementation size */ 729 #endif 730 731 size_t prepare_offset; 732 size_t prepare_length; 733 734 jint code; /* code translation of bytecode 735 instruction */ 736 737 _svmt_stack_and_local_map *stack_and_local_map; 738 _svmt_gc_map_node *stack_gc_map; 739 740 /* fields for subroutine head */ 741 _svmt_instruction_preparation *ret; 742 _svmt_instruction_preparation *unprocessed_callers; 743 744 /* field for jsr */ 745 _svmt_instruction_preparation *next_unprocessed_caller; 746 747 /* for work list */ 748 _svmt_instruction_preparation *work_list_next; 749 750 union 751 { 752 _svmt_arg_preparation arg; 753 _svmt_branch_preparation branch; 754 _svmt_ldc_preparation ldc; 755 _svmt_fieldref_preparation fieldref; 756 _svmt_methodref_preparation methodref; 757 _svmt_imethodref_preparation imethodref; 758 } 759 data; 760 }; 761 762 /* 763 ---------------------------------------------------------------------- 764 _svmt_local_preparation 765 ---------------------------------------------------------------------- 766 */ 767 768 struct _svmt_local_preparation_struct 769 { 770 unsigned method_arg_type:2; /* 0:none, 1:ref, 2:non_ref */ 771 772 unsigned used_as_ref:1; 773 unsigned used_as_non_ref:1; 774 unsigned used_as_long:1; /* first word of local pair */ 775 776 jint ref_index; 777 jint non_ref_index; 778 jint long_index; 779 }; 780 781 /* 782 ---------------------------------------------------------------------- 783 _svmt_method_preparation 784 ---------------------------------------------------------------------- 785 */ 786 787 struct _svmt_method_preparation_struct 788 { 789 jint *instruction_indices; 790 791 jint instruction_count; 792 _svmt_instruction_preparation *instructions; 793 794 _svmt_local_preparation *locals; 795 _svmt_stack_and_local_map *free_list; 796 797 _svmt_sequence_node *sequence; 798 799 size_t code_length; 800 }; 801 802 /* 803 ---------------------------------------------------------------------- 804 _svmt_class_loading 805 ---------------------------------------------------------------------- 806 */ 807 808 struct _svmt_class_loading_struct 809 { 810 _svmt_class_loader_info *class_loader_list; 811 _svmt_bootstrap_classloader boot_loader; 812 813 jint next_interface_id; 814 jint next_interface_method_id; 815 _svmt_imethod_signature_node *interface_method_signature_tree; 816 817 _svmt_method_preparation method_preparation; 818 _svmt_gc_map_node *gc_map_tree; 819 #if defined (_SABLEVM_INLINED_THREADED_INTERPRETER) 820 _svmt_sequence_node *sequence_tree; 821 #endif 822 }; 823 824 /* 825 ---------------------------------------------------------------------- 826 _svmt_threads 827 ---------------------------------------------------------------------- 828 */ 829 830 struct _svmt_threads_struct 831 { 832 jint next_thread_id; /* no thread should have id = 0 (for thin 833 locks to work) */ 834 835 _svmt_JNIEnv **array; /* Array of all JNIEnv structures indexed according to 836 their thread.id */ 837 838 _svmt_JNIEnv *user; /* user thread list */ 839 _svmt_JNIEnv *system; /* system thread list */ 840 841 _svmt_JNIEnv *free_list; /* freed JNIEnv structures, for recycling */ 842 843 pthread_cond_t vm_destruction_cond; 844 }; 845 846 /* 847 ---------------------------------------------------------------------- 848 _svmt_native_globals 849 ---------------------------------------------------------------------- 850 */ 851 852 struct _svmt_native_globals_struct 853 { 854 _svmt_native_ref *list; /* list of all global refs currently in use */ 855 _svmt_native_ref *free_list; 856 }; 857 858 /* 859 ---------------------------------------------------------------------- 860 _svmt_remember_set 861 ---------------------------------------------------------------------- 862 */ 863 #if defined (_SABLEVM_GENCOPY_GC) 864 struct _svmt_remember_set_struct 865 { 866 struct _svmt_remember_set_struct *next; 867 void *ref_hash[SVM_HEAP_REMSET_BUCKET_NUM][SVM_HEAP_REMSET_BUCKET_SIZE]; 868 }; 869 870 typedef struct _svmt_remember_set_struct _svmt_remember_set; 871 #endif /* _SABLEVM_GENCOPY_GC */ 872 873 /* 874 ---------------------------------------------------------------------- 875 _svmt_heap 876 ---------------------------------------------------------------------- 877 */ 878 879 struct _svmt_heap_struct 880 { 881 #if defined (_SABLEVM_NO_GC) 882 883 size_t size; 884 885 void *start; 886 void *end; 887 888 void *alloc; /* current allocation position */ 889 jint hashcode_base; 890 891 #elif defined (_SABLEVM_COPY_GC) || defined (_SABLEVM_GENCOPY_GC) 892 893 size_t min_size; 894 size_t max_size; /* 0 means no max */ 895 size_t allocation_increment; /* 0 means fixed size */ 896 897 void *start; 898 void *end; 899 900 void *alloc; /* current allocation position */ 901 jint hashcode_base; 902 size_t hashed_notmoved; /* number of objects that will inflate on next GC */ 903 904 size_t suggested_next_heap_size; /* for variable size heap */ 905 void *next_heap; /* for fixed size heap */ 906 907 long total_gc_secs; 908 long total_gc_usecs; 909 910 #if defined (_SABLEVM_GENCOPY_GC) 911 912 int global_gc; 913 914 size_t nursery_size; 915 void *nursery_start; 916 void *nursery_end; 917 void *nursery_alloc; 918 919 size_t large_object_size; 920 921 _svmt_remember_set remember_set; 922 923 jint hashcode_base_nursery; 924 size_t hashed_notmoved_nursery; /* number of objects that will inflate on next Local GC */ 925 926 #endif /* defined (_SABLEVM_GENCOPY_GC) */ 927 #endif /* defined (_SABLEVM_NO_GC) */ 928 }; 929 930 /* 931 ---------------------------------------------------------------------- 932 _svmt_instruction_info 933 ---------------------------------------------------------------------- 934 */ 935 936 struct _svmt_instruction_info_struct 937 { 938 _svmt_code code; 939 jint param_count; /* number of arguments to the original bytecode instruction */ 940 #if defined (_SABLEVM_INLINED_THREADED_INTERPRETER) 941 jint flag; 942 _svmt_code inlined_code; 943 size_t inlined_size; 944 #endif 945 #if !defined(NDEBUG) || defined (_SABLEVM_INLINED_THREADED_INTERPRETER) 946 /* See comment about static allocation in inlined_testing.c file. */ 947 char name[_SABLEVM_BYTECODE_NAME_MAX_LENGTH]; 948 #endif 949 }; 950 951 /* 952 ---------------------------------------------------------------------- 953 _svmt_method_frame_info 954 ---------------------------------------------------------------------- 955 */ 956 957 struct _svmt_method_frame_info_struct 958 { 959 /* The actual sablevm internal code array */ 960 _svmt_code *code; 961 962 /* number of non-parameter reference local variables */ 963 jint non_parameter_ref_locals_count; 964 965 size_t start_offset; 966 size_t end_offset; 967 968 size_t java_invoke_frame_size; 969 size_t internal_invoke_frame_size; 970 971 #ifdef STATISTICS 972 973 size_t local_count; 974 size_t local_split_count; 975 976 #endif 977 }; 978 979 /* 980 ---------------------------------------------------------------------- 981 _svmt_method_info 982 ---------------------------------------------------------------------- 983 */ 984 985 struct _svmt_method_info_struct 986 { 987 jint access_flags; 988 _svmt_CONSTANT_Utf8_info **name; 989 _svmt_CONSTANT_Utf8_info **descriptor; 990 991 jint attributes_count; 992 _svmt_attribute_info **attributes; 993 994 _svmt_class_info *class_info; 995 996 jint method_id; 997 998 jint synchronized; /* yes = 1; no = 0 */ 999 jint java_args_count; /* int,ref,boolean,... = 1; double, long = 2 */ 1000 _svmt_gc_map_node *parameters_gc_map; 1001 1002 _svmt_method_frame_info *frame_info; 1003 1004 _svmt_method_frame_info prepared_info; 1005 _svmt_method_frame_info non_prepared_info; 1006 1007 jobject reflection_instance; 1008 1009 union 1010 { 1011 _svmt_Code_attribute *code_attribute; 1012 _svmt_native_method_data *native_method; 1013 } 1014 data; 1015 }; 1016 1017 /* 1018 ---------------------------------------------------------------------- 1019 _svmt_fat_locks 1020 ---------------------------------------------------------------------- 1021 */ 1022 1023 struct _svmt_fat_locks_struct 1024 { 1025 jint next_fat_lock_id; 1026 1027 _svmt_fat_lock **array; 1028 1029 _svmt_fat_lock *free_list; 1030 }; 1031 1032 /* 1033 ---------------------------------------------------------------------- 1034 _svmt_JavaVM 1035 ---------------------------------------------------------------------- 1036 */ 1037 1038 struct _svmt_JavaVM_struct 1039 { 1040 const JNIInvokeInterface *interface; /* This must be first for JNI */ 1041 1042 /* hooks into the linked list of created vms */ 1043 _svmt_JavaVM *previous; 1044 _svmt_JavaVM *next; 1045 1046 /* The initialization ptr is non-NULL during vm initialization. 1047 The vm is guaranteed to be single threaded as long as 1048 (initialization != NULL). [Please make sure you don't 1049 break this rule if you modify SableVM]. 1050 */ 1051 _svmt_initialization *initialization; 1052 1053 /* mutex used to synchronize for global operations like stoppping the world */ 1054 pthread_mutex_t global_mutex; 1055 1056 /* stop-the-world fields */ 1057 struct 1058 { 1059 jint pending_halt_thread_count; 1060 pthread_cond_t requesting_thread_cond; 1061 } 1062 stop_the_world; 1063 1064 /* raw instruction pointer array */ 1065 _svmt_instruction_info *instructions; /* [SVM_INSTRUCTION_COUNT]; */ 1066 1067 /* special methods */ 1068 _svmt_method_info stack_bottom_method; 1069 _svmt_method_info internal_call_method; 1070 _svmt_method_info vm_initiated_call_method; 1071 1072 /* class loading related data */ 1073 _svmt_class_loading class_loading; 1074 1075 /* threads */ 1076 _svmt_threads threads; 1077 1078 /* fat_locks */ 1079 _svmt_fat_locks fat_locks; 1080 1081 /* global data */ 1082 _svmt_native_globals native_globals; 1083 _svmt_heap heap; 1084 1085 /* function pointers received through JNI */ 1086 1087 int (*vfprintf) (FILE *stream, const char *format, va_list ap); 1088 void (*exit) (int status); 1089 void (*abort) (void); 1090 const char *boot_working_directory; 1091 1092 /* global options */ 1093 1094 jboolean verbose_class; 1095 jboolean verbose_gc; 1096 jboolean verbose_jni; 1097 1098 jboolean enforce_structured_locking; 1099 1100 #if !defined(NDEBUG) 1101 1102 jboolean verbose_exceptions; /* dump stack trace for every thrown exception */ 1103 jboolean exit_stack_trace; /* dump stack trace on java.lang.Runtime.exit() */ 1104 1105 #endif 1106 1107 #if !defined(NDEBUG) || defined(_SABLEVM_VERBOSE_INSTRUCTIONS_INLINED) 1108 1109 jboolean verbose_methods; 1110 jboolean verbose_instructions; 1111 jboolean verbose_synchronization; 1112 1113 #endif 1114 1115 #ifdef STATISTICS 1116 1117 size_t class_count; /* number of prepared classes */ 1118 size_t interface_count; 1119 size_t array_count; 1120 size_t method_count; /* number of prepared methods */ 1121 size_t bytecode_instruction_count; /* number of prepared bytecode instructions */ 1122 size_t bytecode_count; /* number of prepared bytecodes */ 1123 size_t code_size; /* size of code arrays in bytes (prepared methods) */ 1124 1125 size_t max_stack_size; /* max stack size in bytes */ 1126 size_t stack_local_count; /* locals count on stack */ 1127 size_t stack_local_split_count; /* Number of split locals on stack */ 1128 1129 /* sparse interface virtual tables */ 1130 size_t total_ivtables; /* size */ 1131 size_t total_holes; /* size */ 1132 size_t total_lost_holes; /* size that have leaked out of the class 1133 loader's free_blocks array */ 1134 1135 /* gc maps */ 1136 size_t total_gc_maps_size; 1137 size_t total_gc_maps_count; 1138 size_t check_points_count; 1139 1140 /* locals */ 1141 size_t total_orig_locals_count; 1142 size_t total_unused_locals_count; 1143 size_t total_added_locals_count; 1144 1145 #if defined (_SABLEVM_INLINED_THREADED_INTERPRETER) 1146 1147 /* inlined threads */ 1148 size_t distinct_inlined_threads_count; 1149 size_t total_distinct_thread_bc_length; 1150 size_t total_distinct_thread_inlined_length; 1151 1152 size_t inlined_threads_count; 1153 size_t total_thread_bc_length; 1154 size_t total_thread_inlined_length; 1155 1156 size_t max_thread_bc_length; 1157 size_t max_thread_inlined_length; 1158 1159 #endif 1160 1161 #endif 1162 1163 1164 size_t stack_min_size; 1165 size_t stack_max_size; 1166 size_t stack_allocation_increment; 1167 1168 size_t class_loader_min_size; 1169 size_t class_loader_max_size; 1170 size_t class_loader_allocation_increment; 1171 }; 1172 1173 /* 1174 ---------------------------------------------------------------------- 1175 _svmt_initialization 1176 ---------------------------------------------------------------------- 1177 */ 1178 1179 struct _svmt_initialization_struct 1180 { 1181 sigjmp_buf unrecoverable_exception_handler; 1182 }; 1183 1184 /* 1185 ---------------------------------------------------------------------- 1186 _svmt_free_block 1187 ---------------------------------------------------------------------- 1188 */ 1189 1190 struct _svmt_free_block_struct 1191 { 1192 size_t size; 1193 void *block; 1194 }; 1195 1196 /* 1197 ---------------------------------------------------------------------- 1198 _svmt__svmt_class_loader_info 1199 ---------------------------------------------------------------------- 1200 */ 1201 1202 struct _svmt_class_loader_info_struct 1203 { 1204 jobject class_loader; 1205 1206 _svmt_class_loader_info *previous; 1207 _svmt_class_loader_info *next; 1208 1209 /* memory management */ 1210 size_t total_allocation_size; 1211 _svmt_memory_block *memory_block_list; /* allocated memory blocks */ 1212 _svmt_free_block free_blocks[SVM_CLASS_LOADER_FREE_ARRAY_SIZE]; /* current free blocks */ 1213 1214 /* native libraries 1215 Note: We must keep this list in loading order (to this 1216 end, we use a tail pointer). 1217 */ 1218 _svmt_native_library *native_library_list; 1219 _svmt_native_library **native_library_list_tail; 1220 }; 1221 1222 /* 1223 ---------------------------------------------------------------------- 1224 _svmt_native_ref 1225 ---------------------------------------------------------------------- 1226 */ 1227 1228 struct _svmt_native_ref_struct 1229 { 1230 _svmt_object_instance *ref; 1231 _svmt_native_ref *previous; 1232 _svmt_native_ref *next; 1233 }; 1234 1235 /* 1236 ---------------------------------------------------------------------- 1237 _svmt_type_info 1238 ---------------------------------------------------------------------- 1239 */ 1240 1241 struct _svmt_type_info_struct 1242 { 1243 char *name; 1244 char *array_type_name; 1245 _svmt_class_loader_info *class_loader_info; 1246 jclass class_instance; 1247 jint access_flags; 1248 jint is_array; 1249 }; 1250 1251 /* 1252 ---------------------------------------------------------------------- 1253 _svmt_array_info 1254 ---------------------------------------------------------------------- 1255 */ 1256 1257 struct _svmt_array_info_struct 1258 { 1259 char *name; 1260 char *array_type_name; 1261 _svmt_class_loader_info *class_loader_info; 1262 jclass class_instance; 1263 jint access_flags; 1264 jint is_array; /* JNI_TRUE */ 1265 1266 jint state; /* SVM_TYPE_STATE_XXX mask */ 1267 jthrowable preparation_error; 1268 1269 jint dimensions; /* 0 < dimensions < 256 */ 1270 jint base_type; /* SVM_TYPE_XXX */ 1271 _svmt_class_info *base_class; /* NULL if primitive array */ 1272 _svmt_array_info *array_element; /* NULL if dimension == 1 */ 1273 1274 _svmt_vtable *vtable; 1275 _svmt_word initial_lockword; 1276 }; 1277 1278 /* 1279 ---------------------------------------------------------------------- 1280 _svmt_noninterface_class_data 1281 ---------------------------------------------------------------------- 1282 */ 1283 1284 struct _svmt_noninterface_class_data_struct 1285 { 1286 _svmt_vtable *vtable; 1287 _svmt_word initial_lockword; 1288 1289 /* instanceof data */ 1290 jint super_classes_size; 1291 _svmt_class_info **super_classes; 1292 1293 jint max_interface_id; 1294 _svmt_u8 *super_interfaces; /* bit array */ 1295 1296 /* methods data */ 1297 jint max_virtual_method_id; 1298 jint max_interface_method_id; 1299 1300 /* instance data */ 1301 size_t next_offset_no_hashcode; 1302 size_t next_offset_with_hashcode; 1303 1304 #if defined (_SABLEVM_BIDIRECTIONAL_OBJECT_LAYOUT) 1305 1306 jint ref_field_count; 1307 size_t start_offset; 1308 1309 #elif defined(_SABLEVM_TRADITIONAL_OBJECT_LAYOUT) 1310 1311 jint ref_field_count; 1312 size_t *ref_field_offsets; 1313 1314 #endif 1315 1316 /* available free space for subclasses */ 1317 jint free_bits_count; 1318 size_t free_bits_offset; 1319 size_t free_space_offset[SVM_ALIGNMENT_POWER]; 1320 }; 1321 1322 /* 1323 ---------------------------------------------------------------------- 1324 _svmt_interface_class_data 1325 ---------------------------------------------------------------------- 1326 */ 1327 1328 struct _svmt_interface_class_data_struct 1329 { 1330 /* instanceof data */ 1331 jint interface_id; 1332 _svmt_u8 *super_interfaces; /* bit array */ 1333 1334 /* methods data */ 1335 jint max_interface_method_id; 1336 }; 1337 1338 /* 1339 ---------------------------------------------------------------------- 1340 _svmt_class_info 1341 ---------------------------------------------------------------------- 1342 */ 1343 1344 struct _svmt_class_info_struct 1345 { 1346 char *name; 1347 char *array_type_name; 1348 _svmt_class_loader_info *class_loader_info; 1349 jclass class_instance; 1350 jint access_flags; 1351 jint is_array; /* JNI_FALSE */ 1352 1353 jint state; /* SVM_TYPE_STATE_XXX mask */ 1354 jthrowable preparation_error; 1355 jthrowable verification_error; 1356 jobject protection_domain; 1357 1358 jint minor_version; 1359 jint major_version; 1360 1361 jint constant_pool_count; 1362 _svmt_cp_info **constant_pool; 1363 1364 _svmt_CONSTANT_Class_info **this_class; 1365 _svmt_CONSTANT_Class_info **super_class; 1366 1367 jint interfaces_count; 1368 _svmt_CONSTANT_Class_info ***interfaces; 1369 1370 jint fields_count; 1371 _svmt_field_info *fields; 1372 1373 jint methods_count; 1374 _svmt_method_info *methods; 1375 1376 jint attributes_count; 1377 _svmt_attribute_info **attributes; 1378 1379 char *file_name; 1380 1381 union 1382 { 1383 _svmt_noninterface_class_data noninterface; 1384 _svmt_interface_class_data interface; 1385 } 1386 data; 1387 }; 1388 1389 /* 1390 ---------------------------------------------------------------------- 1391 _svmt_cp_info 1392 ---------------------------------------------------------------------- 1393 */ 1394 1395 struct _svmt_cp_info_struct 1396 { 1397 jint tag; 1398 }; 1399 1400 /* 1401 ---------------------------------------------------------------------- 1402 _svmt_CONSTANT_Class_info 1403 ---------------------------------------------------------------------- 1404 */ 1405 1406 struct _svmt_CONSTANT_Class_info_struct 1407 { 1408 jint tag; 1409 _svmt_CONSTANT_Utf8_info **name; 1410 1411 _svmt_type_info *type; 1412 jthrowable resolution_error; 1413 }; 1414 1415 /* 1416 ---------------------------------------------------------------------- 1417 _svmt_CONSTANT_Fieldref_info 1418 ---------------------------------------------------------------------- 1419 */ 1420 1421 struct _svmt_CONSTANT_Fieldref_info_struct 1422 { 1423 jint tag; 1424 _svmt_CONSTANT_Class_info **class; 1425 _svmt_CONSTANT_NameAndType_info **name_and_type; 1426 1427 _svmt_field_info *field; 1428 jthrowable resolution_error; 1429 }; 1430 1431 /* 1432 ---------------------------------------------------------------------- 1433 _svmt_CONSTANT_Methodref_info 1434 ---------------------------------------------------------------------- 1435 */ 1436 1437 struct _svmt_CONSTANT_Methodref_info_struct 1438 { 1439 jint tag; 1440 _svmt_CONSTANT_Class_info **class; 1441 _svmt_CONSTANT_NameAndType_info **name_and_type; 1442 1443 _svmt_method_info *method; 1444 jthrowable resolution_error; 1445 }; 1446 1447 /* 1448 ---------------------------------------------------------------------- 1449 _svmt_CONSTANT_InterfaceMethodref_info 1450 ---------------------------------------------------------------------- 1451 */ 1452 1453 struct _svmt_CONSTANT_InterfaceMethodref_info_struct 1454 { 1455 jint tag; 1456 _svmt_CONSTANT_Class_info **class; 1457 _svmt_CONSTANT_NameAndType_info **name_and_type; 1458 1459 _svmt_method_info *method; 1460 jthrowable resolution_error; 1461 }; 1462 1463 /* 1464 ---------------------------------------------------------------------- 1465 _svmt_CONSTANT_String_info 1466 ---------------------------------------------------------------------- 1467 */ 1468 1469 struct _svmt_CONSTANT_String_info_struct 1470 { 1471 jint tag; 1472 _svmt_CONSTANT_Utf8_info **string; 1473 1474 _svmt_class_info *class_info; 1475 jstring value; 1476 }; 1477 1478 /* 1479 ---------------------------------------------------------------------- 1480 _svmt_CONSTANT_Integer_info 1481 ---------------------------------------------------------------------- 1482 */ 1483 1484 struct _svmt_CONSTANT_Integer_info_struct 1485 { 1486 jint tag; 1487 jint value; 1488 }; 1489 1490 /* 1491 ---------------------------------------------------------------------- 1492 _svmt_CONSTANT_Float_info 1493 ---------------------------------------------------------------------- 1494 */ 1495 1496 struct _svmt_CONSTANT_Float_info_struct 1497 { 1498 jint tag; 1499 jfloat value; 1500 }; 1501 1502 /* 1503 ---------------------------------------------------------------------- 1504 _svmt_CONSTANT_Long_info 1505 ---------------------------------------------------------------------- 1506 */ 1507 1508 struct _svmt_CONSTANT_Long_info_struct 1509 { 1510 jint tag; 1511 jlong value; 1512 }; 1513 1514 /* 1515 ---------------------------------------------------------------------- 1516 _svmt_CONSTANT_Double_info 1517 ---------------------------------------------------------------------- 1518 */ 1519 1520 struct _svmt_CONSTANT_Double_info_struct 1521 { 1522 jint tag; 1523 jdouble value; 1524 }; 1525 1526 /* 1527 ---------------------------------------------------------------------- 1528 _svmt_CONSTANT_NameAndType_info 1529 ---------------------------------------------------------------------- 1530 */ 1531 1532 struct _svmt_CONSTANT_NameAndType_info_struct 1533 { 1534 jint tag; 1535 _svmt_CONSTANT_Utf8_info **name; 1536 _svmt_CONSTANT_Utf8_info **descriptor; 1537 }; 1538 1539 /* 1540 ---------------------------------------------------------------------- 1541 _svmt_CONSTANT_Utf8_info 1542 ---------------------------------------------------------------------- 1543 */ 1544 1545 struct _svmt_CONSTANT_Utf8_info_struct 1546 { 1547 jint tag; 1548 jint length; 1549 char *value; 1550 }; 1551 1552 /* 1553 ---------------------------------------------------------------------- 1554 _svmt_instance_field_data 1555 ---------------------------------------------------------------------- 1556 */ 1557 1558 struct _svmt_instance_field_data_struct 1559 { 1560 /* the offset is calculated in bytes, except for boolean fields in 1561 which the offset is calculated in bits */ 1562 size_t offset; 1563 }; 1564 1565 /* 1566 ---------------------------------------------------------------------- 1567 _svmt_class_field_data 1568 ---------------------------------------------------------------------- 1569 */ 1570 1571 struct _svmt_class_field_data_struct 1572 { 1573 jvalue value; 1574 }; 1575 1576 /* 1577 ---------------------------------------------------------------------- 1578 _svmt_field_info 1579 ---------------------------------------------------------------------- 1580 */ 1581 1582 struct _svmt_field_info_struct 1583 { 1584 jint access_flags; 1585 _svmt_CONSTANT_Utf8_info **name; 1586 _svmt_CONSTANT_Utf8_info **descriptor; 1587 1588 jint attributes_count; 1589 _svmt_attribute_info **attributes; 1590 1591 _svmt_class_info *class_info; 1592 1593 jint type; /* SVM_TYPE_XXX */ 1594 1595 jobject reflection_instance; 1596 1597 union 1598 { 1599 _svmt_instance_field_data instance_field; 1600 _svmt_class_field_data class_field; 1601 } 1602 data; 1603 }; 1604 1605 /* 1606 ---------------------------------------------------------------------- 1607 _svmt_native_method_data 1608 ---------------------------------------------------------------------- 1609 */ 1610 1611 struct _svmt_native_method_data_struct 1612 { 1613 char *short_name; 1614 char *long_name; 1615 void (*code) (void); 1616 1617 jint args_count; 1618 jint *arg_types; 1619 jint ret_type; 1620 1621 /* max (java_args_count, ret_size[which is 0,1 or 2]) */ 1622 jint java_args_and_ret_count; 1623 1624 jint refargs_count; 1625 1626 ffi_type **args; 1627 ffi_type *ret; 1628 ffi_cif *cif; 1629 }; 1630 1631 /* 1632 ---------------------------------------------------------------------- 1633 _svmt_attribute_info 1634 ---------------------------------------------------------------------- 1635 */ 1636 1637 struct _svmt_attribute_info_struct 1638 { 1639 _svmt_CONSTANT_Utf8_info **name; 1640 }; 1641 1642 /* 1643 ---------------------------------------------------------------------- 1644 _svmt_ConstantValue_attribute 1645 ---------------------------------------------------------------------- 1646 */ 1647 1648 struct _svmt_ConstantValue_attribute_struct 1649 { 1650 _svmt_CONSTANT_Utf8_info **name; 1651 1652 _svmt_cp_info **constantvalue; 1653 }; 1654 1655 /* 1656 ---------------------------------------------------------------------- 1657 _svmt_exception_table 1658 ---------------------------------------------------------------------- 1659 */ 1660 1661 struct _svmt_exception_table_struct 1662 { 1663 jint start_pc; 1664 jint end_pc; 1665 jint handler_pc; 1666 _svmt_CONSTANT_Class_info **catch_type; 1667 1668 _svmt_code *normal_start; 1669 _svmt_code *normal_end; 1670 _svmt_code *prepare_start; 1671 _svmt_code *prepare_end; 1672 _svmt_code *handler; 1673 }; 1674 1675 /* 1676 ---------------------------------------------------------------------- 1677 _svmt_Code_attribute 1678 ---------------------------------------------------------------------- 1679 */ 1680 1681 struct _svmt_Code_attribute_struct 1682 { 1683 _svmt_CONSTANT_Utf8_info **name; 1684 1685 jint max_stack; 1686 jint max_locals; 1687 1688 jlong code_length; 1689 _svmt_u8 *code; /* original bytecode array */ 1690 1691 jint exception_table_length; 1692 _svmt_exception_table *exception_table; 1693 1694 jint attributes_count; 1695 _svmt_attribute_info **attributes; 1696 1697 _svmt_LineNumberTable_attribute *line_numbers; 1698 }; 1699 1700 /* 1701 ---------------------------------------------------------------------- 1702 _svmt_Exceptions_attribute 1703 ---------------------------------------------------------------------- 1704 */ 1705 1706 struct _svmt_Exceptions_attribute_struct 1707 { 1708 _svmt_CONSTANT_Utf8_info **name; 1709 1710 jint number_of_exceptions; 1711 _svmt_CONSTANT_Class_info ***exception_table; 1712 }; 1713 1714 /* 1715 ---------------------------------------------------------------------- 1716 _svmt_inner_classes 1717 ---------------------------------------------------------------------- 1718 */ 1719 1720 struct _svmt_inner_classes_struct 1721 { 1722 _svmt_CONSTANT_Class_info **inner_class_info; 1723 _svmt_CONSTANT_Class_info **outer_class_info; 1724 _svmt_CONSTANT_Utf8_info **inner_name; 1725 jint inner_class_access_flags; 1726 }; 1727 1728 /* 1729 ---------------------------------------------------------------------- 1730 _svmt_InnerClasses_attribute 1731 ---------------------------------------------------------------------- 1732 */ 1733 1734 struct _svmt_InnerClasses_attribute_struct 1735 { 1736 _svmt_CONSTANT_Utf8_info **name; 1737 1738 jint number_of_classes; 1739 _svmt_inner_classes *classes; 1740 }; 1741 1742 /* 1743 ---------------------------------------------------------------------- 1744 _svmt_Synthetic_attribute 1745 ---------------------------------------------------------------------- 1746 */ 1747 1748 struct _svmt_Synthetic_attribute_struct 1749 { 1750 _svmt_CONSTANT_Utf8_info **name; 1751 }; 1752 1753 /* 1754 ---------------------------------------------------------------------- 1755 _svmt_SourceFile_attribute 1756 ---------------------------------------------------------------------- 1757 */ 1758 1759 struct _svmt_SourceFile_attribute_struct 1760 { 1761 _svmt_CONSTANT_Utf8_info **name; 1762 1763 _svmt_CONSTANT_Utf8_info **sourcefile; 1764 }; 1765 1766 /* 1767 ---------------------------------------------------------------------- 1768 _svmt_line_number_table 1769 ---------------------------------------------------------------------- 1770 */ 1771 1772 struct _svmt_line_number_table_struct 1773 { 1774 jint start_pc; 1775 jint line_number; 1776 _svmt_code *normal_start; 1777 _svmt_code *normal_end; 1778 _svmt_code *prepare_start; 1779 _svmt_code *prepare_end; 1780 }; 1781 1782 /* 1783 ---------------------------------------------------------------------- 1784 _svmt_LineNumberTable_attribute 1785 ---------------------------------------------------------------------- 1786 */ 1787 1788 struct _svmt_LineNumberTable_attribute_struct 1789 { 1790 _svmt_CONSTANT_Utf8_info **name; 1791 1792 jint line_number_table_length; 1793 _svmt_line_number_table *line_number_table; 1794 }; 1795 1796 /* 1797 ---------------------------------------------------------------------- 1798 _svmt_local_variable_table 1799 ---------------------------------------------------------------------- 1800 */ 1801 1802 struct _svmt_local_variable_table_struct 1803 { 1804 jint start_pc; 1805 jint length; 1806 _svmt_CONSTANT_Utf8_info **name; 1807 _svmt_CONSTANT_Utf8_info **descriptor; 1808 jint index; 1809 }; 1810 1811 /* 1812 ---------------------------------------------------------------------- 1813 _svmt_LocalVariableTable_attribute 1814 ---------------------------------------------------------------------- 1815 */ 1816 1817 struct _svmt_LocalVariableTable_attribute_struct 1818 { 1819 _svmt_CONSTANT_Utf8_info **name; 1820 1821 jint local_variable_table_length; 1822 _svmt_local_variable_table *local_variable_table; 1823 }; 1824 1825 /* 1826 ---------------------------------------------------------------------- 1827 _svmt_Deprecated_attribute 1828 ---------------------------------------------------------------------- 1829 */ 1830 1831 struct _svmt_Deprecated_attribute_struct 1832 { 1833 _svmt_CONSTANT_Utf8_info **name; 1834 }; 1835 1836 /* 1837 ---------------------------------------------------------------------- 1838 _svmt_unknown_attribute 1839 ---------------------------------------------------------------------- 1840 */ 1841 1842 struct _svmt_unknown_attribute_struct 1843 { 1844 _svmt_CONSTANT_Utf8_info **name; 1845 _svmt_u32 length; 1846 _svmt_u8 *info; 1847 }; 1848 1849 /* 1850 ---------------------------------------------------------------------- 1851 _svmt_stack_frame 1852 ---------------------------------------------------------------------- 1853 */ 1854 1855 struct _svmt_stack_frame_struct 1856 { 1857 size_t previous_offset; 1858 size_t end_offset; 1859 _svmt_method_info *method; 1860 _svmt_object_instance *stack_trace_element; /* cached element */ 1861 jint lock_count; /* structured locking */ 1862 _svmt_object_instance *this; /* for static methods, this points to 1863 the class instance */ 1864 _svmt_code *pc; 1865 jint stack_size; 1866 }; 1867 1868 /* 1869 ---------------------------------------------------------------------- 1870 _svmt_stack_value 1871 ---------------------------------------------------------------------- 1872 */ 1873 1874 union _svmt_stack_value_union 1875 { 1876 jint jint; 1877 jfloat jfloat; 1878 _svmt_object_instance *reference; 1879 _svmt_code *addr; 1880 void *ptr; 1881 char alignment[SVM_ALIGNMENT]; 1882 }; 1883 1884 /* 1885 ---------------------------------------------------------------------- 1886 _svmt_object_instance 1887 ---------------------------------------------------------------------- 1888 */ 1889 1890 struct _svmt_object_instance_struct 1891 { 1892 _svmt_word lockword; 1893 #ifdef MAGIC 1894 char magic[8]; 1895 #endif 1896 _svmt_vtable *vtable; 1897 1898 }; 1899 1900 /* 1901 ---------------------------------------------------------------------- 1902 _svmt_array_instance 1903 ---------------------------------------------------------------------- 1904 */ 1905 1906 struct _svmt_array_instance_struct 1907 { 1908 _svmt_word lockword; 1909 #ifdef MAGIC 1910 char magic[8]; 1911 #endif 1912 _svmt_vtable *vtable; 1913 jint size; 1914 jint hashcode; 1915 }; 1916 1917 /* 1918 ---------------------------------------------------------------------- 1919 _svmt_vtable 1920 ---------------------------------------------------------------------- 1921 */ 1922 1923 struct _svmt_vtable_struct 1924 { 1925 _svmt_type_info *type; 1926 size_t hashcode_offset; 1927 1928 #if defined (_SABLEVM_BIDIRECTIONAL_OBJECT_LAYOUT) 1929 1930 size_t next_offset_no_hashcode; 1931 size_t next_offset_with_hashcode; 1932 size_t start_offset; 1933 1934 #elif defined(_SABLEVM_TRADITIONAL_OBJECT_LAYOUT) 1935 1936 size_t next_offset_no_hashcode; 1937 size_t next_offset_with_hashcode; 1938 jint ref_field_count; 1939 size_t *ref_field_offsets; 1940 1941 #endif 1942 }; 1943 1944 /* 1945 ---------------------------------------------------------------------- 1946 _svmt_stack_native_reference 1947 ---------------------------------------------------------------------- 1948 */ 1949 1950 union _svmt_stack_native_reference_union 1951 { 1952 jint jint; 1953 size_t size_t; 1954 jobject jobject; 1955 }; 1956 1957 /* 1958 ---------------------------------------------------------------------- 1959 _svmt_native_library 1960 ---------------------------------------------------------------------- 1961 */ 1962 1963 struct _svmt_native_library_struct 1964 { 1965 char *name; 1966 lt_dlhandle handle; 1967 1968 _svmt_native_library *next; 1969 }; 1970 1971 /* 1972 ---------------------------------------------------------------------- 1973 _svmt_memory_block 1974 ---------------------------------------------------------------------- 1975 */ 1976 1977 struct _svmt_memory_block_struct 1978 { 1979 size_t size; 1980 void *block; 1981 1982 _svmt_memory_block *next; 1983 }; 1984 1985 /* 1986 ---------------------------------------------------------------------- 1987 _svmt_type_node 1988 ---------------------------------------------------------------------- 1989 */ 1990 1991 struct _svmt_type_node_struct 1992 { 1993 const char *name; 1994 _svmt_type_info *type; 1995 1996 _svmt_type_node *parent; 1997 _svmt_type_node *left; 1998 _svmt_type_node *right; 1999 }; 2000 2001 /* 2002 ---------------------------------------------------------------------- 2003 _svmt_imethod_signature_node 2004 ---------------------------------------------------------------------- 2005 */ 2006 2007 struct _svmt_imethod_signature_node_struct 2008 { 2009 const char *name; 2010 const char *descriptor; 2011 jint interface_method_id; 2012 2013 _svmt_imethod_signature_node *parent; 2014 _svmt_imethod_signature_node *left; 2015 _svmt_imethod_signature_node *right; 2016 }; 2017 2018 /* 2019 ---------------------------------------------------------------------- 2020 _svmt_sequence_node 2021 ---------------------------------------------------------------------- 2022 */ 2023 2024 struct _svmt_sequence_node_struct 2025 { 2026 size_t instructions_length; 2027 jint *instructions; 2028 size_t implementation_length; 2029 void *implementation; 2030 2031 _svmt_sequence_node *parent; 2032 _svmt_sequence_node *left; 2033 _svmt_sequence_node *right; 2034 }; 2035 2036 /* 2037 ---------------------------------------------------------------------- 2038 _svmt_fat_lock 2039 ---------------------------------------------------------------------- 2040 */ 2041 2042 struct _svmt_fat_lock_struct 2043 { 2044 _svmt_word id; 2045 2046 _svmt_fat_lock *next; 2047 2048 pthread_mutex_t mutex; 2049 pthread_cond_t cond; 2050 2051 _svmt_JNIEnv *owner; 2052 jint recursive_count; 2053 2054 pthread_cond_t notification_cond; 2055 }; 2056 2057 /* 2058 ---------------------------------------------------------------------- 2059 _svmt_internal_method_node 2060 ---------------------------------------------------------------------- 2061 */ 2062 2063 struct _svmt_internal_method_node_struct 2064 { 2065 const char *name; 2066 void (*code) (void); 2067 2068 _svmt_internal_method_node *parent; 2069 _svmt_internal_method_node *left; 2070 _svmt_internal_method_node *right; 2071 }; 2072 2073 #endif /* not SVM_SABLEVM_H */ 2074