1 /*
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
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
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
264 address function;
265 function = method->native_function();
266 assert(function != NULL, "should be set if signature handler is");
267
268 // Build the argument list
269 stack->overflow_check(handler->argument_count() * 2, THREAD);
270 if (HAS_PENDING_EXCEPTION)
271 goto unlock_unwind_and_return;
272
273 void **arguments;
274 void *mirror; {
275 arguments =
276 (void **) stack->alloc(handler->argument_count() * sizeof(void **));
277 void **dst = arguments;
278
279 void *env = thread->jni_environment();
280 *(dst++) = &env;
281
282 if (method->is_static()) {
283 istate->set_oop_temp(
284 method->constants()->pool_holder()->klass_part()->java_mirror());
285 mirror = istate->oop_temp_addr();
286 *(dst++) = &mirror;
287 }
288
289 intptr_t *src = locals;
290 for (int i = dst - arguments; i < handler->argument_count(); i++) {
291 ffi_type *type = handler->argument_type(i);
292 if (type == &ffi_type_pointer) {
293 if (*src) {
294 stack->push((intptr_t) src);
295 *(dst++) = stack->sp();
296 }
297 else {
298 *(dst++) = src;
299 }
300 src--;
301 }
302 else if (type->size == 4) {
303 *(dst++) = src--;
304 }
650 assert(fp - stack->sp() == istate_off, "should be");
651
652 istate->set_locals(locals);
653 istate->set_method(method);
654 istate->set_self_link(istate);
655 istate->set_prev_link(NULL);
656 istate->set_thread(thread);
657 istate->set_bcp(method->is_native() ? NULL : method->code_base());
658 istate->set_constants(method->constants()->cache());
659 istate->set_msg(BytecodeInterpreter::method_entry);
660 istate->set_oop_temp(NULL);
661 istate->set_mdx(NULL);
662 istate->set_callee(NULL);
663
664 istate->set_monitor_base((BasicObjectLock *) stack->sp());
665 if (method->is_synchronized()) {
666 BasicObjectLock *monitor =
667 (BasicObjectLock *) stack->alloc(monitor_words * wordSize);
668 oop object;
669 if (method->is_static())
670 object = method->constants()->pool_holder()->klass_part()->java_mirror();
671 else
672 object = (oop) locals[0];
673 monitor->set_obj(object);
674 }
675
676 istate->set_stack_base(stack->sp());
677 istate->set_stack(stack->sp() - 1);
678 if (stack_words)
679 stack->alloc(stack_words * wordSize);
680 istate->set_stack_limit(stack->sp() - 1);
681
682 return (InterpreterFrame *) fp;
683 }
684
685 int AbstractInterpreter::BasicType_as_index(BasicType type) {
686 int i = 0;
687 switch (type) {
688 case T_BOOLEAN: i = 0; break;
689 case T_CHAR : i = 1; break;
690 case T_BYTE : i = 2; break;
|
1 /*
2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
3 * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
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
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
264 address function;
265 function = method->native_function();
266 assert(function != NULL, "should be set if signature handler is");
267
268 // Build the argument list
269 stack->overflow_check(handler->argument_count() * 2, THREAD);
270 if (HAS_PENDING_EXCEPTION)
271 goto unlock_unwind_and_return;
272
273 void **arguments;
274 void *mirror; {
275 arguments =
276 (void **) stack->alloc(handler->argument_count() * sizeof(void **));
277 void **dst = arguments;
278
279 void *env = thread->jni_environment();
280 *(dst++) = &env;
281
282 if (method->is_static()) {
283 istate->set_oop_temp(
284 method->constants()->pool_holder()->java_mirror());
285 mirror = istate->oop_temp_addr();
286 *(dst++) = &mirror;
287 }
288
289 intptr_t *src = locals;
290 for (int i = dst - arguments; i < handler->argument_count(); i++) {
291 ffi_type *type = handler->argument_type(i);
292 if (type == &ffi_type_pointer) {
293 if (*src) {
294 stack->push((intptr_t) src);
295 *(dst++) = stack->sp();
296 }
297 else {
298 *(dst++) = src;
299 }
300 src--;
301 }
302 else if (type->size == 4) {
303 *(dst++) = src--;
304 }
650 assert(fp - stack->sp() == istate_off, "should be");
651
652 istate->set_locals(locals);
653 istate->set_method(method);
654 istate->set_self_link(istate);
655 istate->set_prev_link(NULL);
656 istate->set_thread(thread);
657 istate->set_bcp(method->is_native() ? NULL : method->code_base());
658 istate->set_constants(method->constants()->cache());
659 istate->set_msg(BytecodeInterpreter::method_entry);
660 istate->set_oop_temp(NULL);
661 istate->set_mdx(NULL);
662 istate->set_callee(NULL);
663
664 istate->set_monitor_base((BasicObjectLock *) stack->sp());
665 if (method->is_synchronized()) {
666 BasicObjectLock *monitor =
667 (BasicObjectLock *) stack->alloc(monitor_words * wordSize);
668 oop object;
669 if (method->is_static())
670 object = method->constants()->pool_holder()->java_mirror();
671 else
672 object = (oop) locals[0];
673 monitor->set_obj(object);
674 }
675
676 istate->set_stack_base(stack->sp());
677 istate->set_stack(stack->sp() - 1);
678 if (stack_words)
679 stack->alloc(stack_words * wordSize);
680 istate->set_stack_limit(stack->sp() - 1);
681
682 return (InterpreterFrame *) fp;
683 }
684
685 int AbstractInterpreter::BasicType_as_index(BasicType type) {
686 int i = 0;
687 switch (type) {
688 case T_BOOLEAN: i = 0; break;
689 case T_CHAR : i = 1; break;
690 case T_BYTE : i = 2; break;
|