Commit 939347bb by Tom Tromey Committed by Tom Tromey

verify.cc (state::check_no_uninitialized_objects): Removed.

	* verify.cc (state::check_no_uninitialized_objects): Removed.
	(push_jump): Updated.
	(push_exception_jump): Likewise.
	(handle_ret_insn): Likewise.
	(handle_jsr_insn): Likewise.

From-SVN: r90040
parent 318627d5
2004-11-01 Tom Tromey <tromey@redhat.com>
* verify.cc (state::check_no_uninitialized_objects): Removed.
(push_jump): Updated.
(push_exception_jump): Likewise.
(handle_ret_insn): Likewise.
(handle_jsr_insn): Likewise.
2004-10-30 Mark Wielaard <mark@klomp.org> 2004-10-30 Mark Wielaard <mark@klomp.org>
PR libgcj/18234 PR libgcj/18234
......
...@@ -100,13 +100,15 @@ debug_print (MAYBE_UNUSED const char *fmt, ...) ...@@ -100,13 +100,15 @@ debug_print (MAYBE_UNUSED const char *fmt, ...)
// subroutine is exited via `goto' or `athrow' and not `ret'. // subroutine is exited via `goto' or `athrow' and not `ret'.
// //
// In some other areas the JVM specification is (mildly) incorrect, // In some other areas the JVM specification is (mildly) incorrect,
// but we still implement what is specified. For instance, you cannot // so we diverge. For instance, you cannot
// violate type safety by allocating an object with `new' and then // violate type safety by allocating an object with `new' and then
// failing to initialize it, no matter how one branches or where one // failing to initialize it, no matter how one branches or where one
// stores the uninitialized reference. See "Improving the official // stores the uninitialized reference. See "Improving the official
// specification of Java bytecode verification" by Alessandro Coglio. // specification of Java bytecode verification" by Alessandro Coglio.
// Similarly, there's no real point in enforcing that padding bytes or //
// the mystery byte of invokeinterface must be 0, but we do that too. // Note that there's no real point in enforcing that padding bytes or
// the mystery byte of invokeinterface must be 0, but we do that
// regardless.
// //
// The verifier is currently neither completely lazy nor eager when it // The verifier is currently neither completely lazy nor eager when it
// comes to loading classes. It tries to represent types by name when // comes to loading classes. It tries to represent types by name when
...@@ -1098,28 +1100,6 @@ private: ...@@ -1098,28 +1100,6 @@ private:
return changed; return changed;
} }
// Throw an exception if there is an uninitialized object on the
// stack or in a local variable. EXCEPTION_SEMANTICS controls
// whether we're using backwards-branch or exception-handing
// semantics.
void check_no_uninitialized_objects (int max_locals,
_Jv_BytecodeVerifier *verifier,
bool exception_semantics = false)
{
if (! exception_semantics)
{
for (int i = 0; i < stacktop; ++i)
if (stack[i].isreference () && ! stack[i].isinitialized ())
verifier->verify_fail ("uninitialized object on stack");
}
for (int i = 0; i < max_locals; ++i)
if (locals[i].isreference () && ! locals[i].isinitialized ())
verifier->verify_fail ("uninitialized object in local variable");
check_this_initialized (verifier);
}
// Ensure that `this' has been initialized. // Ensure that `this' has been initialized.
void check_this_initialized (_Jv_BytecodeVerifier *verifier) void check_this_initialized (_Jv_BytecodeVerifier *verifier)
{ {
...@@ -1434,15 +1414,19 @@ private: ...@@ -1434,15 +1414,19 @@ private:
void push_jump (int offset) void push_jump (int offset)
{ {
int npc = compute_jump (offset); int npc = compute_jump (offset);
if (npc < PC) // According to the JVM Spec, we need to check for uninitialized
current_state->check_no_uninitialized_objects (current_method->max_locals, this); // objects here. However, this does not actually affect type
// safety, and the Eclipse java compiler generates code that
// violates this constraint.
merge_into (npc, current_state); merge_into (npc, current_state);
} }
void push_exception_jump (type t, int pc) void push_exception_jump (type t, int pc)
{ {
current_state->check_no_uninitialized_objects (current_method->max_locals, // According to the JVM Spec, we need to check for uninitialized
this, true); // objects here. However, this does not actually affect type
// safety, and the Eclipse java compiler generates code that
// violates this constraint.
state s (current_state, current_method->max_stack, state s (current_state, current_method->max_stack,
current_method->max_locals); current_method->max_locals);
if (current_method->max_stack < 1) if (current_method->max_stack < 1)
...@@ -1504,9 +1488,10 @@ private: ...@@ -1504,9 +1488,10 @@ private:
if (npc >= current_method->code_length) if (npc >= current_method->code_length)
verify_fail ("fell off end"); verify_fail ("fell off end");
if (npc < PC) // According to the JVM Spec, we need to check for uninitialized
current_state->check_no_uninitialized_objects (current_method->max_locals, // objects here. However, this does not actually affect type
this); // safety, and the Eclipse java compiler generates code that
// violates this constraint.
merge_into (npc, current_state); merge_into (npc, current_state);
invalidate_pc (); invalidate_pc ();
} }
...@@ -1515,8 +1500,10 @@ private: ...@@ -1515,8 +1500,10 @@ private:
{ {
int npc = compute_jump (offset); int npc = compute_jump (offset);
if (npc < PC) // According to the JVM Spec, we need to check for uninitialized
current_state->check_no_uninitialized_objects (current_method->max_locals, this); // objects here. However, this does not actually affect type
// safety, and the Eclipse java compiler generates code that
// violates this constraint.
// Modify our state as appropriate for entry into a subroutine. // Modify our state as appropriate for entry into a subroutine.
type ret_addr (return_address_type); type ret_addr (return_address_type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment