aboutsummaryrefslogtreecommitdiff
path: root/src/cpu/x86/vm/templateTable_x86_64.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpu/x86/vm/templateTable_x86_64.cpp')
-rw-r--r--src/cpu/x86/vm/templateTable_x86_64.cpp59
1 files changed, 56 insertions, 3 deletions
diff --git a/src/cpu/x86/vm/templateTable_x86_64.cpp b/src/cpu/x86/vm/templateTable_x86_64.cpp
index 544019c71..9a8c34c2e 100644
--- a/src/cpu/x86/vm/templateTable_x86_64.cpp
+++ b/src/cpu/x86/vm/templateTable_x86_64.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -219,6 +219,7 @@ void TemplateTable::patch_bytecode(Bytecodes::Code bc, Register bc_reg,
switch (bc) {
case Bytecodes::_fast_aputfield:
case Bytecodes::_fast_bputfield:
+ case Bytecodes::_fast_zputfield:
case Bytecodes::_fast_cputfield:
case Bytecodes::_fast_dputfield:
case Bytecodes::_fast_fputfield:
@@ -1018,6 +1019,16 @@ void TemplateTable::bastore() {
// ebx: index
// rdx: array
index_check(rdx, rbx); // prefer index in ebx
+ // Need to check whether array is boolean or byte
+ // since both types share the bastore bytecode.
+ __ load_klass(rcx, rdx);
+ __ movl(rcx, Address(rcx, Klass::layout_helper_offset()));
+ int diffbit = Klass::layout_helper_boolean_diffbit();
+ __ testl(rcx, diffbit);
+ Label L_skip;
+ __ jccb(Assembler::zero, L_skip);
+ __ andl(rax, 1); // if it is a T_BOOLEAN array, mask the stored value to 0/1
+ __ bind(L_skip);
__ movb(Address(rdx, rbx,
Address::times_1,
arrayOopDesc::base_offset_in_bytes(T_BYTE)),
@@ -2071,7 +2082,14 @@ void TemplateTable::_return(TosState state) {
__ bind(skip_register_finalizer);
}
+ // Narrow result if state is itos but result type is smaller.
+ // Need to narrow in the return bytecode rather than in generate_return_entry
+ // since compiled code callers expect the result to already be narrowed.
+ if (state == itos) {
+ __ narrow(rax);
+ }
__ remove_activation(state, r13);
+
__ jmp(r13);
}
@@ -2289,7 +2307,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static) {
const Address field(obj, off, Address::times_1);
- Label Done, notByte, notInt, notShort, notChar,
+ Label Done, notByte, notBool, notInt, notShort, notChar,
notLong, notFloat, notObj, notDouble;
__ shrl(flags, ConstantPoolCacheEntry::tos_state_shift);
@@ -2308,6 +2326,20 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static) {
__ jmp(Done);
__ bind(notByte);
+ __ cmpl(flags, ztos);
+ __ jcc(Assembler::notEqual, notBool);
+
+ // ztos (same code as btos)
+ __ load_signed_byte(rax, field);
+ __ push(ztos);
+ // Rewrite bytecode to be faster
+ if (!is_static) {
+ // use btos rewriting, no truncating to t/f bit is needed for getfield.
+ patch_bytecode(Bytecodes::_fast_bgetfield, bc, rbx);
+ }
+ __ jmp(Done);
+
+ __ bind(notBool);
__ cmpl(flags, atos);
__ jcc(Assembler::notEqual, notObj);
// atos
@@ -2497,7 +2529,7 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static) {
// field address
const Address field(obj, off, Address::times_1);
- Label notByte, notInt, notShort, notChar,
+ Label notByte, notBool, notInt, notShort, notChar,
notLong, notFloat, notObj, notDouble;
__ shrl(flags, ConstantPoolCacheEntry::tos_state_shift);
@@ -2518,6 +2550,22 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static) {
}
__ bind(notByte);
+ __ cmpl(flags, ztos);
+ __ jcc(Assembler::notEqual, notBool);
+
+ // ztos
+ {
+ __ pop(ztos);
+ if (!is_static) pop_and_check_object(obj);
+ __ andl(rax, 0x1);
+ __ movb(field, rax);
+ if (!is_static) {
+ patch_bytecode(Bytecodes::_fast_zputfield, bc, rbx, true, byte_no);
+ }
+ __ jmp(Done);
+ }
+
+ __ bind(notBool);
__ cmpl(flags, atos);
__ jcc(Assembler::notEqual, notObj);
@@ -2666,6 +2714,7 @@ void TemplateTable::jvmti_post_fast_field_mod() {
switch (bytecode()) { // load values into the jvalue object
case Bytecodes::_fast_aputfield: __ push_ptr(rax); break;
case Bytecodes::_fast_bputfield: // fall through
+ case Bytecodes::_fast_zputfield: // fall through
case Bytecodes::_fast_sputfield: // fall through
case Bytecodes::_fast_cputfield: // fall through
case Bytecodes::_fast_iputfield: __ push_i(rax); break;
@@ -2691,6 +2740,7 @@ void TemplateTable::jvmti_post_fast_field_mod() {
switch (bytecode()) { // restore tos values
case Bytecodes::_fast_aputfield: __ pop_ptr(rax); break;
case Bytecodes::_fast_bputfield: // fall through
+ case Bytecodes::_fast_zputfield: // fall through
case Bytecodes::_fast_sputfield: // fall through
case Bytecodes::_fast_cputfield: // fall through
case Bytecodes::_fast_iputfield: __ pop_i(rax); break;
@@ -2746,6 +2796,9 @@ void TemplateTable::fast_storefield(TosState state) {
case Bytecodes::_fast_iputfield:
__ movl(field, rax);
break;
+ case Bytecodes::_fast_zputfield:
+ __ andl(rax, 0x1); // boolean is true if LSB is 1
+ // fall through to bputfield
case Bytecodes::_fast_bputfield:
__ movb(field, rax);
break;