comparison src/cpu/zero/vm/cppInterpreter_zero.cpp @ 23660:b5f3a471e646

Merge.
author Doug Simon <doug.simon@oracle.com>
date Wed, 01 Jun 2016 00:11:44 +0200
parents dd9cc155639c cc78c97abff8
children 9b69cec6d01b
comparison
equal deleted inserted replaced
23411:d7cf78885a3a 23660:b5f3a471e646
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_ARRAY:
97 case T_LONG:
98 case T_INT:
99 case T_FLOAT:
100 case T_DOUBLE:
101 case T_VOID:
102 return result;
103 default : ShouldNotReachHere();
104 }
105 }
106
107
84 void CppInterpreter::main_loop(int recurse, TRAPS) { 108 void CppInterpreter::main_loop(int recurse, TRAPS) {
85 JavaThread *thread = (JavaThread *) THREAD; 109 JavaThread *thread = (JavaThread *) THREAD;
86 ZeroStack *stack = thread->zero_stack(); 110 ZeroStack *stack = thread->zero_stack();
87 111
88 // If we are entering from a deopt we may need to call 112 // If we are entering from a deopt we may need to call
158 // Resume the interpreter 182 // Resume the interpreter
159 istate->set_msg(BytecodeInterpreter::got_monitors); 183 istate->set_msg(BytecodeInterpreter::got_monitors);
160 } 184 }
161 else if (istate->msg() == BytecodeInterpreter::return_from_method) { 185 else if (istate->msg() == BytecodeInterpreter::return_from_method) {
162 // Copy the result into the caller's frame 186 // Copy the result into the caller's frame
163 result_slots = type2size[result_type_of(method)]; 187 result_slots = type2size[method->result_type()];
164 assert(result_slots >= 0 && result_slots <= 2, "what?"); 188 assert(result_slots >= 0 && result_slots <= 2, "what?");
165 result = istate->stack() + result_slots; 189 result = istate->stack() + result_slots;
166 break; 190 break;
167 } 191 }
168 else if (istate->msg() == BytecodeInterpreter::throwing_exception) { 192 else if (istate->msg() == BytecodeInterpreter::throwing_exception) {
192 216
193 // Pop our local variables 217 // Pop our local variables
194 stack->set_sp(stack->sp() + method->max_locals()); 218 stack->set_sp(stack->sp() + method->max_locals());
195 219
196 // Push our result 220 // Push our result
197 for (int i = 0; i < result_slots; i++) 221 for (int i = 0; i < result_slots; i++) {
198 stack->push(result[-i]); 222 // Adjust result to smaller
223 intptr_t res = result[-i];
224 if (result_slots == 1) {
225 res = narrow(method->result_type(), res);
226 }
227 stack->push(res);
228 }
199 } 229 }
200 230
201 int CppInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) { 231 int CppInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
202 // Make sure method is native and not abstract 232 // Make sure method is native and not abstract
203 assert(method->is_native() && !method->is_abstract(), "should be"); 233 assert(method->is_native() && !method->is_abstract(), "should be");
404 // Pop our parameters 434 // Pop our parameters
405 stack->set_sp(stack->sp() + method->size_of_parameters()); 435 stack->set_sp(stack->sp() + method->size_of_parameters());
406 436
407 // Push our result 437 // Push our result
408 if (!HAS_PENDING_EXCEPTION) { 438 if (!HAS_PENDING_EXCEPTION) {
409 BasicType type = result_type_of(method); 439 BasicType type = method->result_type();
410 stack->set_sp(stack->sp() - type2size[type]); 440 stack->set_sp(stack->sp() - type2size[type]);
411 441
412 switch (type) { 442 switch (type) {
413 case T_VOID: 443 case T_VOID:
414 break; 444 break;
526 case ctos: 556 case ctos:
527 SET_LOCALS_INT(object->char_field_acquire(entry->f2_as_index()), 0); 557 SET_LOCALS_INT(object->char_field_acquire(entry->f2_as_index()), 0);
528 break; 558 break;
529 559
530 case btos: 560 case btos:
561 case ztos:
531 SET_LOCALS_INT(object->byte_field_acquire(entry->f2_as_index()), 0); 562 SET_LOCALS_INT(object->byte_field_acquire(entry->f2_as_index()), 0);
532 break; 563 break;
533 564
534 case stos: 565 case stos:
535 SET_LOCALS_INT(object->short_field_acquire(entry->f2_as_index()), 0); 566 SET_LOCALS_INT(object->short_field_acquire(entry->f2_as_index()), 0);
564 case ctos: 595 case ctos:
565 SET_LOCALS_INT(object->char_field(entry->f2_as_index()), 0); 596 SET_LOCALS_INT(object->char_field(entry->f2_as_index()), 0);
566 break; 597 break;
567 598
568 case btos: 599 case btos:
600 case ztos:
569 SET_LOCALS_INT(object->byte_field(entry->f2_as_index()), 0); 601 SET_LOCALS_INT(object->byte_field(entry->f2_as_index()), 0);
570 break; 602 break;
571 603
572 case stos: 604 case stos:
573 SET_LOCALS_INT(object->short_field(entry->f2_as_index()), 0); 605 SET_LOCALS_INT(object->short_field(entry->f2_as_index()), 0);
760 default : ShouldNotReachHere(); 792 default : ShouldNotReachHere();
761 } 793 }
762 assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, 794 assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers,
763 "index out of bounds"); 795 "index out of bounds");
764 return i; 796 return i;
765 }
766
767 BasicType CppInterpreter::result_type_of(Method* method) {
768 BasicType t;
769 switch (method->result_index()) {
770 case 0 : t = T_BOOLEAN; break;
771 case 1 : t = T_CHAR; break;
772 case 2 : t = T_BYTE; break;
773 case 3 : t = T_SHORT; break;
774 case 4 : t = T_INT; break;
775 case 5 : t = T_LONG; break;
776 case 6 : t = T_VOID; break;
777 case 7 : t = T_FLOAT; break;
778 case 8 : t = T_DOUBLE; break;
779 case 9 : t = T_OBJECT; break;
780 default: ShouldNotReachHere();
781 }
782 assert(AbstractInterpreter::BasicType_as_index(t) == method->result_index(),
783 "out of step with AbstractInterpreter::BasicType_as_index");
784 return t;
785 } 797 }
786 798
787 address InterpreterGenerator::generate_empty_entry() { 799 address InterpreterGenerator::generate_empty_entry() {
788 if (!UseFastEmptyMethods) 800 if (!UseFastEmptyMethods)
789 return NULL; 801 return NULL;