100 value.l = (jobject) val->owner();
101 update_deferred_value(T_OBJECT, index + method()->max_locals() + method()->max_stack(), value);
102 }
103
104 void compiledVFrame::update_deferred_value(BasicType type, int index, jvalue value) {
105 assert(fr().is_deoptimized_frame(), "frame must be scheduled for deoptimization");
106 GrowableArray<jvmtiDeferredLocalVariableSet*>* deferred = thread()->deferred_locals();
107 jvmtiDeferredLocalVariableSet* locals = NULL;
108 if (deferred != NULL ) {
109 // See if this vframe has already had locals with deferred writes
110 for (int f = 0; f < deferred->length(); f++ ) {
111 if (deferred->at(f)->matches(this)) {
112 locals = deferred->at(f);
113 break;
114 }
115 }
116 // No matching vframe must push a new vframe
117 } else {
118 // No deferred updates pending for this thread.
119 // allocate in C heap
120 deferred = new(ResourceObj::C_HEAP, mtCompiler) GrowableArray<jvmtiDeferredLocalVariableSet*> (1, true);
121 thread()->set_deferred_locals(deferred);
122 }
123 if (locals == NULL) {
124 locals = new jvmtiDeferredLocalVariableSet(method(), bci(), fr().id(), vframe_id());
125 deferred->push(locals);
126 assert(locals->id() == fr().id(), "Huh? Must match");
127 }
128 locals->set_value_at(index, type, value);
129 }
130
131 StackValueCollection* compiledVFrame::expressions() const {
132 // Natives has no scope
133 if (scope() == NULL) return new StackValueCollection(0);
134 GrowableArray<ScopeValue*>* scv_list = scope()->expressions();
135 if (scv_list == NULL) return new StackValueCollection(0);
136
137 // scv_list is the list of ScopeValues describing the JVM stack state.
138 // There is one scv_list entry for every JVM stack state in use.
139 int length = scv_list->length();
140 StackValueCollection* result = new StackValueCollection(length);
141 for (int i = 0; i < length; i++) {
292 int compiledVFrame::raw_bci() const {
293 if (scope() == NULL) {
294 // native nmethods have no scope the method/bci is implied
295 nmethod* nm = code()->as_nmethod();
296 assert(nm->is_native_method(), "must be native");
297 return 0;
298 }
299 return scope()->bci();
300 }
301
302 bool compiledVFrame::should_reexecute() const {
303 if (scope() == NULL) {
304 // native nmethods have no scope the method/bci is implied
305 nmethod* nm = code()->as_nmethod();
306 assert(nm->is_native_method(), "must be native");
307 return false;
308 }
309 return scope()->should_reexecute();
310 }
311
312 vframe* compiledVFrame::sender() const {
313 const frame f = fr();
314 if (scope() == NULL) {
315 // native nmethods have no scope the method/bci is implied
316 nmethod* nm = code()->as_nmethod();
317 assert(nm->is_native_method(), "must be native");
318 return vframe::sender();
319 } else {
320 return scope()->is_top()
321 ? vframe::sender()
322 : new compiledVFrame(&f, register_map(), thread(), scope()->sender(), vframe_id() + 1);
323 }
324 }
325
326 jvmtiDeferredLocalVariableSet::jvmtiDeferredLocalVariableSet(Method* method, int bci, intptr_t* id, int vframe_id) {
327 _method = method;
328 _bci = bci;
329 _id = id;
330 _vframe_id = vframe_id;
331 // Alway will need at least one, must be on C heap
332 _locals = new(ResourceObj::C_HEAP, mtCompiler) GrowableArray<jvmtiDeferredLocalVariable*> (1, true);
333 }
334
335 jvmtiDeferredLocalVariableSet::~jvmtiDeferredLocalVariableSet() {
336 for (int i = 0; i < _locals->length(); i++ ) {
337 delete _locals->at(i);
338 }
339 // Free growableArray and c heap for elements
340 delete _locals;
341 }
342
343 bool jvmtiDeferredLocalVariableSet::matches(const vframe* vf) {
344 if (!vf->is_compiled_frame()) return false;
345 compiledVFrame* cvf = (compiledVFrame*)vf;
346 if (cvf->fr().id() == id() && cvf->vframe_id() == vframe_id()) {
347 assert(cvf->method() == method() && cvf->bci() == bci(), "must agree");
348 return true;
349 }
350 return false;
351 }
352
407 }
408 }
409
410
411 void jvmtiDeferredLocalVariableSet::update_stack(StackValueCollection* expressions) {
412 for (int l = 0; l < _locals->length(); l ++) {
413 jvmtiDeferredLocalVariable* val = _locals->at(l);
414 if (val->index() >= method()->max_locals() && val->index() < method()->max_locals() + method()->max_stack()) {
415 update_value(expressions, val->type(), val->index() - method()->max_locals(), val->value());
416 }
417 }
418 }
419
420
421 void jvmtiDeferredLocalVariableSet::update_monitors(GrowableArray<MonitorInfo*>* monitors) {
422 for (int l = 0; l < _locals->length(); l ++) {
423 jvmtiDeferredLocalVariable* val = _locals->at(l);
424 if (val->index() >= method()->max_locals() + method()->max_stack()) {
425 int lock_index = val->index() - (method()->max_locals() + method()->max_stack());
426 MonitorInfo* info = monitors->at(lock_index);
427 MonitorInfo* new_info = new MonitorInfo((oopDesc*)val->value().l, info->lock(), info->eliminated(), info->owner_is_scalar_replaced());
428 monitors->at_put(lock_index, new_info);
429 }
430 }
431 }
432
433
434 void jvmtiDeferredLocalVariableSet::oops_do(OopClosure* f) {
435 // The Method* is on the stack so a live activation keeps it alive
436 // either by mirror in interpreter or code in compiled code.
437 for (int i = 0; i < _locals->length(); i++) {
438 if (_locals->at(i)->type() == T_OBJECT) {
439 f->do_oop(_locals->at(i)->oop_addr());
440 }
441 }
442 }
443
444 jvmtiDeferredLocalVariable::jvmtiDeferredLocalVariable(int index, BasicType type, jvalue value) {
445 _index = index;
446 _type = type;
447 _value = value;
|
100 value.l = (jobject) val->owner();
101 update_deferred_value(T_OBJECT, index + method()->max_locals() + method()->max_stack(), value);
102 }
103
104 void compiledVFrame::update_deferred_value(BasicType type, int index, jvalue value) {
105 assert(fr().is_deoptimized_frame(), "frame must be scheduled for deoptimization");
106 GrowableArray<jvmtiDeferredLocalVariableSet*>* deferred = thread()->deferred_locals();
107 jvmtiDeferredLocalVariableSet* locals = NULL;
108 if (deferred != NULL ) {
109 // See if this vframe has already had locals with deferred writes
110 for (int f = 0; f < deferred->length(); f++ ) {
111 if (deferred->at(f)->matches(this)) {
112 locals = deferred->at(f);
113 break;
114 }
115 }
116 // No matching vframe must push a new vframe
117 } else {
118 // No deferred updates pending for this thread.
119 // allocate in C heap
120 thread()->allocate_deferred_updates();
121 deferred = thread()->deferred_locals();
122 }
123 if (locals == NULL) {
124 locals = new jvmtiDeferredLocalVariableSet(method(), bci(), fr().id(), vframe_id());
125 deferred->push(locals);
126 assert(locals->id() == fr().id(), "Huh? Must match");
127 }
128 locals->set_value_at(index, type, value);
129 }
130
131 StackValueCollection* compiledVFrame::expressions() const {
132 // Natives has no scope
133 if (scope() == NULL) return new StackValueCollection(0);
134 GrowableArray<ScopeValue*>* scv_list = scope()->expressions();
135 if (scv_list == NULL) return new StackValueCollection(0);
136
137 // scv_list is the list of ScopeValues describing the JVM stack state.
138 // There is one scv_list entry for every JVM stack state in use.
139 int length = scv_list->length();
140 StackValueCollection* result = new StackValueCollection(length);
141 for (int i = 0; i < length; i++) {
292 int compiledVFrame::raw_bci() const {
293 if (scope() == NULL) {
294 // native nmethods have no scope the method/bci is implied
295 nmethod* nm = code()->as_nmethod();
296 assert(nm->is_native_method(), "must be native");
297 return 0;
298 }
299 return scope()->bci();
300 }
301
302 bool compiledVFrame::should_reexecute() const {
303 if (scope() == NULL) {
304 // native nmethods have no scope the method/bci is implied
305 nmethod* nm = code()->as_nmethod();
306 assert(nm->is_native_method(), "must be native");
307 return false;
308 }
309 return scope()->should_reexecute();
310 }
311
312 bool compiledVFrame::not_global_escape_in_scope() const {
313 if (scope() == NULL) {
314 // native nmethod, all objs escape
315 nmethod* nm = code()->as_nmethod();
316 assert(nm->is_native_method(), "must be native");
317 return false;
318 }
319 return (scope()->objects() != NULL) || scope()->not_global_escape_in_scope();
320 }
321
322 bool compiledVFrame::arg_escape() const {
323 if (scope() == NULL) {
324 // native nmethod, all objs escape
325 nmethod* nm = code()->as_nmethod();
326 assert(nm->is_native_method(), "must be native");
327 return false;
328 }
329 return scope()->arg_escape();
330 }
331
332 vframe* compiledVFrame::sender() const {
333 const frame f = fr();
334 if (scope() == NULL) {
335 // native nmethods have no scope the method/bci is implied
336 nmethod* nm = code()->as_nmethod();
337 assert(nm->is_native_method(), "must be native");
338 return vframe::sender();
339 } else {
340 return scope()->is_top()
341 ? vframe::sender()
342 : new compiledVFrame(&f, register_map(), thread(), scope()->sender(), vframe_id() + 1);
343 }
344 }
345
346 jvmtiDeferredLocalVariableSet::jvmtiDeferredLocalVariableSet(Method* method, int bci, intptr_t* id, int vframe_id) {
347 _method = method;
348 _bci = bci;
349 _id = id;
350 _vframe_id = vframe_id;
351 // Alway will need at least one, must be on C heap
352 _locals = new(ResourceObj::C_HEAP, mtCompiler) GrowableArray<jvmtiDeferredLocalVariable*> (1, true);
353 _objects_are_deoptimized = false;
354 }
355
356 jvmtiDeferredLocalVariableSet::~jvmtiDeferredLocalVariableSet() {
357 for (int i = 0; i < _locals->length(); i++ ) {
358 delete _locals->at(i);
359 }
360 // Free growableArray and c heap for elements
361 delete _locals;
362 }
363
364 bool jvmtiDeferredLocalVariableSet::matches(const vframe* vf) {
365 if (!vf->is_compiled_frame()) return false;
366 compiledVFrame* cvf = (compiledVFrame*)vf;
367 if (cvf->fr().id() == id() && cvf->vframe_id() == vframe_id()) {
368 assert(cvf->method() == method() && cvf->bci() == bci(), "must agree");
369 return true;
370 }
371 return false;
372 }
373
428 }
429 }
430
431
432 void jvmtiDeferredLocalVariableSet::update_stack(StackValueCollection* expressions) {
433 for (int l = 0; l < _locals->length(); l ++) {
434 jvmtiDeferredLocalVariable* val = _locals->at(l);
435 if (val->index() >= method()->max_locals() && val->index() < method()->max_locals() + method()->max_stack()) {
436 update_value(expressions, val->type(), val->index() - method()->max_locals(), val->value());
437 }
438 }
439 }
440
441
442 void jvmtiDeferredLocalVariableSet::update_monitors(GrowableArray<MonitorInfo*>* monitors) {
443 for (int l = 0; l < _locals->length(); l ++) {
444 jvmtiDeferredLocalVariable* val = _locals->at(l);
445 if (val->index() >= method()->max_locals() + method()->max_stack()) {
446 int lock_index = val->index() - (method()->max_locals() + method()->max_stack());
447 MonitorInfo* info = monitors->at(lock_index);
448 MonitorInfo* new_info = new MonitorInfo((oopDesc*)val->value().l, info->lock(), info->eliminated(), false);
449 monitors->at_put(lock_index, new_info);
450 }
451 }
452 }
453
454
455 void jvmtiDeferredLocalVariableSet::oops_do(OopClosure* f) {
456 // The Method* is on the stack so a live activation keeps it alive
457 // either by mirror in interpreter or code in compiled code.
458 for (int i = 0; i < _locals->length(); i++) {
459 if (_locals->at(i)->type() == T_OBJECT) {
460 f->do_oop(_locals->at(i)->oop_addr());
461 }
462 }
463 }
464
465 jvmtiDeferredLocalVariable::jvmtiDeferredLocalVariable(int index, BasicType type, jvalue value) {
466 _index = index;
467 _type = type;
468 _value = value;
|