1 /*
2 * Copyright (c) 2005, 2017, 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 *
599 // the object, meaning that no other thread has raced to acquire
600 // the bias of the object.
601 markOop biased_value = mark;
602 markOop unbiased_prototype = markOopDesc::prototype()->set_age(mark->age());
603 markOop res_mark = obj->cas_set_mark(unbiased_prototype, mark);
604 if (res_mark == biased_value) {
605 return BIAS_REVOKED;
606 }
607 } else if (mark->has_bias_pattern()) {
608 Klass* k = obj->klass();
609 markOop prototype_header = k->prototype_header();
610 if (!prototype_header->has_bias_pattern()) {
611 // This object has a stale bias from before the bulk revocation
612 // for this data type occurred. It's pointless to update the
613 // heuristics at this point so simply update the header with a
614 // CAS. If we fail this race, the object's bias has been revoked
615 // by another thread so we simply return and let the caller deal
616 // with it.
617 markOop biased_value = mark;
618 markOop res_mark = obj->cas_set_mark(prototype_header, mark);
619 assert(!(*(obj->mark_addr()))->has_bias_pattern(), "even if we raced, should still be revoked");
620 return BIAS_REVOKED;
621 } else if (prototype_header->bias_epoch() != mark->bias_epoch()) {
622 // The epoch of this biasing has expired indicating that the
623 // object is effectively unbiased. Depending on whether we need
624 // to rebias or revoke the bias of this object we can do it
625 // efficiently enough with a CAS that we shouldn't update the
626 // heuristics. This is normally done in the assembly code but we
627 // can reach this point due to various points in the runtime
628 // needing to revoke biases.
629 if (attempt_rebias) {
630 assert(THREAD->is_Java_thread(), "");
631 markOop biased_value = mark;
632 markOop rebiased_prototype = markOopDesc::encode((JavaThread*) THREAD, mark->age(), prototype_header->bias_epoch());
633 markOop res_mark = obj->cas_set_mark(rebiased_prototype, mark);
634 if (res_mark == biased_value) {
635 return BIAS_REVOKED_AND_REBIASED;
636 }
637 } else {
638 markOop biased_value = mark;
639 markOop unbiased_prototype = markOopDesc::prototype()->set_age(mark->age());
|
1 /*
2 * Copyright (c) 2005, 2018, 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 *
599 // the object, meaning that no other thread has raced to acquire
600 // the bias of the object.
601 markOop biased_value = mark;
602 markOop unbiased_prototype = markOopDesc::prototype()->set_age(mark->age());
603 markOop res_mark = obj->cas_set_mark(unbiased_prototype, mark);
604 if (res_mark == biased_value) {
605 return BIAS_REVOKED;
606 }
607 } else if (mark->has_bias_pattern()) {
608 Klass* k = obj->klass();
609 markOop prototype_header = k->prototype_header();
610 if (!prototype_header->has_bias_pattern()) {
611 // This object has a stale bias from before the bulk revocation
612 // for this data type occurred. It's pointless to update the
613 // heuristics at this point so simply update the header with a
614 // CAS. If we fail this race, the object's bias has been revoked
615 // by another thread so we simply return and let the caller deal
616 // with it.
617 markOop biased_value = mark;
618 markOop res_mark = obj->cas_set_mark(prototype_header, mark);
619 assert(!obj->mark()->has_bias_pattern(), "even if we raced, should still be revoked");
620 return BIAS_REVOKED;
621 } else if (prototype_header->bias_epoch() != mark->bias_epoch()) {
622 // The epoch of this biasing has expired indicating that the
623 // object is effectively unbiased. Depending on whether we need
624 // to rebias or revoke the bias of this object we can do it
625 // efficiently enough with a CAS that we shouldn't update the
626 // heuristics. This is normally done in the assembly code but we
627 // can reach this point due to various points in the runtime
628 // needing to revoke biases.
629 if (attempt_rebias) {
630 assert(THREAD->is_Java_thread(), "");
631 markOop biased_value = mark;
632 markOop rebiased_prototype = markOopDesc::encode((JavaThread*) THREAD, mark->age(), prototype_header->bias_epoch());
633 markOop res_mark = obj->cas_set_mark(rebiased_prototype, mark);
634 if (res_mark == biased_value) {
635 return BIAS_REVOKED_AND_REBIASED;
636 }
637 } else {
638 markOop biased_value = mark;
639 markOop unbiased_prototype = markOopDesc::prototype()->set_age(mark->age());
|