# HG changeset patch # User Tom Rodriguez # Date 1470183489 25200 # Node ID 1ceab3d13eb89946bdfa0b6faefe138825c146cf # Parent 5de73b32cff8db6d29d0d3f7e0b8cbec87866848 Add a vframe_id to jvmtiDeferredLocalVariable to properly track vframe identity diff -r 5de73b32cff8 -r 1ceab3d13eb8 src/share/vm/runtime/vframe_hp.cpp --- a/src/share/vm/runtime/vframe_hp.cpp Fri Jul 29 08:47:59 2016 -0700 +++ b/src/share/vm/runtime/vframe_hp.cpp Tue Aug 02 17:18:09 2016 -0700 @@ -157,7 +157,7 @@ deferred = new(ResourceObj::C_HEAP, mtCompiler) GrowableArray (1, true); thread()->set_deferred_locals(deferred); } - deferred->push(new jvmtiDeferredLocalVariableSet(method(), bci(), fr().id())); + deferred->push(new jvmtiDeferredLocalVariableSet(method(), bci(), fr().id(), vframe_id())); assert(deferred->top()->id() == fr().id(), "Huh? Must match"); deferred->top()->set_local_at(index, type, value); } @@ -242,6 +242,7 @@ compiledVFrame::compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, nmethod* nm) : javaVFrame(fr, reg_map, thread) { _scope = NULL; + _vframe_id = 0; // Compiled method (native stub or Java code) // native wrappers have no scope data, it is implied if (!nm->is_native_method()) { @@ -249,9 +250,10 @@ } } -compiledVFrame::compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, ScopeDesc* scope) +compiledVFrame::compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, ScopeDesc* scope, int vframe_id) : javaVFrame(fr, reg_map, thread) { _scope = scope; + _vframe_id = vframe_id; guarantee(_scope != NULL, "scope must be present"); } @@ -315,14 +317,15 @@ } else { return scope()->is_top() ? vframe::sender() - : new compiledVFrame(&f, register_map(), thread(), scope()->sender()); + : new compiledVFrame(&f, register_map(), thread(), scope()->sender(), vframe_id() + 1); } } -jvmtiDeferredLocalVariableSet::jvmtiDeferredLocalVariableSet(Method* method, int bci, intptr_t* id) { +jvmtiDeferredLocalVariableSet::jvmtiDeferredLocalVariableSet(Method* method, int bci, intptr_t* id, int vframe_id) { _method = method; _bci = bci; _id = id; + _vframe_id = vframe_id; // Alway will need at least one, must be on C heap _locals = new(ResourceObj::C_HEAP, mtCompiler) GrowableArray (1, true); } @@ -338,7 +341,11 @@ bool jvmtiDeferredLocalVariableSet::matches(vframe* vf) { if (!vf->is_compiled_frame()) return false; compiledVFrame* cvf = (compiledVFrame*)vf; - return cvf->fr().id() == id() && cvf->method() == method() && cvf->bci() == bci(); + if (cvf->fr().id() == id() && cvf->vframe_id() == vframe_id()) { + assert(cvf->method() == method() && cvf->bci() == bci(), "must agree"); + return true; + } + return false; } void jvmtiDeferredLocalVariableSet::set_local_at(int idx, BasicType type, jvalue val) { diff -r 5de73b32cff8 -r 1ceab3d13eb8 src/share/vm/runtime/vframe_hp.hpp --- a/src/share/vm/runtime/vframe_hp.hpp Fri Jul 29 08:47:59 2016 -0700 +++ b/src/share/vm/runtime/vframe_hp.hpp Tue Aug 02 17:18:09 2016 -0700 @@ -36,6 +36,7 @@ StackValueCollection* locals() const; StackValueCollection* expressions() const; GrowableArray* monitors() const; + int vframe_id() const { return _vframe_id; } void set_locals(StackValueCollection* values) const; @@ -68,14 +69,14 @@ protected: ScopeDesc* _scope; - + int _vframe_id; //StackValue resolve(ScopeValue* sv) const; BasicLock* resolve_monitor_lock(Location location) const; StackValue *create_stack_value(ScopeValue *sv) const; private: - compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, ScopeDesc* scope); + compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, ScopeDesc* scope, int vframe_id); #ifndef PRODUCT public: @@ -95,6 +96,7 @@ Method* _method; int _bci; intptr_t* _id; + int _vframe_id; GrowableArray* _locals; public: @@ -102,6 +104,7 @@ Method* method() const { return _method; } int bci() const { return _bci; } intptr_t* id() const { return _id; } + int vframe_id() const { return _vframe_id; } GrowableArray* locals() const { return _locals; } void set_local_at(int idx, BasicType typ, jvalue val); @@ -111,7 +114,7 @@ void oops_do(OopClosure* f); // constructor - jvmtiDeferredLocalVariableSet(Method* method, int bci, intptr_t* id); + jvmtiDeferredLocalVariableSet(Method* method, int bci, intptr_t* id, int vframe_id); // destructor ~jvmtiDeferredLocalVariableSet();