annotate src/share/vm/oops/valueKlass.cpp @ 13020:4cd1b06ce224

multiple value return
author roland
date Thu, 08 Jun 2017 18:25:59 +0200
parents d16eda688d5d
children b1cf9cbe2ecb
rev   line source
fparain@12964 1 /*
fparain@12964 2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
fparain@12964 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fparain@12964 4 *
fparain@12964 5 * This code is free software; you can redistribute it and/or modify it
fparain@12964 6 * under the terms of the GNU General Public License version 2 only, as
fparain@12964 7 * published by the Free Software Foundation.
fparain@12964 8 *
fparain@12964 9 * This code is distributed in the hope that it will be useful, but WITHOUT
fparain@12964 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fparain@12964 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
fparain@12964 12 * version 2 for more details (a copy is included in the LICENSE file that
fparain@12964 13 * accompanied this code).
fparain@12964 14 *
fparain@12964 15 * You should have received a copy of the GNU General Public License version
fparain@12964 16 * 2 along with this work; if not, write to the Free Software Foundation,
fparain@12964 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fparain@12964 18 *
fparain@12964 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fparain@12964 20 * or visit www.oracle.com if you need additional information or have any
fparain@12964 21 * questions.
fparain@12964 22 *
fparain@12964 23 */
fparain@12964 24
fparain@12964 25 #include "precompiled.hpp"
roland@13020 26 #include "gc/shared/gcLocker.inline.hpp"
fparain@12964 27 #include "interpreter/interpreter.hpp"
fparain@12964 28 #include "oops/oop.inline.hpp"
fparain@12964 29 #include "oops/fieldStreams.hpp"
fparain@12964 30 #include "oops/method.hpp"
fparain@12964 31 #include "oops/objArrayKlass.hpp"
fparain@12964 32 #include "oops/valueKlass.hpp"
fparain@12964 33 #include "oops/valueArrayKlass.hpp"
roland@13020 34 #include "runtime/signature.hpp"
fparain@12964 35 #include "utilities/copy.hpp"
fparain@12964 36
fparain@12964 37 int ValueKlass::first_field_offset() const {
fparain@12964 38 #ifdef ASSERT
fparain@12964 39 int first_offset = INT_MAX;
fparain@12964 40 for (JavaFieldStream fs(this); !fs.done(); fs.next()) {
fparain@12964 41 if (fs.offset() < first_offset) first_offset= fs.offset();
fparain@12964 42 }
fparain@12964 43 #endif
fparain@12964 44 int base_offset = instanceOopDesc::base_offset_in_bytes();
fparain@12964 45 // The first field of value types is aligned on a long boundary
fparain@12964 46 base_offset = align_size_up(base_offset, BytesPerLong);
fparain@12964 47 assert(base_offset = first_offset, "inconsistent offsets");
fparain@12964 48 return base_offset;
fparain@12964 49 }
fparain@12964 50
fparain@12964 51 int ValueKlass::raw_value_byte_size() const {
fparain@12964 52 int heapOopAlignedSize = nonstatic_field_size() << LogBytesPerHeapOop;
fparain@12964 53 // If bigger than 64 bits or needs oop alignment, then use jlong aligned
fparain@12964 54 // which for values should be jlong aligned, asserts in raw_field_copy otherwise
fparain@12964 55 if (heapOopAlignedSize >= longSize || contains_oops()) {
fparain@12964 56 return heapOopAlignedSize;
fparain@12964 57 }
fparain@12964 58 // Small primitives...
fparain@12964 59 // If a few small basic type fields, return the actual size, i.e.
fparain@12964 60 // 1 byte = 1
fparain@12964 61 // 2 byte = 2
fparain@12964 62 // 3 byte = 4, because pow2 needed for element stores
fparain@12964 63 int first_offset = first_field_offset();
fparain@12964 64 int last_offset = 0; // find the last offset, add basic type size
fparain@12964 65 for (JavaFieldStream fs(this); !fs.done(); fs.next()) {
fparain@12964 66 if (fs.offset() > last_offset) {
fparain@12964 67 int tsz = 0;
fparain@12964 68 BasicType type = fs.field_descriptor().field_type();
fparain@12964 69 if (is_java_primitive(type)) {
fparain@12964 70 tsz = type2aelembytes(type);
fparain@12964 71 } else if (type == T_VALUETYPE) {
fparain@12964 72 // Not just primitives. Layout aligns embedded value, so use jlong aligned it is
fparain@12964 73 return heapOopAlignedSize;
fparain@12964 74 } else {
fparain@12964 75 guarantee(0, "Unknown type %d", type);
fparain@12964 76 }
fparain@12964 77 assert(tsz > 0, "Invariant");
fparain@12964 78 last_offset = fs.offset() + tsz;
fparain@12964 79 }
fparain@12964 80 }
fparain@12964 81 assert(last_offset > first_offset, "Invariant");
fparain@12964 82 return 1 << upper_log2(last_offset - first_offset);
fparain@12964 83 }
fparain@12964 84
fparain@12964 85 bool ValueKlass::is_atomic() {
fparain@12964 86 return (nonstatic_field_size() * heapOopSize) <= longSize;
fparain@12964 87 }
fparain@12964 88
fparain@12964 89 int ValueKlass::nonstatic_oop_count() {
fparain@12964 90 int oops = 0;
fparain@12964 91 int map_count = nonstatic_oop_map_count();
fparain@12964 92 OopMapBlock* block = start_of_nonstatic_oop_maps();
fparain@12964 93 OopMapBlock* end = block + map_count;
fparain@12964 94 while (block != end) {
fparain@12964 95 oops += block->count();
fparain@12964 96 block++;
fparain@12964 97 }
fparain@12964 98 return oops;
fparain@12964 99 }
fparain@12964 100
fparain@12964 101 // Arrays of...
fparain@12964 102
fparain@12964 103 bool ValueKlass::flatten_array() {
fparain@12964 104 if (!ValueArrayFlatten) {
fparain@12964 105 return false;
fparain@12964 106 }
fparain@12964 107
fparain@12964 108 int elem_bytes = raw_value_byte_size();
fparain@12964 109 // Too big
fparain@12964 110 if ((ValueArrayElemMaxFlatSize >= 0) && (elem_bytes > ValueArrayElemMaxFlatSize)) {
fparain@12964 111 return false;
fparain@12964 112 }
fparain@12964 113 // Too many embedded oops
fparain@12964 114 if ((ValueArrayElemMaxFlatOops >= 0) && (nonstatic_oop_count() > ValueArrayElemMaxFlatOops)) {
fparain@12964 115 return false;
fparain@12964 116 }
fparain@12964 117
fparain@12964 118 return true;
fparain@12964 119 }
fparain@12964 120
fparain@12964 121
fparain@12964 122 Klass* ValueKlass::array_klass_impl(bool or_null, int n, TRAPS) {
fparain@12964 123 if (!flatten_array()) {
fparain@12964 124 return InstanceKlass::array_klass_impl(or_null, n, THREAD);
fparain@12964 125 }
fparain@12964 126
fparain@12964 127 // Basically the same as instanceKlass, but using "ValueArrayKlass::allocate_klass"
fparain@12964 128 if (array_klasses() == NULL) {
fparain@12964 129 if (or_null) return NULL;
fparain@12964 130
fparain@12964 131 ResourceMark rm;
fparain@12964 132 JavaThread *jt = (JavaThread *)THREAD;
fparain@12964 133 {
fparain@12964 134 // Atomic creation of array_klasses
fparain@12964 135 MutexLocker mc(Compile_lock, THREAD); // for vtables
fparain@12964 136 MutexLocker ma(MultiArray_lock, THREAD);
fparain@12964 137
fparain@12964 138 // Check if update has already taken place
fparain@12964 139 if (array_klasses() == NULL) {
fparain@12964 140 Klass* ak;
fparain@12964 141 if (is_atomic() || (!ValueArrayAtomicAccess)) {
fparain@12964 142 ak = ValueArrayKlass::allocate_klass(this, CHECK_NULL);
fparain@12964 143 } else {
fparain@12964 144 ak = ObjArrayKlass::allocate_objArray_klass(class_loader_data(), 1, this, CHECK_NULL);
fparain@12964 145 }
fparain@12964 146 set_array_klasses(ak);
fparain@12964 147 }
fparain@12964 148 }
fparain@12964 149 }
fparain@12964 150 // _this will always be set at this point
fparain@12964 151 ArrayKlass* ak = ArrayKlass::cast(array_klasses());
fparain@12964 152 if (or_null) {
fparain@12964 153 return ak->array_klass_or_null(n);
fparain@12964 154 }
fparain@12964 155 return ak->array_klass(n, THREAD);
fparain@12964 156 }
fparain@12964 157
fparain@12964 158 Klass* ValueKlass::array_klass_impl(bool or_null, TRAPS) {
fparain@12964 159 return array_klass_impl(or_null, 1, THREAD);
fparain@12964 160 }
fparain@12964 161
fparain@12964 162 void ValueKlass::raw_field_copy(void* src, void* dst, size_t raw_byte_size) {
fparain@12964 163 /*
fparain@12964 164 * Try not to shear fields even if not an atomic store...
fparain@12964 165 *
fparain@12964 166 * First 3 cases handle value array store, otherwise works on the same basis
fparain@12964 167 * as JVM_Clone, at this size data is aligned. The order of primitive types
fparain@12964 168 * is largest to smallest, and it not possible for fields to stradle long
fparain@12964 169 * copy boundaries.
fparain@12964 170 *
fparain@12964 171 * If MT without exclusive access, possible to observe partial value store,
fparain@12964 172 * but not partial primitive and reference field values
fparain@12964 173 */
fparain@12964 174 switch (raw_byte_size) {
fparain@12964 175 case 1:
fparain@12964 176 *((jbyte*) dst) = *(jbyte*)src;
fparain@12964 177 break;
fparain@12964 178 case 2:
fparain@12964 179 *((jshort*) dst) = *(jshort*)src;
fparain@12964 180 break;
fparain@12964 181 case 4:
fparain@12964 182 *((jint*) dst) = *(jint*) src;
fparain@12964 183 break;
fparain@12964 184 default:
fparain@12964 185 assert(raw_byte_size % sizeof(jlong) == 0, "Unaligned raw_byte_size");
fparain@12964 186 Copy::conjoint_jlongs_atomic((jlong*)src, (jlong*)dst, raw_byte_size >> LogBytesPerLong);
fparain@12964 187 }
fparain@12964 188 }
fparain@12964 189
fparain@12964 190 /*
fparain@12964 191 * Store the value of this klass contained with src into dst.
fparain@12964 192 *
fparain@12964 193 * This operation is appropriate for use from vastore, vaload and putfield (for values)
fparain@12964 194 *
fparain@12964 195 * GC barriers currently can lock with no safepoint check and allocate c-heap,
fparain@12964 196 * so raw point is "safe" for now.
fparain@12964 197 *
fparain@12964 198 * Going forward, look to use machine generated (stub gen or bc) version for most used klass layouts
fparain@12964 199 *
fparain@12964 200 */
fparain@12964 201 void ValueKlass::value_store(void* src, void* dst, size_t raw_byte_size, bool dst_heap, bool dst_uninitialized) {
fparain@12964 202 if (contains_oops() && dst_heap) {
fparain@12964 203 // src/dst aren't oops, need offset to adjust oop map offset
fparain@12964 204 const address dst_oop_addr = ((address) dst) - first_field_offset();
fparain@12964 205
fparain@12964 206 // Pre-barriers...
fparain@12964 207 OopMapBlock* map = start_of_nonstatic_oop_maps();
fparain@12964 208 OopMapBlock* const end = map + nonstatic_oop_map_count();
fparain@12964 209 while (map != end) {
fparain@12964 210 // Shame we can't just use the existing oop iterator...src/dst aren't oop
fparain@12964 211 address doop_address = dst_oop_addr + map->offset();
fparain@12964 212 if (UseCompressedOops) {
fparain@12964 213 oopDesc::bs()->write_ref_array_pre((narrowOop*) doop_address, map->count(), dst_uninitialized);
fparain@12964 214 } else {
fparain@12964 215 oopDesc::bs()->write_ref_array_pre((oop*) doop_address, map->count(), dst_uninitialized);
fparain@12964 216 }
fparain@12964 217 map++;
fparain@12964 218 }
fparain@12964 219
fparain@12964 220 raw_field_copy(src, dst, raw_byte_size);
fparain@12964 221
fparain@12964 222 // Post-barriers...
fparain@12964 223 map = start_of_nonstatic_oop_maps();
fparain@12964 224 while (map != end) {
fparain@12964 225 address doop_address = dst_oop_addr + map->offset();
fparain@12964 226 oopDesc::bs()->write_ref_array((HeapWord*) doop_address, map->count());
fparain@12964 227 map++;
fparain@12964 228 }
fparain@12964 229 } else { // Primitive-only case...
fparain@12964 230 raw_field_copy(src, dst, raw_byte_size);
fparain@12964 231 }
fparain@12964 232 }
fparain@12964 233
fparain@12964 234 oop ValueKlass::derive_value_type_copy(Handle src, InstanceKlass* target_klass, TRAPS) {
fparain@12964 235 assert(InstanceKlass::cast(src->klass())->derive_value_type_klass() == target_klass, "Not this DVT");
fparain@12964 236
fparain@12964 237 // Allocate new for safety, simply reinstalling the klass pointer is a little too risky
fparain@12964 238 target_klass->initialize(CHECK_0);
fparain@12964 239 instanceOop value = target_klass->allocate_instance(CHECK_0);
fparain@12964 240 value_store(data_for_oop(src()), data_for_oop(value), true, true);
fparain@12964 241 return value;
fparain@12964 242 }
roland@13020 243
roland@13020 244 // Value type arguments are not passed by reference, instead each
roland@13020 245 // field of the value type is passed as an argument. This helper
roland@13020 246 // function collects the fields of the value types (including embedded
roland@13020 247 // value type's fields) in a list. Included with the field's type is
roland@13020 248 // the offset of each field in the value type: i2c and c2i adapters
roland@13020 249 // need that to load or store fields. Finally, the list of fields is
roland@13020 250 // sorted in order of increasing offsets: the adapters and the
roland@13020 251 // compiled code need and agreed upon order of fields.
roland@13020 252 //
roland@13020 253 // The list of basic types that is returned starts with a T_VALUETYPE
roland@13020 254 // and ends with an extra T_VOID. T_VALUETYPE/T_VOID are used as
roland@13020 255 // delimiters. Every entry between the two is a field of the value
roland@13020 256 // type. If there's an embedded value type in the list, it also starts
roland@13020 257 // with a T_VALUETYPE and ends with a T_VOID. This is so we can
roland@13020 258 // generate a unique fingerprint for the method's adapters and we can
roland@13020 259 // generate the list of basic types from the interpreter point of view
roland@13020 260 // (value types passed as reference: iterate on the list until a
roland@13020 261 // T_VALUETYPE, drop everything until and including the closing
roland@13020 262 // T_VOID) or the compiler point of view (each field of the value
roland@13020 263 // types is an argument: drop all T_VALUETYPE/T_VOID from the list).
roland@13020 264 GrowableArray<SigEntry> ValueKlass::collect_fields(int base_off) const {
roland@13020 265 GrowableArray<SigEntry> sig_extended;
roland@13020 266 sig_extended.push(SigEntry(T_VALUETYPE, base_off));
roland@13020 267 for (JavaFieldStream fs(this); !fs.done(); fs.next()) {
roland@13020 268 if (fs.access_flags().is_static()) continue;
roland@13020 269 fieldDescriptor& fd = fs.field_descriptor();
roland@13020 270 BasicType bt = fd.field_type();
roland@13020 271 int offset = base_off + fd.offset() - (base_off > 0 ? first_field_offset() : 0);
roland@13020 272 if (bt == T_VALUETYPE) {
roland@13020 273 Symbol* signature = fd.signature();
roland@13020 274 JavaThread* THREAD = JavaThread::current();
roland@13020 275 oop loader = class_loader();
roland@13020 276 oop domain = protection_domain();
roland@13020 277 ResetNoHandleMark rnhm;
roland@13020 278 HandleMark hm;
roland@13020 279 NoSafepointVerifier nsv;
roland@13020 280 Klass* klass = SystemDictionary::resolve_or_null(signature,
roland@13020 281 Handle(THREAD, loader), Handle(THREAD, domain),
roland@13020 282 THREAD);
roland@13020 283 assert(klass != NULL && !HAS_PENDING_EXCEPTION, "lookup shouldn't fail");
roland@13020 284 const GrowableArray<SigEntry>& embedded = ValueKlass::cast(klass)->collect_fields(offset);
roland@13020 285 sig_extended.appendAll(&embedded);
roland@13020 286 } else {
roland@13020 287 sig_extended.push(SigEntry(bt, offset));
roland@13020 288 if (bt == T_LONG || bt == T_DOUBLE) {
roland@13020 289 sig_extended.push(SigEntry(T_VOID, offset));
roland@13020 290 }
roland@13020 291 }
roland@13020 292 }
roland@13020 293 int offset = base_off + size_helper()*HeapWordSize - (base_off > 0 ? first_field_offset() : 0);
roland@13020 294 sig_extended.push(SigEntry(T_VOID, offset)); // hack: use T_VOID to mark end of value type fields
roland@13020 295 if (base_off == 0) {
roland@13020 296 sig_extended.sort(SigEntry::compare);
roland@13020 297 }
roland@13020 298 assert(sig_extended.at(0)._bt == T_VALUETYPE && sig_extended.at(sig_extended.length()-1)._bt == T_VOID, "broken structure");
roland@13020 299 return sig_extended;
roland@13020 300 }
roland@13020 301
roland@13020 302 // Returns the basic types and registers for fields to return an
roland@13020 303 // instance of this value type in registers if possible.
roland@13020 304 GrowableArray<SigEntry> ValueKlass::return_convention(VMRegPair*& regs, int& nb_fields) const {
roland@13020 305 assert(ValueTypeReturnedAsFields, "inconsistent");
roland@13020 306 const GrowableArray<SigEntry>& sig_vk = collect_fields();
roland@13020 307 nb_fields = SigEntry::count_fields(sig_vk)+1;
roland@13020 308 BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, nb_fields);
roland@13020 309 sig_bt[0] = T_METADATA;
roland@13020 310 SigEntry::fill_sig_bt(sig_vk, sig_bt+1, nb_fields-1, true);
roland@13020 311 regs = NEW_RESOURCE_ARRAY(VMRegPair, nb_fields);
roland@13020 312 int total = SharedRuntime::java_return_convention(sig_bt, regs, nb_fields);
roland@13020 313
roland@13020 314 if (total <= 0) {
roland@13020 315 regs = NULL;
roland@13020 316 }
roland@13020 317
roland@13020 318 return sig_vk;
roland@13020 319 }
roland@13020 320
roland@13020 321 // Create handles for all oop fields returned in registers that are
roland@13020 322 // going to be live across a safepoint.
roland@13020 323 bool ValueKlass::save_oop_results(RegisterMap& reg_map, GrowableArray<Handle>& handles) const {
roland@13020 324 if (ValueTypeReturnedAsFields) {
roland@13020 325 int nb_fields;
roland@13020 326 VMRegPair* regs;
roland@13020 327 const GrowableArray<SigEntry>& sig_vk = return_convention(regs, nb_fields);
roland@13020 328
roland@13020 329 if (regs != NULL) {
roland@13020 330 regs++;
roland@13020 331 nb_fields--;
roland@13020 332 save_oop_fields(sig_vk, reg_map, regs, handles, nb_fields);
roland@13020 333 return true;
roland@13020 334 }
roland@13020 335 }
roland@13020 336 return false;
roland@13020 337 }
roland@13020 338
roland@13020 339 // Same as above but with pre-computed return convention
roland@13020 340 void ValueKlass::save_oop_fields(const GrowableArray<SigEntry>& sig_vk, RegisterMap& reg_map, const VMRegPair* regs, GrowableArray<Handle>& handles, int nb_fields) const {
roland@13020 341 int j = 0;
roland@13020 342 Thread* thread = Thread::current();
roland@13020 343 for (int i = 0; i < sig_vk.length(); i++) {
roland@13020 344 BasicType bt = sig_vk.at(i)._bt;
roland@13020 345 if (bt == T_OBJECT || bt == T_ARRAY) {
roland@13020 346 int off = sig_vk.at(i)._offset;
roland@13020 347 VMRegPair pair = regs[j];
roland@13020 348 address loc = reg_map.location(pair.first());
roland@13020 349 oop v = *(oop*)loc;
roland@13020 350 assert(v == NULL || v->is_oop(), "not an oop?");
roland@13020 351 assert(Universe::heap()->is_in_or_null(v), "must be heap pointer");
roland@13020 352 handles.push(Handle(thread, v));
roland@13020 353 }
roland@13020 354 if (bt == T_VALUETYPE) {
roland@13020 355 continue;
roland@13020 356 }
roland@13020 357 if (bt == T_VOID &&
roland@13020 358 sig_vk.at(i-1)._bt != T_LONG &&
roland@13020 359 sig_vk.at(i-1)._bt != T_DOUBLE) {
roland@13020 360 continue;
roland@13020 361 }
roland@13020 362 j++;
roland@13020 363 }
roland@13020 364 assert(j == nb_fields, "missed a field?");
roland@13020 365 }
roland@13020 366
roland@13020 367 // Update oop fields in registers from handles after a safepoint
roland@13020 368 void ValueKlass::restore_oop_results(RegisterMap& reg_map, GrowableArray<Handle>& handles) const {
roland@13020 369 assert(ValueTypeReturnedAsFields, "inconsistent");
roland@13020 370 int nb_fields;
roland@13020 371 VMRegPair* regs;
roland@13020 372 const GrowableArray<SigEntry>& sig_vk = return_convention(regs, nb_fields);
roland@13020 373 assert(regs != NULL, "inconsistent");
roland@13020 374
roland@13020 375 regs++;
roland@13020 376 nb_fields--;
roland@13020 377
roland@13020 378 int j = 0;
roland@13020 379 for (int i = 0, k = 0; i < sig_vk.length(); i++) {
roland@13020 380 BasicType bt = sig_vk.at(i)._bt;
roland@13020 381 if (bt == T_OBJECT || bt == T_ARRAY) {
roland@13020 382 int off = sig_vk.at(i)._offset;
roland@13020 383 VMRegPair pair = regs[j];
roland@13020 384 address loc = reg_map.location(pair.first());
roland@13020 385 *(oop*)loc = handles.at(k++)();
roland@13020 386 }
roland@13020 387 if (bt == T_VALUETYPE) {
roland@13020 388 continue;
roland@13020 389 }
roland@13020 390 if (bt == T_VOID &&
roland@13020 391 sig_vk.at(i-1)._bt != T_LONG &&
roland@13020 392 sig_vk.at(i-1)._bt != T_DOUBLE) {
roland@13020 393 continue;
roland@13020 394 }
roland@13020 395 j++;
roland@13020 396 }
roland@13020 397 assert(j == nb_fields, "missed a field?");
roland@13020 398 }
roland@13020 399
roland@13020 400 // Fields are in registers. Create an instance of the value type and
roland@13020 401 // initialize it with the values of the fields.
roland@13020 402 oop ValueKlass::realloc_result(const GrowableArray<SigEntry>& sig_vk, const RegisterMap& reg_map, const VMRegPair* regs,
roland@13020 403 const GrowableArray<Handle>& handles, int nb_fields, TRAPS) {
roland@13020 404 oop new_vt = allocate_instance(CHECK_NULL);
roland@13020 405
roland@13020 406 int j = 0;
roland@13020 407 int k = 0;
roland@13020 408 for (int i = 0; i < sig_vk.length(); i++) {
roland@13020 409 BasicType bt = sig_vk.at(i)._bt;
roland@13020 410 if (bt == T_VALUETYPE) {
roland@13020 411 continue;
roland@13020 412 }
roland@13020 413 if (bt == T_VOID) {
roland@13020 414 if (sig_vk.at(i-1)._bt == T_LONG ||
roland@13020 415 sig_vk.at(i-1)._bt == T_DOUBLE) {
roland@13020 416 j++;
roland@13020 417 }
roland@13020 418 continue;
roland@13020 419 }
roland@13020 420 int off = sig_vk.at(i)._offset;
roland@13020 421 VMRegPair pair = regs[j];
roland@13020 422 address loc = reg_map.location(pair.first());
roland@13020 423 switch(bt) {
roland@13020 424 case T_BOOLEAN: {
roland@13020 425 jboolean v = *(intptr_t*)loc;
roland@13020 426 *(jboolean*)((address)new_vt + off) = v;
roland@13020 427 break;
roland@13020 428 }
roland@13020 429 case T_CHAR: {
roland@13020 430 jchar v = *(intptr_t*)loc;
roland@13020 431 *(jchar*)((address)new_vt + off) = v;
roland@13020 432 break;
roland@13020 433 }
roland@13020 434 case T_BYTE: {
roland@13020 435 jbyte v = *(intptr_t*)loc;
roland@13020 436 *(jbyte*)((address)new_vt + off) = v;
roland@13020 437 break;
roland@13020 438 }
roland@13020 439 case T_SHORT: {
roland@13020 440 jshort v = *(intptr_t*)loc;
roland@13020 441 *(jshort*)((address)new_vt + off) = v;
roland@13020 442 break;
roland@13020 443 }
roland@13020 444 case T_INT: {
roland@13020 445 jint v = *(intptr_t*)loc;
roland@13020 446 *(jint*)((address)new_vt + off) = v;
roland@13020 447 break;
roland@13020 448 }
roland@13020 449 case T_LONG: {
roland@13020 450 #ifdef _LP64
roland@13020 451 jlong v = *(intptr_t*)loc;
roland@13020 452 *(jlong*)((address)new_vt + off) = v;
roland@13020 453 #else
roland@13020 454 Unimplemented();
roland@13020 455 #endif
roland@13020 456 break;
roland@13020 457 }
roland@13020 458 case T_OBJECT:
roland@13020 459 case T_ARRAY: {
roland@13020 460 Handle handle = handles.at(k++);
roland@13020 461 oop v = handle();
roland@13020 462 if (!UseCompressedOops) {
roland@13020 463 oop* p = (oop*)((address)new_vt + off);
roland@13020 464 oopDesc::store_heap_oop(p, v);
roland@13020 465 } else {
roland@13020 466 narrowOop* p = (narrowOop*)((address)new_vt + off);
roland@13020 467 oopDesc::encode_store_heap_oop(p, v);
roland@13020 468 }
roland@13020 469 break;
roland@13020 470 }
roland@13020 471 case T_FLOAT: {
roland@13020 472 jfloat v = *(jfloat*)loc;
roland@13020 473 *(jfloat*)((address)new_vt + off) = v;
roland@13020 474 break;
roland@13020 475 }
roland@13020 476 case T_DOUBLE: {
roland@13020 477 jdouble v = *(jdouble*)loc;
roland@13020 478 *(jdouble*)((address)new_vt + off) = v;
roland@13020 479 break;
roland@13020 480 }
roland@13020 481 default:
roland@13020 482 ShouldNotReachHere();
roland@13020 483 }
roland@13020 484 j++;
roland@13020 485 }
roland@13020 486 assert(j == nb_fields, "missed a field?");
roland@13020 487 assert(k == handles.length(), "missed an oop?");
roland@13020 488 return new_vt;
roland@13020 489 }
roland@13020 490
roland@13020 491 ValueKlass* ValueKlass::returned_value_type(const RegisterMap& map) {
roland@13020 492 BasicType bt = T_METADATA;
roland@13020 493 VMRegPair pair;
roland@13020 494 int nb = SharedRuntime::java_return_convention(&bt, &pair, 1);
roland@13020 495 assert(nb == 1, "broken");
roland@13020 496
roland@13020 497 address loc = map.location(pair.first());
roland@13020 498 intptr_t ptr = *(intptr_t*)loc;
roland@13020 499 if (Universe::heap()->is_in_reserved((void*)ptr)) {
roland@13020 500 return NULL;
roland@13020 501 }
roland@13020 502 return (ValueKlass*)ptr;
roland@13020 503 }