Mercurial > hg > truffle
comparison src/share/vm/runtime/java.cpp @ 356:1ee8caae33af
Merge
author | tonyp |
---|---|
date | Thu, 21 Aug 2008 23:36:31 -0400 |
parents | d95b224e9f17 |
children | fb1a39993f69 |
comparison
equal
deleted
inserted
replaced
355:0edda524b58c | 356:1ee8caae33af |
---|---|
1 /* | 1 /* |
2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
500 { | 500 { |
501 vm_perform_shutdown_actions(); | 501 vm_perform_shutdown_actions(); |
502 os::shutdown(); | 502 os::shutdown(); |
503 } | 503 } |
504 | 504 |
505 void vm_abort() { | 505 void vm_abort(bool dump_core) { |
506 vm_perform_shutdown_actions(); | 506 vm_perform_shutdown_actions(); |
507 os::abort(PRODUCT_ONLY(false)); | 507 os::abort(dump_core); |
508 ShouldNotReachHere(); | 508 ShouldNotReachHere(); |
509 } | 509 } |
510 | 510 |
511 void vm_notify_during_shutdown(const char* error, const char* message) { | 511 void vm_notify_during_shutdown(const char* error, const char* message) { |
512 if (error != NULL) { | 512 if (error != NULL) { |
536 java_lang_Throwable::print(exception, tty); | 536 java_lang_Throwable::print(exception, tty); |
537 tty->cr(); | 537 tty->cr(); |
538 java_lang_Throwable::print_stack_trace(exception(), tty); | 538 java_lang_Throwable::print_stack_trace(exception(), tty); |
539 tty->cr(); | 539 tty->cr(); |
540 vm_notify_during_shutdown(NULL, NULL); | 540 vm_notify_during_shutdown(NULL, NULL); |
541 vm_abort(); | 541 |
542 // Failure during initialization, we don't want to dump core | |
543 vm_abort(false); | |
542 } | 544 } |
543 | 545 |
544 void vm_exit_during_initialization(symbolHandle ex, const char* message) { | 546 void vm_exit_during_initialization(symbolHandle ex, const char* message) { |
545 ResourceMark rm; | 547 ResourceMark rm; |
546 vm_notify_during_shutdown(ex->as_C_string(), message); | 548 vm_notify_during_shutdown(ex->as_C_string(), message); |
547 vm_abort(); | 549 |
550 // Failure during initialization, we don't want to dump core | |
551 vm_abort(false); | |
548 } | 552 } |
549 | 553 |
550 void vm_exit_during_initialization(const char* error, const char* message) { | 554 void vm_exit_during_initialization(const char* error, const char* message) { |
551 vm_notify_during_shutdown(error, message); | 555 vm_notify_during_shutdown(error, message); |
552 vm_abort(); | 556 |
557 // Failure during initialization, we don't want to dump core | |
558 vm_abort(false); | |
553 } | 559 } |
554 | 560 |
555 void vm_shutdown_during_initialization(const char* error, const char* message) { | 561 void vm_shutdown_during_initialization(const char* error, const char* message) { |
556 vm_notify_during_shutdown(error, message); | 562 vm_notify_during_shutdown(error, message); |
557 vm_shutdown(); | 563 vm_shutdown(); |
558 } | 564 } |
559 | 565 |
560 jdk_version_info JDK_Version::_version_info = {0}; | 566 JDK_Version JDK_Version::_current; |
561 bool JDK_Version::_pre_jdk16_version = false; | |
562 int JDK_Version::_jdk_version = 0; | |
563 | 567 |
564 void JDK_Version::initialize() { | 568 void JDK_Version::initialize() { |
569 jdk_version_info info; | |
570 assert(!_current.is_valid(), "Don't initialize twice"); | |
571 | |
565 void *lib_handle = os::native_java_library(); | 572 void *lib_handle = os::native_java_library(); |
566 jdk_version_info_fn_t func = | 573 jdk_version_info_fn_t func = CAST_TO_FN_PTR(jdk_version_info_fn_t, |
567 CAST_TO_FN_PTR(jdk_version_info_fn_t, hpi::dll_lookup(lib_handle, "JDK_GetVersionInfo0")); | 574 os::dll_lookup(lib_handle, "JDK_GetVersionInfo0")); |
568 | 575 |
569 if (func == NULL) { | 576 if (func == NULL) { |
570 // JDK older than 1.6 | 577 // JDK older than 1.6 |
571 _pre_jdk16_version = true; | 578 _current._partially_initialized = true; |
572 return; | |
573 } | |
574 | |
575 if (func != NULL) { | |
576 (*func)(&_version_info, sizeof(_version_info)); | |
577 } | |
578 if (jdk_major_version() == 1) { | |
579 _jdk_version = jdk_minor_version(); | |
580 } else { | 579 } else { |
581 // If the release version string is changed to n.x.x (e.g. 7.0.0) in a future release | 580 (*func)(&info, sizeof(info)); |
582 _jdk_version = jdk_major_version(); | 581 |
583 } | 582 int major = JDK_VERSION_MAJOR(info.jdk_version); |
583 int minor = JDK_VERSION_MINOR(info.jdk_version); | |
584 int micro = JDK_VERSION_MICRO(info.jdk_version); | |
585 int build = JDK_VERSION_BUILD(info.jdk_version); | |
586 if (major == 1 && minor > 4) { | |
587 // We represent "1.5.0" as "5.0", but 1.4.2 as itself. | |
588 major = minor; | |
589 minor = micro; | |
590 micro = 0; | |
591 } | |
592 _current = JDK_Version(major, minor, micro, info.update_version, | |
593 info.special_update_version, build, | |
594 info.thread_park_blocker == 1); | |
595 } | |
596 } | |
597 | |
598 void JDK_Version::fully_initialize( | |
599 uint8_t major, uint8_t minor, uint8_t micro, uint8_t update) { | |
600 // This is only called when current is less than 1.6 and we've gotten | |
601 // far enough in the initialization to determine the exact version. | |
602 assert(major < 6, "not needed for JDK version >= 6"); | |
603 assert(is_partially_initialized(), "must not initialize"); | |
604 if (major < 5) { | |
605 // JDK verison sequence: 1.2.x, 1.3.x, 1.4.x, 5.0.x, 6.0.x, etc. | |
606 micro = minor; | |
607 minor = major; | |
608 major = 1; | |
609 } | |
610 _current = JDK_Version(major, minor, micro, update); | |
584 } | 611 } |
585 | 612 |
586 void JDK_Version_init() { | 613 void JDK_Version_init() { |
587 JDK_Version::initialize(); | 614 JDK_Version::initialize(); |
588 } | 615 } |
616 | |
617 static int64_t encode_jdk_version(const JDK_Version& v) { | |
618 return | |
619 ((int64_t)v.major_version() << (BitsPerByte * 5)) | | |
620 ((int64_t)v.minor_version() << (BitsPerByte * 4)) | | |
621 ((int64_t)v.micro_version() << (BitsPerByte * 3)) | | |
622 ((int64_t)v.update_version() << (BitsPerByte * 2)) | | |
623 ((int64_t)v.special_update_version() << (BitsPerByte * 1)) | | |
624 ((int64_t)v.build_number() << (BitsPerByte * 0)); | |
625 } | |
626 | |
627 int JDK_Version::compare(const JDK_Version& other) const { | |
628 assert(is_valid() && other.is_valid(), "Invalid version (uninitialized?)"); | |
629 if (!is_partially_initialized() && other.is_partially_initialized()) { | |
630 return -(other.compare(*this)); // flip the comparators | |
631 } | |
632 assert(!other.is_partially_initialized(), "Not initialized yet"); | |
633 if (is_partially_initialized()) { | |
634 assert(other.major_version() >= 6, | |
635 "Invalid JDK version comparison during initialization"); | |
636 return -1; | |
637 } else { | |
638 uint64_t e = encode_jdk_version(*this); | |
639 uint64_t o = encode_jdk_version(other); | |
640 return (e > o) ? 1 : ((e == o) ? 0 : -1); | |
641 } | |
642 } | |
643 | |
644 void JDK_Version::to_string(char* buffer, size_t buflen) const { | |
645 size_t index = 0; | |
646 if (!is_valid()) { | |
647 jio_snprintf(buffer, buflen, "%s", "(uninitialized)"); | |
648 } else if (is_partially_initialized()) { | |
649 jio_snprintf(buffer, buflen, "%s", "(uninitialized) pre-1.6.0"); | |
650 } else { | |
651 index += jio_snprintf( | |
652 &buffer[index], buflen - index, "%d.%d", _major, _minor); | |
653 if (_micro > 0) { | |
654 index += jio_snprintf(&buffer[index], buflen - index, ".%d", _micro); | |
655 } | |
656 if (_update > 0) { | |
657 index += jio_snprintf(&buffer[index], buflen - index, "_%02d", _update); | |
658 } | |
659 if (_special > 0) { | |
660 index += jio_snprintf(&buffer[index], buflen - index, "%c", _special); | |
661 } | |
662 if (_build > 0) { | |
663 index += jio_snprintf(&buffer[index], buflen - index, "-b%02d", _build); | |
664 } | |
665 } | |
666 } |