1 /* |
1 /* |
2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
26 #include "asm/assembler.hpp" |
26 #include "asm/assembler.hpp" |
27 #include "assembler_x86.inline.hpp" |
27 #include "assembler_x86.inline.hpp" |
28 #include "interpreter/interpreter.hpp" |
28 #include "interpreter/interpreter.hpp" |
29 #include "nativeInst_x86.hpp" |
29 #include "nativeInst_x86.hpp" |
30 #include "oops/instanceOop.hpp" |
30 #include "oops/instanceOop.hpp" |
31 #include "oops/methodOop.hpp" |
31 #include "oops/method.hpp" |
32 #include "oops/objArrayKlass.hpp" |
32 #include "oops/objArrayKlass.hpp" |
33 #include "oops/oop.inline.hpp" |
33 #include "oops/oop.inline.hpp" |
34 #include "prims/methodHandles.hpp" |
34 #include "prims/methodHandles.hpp" |
35 #include "runtime/frame.inline.hpp" |
35 #include "runtime/frame.inline.hpp" |
36 #include "runtime/handles.inline.hpp" |
36 #include "runtime/handles.inline.hpp" |
107 // |
107 // |
108 // Linux Arguments: |
108 // Linux Arguments: |
109 // c_rarg0: call wrapper address address |
109 // c_rarg0: call wrapper address address |
110 // c_rarg1: result address |
110 // c_rarg1: result address |
111 // c_rarg2: result type BasicType |
111 // c_rarg2: result type BasicType |
112 // c_rarg3: method methodOop |
112 // c_rarg3: method Method* |
113 // c_rarg4: (interpreter) entry point address |
113 // c_rarg4: (interpreter) entry point address |
114 // c_rarg5: parameters intptr_t* |
114 // c_rarg5: parameters intptr_t* |
115 // 16(rbp): parameter size (in words) int |
115 // 16(rbp): parameter size (in words) int |
116 // 24(rbp): thread Thread* |
116 // 24(rbp): thread Thread* |
117 // |
117 // |
137 // |
137 // |
138 // Windows Arguments: |
138 // Windows Arguments: |
139 // c_rarg0: call wrapper address address |
139 // c_rarg0: call wrapper address address |
140 // c_rarg1: result address |
140 // c_rarg1: result address |
141 // c_rarg2: result type BasicType |
141 // c_rarg2: result type BasicType |
142 // c_rarg3: method methodOop |
142 // c_rarg3: method Method* |
143 // 48(rbp): (interpreter) entry point address |
143 // 48(rbp): (interpreter) entry point address |
144 // 56(rbp): parameters intptr_t* |
144 // 56(rbp): parameters intptr_t* |
145 // 64(rbp): parameter size (in words) int |
145 // 64(rbp): parameter size (in words) int |
146 // 72(rbp): thread Thread* |
146 // 72(rbp): thread Thread* |
147 // |
147 // |
330 __ push(rax); // pass parameter |
330 __ push(rax); // pass parameter |
331 __ jcc(Assembler::notZero, loop); |
331 __ jcc(Assembler::notZero, loop); |
332 |
332 |
333 // call Java function |
333 // call Java function |
334 __ BIND(parameters_done); |
334 __ BIND(parameters_done); |
335 __ movptr(rbx, method); // get methodOop |
335 __ movptr(rbx, method); // get Method* |
336 __ movptr(c_rarg1, entry_point); // get entry_point |
336 __ movptr(c_rarg1, entry_point); // get entry_point |
337 __ mov(r13, rsp); // set sender sp |
337 __ mov(r13, rsp); // set sender sp |
338 BLOCK_COMMENT("call Java function"); |
338 BLOCK_COMMENT("call Java function"); |
339 __ call(c_rarg1); |
339 __ call(c_rarg1); |
340 |
340 |
1025 __ jcc(Assembler::notZero, error); |
1025 __ jcc(Assembler::notZero, error); |
1026 |
1026 |
1027 // set r12 to heapbase for load_klass() |
1027 // set r12 to heapbase for load_klass() |
1028 __ reinit_heapbase(); |
1028 __ reinit_heapbase(); |
1029 |
1029 |
1030 // make sure klass is 'reasonable' |
1030 // make sure klass is 'reasonable', which is not zero. |
1031 __ load_klass(rax, rax); // get klass |
1031 __ load_klass(rax, rax); // get klass |
1032 __ testptr(rax, rax); |
1032 __ testptr(rax, rax); |
1033 __ jcc(Assembler::zero, error); // if klass is NULL it is broken |
1033 __ jcc(Assembler::zero, error); // if klass is NULL it is broken |
1034 // Check if the klass is in the right area of memory |
1034 // TODO: Future assert that klass is lower 4g memory for UseCompressedKlassPointers |
1035 __ mov(c_rarg2, rax); |
|
1036 __ movptr(c_rarg3, (intptr_t) Universe::verify_klass_mask()); |
|
1037 __ andptr(c_rarg2, c_rarg3); |
|
1038 __ movptr(c_rarg3, (intptr_t) Universe::verify_klass_bits()); |
|
1039 __ cmpptr(c_rarg2, c_rarg3); |
|
1040 __ jcc(Assembler::notZero, error); |
|
1041 |
|
1042 // make sure klass' klass is 'reasonable' |
|
1043 __ load_klass(rax, rax); |
|
1044 __ testptr(rax, rax); |
|
1045 __ jcc(Assembler::zero, error); // if klass' klass is NULL it is broken |
|
1046 // Check if the klass' klass is in the right area of memory |
|
1047 __ movptr(c_rarg3, (intptr_t) Universe::verify_klass_mask()); |
|
1048 __ andptr(rax, c_rarg3); |
|
1049 __ movptr(c_rarg3, (intptr_t) Universe::verify_klass_bits()); |
|
1050 __ cmpptr(rax, c_rarg3); |
|
1051 __ jcc(Assembler::notZero, error); |
|
1052 |
1035 |
1053 // return if everything seems ok |
1036 // return if everything seems ok |
1054 __ bind(exit); |
1037 __ bind(exit); |
1055 __ movptr(rax, Address(rsp, saved_rax)); // get saved rax back |
1038 __ movptr(rax, Address(rsp, saved_rax)); // get saved rax back |
1056 __ movptr(rscratch1, Address(rsp, saved_r10)); // get saved r10 back |
1039 __ movptr(rscratch1, Address(rsp, saved_r10)); // get saved r10 back |