comparison src/cpu/zero/vm/cppInterpreter_zero.cpp @ 23614:32b682649973 jdk8u75-b04

8132051: Better byte behavior Reviewed-by: coleenp, roland
author kevinw
date Fri, 15 Jan 2016 22:33:15 +0000
parents 6d13c17668d1
children cc78c97abff8
comparison
equal deleted inserted replaced
23613:b374548dcb48 23614:32b682649973
1 /* 1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
3 * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. 3 * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * 5 *
6 * This code is free software; you can redistribute it and/or modify it 6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as 7 * under the terms of the GNU General Public License version 2 only, as
79 79
80 // No deoptimized frames on the stack 80 // No deoptimized frames on the stack
81 return 0; 81 return 0;
82 } 82 }
83 83
84 intptr_t narrow(BasicType type, intptr_t result) {
85 // mask integer result to narrower return type.
86 switch (type) {
87 case T_BOOLEAN:
88 return result&1;
89 case T_BYTE:
90 return (intptr_t)(jbyte)result;
91 case T_CHAR:
92 return (intptr_t)(uintptr_t)(jchar)result;
93 case T_SHORT:
94 return (intptr_t)(jshort)result;
95 case T_OBJECT: // nothing to do fall through
96 case T_LONG:
97 case T_INT:
98 case T_FLOAT:
99 case T_DOUBLE:
100 case T_VOID:
101 return result;
102 default : ShouldNotReachHere();
103 }
104 }
105
106
84 void CppInterpreter::main_loop(int recurse, TRAPS) { 107 void CppInterpreter::main_loop(int recurse, TRAPS) {
85 JavaThread *thread = (JavaThread *) THREAD; 108 JavaThread *thread = (JavaThread *) THREAD;
86 ZeroStack *stack = thread->zero_stack(); 109 ZeroStack *stack = thread->zero_stack();
87 110
88 // If we are entering from a deopt we may need to call 111 // If we are entering from a deopt we may need to call
192 215
193 // Pop our local variables 216 // Pop our local variables
194 stack->set_sp(stack->sp() + method->max_locals()); 217 stack->set_sp(stack->sp() + method->max_locals());
195 218
196 // Push our result 219 // Push our result
197 for (int i = 0; i < result_slots; i++) 220 for (int i = 0; i < result_slots; i++) {
198 stack->push(result[-i]); 221 // Adjust result to smaller
222 intptr_t res = result[-i];
223 if (result_slots == 1) {
224 res = narrow(result_type_of(method), res);
225 }
226 stack->push(res);
227 }
199 } 228 }
200 229
201 int CppInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) { 230 int CppInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
202 // Make sure method is native and not abstract 231 // Make sure method is native and not abstract
203 assert(method->is_native() && !method->is_abstract(), "should be"); 232 assert(method->is_native() && !method->is_abstract(), "should be");
526 case ctos: 555 case ctos:
527 SET_LOCALS_INT(object->char_field_acquire(entry->f2_as_index()), 0); 556 SET_LOCALS_INT(object->char_field_acquire(entry->f2_as_index()), 0);
528 break; 557 break;
529 558
530 case btos: 559 case btos:
560 case ztos:
531 SET_LOCALS_INT(object->byte_field_acquire(entry->f2_as_index()), 0); 561 SET_LOCALS_INT(object->byte_field_acquire(entry->f2_as_index()), 0);
532 break; 562 break;
533 563
534 case stos: 564 case stos:
535 SET_LOCALS_INT(object->short_field_acquire(entry->f2_as_index()), 0); 565 SET_LOCALS_INT(object->short_field_acquire(entry->f2_as_index()), 0);
564 case ctos: 594 case ctos:
565 SET_LOCALS_INT(object->char_field(entry->f2_as_index()), 0); 595 SET_LOCALS_INT(object->char_field(entry->f2_as_index()), 0);
566 break; 596 break;
567 597
568 case btos: 598 case btos:
599 case ztos:
569 SET_LOCALS_INT(object->byte_field(entry->f2_as_index()), 0); 600 SET_LOCALS_INT(object->byte_field(entry->f2_as_index()), 0);
570 break; 601 break;
571 602
572 case stos: 603 case stos:
573 SET_LOCALS_INT(object->short_field(entry->f2_as_index()), 0); 604 SET_LOCALS_INT(object->short_field(entry->f2_as_index()), 0);