71 assert(thread == JavaThread::current(), "sanity check");
72
73 JvmtiAgentThread *dthread = (JvmtiAgentThread *)thread;
74 dthread->call_start_function();
75 }
76
77 void
78 JvmtiAgentThread::call_start_function() {
79 ThreadToNativeFromVM transition(this);
80 _start_fn(_env->jvmti_external(), jni_environment(), (void*)_start_arg);
81 }
82
83
84 //
85 // class GrowableCache - private methods
86 //
87
88 void GrowableCache::recache() {
89 int len = _elements->length();
90
91 FREE_C_HEAP_ARRAY(address, _cache, mtInternal);
92 _cache = NEW_C_HEAP_ARRAY(address,len+1, mtInternal);
93
94 for (int i=0; i<len; i++) {
95 _cache[i] = _elements->at(i)->getCacheValue();
96 //
97 // The cache entry has gone bad. Without a valid frame pointer
98 // value, the entry is useless so we simply delete it in product
99 // mode. The call to remove() will rebuild the cache again
100 // without the bad entry.
101 //
102 if (_cache[i] == NULL) {
103 assert(false, "cannot recache NULL elements");
104 remove(i);
105 return;
106 }
107 }
108 _cache[len] = NULL;
109
110 _listener_fun(_this_obj,_cache);
111 }
115 assert(e1 != NULL, "e1 != NULL");
116 assert(e2 != NULL, "e2 != NULL");
117
118 return e1->equals(e2);
119 }
120
121 //
122 // class GrowableCache - public methods
123 //
124
125 GrowableCache::GrowableCache() {
126 _this_obj = NULL;
127 _listener_fun = NULL;
128 _elements = NULL;
129 _cache = NULL;
130 }
131
132 GrowableCache::~GrowableCache() {
133 clear();
134 delete _elements;
135 FREE_C_HEAP_ARRAY(address, _cache, mtInternal);
136 }
137
138 void GrowableCache::initialize(void *this_obj, void listener_fun(void *, address*) ) {
139 _this_obj = this_obj;
140 _listener_fun = listener_fun;
141 _elements = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<GrowableElement*>(5,true);
142 recache();
143 }
144
145 // number of elements in the collection
146 int GrowableCache::length() {
147 return _elements->length();
148 }
149
150 // get the value of the index element in the collection
151 GrowableElement* GrowableCache::at(int index) {
152 GrowableElement *e = (GrowableElement *) _elements->at(index);
153 assert(e != NULL, "e != NULL");
154 return e;
155 }
|
71 assert(thread == JavaThread::current(), "sanity check");
72
73 JvmtiAgentThread *dthread = (JvmtiAgentThread *)thread;
74 dthread->call_start_function();
75 }
76
77 void
78 JvmtiAgentThread::call_start_function() {
79 ThreadToNativeFromVM transition(this);
80 _start_fn(_env->jvmti_external(), jni_environment(), (void*)_start_arg);
81 }
82
83
84 //
85 // class GrowableCache - private methods
86 //
87
88 void GrowableCache::recache() {
89 int len = _elements->length();
90
91 FREE_C_HEAP_ARRAY(address, _cache);
92 _cache = NEW_C_HEAP_ARRAY(address,len+1, mtInternal);
93
94 for (int i=0; i<len; i++) {
95 _cache[i] = _elements->at(i)->getCacheValue();
96 //
97 // The cache entry has gone bad. Without a valid frame pointer
98 // value, the entry is useless so we simply delete it in product
99 // mode. The call to remove() will rebuild the cache again
100 // without the bad entry.
101 //
102 if (_cache[i] == NULL) {
103 assert(false, "cannot recache NULL elements");
104 remove(i);
105 return;
106 }
107 }
108 _cache[len] = NULL;
109
110 _listener_fun(_this_obj,_cache);
111 }
115 assert(e1 != NULL, "e1 != NULL");
116 assert(e2 != NULL, "e2 != NULL");
117
118 return e1->equals(e2);
119 }
120
121 //
122 // class GrowableCache - public methods
123 //
124
125 GrowableCache::GrowableCache() {
126 _this_obj = NULL;
127 _listener_fun = NULL;
128 _elements = NULL;
129 _cache = NULL;
130 }
131
132 GrowableCache::~GrowableCache() {
133 clear();
134 delete _elements;
135 FREE_C_HEAP_ARRAY(address, _cache);
136 }
137
138 void GrowableCache::initialize(void *this_obj, void listener_fun(void *, address*) ) {
139 _this_obj = this_obj;
140 _listener_fun = listener_fun;
141 _elements = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<GrowableElement*>(5,true);
142 recache();
143 }
144
145 // number of elements in the collection
146 int GrowableCache::length() {
147 return _elements->length();
148 }
149
150 // get the value of the index element in the collection
151 GrowableElement* GrowableCache::at(int index) {
152 GrowableElement *e = (GrowableElement *) _elements->at(index);
153 assert(e != NULL, "e != NULL");
154 return e;
155 }
|