Skip to content

Commit 74b27d0

Browse files
committed
Refactor frame::send
1 parent b3842e1 commit 74b27d0

File tree

8 files changed

+77
-106
lines changed

8 files changed

+77
-106
lines changed

src/hotspot/cpu/aarch64/frame_aarch64.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -450,18 +450,6 @@ frame frame::sender_for_interpreter_frame(RegisterMap* map) const {
450450
return frame(sender_sp, unextended_sp, sender_fp, sender_pc);
451451
}
452452

453-
//------------------------------------------------------------------------------
454-
// frame::sender
455-
frame frame::sender(RegisterMap* map) const {
456-
frame result = sender_raw(map);
457-
458-
if (map->process_frames() && !map->in_cont()) {
459-
StackWatermarkSet::on_iteration(map->thread(), result);
460-
}
461-
462-
return result;
463-
}
464-
465453
bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
466454
assert(is_interpreted_frame(), "Not an interpreted frame");
467455
// These are reasonable sanity checks

src/hotspot/cpu/aarch64/frame_aarch64.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,8 @@
172172
template <bool relative = false>
173173
intptr_t* interpreter_frame_last_sp() const;
174174

175-
// helper to update a map with callee-saved RBP
176175
template <typename RegisterMapT>
177176
static void update_map_with_saved_link(RegisterMapT* map, intptr_t** link_addr);
178-
template <typename RegisterMapT>
179-
static intptr_t** saved_link_address(const RegisterMapT* map);
180177

181178
// deoptimization support
182179
void interpreter_frame_set_last_sp(intptr_t* sp);

src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -254,33 +254,6 @@ inline void frame::interpreted_frame_oop_map(InterpreterOopMap* mask) const {
254254
m->mask_for(bci, mask); // OopMapCache::compute_one_oop_map(m, bci, mask);
255255
}
256256

257-
// helper to update a map with callee-saved RBP
258-
259-
template <typename RegisterMapT>
260-
void frame::update_map_with_saved_link(RegisterMapT* map, intptr_t** link_addr) {
261-
// The interpreter and compiler(s) always save EBP/RBP in a known
262-
// location on entry. We must record where that location is
263-
// so this if EBP/RBP was live on callout from c2 we can find
264-
// the saved copy no matter what it called.
265-
266-
// Since the interpreter always saves EBP/RBP if we record where it is then
267-
// we don't have to always save EBP/RBP on entry and exit to c2 compiled
268-
// code, on entry will be enough.
269-
map->set_location(rfp->as_VMReg(), (address) link_addr);
270-
// this is weird "H" ought to be at a higher address however the
271-
// oopMaps seems to have the "H" regs at the same address and the
272-
// vanilla register.
273-
// XXXX make this go away
274-
if (true) {
275-
map->set_location(rfp->as_VMReg()->next(), (address) link_addr);
276-
}
277-
}
278-
279-
template <typename RegisterMapT>
280-
intptr_t** frame::saved_link_address(const RegisterMapT* map) {
281-
return (intptr_t**)map->location(rfp->as_VMReg());
282-
}
283-
284257
// Return address:
285258

286259
inline address* frame::sender_pc_addr() const { return (address*) addr_at( return_addr_offset); }
@@ -414,6 +387,18 @@ inline const ImmutableOopMap* frame::get_oop_map() const {
414387
return NULL;
415388
}
416389

390+
//------------------------------------------------------------------------------
391+
// frame::sender
392+
inline frame frame::sender(RegisterMap* map) const {
393+
frame result = sender_raw(map);
394+
395+
if (map->process_frames() && !map->in_cont()) {
396+
StackWatermarkSet::on_iteration(map->thread(), result);
397+
}
398+
399+
return result;
400+
}
401+
417402
inline frame frame::sender_raw(RegisterMap* map) const {
418403
// Default is we done have to follow them. The sender_for_xxx will
419404
// update it accordingly
@@ -428,17 +413,14 @@ inline frame frame::sender_raw(RegisterMap* map) const {
428413
if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
429414

430415
assert(_cb == CodeCache::find_blob(pc()), "Must be the same");
416+
if (_cb != NULL) return sender_for_compiled_frame(map);
431417

432-
if (_cb != NULL) {
433-
return _cb->is_compiled() ? sender_for_compiled_frame<false>(map) : sender_for_compiled_frame<true>(map);
434-
}
435418
// Must be native-compiled frame, i.e. the marshaling code for native
436419
// methods that exists in the core system.
437420
return frame(sender_sp(), link(), sender_pc());
438421
}
439422

440-
template <bool stub>
441-
frame frame::sender_for_compiled_frame(RegisterMap* map) const {
423+
inline frame frame::sender_for_compiled_frame(RegisterMap* map) const {
442424
// we cannot rely upon the last fp having been saved to the thread
443425
// in C2 code but it will have been pushed onto the stack. so we
444426
// have to find it relative to the unextended sp
@@ -456,7 +438,7 @@ frame frame::sender_for_compiled_frame(RegisterMap* map) const {
456438
// Tell GC to use argument oopmaps for some runtime stubs that need it.
457439
// For C1, the runtime stub might not have oop maps, so set this flag
458440
// outside of update_register_map.
459-
if (stub) { // compiled frames do not use callee-saved registers
441+
if (!_cb->is_compiled()) { // compiled frames do not use callee-saved registers
460442
map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));
461443
if (oop_map() != NULL) {
462444
_oop_map->update_register_map(this, map);
@@ -485,4 +467,23 @@ frame frame::sender_for_compiled_frame(RegisterMap* map) const {
485467
return frame(sender_sp, unextended_sp, *saved_fp_addr, sender_pc);
486468
}
487469

470+
template <typename RegisterMapT>
471+
void frame::update_map_with_saved_link(RegisterMapT* map, intptr_t** link_addr) {
472+
// The interpreter and compiler(s) always save EBP/RBP in a known
473+
// location on entry. We must record where that location is
474+
// so this if EBP/RBP was live on callout from c2 we can find
475+
// the saved copy no matter what it called.
476+
477+
// Since the interpreter always saves EBP/RBP if we record where it is then
478+
// we don't have to always save EBP/RBP on entry and exit to c2 compiled
479+
// code, on entry will be enough.
480+
map->set_location(rfp->as_VMReg(), (address) link_addr);
481+
// this is weird "H" ought to be at a higher address however the
482+
// oopMaps seems to have the "H" regs at the same address and the
483+
// vanilla register.
484+
// XXXX make this go away
485+
if (true) {
486+
map->set_location(rfp->as_VMReg()->next(), (address) link_addr);
487+
}
488+
}
488489
#endif // CPU_AARCH64_FRAME_AARCH64_INLINE_HPP

src/hotspot/cpu/x86/frame_x86.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -475,20 +475,6 @@ frame frame::sender_for_interpreter_frame(RegisterMap* map) const {
475475
return frame(sender_sp, unextended_sp, sender_fp, sender_pc);
476476
}
477477

478-
479-
//------------------------------------------------------------------------------
480-
// frame::sender
481-
482-
frame frame::sender(RegisterMap* map) const {
483-
frame result = sender_raw(map);
484-
485-
if (map->process_frames() && !map->in_cont()) {
486-
StackWatermarkSet::on_iteration(map->thread(), result);
487-
}
488-
489-
return result;
490-
}
491-
492478
bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
493479
assert(is_interpreted_frame(), "Not an interpreted frame");
494480
// These are reasonable sanity checks

src/hotspot/cpu/x86/frame_x86.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -162,11 +162,8 @@
162162
template <bool relative = false>
163163
intptr_t* interpreter_frame_last_sp() const;
164164

165-
// helper to update a map with callee-saved RBP
166165
template <typename RegisterMapT>
167166
static void update_map_with_saved_link(RegisterMapT* map, intptr_t** link_addr);
168-
template <typename RegisterMapT>
169-
static intptr_t** saved_link_address(const RegisterMapT* map);
170167

171168
// deoptimization support
172169
void interpreter_frame_set_last_sp(intptr_t* sp);

src/hotspot/cpu/x86/frame_x86.inline.hpp

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -241,35 +241,6 @@ inline void frame::interpreted_frame_oop_map(InterpreterOopMap* mask) const {
241241
m->mask_for(bci, mask); // OopMapCache::compute_one_oop_map(m, bci, mask);
242242
}
243243

244-
// helper to update a map with callee-saved RBP
245-
246-
template <typename RegisterMapT>
247-
void frame::update_map_with_saved_link(RegisterMapT* map, intptr_t** link_addr) {
248-
// The interpreter and compiler(s) always save EBP/RBP in a known
249-
// location on entry. We must record where that location is
250-
// so this if EBP/RBP was live on callout from c2 we can find
251-
// the saved copy no matter what it called.
252-
253-
// Since the interpreter always saves EBP/RBP if we record where it is then
254-
// we don't have to always save EBP/RBP on entry and exit to c2 compiled
255-
// code, on entry will be enough.
256-
map->set_location(rbp->as_VMReg(), (address) link_addr);
257-
#ifdef AMD64
258-
// this is weird "H" ought to be at a higher address however the
259-
// oopMaps seems to have the "H" regs at the same address and the
260-
// vanilla register.
261-
// XXXX make this go away
262-
if (true) {
263-
map->set_location(rbp->as_VMReg()->next(), (address) link_addr);
264-
}
265-
#endif // AMD64
266-
}
267-
268-
template <typename RegisterMapT>
269-
intptr_t** frame::saved_link_address(const RegisterMapT* map) {
270-
return (intptr_t**)map->location(rbp->as_VMReg());
271-
}
272-
273244
// Return address:
274245

275246
inline address* frame::sender_pc_addr() const { return (address*) addr_at(return_addr_offset); }
@@ -400,6 +371,19 @@ inline const ImmutableOopMap* frame::get_oop_map() const {
400371
return NULL;
401372
}
402373

374+
//------------------------------------------------------------------------------
375+
// frame::sender
376+
377+
inline frame frame::sender(RegisterMap* map) const {
378+
frame result = sender_raw(map);
379+
380+
if (map->process_frames() && !map->in_cont()) {
381+
StackWatermarkSet::on_iteration(map->thread(), result);
382+
}
383+
384+
return result;
385+
}
386+
403387
inline frame frame::sender_raw(RegisterMap* map) const {
404388
// Default is we done have to follow them. The sender_for_xxx will
405389
// update it accordingly
@@ -414,17 +398,14 @@ inline frame frame::sender_raw(RegisterMap* map) const {
414398
if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
415399

416400
assert(_cb == CodeCache::find_blob(pc()), "Must be the same");
401+
if (_cb != NULL) return sender_for_compiled_frame(map);
417402

418-
if (_cb != NULL) {
419-
return _cb->is_compiled() ? sender_for_compiled_frame<false>(map) : sender_for_compiled_frame<true>(map);
420-
}
421403
// Must be native-compiled frame, i.e. the marshaling code for native
422404
// methods that exists in the core system.
423405
return frame(sender_sp(), link(), sender_pc());
424406
}
425407

426-
template <bool stub>
427-
frame frame::sender_for_compiled_frame(RegisterMap* map) const {
408+
inline frame frame::sender_for_compiled_frame(RegisterMap* map) const {
428409
assert(map != NULL, "map must be set");
429410

430411
// frame owned by optimizing compiler
@@ -444,7 +425,7 @@ frame frame::sender_for_compiled_frame(RegisterMap* map) const {
444425
// Tell GC to use argument oopmaps for some runtime stubs that need it.
445426
// For C1, the runtime stub might not have oop maps, so set this flag
446427
// outside of update_register_map.
447-
if (stub) { // compiled frames do not use callee-saved registers
428+
if (!_cb->is_compiled()) { // compiled frames do not use callee-saved registers
448429
map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));
449430
if (oop_map() != NULL) {
450431
_oop_map->update_register_map(this, map);
@@ -475,4 +456,25 @@ frame frame::sender_for_compiled_frame(RegisterMap* map) const {
475456
return frame(sender_sp, unextended_sp, *saved_fp_addr, sender_pc);
476457
}
477458

459+
template <typename RegisterMapT>
460+
void frame::update_map_with_saved_link(RegisterMapT* map, intptr_t** link_addr) {
461+
// The interpreter and compiler(s) always save EBP/RBP in a known
462+
// location on entry. We must record where that location is
463+
// so this if EBP/RBP was live on callout from c2 we can find
464+
// the saved copy no matter what it called.
465+
466+
// Since the interpreter always saves EBP/RBP if we record where it is then
467+
// we don't have to always save EBP/RBP on entry and exit to c2 compiled
468+
// code, on entry will be enough.
469+
map->set_location(rbp->as_VMReg(), (address) link_addr);
470+
#ifdef AMD64
471+
// this is weird "H" ought to be at a higher address however the
472+
// oopMaps seems to have the "H" regs at the same address and the
473+
// vanilla register.
474+
// XXXX make this go away
475+
if (true) {
476+
map->set_location(rbp->as_VMReg()->next(), (address) link_addr);
477+
}
478+
#endif // AMD64
479+
}
478480
#endif // CPU_X86_FRAME_X86_INLINE_HPP

src/hotspot/share/runtime/frame.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class frame {
200200
inline void interpreted_frame_oop_map(InterpreterOopMap* mask) const;
201201

202202
// returns the sending frame
203-
frame sender(RegisterMap* map) const;
203+
inline frame sender(RegisterMap* map) const;
204204

205205
bool safe_for_sender(JavaThread *thread);
206206

@@ -213,8 +213,7 @@ class frame {
213213

214214
private:
215215
// Helper methods for better factored code in frame::sender
216-
template <bool stub>
217-
frame sender_for_compiled_frame(RegisterMap* map) const;
216+
inline frame sender_for_compiled_frame(RegisterMap* map) const;
218217
frame sender_for_entry_frame(RegisterMap* map) const;
219218
frame sender_for_interpreter_frame(RegisterMap* map) const;
220219
frame sender_for_native_frame(RegisterMap* map) const;

src/hotspot/share/runtime/stackWatermark.inline.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
2828
#include "runtime/stackWatermark.hpp"
2929

3030
#include "code/nmethod.hpp"
31+
#include "runtime/frame.inline.hpp"
3132
#include "runtime/registerMap.hpp"
3233
#include "runtime/thread.hpp"
3334

0 commit comments

Comments
 (0)