1 /* |
1 /* |
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2016, 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. |
24 |
24 |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "asm/macroAssembler.hpp" |
26 #include "asm/macroAssembler.hpp" |
27 #include "interpreter/interp_masm.hpp" |
27 #include "interpreter/interp_masm.hpp" |
28 #include "interpreter/interpreter.hpp" |
28 #include "interpreter/interpreter.hpp" |
|
29 #include "interpreter/interpreterRuntime.hpp" |
29 #include "interpreter/templateInterpreterGenerator.hpp" |
30 #include "interpreter/templateInterpreterGenerator.hpp" |
30 #include "runtime/arguments.hpp" |
31 #include "runtime/arguments.hpp" |
|
32 #include "runtime/sharedRuntime.hpp" |
31 |
33 |
32 #define __ _masm-> |
34 #define __ _masm-> |
33 |
35 |
|
36 |
|
37 address TemplateInterpreterGenerator::generate_slow_signature_handler() { |
|
38 address entry = __ pc(); |
|
39 // rbx,: method |
|
40 // rcx: temporary |
|
41 // rdi: pointer to locals |
|
42 // rsp: end of copied parameters area |
|
43 __ mov(rcx, rsp); |
|
44 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), rbx, rdi, rcx); |
|
45 __ ret(0); |
|
46 return entry; |
|
47 } |
34 |
48 |
35 /** |
49 /** |
36 * Method entry for static native methods: |
50 * Method entry for static native methods: |
37 * int java.util.zip.CRC32.update(int crc, int b) |
51 * int java.util.zip.CRC32.update(int crc, int b) |
38 */ |
52 */ |
299 return entry; |
313 return entry; |
300 } |
314 } |
301 |
315 |
302 return NULL; |
316 return NULL; |
303 } |
317 } |
|
318 |
|
319 address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) { |
|
320 |
|
321 // rbx,: Method* |
|
322 // rcx: scratrch |
|
323 // rsi: sender sp |
|
324 |
|
325 if (!InlineIntrinsics) return NULL; // Generate a vanilla entry |
|
326 |
|
327 address entry_point = __ pc(); |
|
328 |
|
329 // These don't need a safepoint check because they aren't virtually |
|
330 // callable. We won't enter these intrinsics from compiled code. |
|
331 // If in the future we added an intrinsic which was virtually callable |
|
332 // we'd have to worry about how to safepoint so that this code is used. |
|
333 |
|
334 // mathematical functions inlined by compiler |
|
335 // (interpreter must provide identical implementation |
|
336 // in order to avoid monotonicity bugs when switching |
|
337 // from interpreter to compiler in the middle of some |
|
338 // computation) |
|
339 // |
|
340 // stack: [ ret adr ] <-- rsp |
|
341 // [ lo(arg) ] |
|
342 // [ hi(arg) ] |
|
343 // |
|
344 |
|
345 __ fld_d(Address(rsp, 1*wordSize)); |
|
346 switch (kind) { |
|
347 case Interpreter::java_lang_math_sin : |
|
348 __ trigfunc('s'); |
|
349 break; |
|
350 case Interpreter::java_lang_math_cos : |
|
351 __ trigfunc('c'); |
|
352 break; |
|
353 case Interpreter::java_lang_math_tan : |
|
354 __ trigfunc('t'); |
|
355 break; |
|
356 case Interpreter::java_lang_math_sqrt: |
|
357 __ fsqrt(); |
|
358 break; |
|
359 case Interpreter::java_lang_math_abs: |
|
360 __ fabs(); |
|
361 break; |
|
362 case Interpreter::java_lang_math_log: |
|
363 __ subptr(rsp, 2 * wordSize); |
|
364 __ fstp_d(Address(rsp, 0)); |
|
365 if (VM_Version::supports_sse2()) { |
|
366 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog()))); |
|
367 } |
|
368 else { |
|
369 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog))); |
|
370 } |
|
371 __ addptr(rsp, 2 * wordSize); |
|
372 break; |
|
373 case Interpreter::java_lang_math_log10: |
|
374 __ flog10(); |
|
375 // Store to stack to convert 80bit precision back to 64bits |
|
376 __ push_fTOS(); |
|
377 __ pop_fTOS(); |
|
378 break; |
|
379 case Interpreter::java_lang_math_pow: |
|
380 __ fld_d(Address(rsp, 3*wordSize)); // second argument |
|
381 __ pow_with_fallback(0); |
|
382 // Store to stack to convert 80bit precision back to 64bits |
|
383 __ push_fTOS(); |
|
384 __ pop_fTOS(); |
|
385 break; |
|
386 case Interpreter::java_lang_math_exp: |
|
387 __ subptr(rsp, 2*wordSize); |
|
388 __ fstp_d(Address(rsp, 0)); |
|
389 if (VM_Version::supports_sse2()) { |
|
390 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp()))); |
|
391 } else { |
|
392 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dexp))); |
|
393 } |
|
394 __ addptr(rsp, 2*wordSize); |
|
395 break; |
|
396 default : |
|
397 ShouldNotReachHere(); |
|
398 } |
|
399 |
|
400 // return double result in xmm0 for interpreter and compilers. |
|
401 if (UseSSE >= 2) { |
|
402 __ subptr(rsp, 2*wordSize); |
|
403 __ fstp_d(Address(rsp, 0)); |
|
404 __ movdbl(xmm0, Address(rsp, 0)); |
|
405 __ addptr(rsp, 2*wordSize); |
|
406 } |
|
407 |
|
408 // done, result in FPU ST(0) or XMM0 |
|
409 __ pop(rdi); // get return address |
|
410 __ mov(rsp, rsi); // set sp to sender sp |
|
411 __ jmp(rdi); |
|
412 |
|
413 return entry_point; |
|
414 } |