--- old/src/share/vm/prims/jvmtiEnv.cpp 2013-10-15 17:35:36.111008450 +0200 +++ new/src/share/vm/prims/jvmtiEnv.cpp 2013-10-15 17:35:36.031008454 +0200 @@ -1985,7 +1985,7 @@ return JVMTI_ERROR_INVALID_LOCATION; } - ResourceMark rm; + HandleMark hm; JvmtiBreakpoint bp(method_oop, location); JvmtiBreakpoints& jvmti_breakpoints = JvmtiCurrentBreakpoints::get_jvmti_breakpoints(); if (jvmti_breakpoints.set(bp) == JVMTI_ERROR_DUPLICATE) @@ -2003,18 +2003,16 @@ jvmtiError JvmtiEnv::ClearBreakpoint(Method* method_oop, jlocation location) { NULL_CHECK(method_oop, JVMTI_ERROR_INVALID_METHODID); - if (location < 0) { // simple invalid location check first return JVMTI_ERROR_INVALID_LOCATION; } - // verify that the breakpoint is not past the end of the method if (location >= (jlocation) method_oop->code_size()) { return JVMTI_ERROR_INVALID_LOCATION; } + HandleMark hm; JvmtiBreakpoint bp(method_oop, location); - JvmtiBreakpoints& jvmti_breakpoints = JvmtiCurrentBreakpoints::get_jvmti_breakpoints(); if (jvmti_breakpoints.clear(bp) == JVMTI_ERROR_NOT_FOUND) return JVMTI_ERROR_NOT_FOUND; --- old/src/share/vm/prims/jvmtiImpl.cpp 2013-10-15 17:35:36.567008436 +0200 +++ new/src/share/vm/prims/jvmtiImpl.cpp 2013-10-15 17:35:36.475008440 +0200 @@ -164,24 +164,6 @@ recache(); } -// insert a copy of the element using lessthan() -void GrowableCache::insert(GrowableElement* e) { - GrowableElement *new_e = e->clone(); - _elements->append(new_e); - - int n = length()-2; - for (int i=n; i>=0; i--) { - GrowableElement *e1 = _elements->at(i); - GrowableElement *e2 = _elements->at(i+1); - if (e2->lessThan(e1)) { - _elements->at_put(i+1, e1); - _elements->at_put(i, e2); - } - } - - recache(); -} - // remove the element at index void GrowableCache::remove (int index) { GrowableElement *e = _elements->at(index); @@ -221,36 +203,13 @@ // class JvmtiBreakpoint // -JvmtiBreakpoint::JvmtiBreakpoint() { - _method = NULL; - _bci = 0; - _class_loader = NULL; -#ifdef CHECK_UNHANDLED_OOPS - // This one is always allocated with new, but check it just in case. - Thread *thread = Thread::current(); - if (thread->is_in_stack((address)&_method)) { - thread->allow_unhandled_oop((oop*)&_method); - } -#endif // CHECK_UNHANDLED_OOPS -} - -JvmtiBreakpoint::JvmtiBreakpoint(Method* m_method, jlocation location) { - _method = m_method; - _class_loader = _method->method_holder()->class_loader_data()->class_loader(); - assert(_method != NULL, "_method != NULL"); - _bci = (int) location; - assert(_bci >= 0, "_bci >= 0"); -} - -void JvmtiBreakpoint::copy(JvmtiBreakpoint& bp) { - _method = bp._method; - _bci = bp._bci; - _class_loader = bp._class_loader; -} - -bool JvmtiBreakpoint::lessThan(JvmtiBreakpoint& bp) { - Unimplemented(); - return false; +JvmtiBreakpoint::JvmtiBreakpoint(Method* m_method, jlocation location) : + _method(m_method), + _bci((int) location), + _class_loader(NULL), + _class_loader_handle(_method->method_holder()->class_loader_data()->class_loader()) { + assert(Thread::current()->is_in_stack((address) this), + "Should only be allocated on stack"); } bool JvmtiBreakpoint::equals(JvmtiBreakpoint& bp) { @@ -355,14 +314,6 @@ } } -void VM_ChangeBreakpoints::oops_do(OopClosure* f) { - // The JvmtiBreakpoints in _breakpoints will be visited via - // JvmtiExport::oops_do. - if (_bp != NULL) { - _bp->oops_do(f); - } -} - // // class JvmtiBreakpoints // --- old/src/share/vm/prims/jvmtiImpl.hpp 2013-10-15 17:35:36.975008423 +0200 +++ new/src/share/vm/prims/jvmtiImpl.hpp 2013-10-15 17:35:36.891008427 +0200 @@ -66,7 +66,6 @@ public: virtual address getCacheValue() =0; virtual bool equals(GrowableElement* e) =0; - virtual bool lessThan(GrowableElement *e)=0; virtual GrowableElement *clone() =0; virtual void oops_do(OopClosure* f) =0; }; @@ -107,8 +106,6 @@ int find(GrowableElement* e); // append a copy of the element to the end of the collection, notify listener void append(GrowableElement* e); - // insert a copy of the element using lessthan(), notify listener - void insert(GrowableElement* e); // remove the element at index, notify listener void remove (int index); // clear out all elements and release all heap space, notify listener @@ -168,15 +165,18 @@ private: Method* _method; int _bci; - Bytecodes::Code _orig_bytecode; oop _class_loader; + Handle _class_loader_handle; + + JvmtiBreakpoint(Method* method, int bci, Handle class_loader_handle) : + _method(method), + _bci(bci), + _class_loader(class_loader_handle()), + _class_loader_handle(NULL) {} public: - JvmtiBreakpoint(); JvmtiBreakpoint(Method* m_method, jlocation location); bool equals(JvmtiBreakpoint& bp); - bool lessThan(JvmtiBreakpoint &bp); - void copy(JvmtiBreakpoint& bp); bool is_valid(); address getBcp(); void each_method_version_do(method_action meth_act); @@ -188,16 +188,13 @@ // GrowableElement implementation address getCacheValue() { return getBcp(); } - bool lessThan(GrowableElement* e) { Unimplemented(); return false; } bool equals(GrowableElement* e) { return equals((JvmtiBreakpoint&) *e); } void oops_do(OopClosure* f) { // Mark the method loader as live f->do_oop(&_class_loader); } GrowableElement *clone() { - JvmtiBreakpoint *bp = new JvmtiBreakpoint(); - bp->copy(*this); - return bp; + return new JvmtiBreakpoint(_method, _bci, _class_loader_handle); } }; @@ -331,7 +328,6 @@ VMOp_Type type() const { return VMOp_ChangeBreakpoints; } void doit(); - void oops_do(OopClosure* f); };