1 /*
2 * Copyright (c) 2000, 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 *
1888 __ mov(dst, obj);
1889 }
1890 } else
1891 if (code == lir_instanceof) {
1892 Register obj = op->object()->as_register();
1893 Register dst = op->result_opr()->as_register();
1894 Label success, failure, done;
1895 emit_typecheck_helper(op, &success, &failure, &failure);
1896 __ bind(failure);
1897 __ xorptr(dst, dst);
1898 __ jmpb(done);
1899 __ bind(success);
1900 __ movptr(dst, 1);
1901 __ bind(done);
1902 } else {
1903 ShouldNotReachHere();
1904 }
1905
1906 }
1907
1908
1909 void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
1910 if (LP64_ONLY(false &&) op->code() == lir_cas_long && VM_Version::supports_cx8()) {
1911 assert(op->cmp_value()->as_register_lo() == rax, "wrong register");
1912 assert(op->cmp_value()->as_register_hi() == rdx, "wrong register");
1913 assert(op->new_value()->as_register_lo() == rbx, "wrong register");
1914 assert(op->new_value()->as_register_hi() == rcx, "wrong register");
1915 Register addr = op->addr()->as_register();
1916 __ lock();
1917 NOT_LP64(__ cmpxchg8(Address(addr, 0)));
1918
1919 } else if (op->code() == lir_cas_int || op->code() == lir_cas_obj ) {
1920 NOT_LP64(assert(op->addr()->is_single_cpu(), "must be single");)
1921 Register addr = (op->addr()->is_single_cpu() ? op->addr()->as_register() : op->addr()->as_register_lo());
1922 Register newval = op->new_value()->as_register();
1923 Register cmpval = op->cmp_value()->as_register();
1924 assert(cmpval == rax, "wrong register");
1925 assert(newval != NULL, "new val must be register");
1926 assert(cmpval != newval, "cmp and new values must be in different registers");
1927 assert(cmpval != addr, "cmp and addr must be in different registers");
|
1 /*
2 * Copyright (c) 2000, 2019, 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 *
1888 __ mov(dst, obj);
1889 }
1890 } else
1891 if (code == lir_instanceof) {
1892 Register obj = op->object()->as_register();
1893 Register dst = op->result_opr()->as_register();
1894 Label success, failure, done;
1895 emit_typecheck_helper(op, &success, &failure, &failure);
1896 __ bind(failure);
1897 __ xorptr(dst, dst);
1898 __ jmpb(done);
1899 __ bind(success);
1900 __ movptr(dst, 1);
1901 __ bind(done);
1902 } else {
1903 ShouldNotReachHere();
1904 }
1905
1906 }
1907
1908 void LIR_Assembler::emit_opFlattenedStoreCheck(LIR_OpFlattenedStoreCheck* op) {
1909 Klass* k = (Klass*)(op->element_klass()->constant_encoding());
1910 assert(k->is_klass(), "must be a loaded klass");
1911 add_debug_info_for_null_check_here(op->info_for_exception());
1912
1913 #ifdef _LP64
1914 if (UseCompressedClassPointers) {
1915 __ movl(op->tmp1()->as_register(), Address(op->object()->as_register(), oopDesc::klass_offset_in_bytes()));
1916 __ cmp_narrow_klass(op->tmp1()->as_register(), k);
1917 } else {
1918 __ movq(op->tmp1()->as_register(), Address(op->object()->as_register(), oopDesc::klass_offset_in_bytes()));
1919 __ cmpq(op->tmp1()->as_register(), op->tmp2()->as_register());
1920 }
1921 #else
1922 Unimplemented(); // FIXME
1923 #endif
1924
1925 __ jcc(Assembler::notEqual, *op->stub()->entry());
1926 __ bind(*op->stub()->continuation());
1927 }
1928
1929 void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
1930 if (LP64_ONLY(false &&) op->code() == lir_cas_long && VM_Version::supports_cx8()) {
1931 assert(op->cmp_value()->as_register_lo() == rax, "wrong register");
1932 assert(op->cmp_value()->as_register_hi() == rdx, "wrong register");
1933 assert(op->new_value()->as_register_lo() == rbx, "wrong register");
1934 assert(op->new_value()->as_register_hi() == rcx, "wrong register");
1935 Register addr = op->addr()->as_register();
1936 __ lock();
1937 NOT_LP64(__ cmpxchg8(Address(addr, 0)));
1938
1939 } else if (op->code() == lir_cas_int || op->code() == lir_cas_obj ) {
1940 NOT_LP64(assert(op->addr()->is_single_cpu(), "must be single");)
1941 Register addr = (op->addr()->is_single_cpu() ? op->addr()->as_register() : op->addr()->as_register_lo());
1942 Register newval = op->new_value()->as_register();
1943 Register cmpval = op->cmp_value()->as_register();
1944 assert(cmpval == rax, "wrong register");
1945 assert(newval != NULL, "new val must be register");
1946 assert(cmpval != newval, "cmp and new values must be in different registers");
1947 assert(cmpval != addr, "cmp and addr must be in different registers");
|