832 // Insert expression stack entries into the exparray
833 GrowableArray<ScopeValue*> *exparray = new GrowableArray<ScopeValue*>(num_exps);
834 for( idx = 0; idx < num_exps; idx++ ) {
835 FillLocArray( idx, sfn, sfn->stack(jvms, idx), exparray, objs );
836 }
837
838 // Add in mappings of the monitors
839 assert( !method ||
840 !method->is_synchronized() ||
841 method->is_native() ||
842 num_mon > 0 ||
843 !GenerateSynchronizationCode,
844 "monitors must always exist for synchronized methods");
845
846 // Build the growable array of ScopeValues for exp stack
847 GrowableArray<MonitorValue*> *monarray = new GrowableArray<MonitorValue*>(num_mon);
848
849 // Loop over monitors and insert into array
850 for(idx = 0; idx < num_mon; idx++) {
851 // Grab the node that defines this monitor
852 Node* box_node;
853 Node* obj_node;
854 box_node = sfn->monitor_box(jvms, idx);
855 obj_node = sfn->monitor_obj(jvms, idx);
856
857 // Create ScopeValue for object
858 ScopeValue *scval = NULL;
859
860 if( obj_node->is_SafePointScalarObject() ) {
861 SafePointScalarObjectNode* spobj = obj_node->as_SafePointScalarObject();
862 scval = Compile::sv_for_node_id(objs, spobj->_idx);
863 if (scval == NULL) {
864 const Type *t = obj_node->bottom_type();
865 ciKlass* cik = t->is_oopptr()->klass();
866 assert(cik->is_instance_klass() ||
867 cik->is_array_klass(), "Not supported allocation.");
868 ObjectValue* sv = new ObjectValue(spobj->_idx,
869 new ConstantOopWriteValue(cik->encoding()));
870 Compile::set_sv_for_object_node(objs, sv);
871
872 uint first_ind = spobj->first_index();
873 for (uint i = 0; i < spobj->n_fields(); i++) {
874 Node* fld_node = sfn->in(first_ind+i);
875 (void)FillLocArray(sv->field_values()->length(), sfn, fld_node, sv->field_values(), objs);
876 }
877 scval = sv;
878 }
879 } else if( !obj_node->is_Con() ) {
880 OptoReg::Name obj_reg = _regalloc->get_reg_first(obj_node);
881 if( obj_node->bottom_type()->base() == Type::NarrowOop ) {
882 scval = new_loc_value( _regalloc, obj_reg, Location::narrowoop );
883 } else {
884 scval = new_loc_value( _regalloc, obj_reg, Location::oop );
885 }
886 } else {
887 const TypePtr *tp = obj_node->bottom_type()->make_ptr();
888 scval = new ConstantOopWriteValue(tp->is_instptr()->const_oop()->encoding());
889 }
890
891 OptoReg::Name box_reg = BoxLockNode::stack_slot(box_node);
892 Location basic_lock = Location::new_stk_loc(Location::normal,_regalloc->reg2offset(box_reg));
893 monarray->append(new MonitorValue(scval, basic_lock, box_node->as_BoxLock()->is_eliminated()));
894 }
895
896 // We dump the object pool first, since deoptimization reads it in first.
897 debug_info()->dump_object_pool(objs);
898
899 // Build first class objects to pass to scope
900 DebugToken *locvals = debug_info()->create_scope_values(locarray);
901 DebugToken *expvals = debug_info()->create_scope_values(exparray);
902 DebugToken *monvals = debug_info()->create_monitor_values(monarray);
903
904 // Make method available for all Safepoints
905 ciMethod* scope_method = method ? method : _method;
906 // Describe the scope here
907 assert(jvms->bci() >= InvocationEntryBci && jvms->bci() <= 0x10000, "must be a valid or entry BCI");
908 // Now we can describe the scope.
909 debug_info()->describe_scope(safepoint_pc_offset,scope_method,jvms->bci(),locvals,expvals,monvals);
910 } // End jvms loop
911
912 // Mark the end of the scope set.
|
832 // Insert expression stack entries into the exparray
833 GrowableArray<ScopeValue*> *exparray = new GrowableArray<ScopeValue*>(num_exps);
834 for( idx = 0; idx < num_exps; idx++ ) {
835 FillLocArray( idx, sfn, sfn->stack(jvms, idx), exparray, objs );
836 }
837
838 // Add in mappings of the monitors
839 assert( !method ||
840 !method->is_synchronized() ||
841 method->is_native() ||
842 num_mon > 0 ||
843 !GenerateSynchronizationCode,
844 "monitors must always exist for synchronized methods");
845
846 // Build the growable array of ScopeValues for exp stack
847 GrowableArray<MonitorValue*> *monarray = new GrowableArray<MonitorValue*>(num_mon);
848
849 // Loop over monitors and insert into array
850 for(idx = 0; idx < num_mon; idx++) {
851 // Grab the node that defines this monitor
852 Node* box_node = sfn->monitor_box(jvms, idx);
853 Node* obj_node = sfn->monitor_obj(jvms, idx);
854
855 // Create ScopeValue for object
856 ScopeValue *scval = NULL;
857
858 if( obj_node->is_SafePointScalarObject() ) {
859 SafePointScalarObjectNode* spobj = obj_node->as_SafePointScalarObject();
860 scval = Compile::sv_for_node_id(objs, spobj->_idx);
861 if (scval == NULL) {
862 const Type *t = obj_node->bottom_type();
863 ciKlass* cik = t->is_oopptr()->klass();
864 assert(cik->is_instance_klass() ||
865 cik->is_array_klass(), "Not supported allocation.");
866 ObjectValue* sv = new ObjectValue(spobj->_idx,
867 new ConstantOopWriteValue(cik->encoding()));
868 Compile::set_sv_for_object_node(objs, sv);
869
870 uint first_ind = spobj->first_index();
871 for (uint i = 0; i < spobj->n_fields(); i++) {
872 Node* fld_node = sfn->in(first_ind+i);
873 (void)FillLocArray(sv->field_values()->length(), sfn, fld_node, sv->field_values(), objs);
874 }
875 scval = sv;
876 }
877 } else if( !obj_node->is_Con() ) {
878 OptoReg::Name obj_reg = _regalloc->get_reg_first(obj_node);
879 if( obj_node->bottom_type()->base() == Type::NarrowOop ) {
880 scval = new_loc_value( _regalloc, obj_reg, Location::narrowoop );
881 } else {
882 scval = new_loc_value( _regalloc, obj_reg, Location::oop );
883 }
884 } else {
885 const TypePtr *tp = obj_node->bottom_type()->make_ptr();
886 scval = new ConstantOopWriteValue(tp->is_instptr()->const_oop()->encoding());
887 }
888
889 OptoReg::Name box_reg = BoxLockNode::stack_slot(box_node);
890 Location basic_lock = Location::new_stk_loc(Location::normal,_regalloc->reg2offset(box_reg));
891 while( !box_node->is_BoxLock() ) box_node = box_node->in(1);
892 monarray->append(new MonitorValue(scval, basic_lock, box_node->as_BoxLock()->is_eliminated()));
893 }
894
895 // We dump the object pool first, since deoptimization reads it in first.
896 debug_info()->dump_object_pool(objs);
897
898 // Build first class objects to pass to scope
899 DebugToken *locvals = debug_info()->create_scope_values(locarray);
900 DebugToken *expvals = debug_info()->create_scope_values(exparray);
901 DebugToken *monvals = debug_info()->create_monitor_values(monarray);
902
903 // Make method available for all Safepoints
904 ciMethod* scope_method = method ? method : _method;
905 // Describe the scope here
906 assert(jvms->bci() >= InvocationEntryBci && jvms->bci() <= 0x10000, "must be a valid or entry BCI");
907 // Now we can describe the scope.
908 debug_info()->describe_scope(safepoint_pc_offset,scope_method,jvms->bci(),locvals,expvals,monvals);
909 } // End jvms loop
910
911 // Mark the end of the scope set.
|