mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8132051: Better byte behavior
Co-authored-by: Roland Westerlin <roland.westerlin@oracle.com> Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com> Co-authored-by: John Rose <john.r.rose@oracle.com> Reviewed-by: bdelsart, roland, kvn, jrose, ahgross
This commit is contained in:
parent
ed18f94d21
commit
200784d505
40 changed files with 514 additions and 88 deletions
|
@ -82,6 +82,29 @@ int CppInterpreter::normal_entry(Method* method, intptr_t UNUSED, TRAPS) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
intptr_t narrow(BasicType type, intptr_t result) {
|
||||
// mask integer result to narrower return type.
|
||||
switch (type) {
|
||||
case T_BOOLEAN:
|
||||
return result&1;
|
||||
case T_BYTE:
|
||||
return (intptr_t)(jbyte)result;
|
||||
case T_CHAR:
|
||||
return (intptr_t)(uintptr_t)(jchar)result;
|
||||
case T_SHORT:
|
||||
return (intptr_t)(jshort)result;
|
||||
case T_OBJECT: // nothing to do fall through
|
||||
case T_LONG:
|
||||
case T_INT:
|
||||
case T_FLOAT:
|
||||
case T_DOUBLE:
|
||||
case T_VOID:
|
||||
return result;
|
||||
default : ShouldNotReachHere();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CppInterpreter::main_loop(int recurse, TRAPS) {
|
||||
JavaThread *thread = (JavaThread *) THREAD;
|
||||
ZeroStack *stack = thread->zero_stack();
|
||||
|
@ -195,8 +218,14 @@ void CppInterpreter::main_loop(int recurse, TRAPS) {
|
|||
stack->set_sp(stack->sp() + method->max_locals());
|
||||
|
||||
// Push our result
|
||||
for (int i = 0; i < result_slots; i++)
|
||||
stack->push(result[-i]);
|
||||
for (int i = 0; i < result_slots; i++) {
|
||||
// Adjust result to smaller
|
||||
intptr_t res = result[-i];
|
||||
if (result_slots == 1) {
|
||||
res = narrow(result_type_of(method), res);
|
||||
}
|
||||
stack->push(res);
|
||||
}
|
||||
}
|
||||
|
||||
int CppInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
|
||||
|
@ -532,6 +561,7 @@ int CppInterpreter::accessor_entry(Method* method, intptr_t UNUSED, TRAPS) {
|
|||
break;
|
||||
|
||||
case btos:
|
||||
case ztos:
|
||||
SET_LOCALS_INT(object->byte_field_acquire(entry->f2_as_index()), 0);
|
||||
break;
|
||||
|
||||
|
@ -570,6 +600,7 @@ int CppInterpreter::accessor_entry(Method* method, intptr_t UNUSED, TRAPS) {
|
|||
break;
|
||||
|
||||
case btos:
|
||||
case ztos:
|
||||
SET_LOCALS_INT(object->byte_field(entry->f2_as_index()), 0);
|
||||
break;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue