* [RFA] Fix bytecode interpreter bitrot
@ 2006-09-28 19:09 Keith Seitz
2006-09-29 20:33 ` Tom Tromey
0 siblings, 1 reply; 6+ messages in thread
From: Keith Seitz @ 2006-09-28 19:09 UTC (permalink / raw)
To: Java Patch List
[-- Attachment #1: Type: text/plain, Size: 987 bytes --]
Hi,
I don't know if anybody actually uses the bytecode interpreter anymore,
but since we do have all the code lurking in the sources somewhere, it
would be nice to keep it working.
It seems that over the past months, several bugs have found their way
into the BC interpreter. I believe this patch fixes those problems.
Keith
ChangeLog
2006-09-28 Keith Seitz <keiths@redhat.com>
* include/java-interp.h (prepared): Change type to pc_t.
(insn_index): Define for both DIRECT_THREADED and bytecode
interpreters.
* interpret.cc [!DIRECT_THREADED] (POKEI): Fix typo.
(insn_index): Implement for bytecode interpreter.
* interpret-run.cc [!DIRECT_THREADED] (AVAL1U): Add _Jv_Linker
class
qualifier to resolve_pool_entry.
[!DIRECT_THREADED] (AVAL2U): Likewise.
[!DIRECT_THREADED] bytecode() cannot be called without an object.
Changed all typos.
[!DIRECT_THREADED] Likewise for defining_class.
[-- Attachment #2: bc-bitrot.patch --]
[-- Type: text/x-patch, Size: 4182 bytes --]
Index: include/java-interp.h
===================================================================
--- include/java-interp.h (revision 117093)
+++ include/java-interp.h (working copy)
@@ -144,7 +144,7 @@
int line_table_len;
_Jv_LineTableEntry *line_table;
- void *prepared;
+ pc_t prepared;
int number_insn_slots;
unsigned char* bytecode ()
@@ -191,13 +191,9 @@
// number info is unavailable.
int get_source_line(pc_t mpc);
-
-
-#ifdef DIRECT_THREADED
// Convenience function for indexing bytecode PC/insn slots in
// line tables for JDWP
jlong insn_index (pc_t pc);
-#endif
public:
Index: interpret.cc
===================================================================
--- interpret.cc (revision 117093)
+++ interpret.cc (working copy)
@@ -200,7 +200,7 @@
#define PEEKA(I) (locals+(I))->o
#define POKEI(I,V) \
-DEBUG_LOCALS_INSN(I,i) \
+DEBUG_LOCALS_INSN(I,'i'); \
((locals+(I))->i = (V))
@@ -1307,23 +1307,27 @@
return self->ncode;
}
-#ifdef DIRECT_THREADED
/* Find the index of the given insn in the array of insn slots
for this method. Returns -1 if not found. */
jlong
_Jv_InterpMethod::insn_index (pc_t pc)
{
jlong left = 0;
+#ifdef DIRECT_THREADED
jlong right = number_insn_slots;
- insn_slot* slots = reinterpret_cast<insn_slot*> (prepared);
+ pc_t insns = prepared;
+#else
+ jlong right = code_length;
+ pc_t insns = bytecode ();
+#endif
while (right >= 0)
{
jlong mid = (left + right) / 2;
- if (&slots[mid] == pc)
+ if (&insns[mid] == pc)
return mid;
- if (pc < &slots[mid])
+ if (pc < &insns[mid])
right = mid - 1;
else
left = mid + 1;
@@ -1331,7 +1335,6 @@
return -1;
}
-#endif // DIRECT_THREADED
void
_Jv_InterpMethod::get_line_table (jlong& start, jlong& end,
Index: interpret-run.cc
===================================================================
--- interpret-run.cc (revision 117093)
+++ interpret-run.cc (working copy)
@@ -291,10 +291,10 @@
// class'.
#define AVAL1U() \
({ int index = get1u (pc++); \
- resolve_pool_entry (meth->defining_class, index).o; })
+ _Jv_Linker::resolve_pool_entry (meth->defining_class, index).o; })
#define AVAL2U() \
({ int index = get2u (pc); pc += 2; \
- resolve_pool_entry (meth->defining_class, index).o; })
+ _Jv_Linker::resolve_pool_entry (meth->defining_class, index).o; })
// Note that we don't need to resolve the pool entry here as class
// constants are never wide.
#define AVAL2UP() ({ int index = get2u (pc); pc += 2; &pool_data[index]; })
@@ -303,7 +303,7 @@
#define PCVAL(unionval) unionval.i
#define AMPAMP(label) NULL
- pc = bytecode ();
+ pc = meth->bytecode ();
#endif /* DIRECT_THREADED */
@@ -1545,7 +1545,7 @@
pc_t base_pc = pc - 1;
int index = POPI ();
- pc_t base = (pc_t) bytecode ();
+ pc_t base = (pc_t) meth->bytecode ();
while ((pc - base) % 4 != 0)
++pc;
@@ -1601,7 +1601,7 @@
unsigned char *base_pc = pc-1;
int index = POPI();
- unsigned char* base = bytecode ();
+ unsigned char* base = meth->bytecode ();
while ((pc-base) % 4 != 0)
++pc;
@@ -2469,7 +2469,7 @@
#ifdef DIRECT_THREADED
void *logical_pc = (void *) ((insn_slot *) pc - 1);
#else
- int logical_pc = pc - 1 - bytecode ();
+ int logical_pc = pc - 1 - meth->bytecode ();
#endif
_Jv_InterpException *exc = meth->exceptions ();
jclass exc_class = ex->getClass ();
@@ -2484,8 +2484,8 @@
#else
jclass handler = NULL;
if (exc[i].handler_type.i != 0)
- handler = (_Jv_Linker::resolve_pool_entry (defining_class,
- exc[i].handler_type.i)).clazz;
+ handler = (_Jv_Linker::resolve_pool_entry (meth->defining_class,
+ exc[i].handler_type.i)).clazz;
#endif /* DIRECT_THREADED */
if (handler == NULL || handler->isAssignableFrom (exc_class))
@@ -2494,7 +2494,7 @@
#ifdef DIRECT_THREADED
pc = (insn_slot *) exc[i].handler_pc.p;
#else
- pc = bytecode () + exc[i].handler_pc.i;
+ pc = meth->bytecode () + exc[i].handler_pc.i;
#endif /* DIRECT_THREADED */
sp = stack;
sp++->o = ex; // Push exception.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] Fix bytecode interpreter bitrot
2006-09-28 19:09 [RFA] Fix bytecode interpreter bitrot Keith Seitz
@ 2006-09-29 20:33 ` Tom Tromey
2006-09-29 20:47 ` David Daney
2006-09-30 19:21 ` Keith Seitz
0 siblings, 2 replies; 6+ messages in thread
From: Tom Tromey @ 2006-09-29 20:33 UTC (permalink / raw)
To: Keith Seitz; +Cc: Java Patch List
>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
Keith> I don't know if anybody actually uses the bytecode interpreter
Keith> anymore
Me neither.
Keith> It seems that over the past months, several bugs have found their way
Keith> into the BC interpreter. I believe this patch fixes those problems.
This is ok, thanks.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] Fix bytecode interpreter bitrot
2006-09-29 20:33 ` Tom Tromey
@ 2006-09-29 20:47 ` David Daney
2006-09-29 21:09 ` Casey Marshall
2006-09-29 21:23 ` Tom Tromey
2006-09-30 19:21 ` Keith Seitz
1 sibling, 2 replies; 6+ messages in thread
From: David Daney @ 2006-09-29 20:47 UTC (permalink / raw)
To: tromey; +Cc: Keith Seitz, Java Patch List
Tom Tromey wrote:
>>>>>>"Keith" == Keith Seitz <keiths@redhat.com> writes:
>
>
> Keith> I don't know if anybody actually uses the bytecode interpreter
> Keith> anymore
>
> Me neither.
>
Correct me if I am wrong, but don't most of the gij test cases use it?
Also it seems that it would be very useful for loading bytecode at
runtime (for rmi and jini code for example).
David Daney
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] Fix bytecode interpreter bitrot
2006-09-29 20:47 ` David Daney
@ 2006-09-29 21:09 ` Casey Marshall
2006-09-29 21:23 ` Tom Tromey
1 sibling, 0 replies; 6+ messages in thread
From: Casey Marshall @ 2006-09-29 21:09 UTC (permalink / raw)
To: David Daney; +Cc: tromey, Keith Seitz, Java Patch List
David Daney wrote:
> Tom Tromey wrote:
>>>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
>>
>>
>> Keith> I don't know if anybody actually uses the bytecode interpreter
>> Keith> anymore
>>
>> Me neither.
>>
>
> Correct me if I am wrong, but don't most of the gij test cases use it?
>
> Also it seems that it would be very useful for loading bytecode at
> runtime (for rmi and jini code for example).
>
Also applets.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] Fix bytecode interpreter bitrot
2006-09-29 20:47 ` David Daney
2006-09-29 21:09 ` Casey Marshall
@ 2006-09-29 21:23 ` Tom Tromey
1 sibling, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2006-09-29 21:23 UTC (permalink / raw)
To: David Daney; +Cc: Keith Seitz, Java Patch List
David> Correct me if I am wrong, but don't most of the gij test cases use it?
Keith meant the old "pure bytecode" interpreter. You have to build
libgcj specially to get this -- the default is to use the direct
threaded interpreter, which is faster but uses more memory.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] Fix bytecode interpreter bitrot
2006-09-29 20:33 ` Tom Tromey
2006-09-29 20:47 ` David Daney
@ 2006-09-30 19:21 ` Keith Seitz
1 sibling, 0 replies; 6+ messages in thread
From: Keith Seitz @ 2006-09-30 19:21 UTC (permalink / raw)
To: Java Patch List
Tom Tromey wrote:
> Keith> It seems that over the past months, several bugs have found their way
> Keith> into the BC interpreter. I believe this patch fixes those problems.
>
> This is ok, thanks.
Thanks!
Keith
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-09-30 19:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-28 19:09 [RFA] Fix bytecode interpreter bitrot Keith Seitz
2006-09-29 20:33 ` Tom Tromey
2006-09-29 20:47 ` David Daney
2006-09-29 21:09 ` Casey Marshall
2006-09-29 21:23 ` Tom Tromey
2006-09-30 19:21 ` Keith Seitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).