[vmkit-commits] [vmkit] r200691 - Inspect LineAttribute to find the line numbers.
Gael Thomas
gael.thomas at lip6.fr
Mon Feb 3 04:49:37 PST 2014
Author: gthomas
Date: Mon Feb 3 06:49:37 2014
New Revision: 200691
URL: http://llvm.org/viewvc/llvm-project?rev=200691&view=rev
Log:
Inspect LineAttribute to find the line numbers.
Modified:
vmkit/branches/mcjit/include/j3/j3method.h
vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc
vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc
vmkit/branches/mcjit/lib/j3/vm/j3method.cc
Modified: vmkit/branches/mcjit/include/j3/j3method.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3method.h?rev=200691&r1=200690&r2=200691&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3method.h (original)
+++ vmkit/branches/mcjit/include/j3/j3method.h Mon Feb 3 06:49:37 2014
@@ -78,9 +78,7 @@ namespace j3 {
uint32_t index();
- void setCodeAttributes(J3Attributes* attributes) { _codeAttributes = attributes; }
- J3Attributes* codeAttributes() const { return _codeAttributes; }
-
+ J3Attributes* codeAttributes();
J3Attributes* attributes() const { return _attributes; }
uint16_t access() const { return _access; }
J3Class* cl() const { return _cl; }
Modified: vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc?rev=200691&r1=200690&r2=200691&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc (original)
+++ vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc Mon Feb 3 06:49:37 2014
@@ -418,18 +418,26 @@ static jobject translateStackTrace(jobje
const vmkit::Name* sourceFile = 0;
if(sourceAttr) {
J3Reader reader(m->cl()->bytes());
- reader.seek(sourceAttr->offset(), reader.SeekSet);
- reader.readU4();
+ reader.seek(sourceAttr->offset() + 4, reader.SeekSet);
sourceFile = m->cl()->nameAt(reader.readU2());
}
uint32_t lineNumber = -1;
- J3Attribute* lineAttr = m->cl()->attributes()->lookup(vm->lineNumberTableAttribute);
- if(lineAttr) {
- fprintf(stderr, " find line attribute...\n");
- //sf->sourceIndex(j));
- abort();
+ if(m->codeAttributes()) {
+ J3Attribute* lineAttr = m->codeAttributes()->lookup(vm->lineNumberTableAttribute);
+ if(lineAttr) {
+ J3Reader reader(m->cl()->bytes());
+ reader.seek(lineAttr->offset() + 4, reader.SeekSet);
+ uint32_t n = reader.readU2();
+ bool found = 0;
+ for(uint32_t i=0; i<n && !found; i++) {
+ if(sf->sourceIndex(j) < reader.readU2())
+ found = 1;
+ else
+ lineNumber = reader.readU2();
+ }
+ }
}
vm->stackTraceElementClassInit
Modified: vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc?rev=200691&r1=200690&r2=200691&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc Mon Feb 3 06:49:37 2014
@@ -1774,7 +1774,6 @@ void J3CodeGen::generateJava() {
reader.seek(codeLength, reader.SeekCur);
exceptions.read(&reader, codeLength);
- //method->setCodeAttributes(cl->readAttributes(&reader));
pendingBranchs[topPendingBranchs++] = codeReader->tell();
Modified: vmkit/branches/mcjit/lib/j3/vm/j3method.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3method.cc?rev=200691&r1=200690&r2=200691&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3method.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3method.cc Mon Feb 3 06:49:37 2014
@@ -10,6 +10,7 @@
#include "j3/j3codegen.h"
#include "j3/j3trampoline.h"
#include "j3/j3attribute.h"
+#include "j3/j3reader.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Module.h"
@@ -31,6 +32,21 @@ J3Method::J3Method(uint16_t access, J3Cl
_index = -1;
}
+J3Attributes* J3Method::codeAttributes() {
+ if(!_codeAttributes) {
+ J3* vm = J3Thread::get()->vm();
+ J3Attribute* codeAttr = attributes()->lookup(vm->codeAttribute);
+ if(codeAttr) {
+ J3Reader reader(cl()->bytes());
+ reader.seek(codeAttr->offset()+8, reader.SeekSet);
+ reader.seek(reader.readU4(), reader.SeekCur);
+ reader.seek(reader.readU2()*8, reader.SeekCur);
+ _codeAttributes = cl()->readAttributes(&reader);
+ }
+ }
+ return _codeAttributes;
+}
+
vmkit::CompilationUnit* J3Method::unit() {
return cl()->loader();
}
More information about the vmkit-commits
mailing list