From dadc8613277c5193f947074ce7d29d6dbda67230 Mon Sep 17 00:00:00 2001 From: twisti Date: Wed, 17 Mar 2010 10:22:41 +0100 Subject: [PATCH] 6934966: JSR 292 add C1 logic for saved SP over MethodHandle calls Summary: The logic for x86 C1 to save the SP over MH calls is pretty straight forward but SPARC handles that differently. Reviewed-by: never, jrose --- src/cpu/sparc/vm/c1_FrameMap_sparc.hpp | 5 ++++- src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp | 4 ++-- src/cpu/x86/vm/c1_FrameMap_x86.hpp | 5 ++++- src/cpu/x86/vm/c1_LIRAssembler_x86.cpp | 8 ++++---- src/share/vm/c1/c1_LIR.cpp | 1 + src/share/vm/c1/c1_LIRAssembler.cpp | 4 ++-- src/share/vm/c1/c1_LIRAssembler.hpp | 5 +++-- 7 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/cpu/sparc/vm/c1_FrameMap_sparc.hpp b/src/cpu/sparc/vm/c1_FrameMap_sparc.hpp index 265178446..81b979832 100644 --- a/src/cpu/sparc/vm/c1_FrameMap_sparc.hpp +++ b/src/cpu/sparc/vm/c1_FrameMap_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -143,3 +143,6 @@ static bool is_caller_save_register (LIR_Opr reg); static bool is_caller_save_register (Register r); + + // JSR 292 + static LIR_Opr& method_handle_invoke_SP_save_opr() { return L7_opr; } diff --git a/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp b/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp index 05804c52d..3fe53ae89 100644 --- a/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp +++ b/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp @@ -712,12 +712,12 @@ void LIR_Assembler::vtable_call(LIR_OpJavaCall* op) { } -void LIR_Assembler::preserve_SP() { +void LIR_Assembler::preserve_SP(LIR_OpJavaCall* op) { Unimplemented(); } -void LIR_Assembler::restore_SP() { +void LIR_Assembler::restore_SP(LIR_OpJavaCall* op) { Unimplemented(); } diff --git a/src/cpu/x86/vm/c1_FrameMap_x86.hpp b/src/cpu/x86/vm/c1_FrameMap_x86.hpp index 65671c32d..110dedd7c 100644 --- a/src/cpu/x86/vm/c1_FrameMap_x86.hpp +++ b/src/cpu/x86/vm/c1_FrameMap_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -126,3 +126,6 @@ assert(i >= 0 && i < nof_caller_save_xmm_regs, "out of bounds"); return _caller_save_xmm_regs[i]; } + + // JSR 292 + static LIR_Opr& method_handle_invoke_SP_save_opr() { return rbp_opr; } diff --git a/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp b/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp index eb1ee51bd..987a9de7d 100644 --- a/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp +++ b/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp @@ -2762,13 +2762,13 @@ void LIR_Assembler::vtable_call(LIR_OpJavaCall* op) { } -void LIR_Assembler::preserve_SP() { - __ movptr(rbp, rsp); +void LIR_Assembler::preserve_SP(LIR_OpJavaCall* op) { + __ movptr(FrameMap::method_handle_invoke_SP_save_opr()->as_register(), rsp); } -void LIR_Assembler::restore_SP() { - __ movptr(rsp, rbp); +void LIR_Assembler::restore_SP(LIR_OpJavaCall* op) { + __ movptr(rsp, FrameMap::method_handle_invoke_SP_save_opr()->as_register()); } diff --git a/src/share/vm/c1/c1_LIR.cpp b/src/share/vm/c1/c1_LIR.cpp index ce8efb9b4..4d9f6958a 100644 --- a/src/share/vm/c1/c1_LIR.cpp +++ b/src/share/vm/c1/c1_LIR.cpp @@ -705,6 +705,7 @@ void LIR_OpVisitState::visit(LIR_Op* op) { } if (opJavaCall->_info) do_info(opJavaCall->_info); + if (opJavaCall->is_method_handle_invoke()) do_temp(FrameMap::method_handle_invoke_SP_save_opr()); do_call(); if (opJavaCall->_result->is_valid()) do_output(opJavaCall->_result); diff --git a/src/share/vm/c1/c1_LIRAssembler.cpp b/src/share/vm/c1/c1_LIRAssembler.cpp index a58051f1a..14c4485e3 100644 --- a/src/share/vm/c1/c1_LIRAssembler.cpp +++ b/src/share/vm/c1/c1_LIRAssembler.cpp @@ -416,7 +416,7 @@ void LIR_Assembler::emit_call(LIR_OpJavaCall* op) { // JSR 292 // Preserve the SP over MethodHandle call sites. if (op->is_method_handle_invoke()) { - preserve_SP(); + preserve_SP(op); } if (os::is_MP()) { @@ -445,7 +445,7 @@ void LIR_Assembler::emit_call(LIR_OpJavaCall* op) { } if (op->is_method_handle_invoke()) { - restore_SP(); + restore_SP(op); } #if defined(X86) && defined(TIERED) diff --git a/src/share/vm/c1/c1_LIRAssembler.hpp b/src/share/vm/c1/c1_LIRAssembler.hpp index 01de986d8..a7c1ecc86 100644 --- a/src/share/vm/c1/c1_LIRAssembler.hpp +++ b/src/share/vm/c1/c1_LIRAssembler.hpp @@ -209,8 +209,9 @@ class LIR_Assembler: public CompilationResourceObj { void ic_call( LIR_OpJavaCall* op); void vtable_call( LIR_OpJavaCall* op); - void preserve_SP(); - void restore_SP(); + // JSR 292 + void preserve_SP(LIR_OpJavaCall* op); + void restore_SP( LIR_OpJavaCall* op); void osr_entry(); -- GitLab