comparison src/share/vm/jvmci/jvmciCodeInstaller.cpp @ 21982:861108f5408e

Support derived references in HotSpotReferenceMap.
author Roland Schatz <roland.schatz@oracle.com>
date Tue, 16 Jun 2015 16:30:34 +0200
parents df9d2375512a
children ab879bff09ab
comparison
equal deleted inserted replaced
21981:007e88ccbba9 21982:861108f5408e
1 /* 1 /*
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
67 Method* getMethodFromHotSpotMethod(oop hotspot_method) { 67 Method* getMethodFromHotSpotMethod(oop hotspot_method) {
68 assert(hotspot_method != NULL && hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass()), "sanity"); 68 assert(hotspot_method != NULL && hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass()), "sanity");
69 return asMethod(HotSpotResolvedJavaMethodImpl::metaspaceMethod(hotspot_method)); 69 return asMethod(HotSpotResolvedJavaMethodImpl::metaspaceMethod(hotspot_method));
70 } 70 }
71 71
72 VMReg getVMRegFromLocation(oop location, int total_frame_size) {
73 oop reg = code_Location::reg(location);
74 jint offset = code_Location::offset(location);
75
76 if (reg != NULL) {
77 // register
78 jint number = code_Register::number(reg);
79 VMReg vmReg = CodeInstaller::get_hotspot_reg(number);
80 assert(offset % 4 == 0, "must be aligned");
81 return vmReg->next(offset / 4);
82 } else {
83 // stack slot
84 #ifdef TARGET_ARCH_sparc
85 if(offset >= 0) {
86 offset += 128;
87 }
88 #endif
89 if (code_Location::addFrameSize(location)) {
90 offset += total_frame_size;
91 }
92 assert(offset % 4 == 0, "must be aligned");
93 return VMRegImpl::stack2reg(offset / 4);
94 }
95 }
96
72 // creates a HotSpot oop map out of the byte arrays provided by DebugInfo 97 // creates a HotSpot oop map out of the byte arrays provided by DebugInfo
73 OopMap* CodeInstaller::create_oop_map(oop debug_info) { 98 OopMap* CodeInstaller::create_oop_map(oop debug_info) {
74 oop reference_map = DebugInfo::referenceMap(debug_info); 99 oop reference_map = DebugInfo::referenceMap(debug_info);
75 if (HotSpotReferenceMap::maxRegisterSize(reference_map) > 16) { 100 if (HotSpotReferenceMap::maxRegisterSize(reference_map) > 16) {
76 _has_wide_vector = true; 101 _has_wide_vector = true;
77 } 102 }
78 OopMap* map = new OopMap(_total_frame_size, _parameter_count); 103 OopMap* map = new OopMap(_total_frame_size, _parameter_count);
79 objArrayOop objects = HotSpotReferenceMap::objects(reference_map); 104 objArrayOop objects = HotSpotReferenceMap::objects(reference_map);
80 typeArrayOop bytesPerArray = HotSpotReferenceMap::bytesPerElement(reference_map); 105 objArrayOop derivedBase = HotSpotReferenceMap::derivedBase(reference_map);
106 typeArrayOop sizeInBytes = HotSpotReferenceMap::sizeInBytes(reference_map);
81 for (int i = 0; i < objects->length(); i++) { 107 for (int i = 0; i < objects->length(); i++) {
82 oop value = objects->obj_at(i); 108 oop location = objects->obj_at(i);
83 oop lirKind = AbstractValue::lirKind(value); 109 oop baseLocation = derivedBase->obj_at(i);
84 oop platformKind = LIRKind::platformKind(lirKind); 110 int bytes = sizeInBytes->int_at(i);
85 int bytesPerElement = bytesPerArray->int_at(i); 111
86 assert(bytesPerElement == 4 || bytesPerElement == 8, "wrong sizes"); 112 VMReg vmReg = getVMRegFromLocation(location, _total_frame_size);
87 jint referenceMask = LIRKind::referenceMask(lirKind); 113 if (baseLocation != NULL) {
88 assert(referenceMask != 0, "must be a reference type"); 114 // derived oop
89 assert(referenceMask != -1, "must not be a derived reference type"); 115 assert(bytes == 8, "derived oop can't be compressed");
90 116 VMReg baseReg = getVMRegFromLocation(baseLocation, _total_frame_size);
91 VMReg vmReg; 117 map->set_derived_oop(vmReg, baseReg);
92 if (value->is_a(RegisterValue::klass())) { 118 } else if (bytes == 8) {
93 oop reg = RegisterValue::reg(value); 119 // wide oop
94 jint number = code_Register::number(reg); 120 map->set_oop(vmReg);
95 vmReg = CodeInstaller::get_hotspot_reg(number); 121 } else {
96 } else if (value->is_a(StackSlot::klass())) { 122 // narrow oop
97 jint offset = StackSlot::offset(value); 123 assert(bytes == 4, "wrong size");
98 #ifdef TARGET_ARCH_sparc 124 map->set_narrowoop(vmReg);
99 if(offset >= 0) { 125 }
100 offset += 128; 126 }
101 } 127
102 #endif
103 if (StackSlot::addFrameSize(value)) {
104 offset += _total_frame_size;
105 }
106 assert(offset % 4 == 0, "must be aligned");
107 vmReg = VMRegImpl::stack2reg(offset / 4);
108 }
109
110 int bit = 1;
111 while (referenceMask != 0) {
112 if (referenceMask & bit) {
113 if (bytesPerElement == 8) {
114 map->set_oop(vmReg);
115 } else {
116 map->set_narrowoop(vmReg);
117 }
118 referenceMask &= ~bit;
119 }
120 vmReg = vmReg->next();
121 if (bytesPerElement == 8) {
122 vmReg = vmReg->next();
123 }
124 bit <<= 1;
125 }
126 }
127 oop callee_save_info = (oop) DebugInfo::calleeSaveInfo(debug_info); 128 oop callee_save_info = (oop) DebugInfo::calleeSaveInfo(debug_info);
128 if (callee_save_info != NULL) { 129 if (callee_save_info != NULL) {
129 objArrayOop registers = RegisterSaveLayout::registers(callee_save_info); 130 objArrayOop registers = RegisterSaveLayout::registers(callee_save_info);
130 typeArrayOop slots = RegisterSaveLayout::slots(callee_save_info); 131 typeArrayOop slots = RegisterSaveLayout::slots(callee_save_info);
131 for (jint i = 0; i < slots->length(); i++) { 132 for (jint i = 0; i < slots->length(); i++) {