comparison src/share/vm/interpreter/rewriter.cpp @ 14909:4ca6dc0799b6

Backout jdk9 merge
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 01 Apr 2014 13:57:07 +0200
parents d8041d695d19
children 52b4284cb496
comparison
equal deleted inserted replaced
14908:8db6e76cb658 14909:4ca6dc0799b6
1 /* 1 /*
2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1998, 2013, 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.
248 int cache_index = ConstantPool::decode_invokedynamic_index( 248 int cache_index = ConstantPool::decode_invokedynamic_index(
249 Bytes::get_native_u4(p)); 249 Bytes::get_native_u4(p));
250 // We will reverse the bytecode rewriting _after_ adjusting them. 250 // We will reverse the bytecode rewriting _after_ adjusting them.
251 // Adjust the cache index by offset to the invokedynamic entries in the 251 // Adjust the cache index by offset to the invokedynamic entries in the
252 // cpCache plus the delta if the invokedynamic bytecodes were adjusted. 252 // cpCache plus the delta if the invokedynamic bytecodes were adjusted.
253 int adjustment = cp_cache_delta() + _first_iteration_cp_cache_limit; 253 cache_index = cp_cache_delta() + _first_iteration_cp_cache_limit;
254 int cp_index = invokedynamic_cp_cache_entry_pool_index(cache_index - adjustment); 254 int cp_index = invokedynamic_cp_cache_entry_pool_index(cache_index);
255 assert(_pool->tag_at(cp_index).is_invoke_dynamic(), "wrong index"); 255 assert(_pool->tag_at(cp_index).is_invoke_dynamic(), "wrong index");
256 // zero out 4 bytes 256 // zero out 4 bytes
257 Bytes::put_Java_u4(p, 0); 257 Bytes::put_Java_u4(p, 0);
258 Bytes::put_Java_u2(p, cp_index); 258 Bytes::put_Java_u2(p, cp_index);
259 } 259 }
451 } 451 }
452 452
453 return method; 453 return method;
454 } 454 }
455 455
456 void Rewriter::rewrite_bytecodes(TRAPS) { 456 void Rewriter::rewrite(instanceKlassHandle klass, TRAPS) {
457 ResourceMark rm(THREAD);
458 Rewriter rw(klass, klass->constants(), klass->methods(), CHECK);
459 // (That's all, folks.)
460 }
461
462
463 Rewriter::Rewriter(instanceKlassHandle klass, constantPoolHandle cpool, Array<Method*>* methods, TRAPS)
464 : _klass(klass),
465 _pool(cpool),
466 _methods(methods)
467 {
457 assert(_pool->cache() == NULL, "constant pool cache must not be set yet"); 468 assert(_pool->cache() == NULL, "constant pool cache must not be set yet");
458 469
459 // determine index maps for Method* rewriting 470 // determine index maps for Method* rewriting
460 compute_index_maps(); 471 compute_index_maps();
461 472
495 } 506 }
496 507
497 // May have to fix invokedynamic bytecodes if invokestatic/InterfaceMethodref 508 // May have to fix invokedynamic bytecodes if invokestatic/InterfaceMethodref
498 // entries had to be added. 509 // entries had to be added.
499 patch_invokedynamic_bytecodes(); 510 patch_invokedynamic_bytecodes();
500 }
501
502 void Rewriter::rewrite(instanceKlassHandle klass, TRAPS) {
503 ResourceMark rm(THREAD);
504 Rewriter rw(klass, klass->constants(), klass->methods(), CHECK);
505 // (That's all, folks.)
506 }
507
508
509 Rewriter::Rewriter(instanceKlassHandle klass, constantPoolHandle cpool, Array<Method*>* methods, TRAPS)
510 : _klass(klass),
511 _pool(cpool),
512 _methods(methods)
513 {
514
515 // Rewrite bytecodes - exception here exits.
516 rewrite_bytecodes(CHECK);
517
518 // Stress restoring bytecodes
519 if (StressRewriter) {
520 restore_bytecodes();
521 rewrite_bytecodes(CHECK);
522 }
523 511
524 // allocate constant pool cache, now that we've seen all the bytecodes 512 // allocate constant pool cache, now that we've seen all the bytecodes
525 make_constant_pool_cache(THREAD); 513 make_constant_pool_cache(THREAD);
526 514
527 // Restore bytecodes to their unrewritten state if there are exceptions 515 // Restore bytecodes to their unrewritten state if there are exceptions
533 521
534 // Relocate after everything, but still do this under the is_rewritten flag, 522 // Relocate after everything, but still do this under the is_rewritten flag,
535 // so methods with jsrs in custom class lists in aren't attempted to be 523 // so methods with jsrs in custom class lists in aren't attempted to be
536 // rewritten in the RO section of the shared archive. 524 // rewritten in the RO section of the shared archive.
537 // Relocated bytecodes don't have to be restored, only the cp cache entries 525 // Relocated bytecodes don't have to be restored, only the cp cache entries
538 int len = _methods->length();
539 for (int i = len-1; i >= 0; i--) { 526 for (int i = len-1; i >= 0; i--) {
540 methodHandle m(THREAD, _methods->at(i)); 527 methodHandle m(THREAD, _methods->at(i));
541 528
542 if (m->has_jsrs()) { 529 if (m->has_jsrs()) {
543 m = rewrite_jsrs(m, THREAD); 530 m = rewrite_jsrs(m, THREAD);