8387637: Dead code for upwards interpreter stacks

Reviewed-by: coleenp, dholmes, shade
This commit is contained in:
Benjamin Peterson 2026-07-14 13:29:26 +00:00 committed by Aleksey Shipilev
parent 6e2a4f847f
commit feb944c6c9
11 changed files with 11 additions and 47 deletions

View File

@ -186,8 +186,6 @@
// deoptimization support
void interpreter_frame_set_last_sp(intptr_t* sp);
static jint interpreter_frame_expression_stack_direction() { return -1; }
// returns the sending frame, without applying any barriers
inline frame sender_raw(RegisterMap* map) const;

View File

@ -122,6 +122,4 @@
// helper to update a map with callee-saved FP
static void update_map_with_saved_link(RegisterMap* map, intptr_t** link_addr);
static jint interpreter_frame_expression_stack_direction() { return -1; }
#endif // CPU_ARM_FRAME_ARM_HPP

View File

@ -407,8 +407,6 @@
align_wiggle = 1
};
static jint interpreter_frame_expression_stack_direction() { return -1; }
// returns the sending frame, without applying any barriers
inline frame sender_raw(RegisterMap* map) const;

View File

@ -218,8 +218,6 @@
// deoptimization support
void interpreter_frame_set_last_sp(intptr_t* last_sp);
static jint interpreter_frame_expression_stack_direction() { return -1; }
// returns the sending frame, without applying any barriers
inline frame sender_raw(RegisterMap* map) const;

View File

@ -572,8 +572,6 @@
align_wiggle = 0
};
static jint interpreter_frame_expression_stack_direction() { return -1; }
// returns the sending frame, without applying any barriers
inline frame sender_raw(RegisterMap* map) const;

View File

@ -170,8 +170,6 @@
// deoptimization support
void interpreter_frame_set_last_sp(intptr_t* sp);
static jint interpreter_frame_expression_stack_direction() { return -1; }
// returns the sending frame, without applying any barriers
inline frame sender_raw(RegisterMap* map) const;

View File

@ -82,8 +82,6 @@
char* buf,
int buflen) const;
static jint interpreter_frame_expression_stack_direction() { return -1; }
inline address* sender_pc_addr() const;
template <typename RegisterMapT>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. 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
@ -262,8 +262,8 @@ class AbstractInterpreter: AllStatic {
#endif
// Local values relative to locals[n]
static int local_offset_in_bytes(int n) {
return ((frame::interpreter_frame_expression_stack_direction() * n) * stackElementSize);
static int local_offset_in_bytes(int n) {
return -n * stackElementSize;
}
// access to stacked values according to type:

View File

@ -500,23 +500,16 @@ intptr_t* frame::interpreter_frame_local_at(int index) const {
}
intptr_t* frame::interpreter_frame_expression_stack_at(jint offset) const {
const int i = offset * interpreter_frame_expression_stack_direction();
const int n = i * Interpreter::stackElementWords;
return &(interpreter_frame_expression_stack()[n]);
const int n = offset * Interpreter::stackElementWords;
return interpreter_frame_expression_stack() - n;
}
jint frame::interpreter_frame_expression_stack_size() const {
// Number of elements on the interpreter expression stack
// Callers should span by stackElementWords
int element_size = Interpreter::stackElementWords;
size_t stack_size = 0;
if (frame::interpreter_frame_expression_stack_direction() < 0) {
stack_size = (interpreter_frame_expression_stack() -
interpreter_frame_tos_address() + 1)/element_size;
} else {
stack_size = (interpreter_frame_tos_address() -
interpreter_frame_expression_stack() + 1)/element_size;
}
size_t stack_size = (interpreter_frame_expression_stack() -
interpreter_frame_tos_address() + 1)/element_size;
assert(stack_size <= (size_t)max_jint, "stack size too big");
return (jint)stack_size;
}
@ -791,14 +784,8 @@ class InterpreterFrameClosure : public OffsetClosure {
} else {
addr = (oop*) _fr->interpreter_frame_expression_stack_at((offset - _max_locals));
// In case of exceptions, the expression stack is invalid and the esp will be reset to express
// this condition. Therefore, we call f only if addr is 'inside' the stack (i.e., addr >= esp for Intel).
bool in_stack;
if (frame::interpreter_frame_expression_stack_direction() > 0) {
in_stack = (intptr_t*)addr <= _fr->interpreter_frame_tos_address();
} else {
in_stack = (intptr_t*)addr >= _fr->interpreter_frame_tos_address();
}
if (in_stack) {
// this condition. Therefore, we call f only if addr is 'inside' the stack (i.e., addr >= esp).
if ((intptr_t*)addr >= _fr->interpreter_frame_tos_address()) {
_f->do_oop(addr);
}
}

View File

@ -318,13 +318,9 @@ static StackValue* create_stack_value_from_oop_map(const InterpreterOopMap& oop_
static bool is_in_expression_stack(const frame& fr, const intptr_t* const addr) {
assert(addr != nullptr, "invariant");
// Ensure to be 'inside' the expression stack (i.e., addr >= sp for Intel).
// Ensure to be 'inside' the expression stack (i.e., addr >= sp).
// In case of exceptions, the expression stack is invalid and the sp
// will be reset to express this condition.
if (frame::interpreter_frame_expression_stack_direction() > 0) {
return addr <= fr.interpreter_frame_tos_address();
}
return addr >= fr.interpreter_frame_tos_address();
}

View File

@ -473,12 +473,7 @@ void vframeArrayElement::unpack_on_stack(int caller_actual_parameters,
"expression stack size should have been extended");
#endif // ASSERT
int top_element = iframe()->interpreter_frame_expression_stack_size()-1;
intptr_t* base;
if (frame::interpreter_frame_expression_stack_direction() < 0) {
base = iframe()->interpreter_frame_expression_stack_at(top_element);
} else {
base = iframe()->interpreter_frame_expression_stack();
}
intptr_t* base = iframe()->interpreter_frame_expression_stack_at(top_element);
Copy::conjoint_jbytes(saved_args,
base,
popframe_preserved_args_size_in_bytes);