forked from dcevm/dcevm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
full-jdk7u79-b15.patch
12372 lines (12003 loc) · 505 KB
/
full-jdk7u79-b15.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# HG changeset patch
# Parent 882f6c762ac5352a0d94efcea46c8f9a917ceb08
diff -r 882f6c762ac5 make/bsd/makefiles/gcc.make
--- a/make/bsd/makefiles/gcc.make Thu Jul 09 23:10:04 2015 -0700
+++ b/make/bsd/makefiles/gcc.make Thu Jul 09 23:18:17 2015 -0700
@@ -117,7 +117,10 @@
CFLAGS += -fno-rtti
CFLAGS += -fno-exceptions
CFLAGS += -pthread
-CFLAGS += -fcheck-new
+## well, strictly speaking we should check for clang not Darwin
+ifneq ($(OS_VENDOR), Darwin)
+ CFLAGS += -fcheck-new
+endif
# version 4 and above support fvisibility=hidden (matches jni_x86.h file)
# except 4.1.2 gives pointless warnings that can't be disabled (afaik)
ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
diff -r 882f6c762ac5 src/cpu/x86/vm/templateTable_x86_32.cpp
--- a/src/cpu/x86/vm/templateTable_x86_32.cpp Thu Jul 09 23:10:04 2015 -0700
+++ b/src/cpu/x86/vm/templateTable_x86_32.cpp Thu Jul 09 23:18:17 2015 -0700
@@ -2109,6 +2109,22 @@
// resolve first time through
address entry;
switch (bytecode()) {
+ case Bytecodes::_fast_agetfield : // fall through
+ case Bytecodes::_fast_bgetfield : // fall through
+ case Bytecodes::_fast_cgetfield : // fall through
+ case Bytecodes::_fast_dgetfield : // fall through
+ case Bytecodes::_fast_fgetfield : // fall through
+ case Bytecodes::_fast_igetfield : // fall through
+ case Bytecodes::_fast_lgetfield : // fall through
+ case Bytecodes::_fast_sgetfield : // fall through
+ case Bytecodes::_fast_aputfield : // fall through
+ case Bytecodes::_fast_bputfield : // fall through
+ case Bytecodes::_fast_cputfield : // fall through
+ case Bytecodes::_fast_dputfield : // fall through
+ case Bytecodes::_fast_fputfield : // fall through
+ case Bytecodes::_fast_iputfield : // fall through
+ case Bytecodes::_fast_lputfield : // fall through
+ case Bytecodes::_fast_sputfield : // fall through
case Bytecodes::_getstatic : // fall through
case Bytecodes::_putstatic : // fall through
case Bytecodes::_getfield : // fall through
@@ -2211,6 +2227,7 @@
// Correct values of the cache and index registers are preserved.
void TemplateTable::jvmti_post_field_access(Register cache,
Register index,
+ int byte_no,
bool is_static,
bool has_tos) {
if (JvmtiExport::can_post_field_access()) {
@@ -2237,7 +2254,11 @@
// cache: cache entry pointer
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_access),
rax, cache);
- __ get_cache_and_index_at_bcp(cache, index, 1);
+
+ // DCEVM: Redefinition might have occured => reresolve the cp entry.
+ __ restore_bcp();
+ resolve_cache_and_index(byte_no, noreg, cache, index, sizeof(u2));
+
__ bind(L1);
}
}
@@ -2258,7 +2279,7 @@
const Register flags = rax;
resolve_cache_and_index(byte_no, noreg, cache, index, sizeof(u2));
- jvmti_post_field_access(cache, index, is_static, false);
+ jvmti_post_field_access(cache, index, byte_no, is_static, false);
load_field_cp_cache_entry(obj, cache, index, off, flags, is_static);
if (!is_static) pop_and_check_object(obj);
@@ -2393,7 +2414,7 @@
// The registers cache and index expected to be set before call.
// The function may destroy various registers, just not the cache and index registers.
-void TemplateTable::jvmti_post_field_mod(Register cache, Register index, bool is_static) {
+void TemplateTable::jvmti_post_field_mod(Register cache, Register index, int byte_no, bool is_static) {
ByteSize cp_base_offset = constantPoolCacheOopDesc::base_offset();
@@ -2451,7 +2472,11 @@
// rcx: jvalue object on the stack
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_modification),
rbx, rax, rcx);
- __ get_cache_and_index_at_bcp(cache, index, 1);
+
+ // (tw) Redefinition might have occured => reresolve the cp entry.
+ __ restore_bcp();
+ resolve_cache_and_index(byte_no, noreg, cache, index, sizeof(u2));
+
__ bind(L1);
}
}
@@ -2467,7 +2492,7 @@
const Register flags = rax;
resolve_cache_and_index(byte_no, noreg, cache, index, sizeof(u2));
- jvmti_post_field_mod(cache, index, is_static);
+ jvmti_post_field_mod(cache, index, byte_no, is_static);
load_field_cp_cache_entry(obj, cache, index, off, flags, is_static);
// Doug Lea believes this is not needed with current Sparcs (TSO) and Intel (PSO).
@@ -2818,6 +2843,11 @@
// rcx: cache entry pointer
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_access), rax, rcx);
__ pop_ptr(rax); // restore object pointer
+
+ // DCEVM: Redefinition might have occured => reresolve the cp entry.
+ __ restore_bcp();
+ resolve_cache_and_index(1, noreg, rax, rcx, sizeof(u2));
+
__ bind(L1);
}
@@ -3008,6 +3038,26 @@
__ bind(notFinal);
+ // DCEVM: Check if we are calling an old method (and have to go slow path)
+ Label notOld;
+ __ movl(rax, flags);
+ __ andl(rax, (1 << ConstantPoolCacheEntry::is_old_method_shift));
+ __ jcc(Assembler::zero, notOld);
+
+ // Need a null check here!
+ __ null_check(recv);
+
+ // Call out to VM to do look up based on correct vTable version (has to iterate back over the class history of the receiver class)
+ // DCEVM: TODO: Check if we can improve performance by inlining.
+ // DCEVM: TODO: Check if this additional branch affects normal execution time.
+ __ call_VM(method, CAST_FROM_FN_PTR(address, InterpreterRuntime::find_correct_method), recv, index);
+
+ // profile this call
+ __ profile_final_call(rax);
+ __ jump_from_interpreted(method, rdx);
+
+ __ bind(notOld);
+
// get receiver klass
__ null_check(recv, oopDesc::klass_offset_in_bytes());
__ load_klass(rax, recv);
@@ -3093,6 +3143,31 @@
invokevirtual_helper(rbx, rcx, rdx);
__ bind(notMethod);
+ // DCEVM: Check if we are calling an old method (and have to go slow path)
+ //__ movl(rax, rdx);
+ Label notOld;
+ __ andl(rdx, (1 << ConstantPoolCacheEntry::is_old_method_shift));
+ __ jcc(Assembler::zero, notOld);
+
+ // Get receiver klass into rdx - also a null check
+ __ movptr(rdx, Address(rcx, oopDesc::klass_offset_in_bytes()));
+ __ verify_oop(rdx);
+
+ // Call out to VM to do look up based on correct vTable version (has to iterate back over the class history of the receiver class)
+ // DCEVM: TODO: Check if we can improve performance by inlining.
+ // DCEVM: TODO: Check if this additional branch affects normal execution time.
+ // DCEVM: TODO: Check the exact semantic (with respect to destoying registers) of call_VM
+ __ call_VM(rbx, CAST_FROM_FN_PTR(address, InterpreterRuntime::find_correct_interface_method), rcx, rax, rbx);
+
+ // DCEVM: TODO: Check if resolved method could be null.
+
+ // profile this call
+ __ profile_virtual_call(rdx, rsi, rdi);
+
+ __ jump_from_interpreted(rbx, rdx);
+
+ __ bind(notOld);
+
// Get receiver klass into rdx - also a null check
__ restore_locals(); // restore rdi
__ null_check(rcx, oopDesc::klass_offset_in_bytes());
diff -r 882f6c762ac5 src/cpu/x86/vm/templateTable_x86_64.cpp
--- a/src/cpu/x86/vm/templateTable_x86_64.cpp Thu Jul 09 23:10:04 2015 -0700
+++ b/src/cpu/x86/vm/templateTable_x86_64.cpp Thu Jul 09 23:18:17 2015 -0700
@@ -2151,6 +2151,22 @@
// resolve first time through
address entry;
switch (bytecode()) {
+ case Bytecodes::_fast_agetfield : // fall through
+ case Bytecodes::_fast_bgetfield : // fall through
+ case Bytecodes::_fast_cgetfield : // fall through
+ case Bytecodes::_fast_dgetfield : // fall through
+ case Bytecodes::_fast_fgetfield : // fall through
+ case Bytecodes::_fast_igetfield : // fall through
+ case Bytecodes::_fast_lgetfield : // fall through
+ case Bytecodes::_fast_sgetfield : // fall through
+ case Bytecodes::_fast_aputfield : // fall through
+ case Bytecodes::_fast_bputfield : // fall through
+ case Bytecodes::_fast_cputfield : // fall through
+ case Bytecodes::_fast_dputfield : // fall through
+ case Bytecodes::_fast_fputfield : // fall through
+ case Bytecodes::_fast_iputfield : // fall through
+ case Bytecodes::_fast_lputfield : // fall through
+ case Bytecodes::_fast_sputfield : // fall through
case Bytecodes::_getstatic:
case Bytecodes::_putstatic:
case Bytecodes::_getfield:
@@ -2267,7 +2283,7 @@
// The registers cache and index expected to be set before call.
// Correct values of the cache and index registers are preserved.
void TemplateTable::jvmti_post_field_access(Register cache, Register index,
- bool is_static, bool has_tos) {
+ int byte_no, bool is_static, bool has_tos) {
// do the JVMTI work here to avoid disturbing the register state below
// We use c_rarg registers here because we want to use the register used in
// the call to the VM
@@ -2298,7 +2314,11 @@
__ call_VM(noreg, CAST_FROM_FN_PTR(address,
InterpreterRuntime::post_field_access),
c_rarg1, c_rarg2, c_rarg3);
- __ get_cache_and_index_at_bcp(cache, index, 1);
+
+ // DCEVM: Redefinition might have occured => reresolve the cp entry.
+ __ restore_bcp();
+ resolve_cache_and_index(byte_no, noreg, cache, index, sizeof(u2));
+
__ bind(L1);
}
}
@@ -2320,7 +2340,7 @@
const Register bc = c_rarg3; // uses same reg as obj, so don't mix them
resolve_cache_and_index(byte_no, noreg, cache, index, sizeof(u2));
- jvmti_post_field_access(cache, index, is_static, false);
+ jvmti_post_field_access(cache, index, byte_no, is_static, false);
load_field_cp_cache_entry(obj, cache, index, off, flags, is_static);
if (!is_static) {
@@ -2455,7 +2475,7 @@
// The registers cache and index expected to be set before call.
// The function may destroy various registers, just not the cache and index registers.
-void TemplateTable::jvmti_post_field_mod(Register cache, Register index, bool is_static) {
+void TemplateTable::jvmti_post_field_mod(Register cache, Register index, int byte_no, bool is_static) {
transition(vtos, vtos);
ByteSize cp_base_offset = constantPoolCacheOopDesc::base_offset();
@@ -2507,7 +2527,11 @@
CAST_FROM_FN_PTR(address,
InterpreterRuntime::post_field_modification),
c_rarg1, c_rarg2, c_rarg3);
- __ get_cache_and_index_at_bcp(cache, index, 1);
+
+ // DCEVM: Redefinition might have occured => reresolve the cp entry.
+ __ restore_bcp();
+ resolve_cache_and_index(byte_no, noreg, cache, index, sizeof(u2));
+
__ bind(L1);
}
}
@@ -2523,7 +2547,7 @@
const Register bc = c_rarg3;
resolve_cache_and_index(byte_no, noreg, cache, index, sizeof(u2));
- jvmti_post_field_mod(cache, index, is_static);
+ jvmti_post_field_mod(cache, index, byte_no, is_static);
load_field_cp_cache_entry(obj, cache, index, off, flags, is_static);
// [jk] not needed currently
@@ -2837,6 +2861,11 @@
InterpreterRuntime::post_field_access),
c_rarg1, c_rarg2);
__ pop_ptr(rax); // restore object pointer
+
+ // DCEVM: Redefinition might have occured => reresolve the cp entry.
+ __ restore_bcp();
+ resolve_cache_and_index(1, noreg, rax, rcx, sizeof(u2));
+
__ bind(L1);
}
@@ -3073,6 +3102,26 @@
__ bind(notFinal);
+ // DCEVM: Check if we are calling an old method (and have to go slow path)
+ Label notOld;
+ __ movl(rax, flags);
+ __ andl(rax, (1 << ConstantPoolCacheEntry::is_old_method_shift));
+ __ jcc(Assembler::zero, notOld);
+
+ // Need a null check here!
+ __ null_check(recv);
+
+ // Call out to VM to do look up based on correct vTable version (has to iterate back over the class history of the receiver class)
+ // DCEVM: TODO: Check if we can improve performance by inlining.
+ // DCEVM: TODO: Check if this additional branch affects normal execution time.
+ __ call_VM(method, CAST_FROM_FN_PTR(address, InterpreterRuntime::find_correct_method), recv, index);
+
+ // profile this call
+ __ profile_final_call(rax);
+ __ jump_from_interpreted(method, rdx);
+
+ __ bind(notOld);
+
// get receiver klass
__ null_check(recv, oopDesc::klass_offset_in_bytes());
__ load_klass(rax, recv);
@@ -3156,6 +3205,35 @@
invokevirtual_helper(rbx, rcx, rdx);
__ bind(notMethod);
+ // DCEVM: Check if we are calling an old method (and have to go slow path)
+ Label notOld;
+ __ andl(rdx, (1 << ConstantPoolCacheEntry::is_old_method_shift));
+ __ jcc(Assembler::zero, notOld);
+
+ // Call out to VM to do look up based on correct vTable version (has to iterate back over the class history of the receiver class)
+ // DCEVM: TODO: Check if we can improve performance by inlining.
+ // DCEVM: TODO: Check if this additional branch affects normal execution time.
+ // DCEVM: TODO: Check the exact semantic (with respect to destoying registers) of call_VM
+ // DCEVM: FIXME: What exactly should we store here?
+ __ push(rcx); // destroyed by Linux arguments passing conventions
+ __ movptr(r14, rcx);
+ __ call_VM(rbx, CAST_FROM_FN_PTR(address, InterpreterRuntime::find_correct_interface_method), r14, rax, rbx);
+ __ pop(rcx);
+
+ // Get receiver klass into rdx - also a null check
+ __ restore_locals(); // restore r14
+ __ load_klass(rdx, rcx);
+ __ verify_oop(rdx);
+
+ // DCEVM: TODO: Check if resolved method could be null.
+
+ // profile this call
+ __ profile_virtual_call(rdx, r13, r14);
+
+ __ jump_from_interpreted(rbx, rdx);
+
+ __ bind(notOld);
+
// Get receiver klass into rdx - also a null check
__ restore_locals(); // restore r14
__ null_check(rcx, oopDesc::klass_offset_in_bytes());
diff -r 882f6c762ac5 src/share/vm/c1/c1_Compilation.hpp
--- a/src/share/vm/c1/c1_Compilation.hpp Thu Jul 09 23:10:04 2015 -0700
+++ b/src/share/vm/c1/c1_Compilation.hpp Thu Jul 09 23:18:17 2015 -0700
@@ -242,8 +242,8 @@
#define BAILOUT(msg) { bailout(msg); return; }
#define BAILOUT_(msg, res) { bailout(msg); return res; }
-#define CHECK_BAILOUT() { if (bailed_out()) return; }
-#define CHECK_BAILOUT_(res) { if (bailed_out()) return res; }
+#define CHECK_BAILOUT() { if (((CompilerThread *)Thread::current())->should_bailout()) bailout("Aborted externally"); if (bailed_out()) return; }
+#define CHECK_BAILOUT_(res) { if (((CompilerThread *)Thread::current())->should_bailout()) bailout("Aborted externally"); if (bailed_out()) return res; }
class InstructionMark: public StackObj {
diff -r 882f6c762ac5 src/share/vm/ci/ciEnv.cpp
--- a/src/share/vm/ci/ciEnv.cpp Thu Jul 09 23:10:04 2015 -0700
+++ b/src/share/vm/ci/ciEnv.cpp Thu Jul 09 23:18:17 2015 -0700
@@ -1172,3 +1172,11 @@
// If memory is low, we stop compiling methods.
record_method_not_compilable("out of memory");
}
+
+// DCEVM: Called after class redefinition to clean up possibly invalidated state.
+void ciEnv::cleanup_after_redefinition() {
+
+ if (_factory != NULL) {
+ _factory->cleanup_after_redefinition();
+ }
+}
diff -r 882f6c762ac5 src/share/vm/ci/ciEnv.hpp
--- a/src/share/vm/ci/ciEnv.hpp Thu Jul 09 23:10:04 2015 -0700
+++ b/src/share/vm/ci/ciEnv.hpp Thu Jul 09 23:18:17 2015 -0700
@@ -417,6 +417,8 @@
void record_failure(const char* reason);
void record_method_not_compilable(const char* reason, bool all_tiers = true);
void record_out_of_memory_failure();
+
+ void cleanup_after_redefinition();
};
#endif // SHARE_VM_CI_CIENV_HPP
diff -r 882f6c762ac5 src/share/vm/ci/ciObjectFactory.cpp
--- a/src/share/vm/ci/ciObjectFactory.cpp Thu Jul 09 23:10:04 2015 -0700
+++ b/src/share/vm/ci/ciObjectFactory.cpp Thu Jul 09 23:18:17 2015 -0700
@@ -296,6 +296,11 @@
// into the table. We need to recompute our index.
index = find(keyHandle(), _ci_objects);
}
+
+ if (is_found_at(index, keyHandle(), _ci_objects)) {
+ // DCEVM: Check if this is an error? Can occur when redefining classes.
+ return _ci_objects->at(index);
+ }
assert(!is_found_at(index, keyHandle(), _ci_objects), "no double insert");
insert(index, new_object, _ci_objects);
return new_object;
@@ -764,3 +769,50 @@
_unloaded_instances->length(),
_unloaded_klasses->length());
}
+
+// DCEVM: Resoring the ciObject arrays after class redefinition
+void ciObjectFactory::sort_ci_objects(GrowableArray<ciObject*>* objects) {
+
+ // Resort the _ci_objects array. The order of two class pointers can be changed during class redefinition.
+ oop last = NULL;
+ for (int j = 0; j< objects->length(); j++) {
+ oop o = objects->at(j)->get_oop();
+ if (last >= o) {
+ int cur_last_index = j - 1;
+ oop cur_last = last;
+ while (cur_last >= o) {
+
+ // Swap the two objects to guarantee ordering
+ ciObject *tmp = objects->at(cur_last_index);
+ objects->at_put(cur_last_index, objects->at(cur_last_index + 1));
+ objects->at_put(cur_last_index + 1, tmp);
+
+ // Decrement index to move one step to the left
+ cur_last_index--;
+ if (cur_last_index < 0) {
+ break;
+ }
+ cur_last = objects->at(cur_last_index)->get_oop();
+ }
+ } else {
+ assert(last < o, "out of order");
+ last = o;
+ }
+ }
+
+#ifdef ASSERT
+ if (CIObjectFactoryVerify) {
+ oop last = NULL;
+ for (int j = 0; j< objects->length(); j++) {
+ oop o = objects->at(j)->get_oop();
+ assert(last < o, "out of order");
+ last = o;
+ }
+ }
+#endif // ASSERT
+}
+
+// DCEVM: Called after class redefinition to clean up possibly invalidated state.
+void ciObjectFactory::cleanup_after_redefinition() {
+ sort_ci_objects(_ci_objects);
+}
diff -r 882f6c762ac5 src/share/vm/ci/ciObjectFactory.hpp
--- a/src/share/vm/ci/ciObjectFactory.hpp Thu Jul 09 23:10:04 2015 -0700
+++ b/src/share/vm/ci/ciObjectFactory.hpp Thu Jul 09 23:18:17 2015 -0700
@@ -38,6 +38,7 @@
class ciObjectFactory : public ResourceObj {
friend class VMStructs;
friend class ciEnv;
+ friend class CompileBroker;
private:
static volatile bool _initialized;
@@ -137,6 +138,11 @@
void print_contents();
void print();
+
+private:
+
+ static void sort_ci_objects(GrowableArray<ciObject*>* objects);
+ void cleanup_after_redefinition();
};
#endif // SHARE_VM_CI_CIOBJECTFACTORY_HPP
diff -r 882f6c762ac5 src/share/vm/classfile/classFileParser.cpp
--- a/src/share/vm/classfile/classFileParser.cpp Thu Jul 09 23:10:04 2015 -0700
+++ b/src/share/vm/classfile/classFileParser.cpp Thu Jul 09 23:18:17 2015 -0700
@@ -795,6 +795,7 @@
Handle class_loader,
Handle protection_domain,
Symbol* class_name,
+ KlassHandle old_klass,
TRAPS) {
ClassFileStream* cfs = stream();
assert(length > 0, "only called for length>0");
@@ -813,6 +814,9 @@
interface_index, CHECK_(nullHandle));
if (cp->tag_at(interface_index).is_klass()) {
interf = KlassHandle(THREAD, cp->resolved_klass_at(interface_index));
+ if (!old_klass.is_null() && !interf->is_newest_version()) {
+ interf = KlassHandle(THREAD, interf->newest_version());
+ }
} else {
Symbol* unresolved_klass = cp->klass_name_at(interface_index);
@@ -825,6 +829,9 @@
klassOop k = SystemDictionary::resolve_super_or_fail(class_name,
unresolved_klass, class_loader, protection_domain,
false, CHECK_(nullHandle));
+ if (!old_klass.is_null()) {
+ k = k->klass_part()->newest_version();
+ }
interf = KlassHandle(THREAD, k);
}
@@ -1923,6 +1930,8 @@
int runtime_invisible_parameter_annotations_length = 0;
u1* annotation_default = NULL;
int annotation_default_length = 0;
+ u2 code_section_table_length;
+ typeArrayHandle code_section_table;
// Parse code and exceptions attribute
u2 method_attributes_count = cfs->get_u2_fast();
@@ -2092,6 +2101,24 @@
parse_stackmap_table(code_attribute_length, CHECK_(nullHandle));
stackmap_data = typeArrayHandle(THREAD, sm);
parsed_stackmap_attribute = true;
+ } else if (UseMethodForwardPoints && cp->symbol_at(code_attribute_name_index) == vmSymbols::tag_code_sections()) {
+ int length = code_attribute_length;
+ int value_count = length / sizeof(u2);
+ int line_count = length / 3;
+ if (TraceRedefineClasses >= 3) {
+ tty->print_cr("Found code section attribute when loading class with %d entries", value_count, line_count);
+ }
+ code_section_table_length = value_count;
+ code_section_table = oopFactory::new_permanent_shortArray(value_count, CHECK_NULL);
+ code_section_table->set_length(value_count);
+
+ for (int i = 0; i < value_count; ++i) {
+ u2 value = cfs->get_u2(CHECK_(nullHandle));
+ code_section_table->short_at_put(i, value);
+ if (TraceRedefineClasses >= 4) {
+ tty->print_cr("Code section table at %d: %d", i, value);
+ }
+ }
} else {
// Skip unknown attributes
cfs->skip_u1(code_attribute_length, CHECK_(nullHandle));
@@ -2216,6 +2243,18 @@
}
#endif
+ // DCEVM: TODO: Get a different solution for the problem of method forward
+ // points and variable sized interpreter frames.
+ if (UseMethodForwardPoints) {
+ if (max_stack > MethodForwardPointsMaxStack) {
+ fatal(err_msg("Method has too large stack (%d), increase the value of MethodForwardPointsMaxStack (%d)", max_stack, MethodForwardPointsMaxStack));
+ }
+ if (max_locals > MethodForwardPointsMaxLocals) {
+ fatal(err_msg("Method has too many locals (%d), increase the value of MethodForwardPointsMaxLocals (%d)", max_stack, MethodForwardPointsMaxStack));
+ }
+ max_stack = MethodForwardPointsMaxStack;
+ max_locals = MethodForwardPointsMaxLocals;
+ }
// Fill in code attribute information
m->set_max_stack(max_stack);
m->set_max_locals(max_locals);
@@ -2229,6 +2268,8 @@
*/
m->constMethod()->set_stackmap_data(stackmap_data());
+ m->constMethod()->set_code_section_table(code_section_table());
+
// Copy byte codes
m->set_code(code_start);
@@ -2825,6 +2866,15 @@
"Invalid Deprecated classfile attribute length %u in class file %s",
attribute_length, CHECK);
}
+ } else if (tag == vmSymbols::tag_field_redefinition_policy()) {
+ // DCEVM: Check for deleted field attribute
+ _field_redefinition_policy = cfs->get_u1_fast();
+ } else if (tag == vmSymbols::tag_static_field_redefinition_policy()) {
+ // DCEVM: Check for deleted static field attribute
+ _static_field_redefinition_policy = cfs->get_u1_fast();
+ } else if (tag == vmSymbols::tag_method_redefinition_policy()) {
+ // DCEVM: Check for deleted method attribute
+ _method_redefinition_policy = cfs->get_u1_fast();
} else if (_major_version >= JAVA_1_5_VERSION) {
if (tag == vmSymbols::tag_signature()) {
if (attribute_length != 2) {
@@ -2929,6 +2979,17 @@
}
k->set_inner_classes(_inner_classes());
k->set_class_annotations(_annotations());
+
+
+ if (_field_redefinition_policy != 0xff) {
+ k->set_field_redefinition_policy(_field_redefinition_policy);
+ }
+ if (_static_field_redefinition_policy != 0xff) {
+ k->set_static_field_redefinition_policy(_static_field_redefinition_policy);
+ }
+ if (_method_redefinition_policy != 0xff) {
+ k->set_method_redefinition_policy(_method_redefinition_policy);
+ }
}
typeArrayHandle ClassFileParser::assemble_annotations(u1* runtime_visible_annotations,
@@ -2952,9 +3013,126 @@
}
+// DCEVM: Finds the super symbols by reading the bytes of the class and returns
+// them in a growable array.
+void ClassFileParser::findSuperSymbols(Symbol* name,
+ Handle class_loader,
+ Handle protection_domain,
+ KlassHandle old_klass,
+ GrowableArray<Symbol*> &handles,
+ TRAPS) {
+
+ _cp_patches = NULL;
+ // So that JVMTI can cache class file in the state before retransformable agents
+ // have modified it
+ unsigned char *cached_class_file_bytes = NULL;
+
+ ClassFileStream* cfs = stream();
+
+ _has_finalizer = _has_empty_finalizer = _has_vanilla_constructor = false;
+
+ instanceKlassHandle nullHandle;
+
+ // Save the class file name for easier error message printing.
+ _class_name = name != NULL ? name : vmSymbols::unknown_class_name();
+
+ cfs->guarantee_more(8, CHECK); // magic, major, minor
+ // Magic value
+ u4 magic = cfs->get_u4_fast();
+ if (magic != JAVA_CLASSFILE_MAGIC) {
+ // Invalid class file!
+ return;
+ }
+
+ // Version numbers
+ u2 minor_version = cfs->get_u2_fast();
+ u2 major_version = cfs->get_u2_fast();
+
+ // Check version numbers - we check this even with verifier off
+ if (!is_supported_version(major_version, minor_version)) {
+
+ // Unsupported version!
+ return;
+ }
+
+ _major_version = major_version;
+ _minor_version = minor_version;
+
+
+ // Check if verification needs to be relaxed for this class file
+ // Do not restrict it to jdk1.0 or jdk1.1 to maintain backward compatibility (4982376)
+ _relax_verify = Verifier::relax_verify_for(class_loader());
+ _need_verify = false;
+
+ // Constant pool
+ constantPoolHandle cp = parse_constant_pool(class_loader(), CHECK);
+ int cp_size = cp->length();
+
+ cfs->guarantee_more(8, CHECK); // flags, this_class, super_class, infs_len
+
+ // Access flags
+ AccessFlags access_flags;
+ jint flags = cfs->get_u2_fast() & JVM_RECOGNIZED_CLASS_MODIFIERS;
+
+ if ((flags & JVM_ACC_INTERFACE) && _major_version < JAVA_6_VERSION) {
+ // Set abstract bit for old class files for backward compatibility
+ flags |= JVM_ACC_ABSTRACT;
+ }
+ access_flags.set_flags(flags);
+
+ // This class and superclass
+ instanceKlassHandle super_klass;
+ u2 this_class_index = cfs->get_u2_fast();
+ check_property(
+ valid_cp_range(this_class_index, cp_size) &&
+ cp->tag_at(this_class_index).is_unresolved_klass(),
+ "Invalid this class index %u in constant pool in class file %s",
+ this_class_index, CHECK);
+
+ Symbol* class_name = cp->unresolved_klass_at(this_class_index);
+ assert(class_name != NULL, "class_name can't be null");
+
+ // Update _class_name which could be null previously to be class_name
+ _class_name = class_name;
+
+ // DCEVM: DO NOT release all handles when parsing is done
+ {// HandleMark hm(THREAD);
+
+ // Checks if name in class file matches requested name
+ if (name != NULL && class_name != name) {
+ return;
+ }
+
+ u2 super_class_index = cfs->get_u2_fast();
+
+ if (super_class_index != 0) {
+ Symbol* super_class = cp->klass_name_at(super_class_index);
+ handles.append(super_class);
+ } else {
+ // DCEVM: This redefinition must be for the Object class.
+ }
+
+ // Interfaces
+ u2 itfs_len = cfs->get_u2_fast();
+ objArrayHandle local_interfaces;
+ if (itfs_len == 0) {
+ local_interfaces = objArrayHandle(THREAD, Universe::the_empty_system_obj_array());
+ } else {
+ local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, _class_name, old_klass, CHECK);
+ }
+
+ for (int i=0; i<local_interfaces->length(); i++) {
+ oop o = local_interfaces->obj_at(i);
+ Symbol* interface_handle = ((klassOop)o)->klass_part()->name();
+ handles.append(interface_handle);
+ }
+ }
+}
+
instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
Handle class_loader,
Handle protection_domain,
+ KlassHandle old_klass,
KlassHandle host_klass,
GrowableArray<Handle>* cp_patches,
TempNewSymbol& parsed_name,
@@ -3005,10 +3183,13 @@
unsigned char* ptr = cfs->buffer();
unsigned char* end_ptr = cfs->buffer() + cfs->length();
+ bool pretend_new_universe = Thread::current()->pretend_new_universe();
+ Thread::current()->set_pretend_new_universe(false);
JvmtiExport::post_class_file_load_hook(name, class_loader, protection_domain,
&ptr, &end_ptr,
&cached_class_file_bytes,
&cached_class_file_length);
+ Thread::current()->set_pretend_new_universe(pretend_new_universe);
if (ptr != cfs->buffer()) {
// JVMTI agent has modified class file data.
@@ -3164,7 +3345,11 @@
// However, make sure it is not an array type.
bool is_array = false;
if (cp->tag_at(super_class_index).is_klass()) {
- super_klass = instanceKlassHandle(THREAD, cp->resolved_klass_at(super_class_index));
+ klassOop resolved_klass = cp->resolved_klass_at(super_class_index);
+ if (!old_klass.is_null()) {
+ resolved_klass = resolved_klass->klass_part()->newest_version();
+ }
+ super_klass = instanceKlassHandle(THREAD, resolved_klass);
if (_need_verify)
is_array = super_klass->oop_is_array();
} else if (_need_verify) {
@@ -3182,7 +3367,7 @@
if (itfs_len == 0) {
local_interfaces = objArrayHandle(THREAD, Universe::the_empty_system_obj_array());
} else {
- local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, _class_name, CHECK_(nullHandle));
+ local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, _class_name, old_klass, CHECK_(nullHandle));
}
u2 java_fields_count = 0;
@@ -3237,7 +3422,9 @@
protection_domain,
true,
CHECK_(nullHandle));
-
+ if (!old_klass.is_null()) {
+ k = k->klass_part()->newest_version();
+ }
KlassHandle kh (THREAD, k);
super_klass = instanceKlassHandle(THREAD, kh());
}
@@ -3626,6 +3813,19 @@
rt = REF_NONE;
} else {
rt = super_klass->reference_type();
+
+ // DCEVM: With class redefinition, it can also happen that special classes are loaded.
+ if (name == vmSymbols::java_lang_ref_Reference()) {
+ rt = REF_OTHER;
+ } else if (name == vmSymbols::java_lang_ref_SoftReference()) {
+ rt = REF_SOFT;
+ } else if (name == vmSymbols::java_lang_ref_WeakReference()) {
+ rt = REF_WEAK;
+ } else if (name == vmSymbols::java_lang_ref_FinalReference()) {
+ rt = REF_FINAL;
+ } else if (name == vmSymbols::java_lang_ref_PhantomReference()) {
+ rt = REF_PHANTOM;
+ }
}
// We can now create the basic klassOop for this klass
@@ -3726,7 +3926,7 @@
fill_oop_maps(this_klass, nonstatic_oop_map_count, nonstatic_oop_offsets, nonstatic_oop_counts);
// Fill in has_finalizer, has_vanilla_constructor, and layout_helper
- set_precomputed_flags(this_klass);
+ set_precomputed_flags(this_klass, old_klass);
// reinitialize modifiers, using the InnerClasses attribute
int computed_modifiers = this_klass->compute_modifier_flags(CHECK_(nullHandle));
@@ -3749,6 +3949,10 @@
// Allocate mirror and initialize static fields
java_lang_Class::create_mirror(this_klass, CHECK_(nullHandle));
+ if (rt == REF_OTHER) {
+ instanceRefKlass::update_nonstatic_oop_maps(ik);
+ }
+
ClassLoadingService::notify_class_loaded(instanceKlass::cast(this_klass()),
false /* not shared class */);
@@ -3891,7 +4095,7 @@
}
-void ClassFileParser::set_precomputed_flags(instanceKlassHandle k) {
+void ClassFileParser::set_precomputed_flags(instanceKlassHandle k, KlassHandle old_klass) {
klassOop super = k->super();
// Check if this klass has an empty finalize method (i.e. one with return bytecode only),
@@ -3899,7 +4103,9 @@
if (!_has_empty_finalizer) {
if (_has_finalizer ||
(super != NULL && super->klass_part()->has_finalizer())) {
- k->set_has_finalizer();
+ if (old_klass.is_null() || old_klass->has_finalizer()) {
+ k->set_has_finalizer();
+ }
}
}
@@ -3915,7 +4121,7 @@
// Check if this klass supports the java.lang.Cloneable interface
if (SystemDictionary::Cloneable_klass_loaded()) {
- if (k->is_subtype_of(SystemDictionary::Cloneable_klass())) {
+ if (k->is_subtype_of(SystemDictionary::Cloneable_klass()) || k->is_subtype_of(SystemDictionary::Cloneable_klass()->klass_part()->newest_version())) {
k->set_is_cloneable();
}
}
diff -r 882f6c762ac5 src/share/vm/classfile/classFileParser.hpp
--- a/src/share/vm/classfile/classFileParser.hpp Thu Jul 09 23:10:04 2015 -0700
+++ b/src/share/vm/classfile/classFileParser.hpp Thu Jul 09 23:18:17 2015 -0700
@@ -64,6 +64,9 @@
int _sde_length;
typeArrayHandle _inner_classes;
typeArrayHandle _annotations;
+ u1 _field_redefinition_policy;
+ u1 _static_field_redefinition_policy;
+ u1 _method_redefinition_policy;
void set_class_synthetic_flag(bool x) { _synthetic_flag = x; }
void set_class_sourcefile(Symbol* x) { _sourcefile = x; }
@@ -151,6 +154,7 @@
Handle class_loader,
Handle protection_domain,
Symbol* class_name,
+ KlassHandle old_klass,
TRAPS);
// Field parsing
@@ -239,7 +243,7 @@
unsigned int nonstatic_oop_map_count,
int* nonstatic_oop_offsets,
unsigned int* nonstatic_oop_counts);
- void set_precomputed_flags(instanceKlassHandle k);
+ void set_precomputed_flags(instanceKlassHandle k, KlassHandle old_klass);
objArrayHandle compute_transitive_interfaces(instanceKlassHandle super,
objArrayHandle local_ifs, TRAPS);
@@ -345,7 +349,12 @@
public:
// Constructor
- ClassFileParser(ClassFileStream* st) { set_stream(st); }
+ ClassFileParser(ClassFileStream* st) {
+ set_stream(st);
+ _field_redefinition_policy = 0xff;
+ _static_field_redefinition_policy = 0xff;
+ _method_redefinition_policy = 0xff;
+ }
// Parse .class file and return new klassOop. The klassOop is not hooked up
// to the system dictionary or any other structures, so a .class file can
@@ -357,21 +366,33 @@
instanceKlassHandle parseClassFile(Symbol* name,
Handle class_loader,
Handle protection_domain,
+ KlassHandle old_klass,
TempNewSymbol& parsed_name,
bool verify,
TRAPS) {
KlassHandle no_host_klass;
- return parseClassFile(name, class_loader, protection_domain, no_host_klass, NULL, parsed_name, verify, THREAD);
+ return parseClassFile(name, class_loader, protection_domain, old_klass, no_host_klass, NULL, parsed_name, verify, THREAD);
}
instanceKlassHandle parseClassFile(Symbol* name,
Handle class_loader,
Handle protection_domain,
+ KlassHandle old_klass,
KlassHandle host_klass,
GrowableArray<Handle>* cp_patches,
TempNewSymbol& parsed_name,
bool verify,
TRAPS);
+ static void initialize_static_field(fieldDescriptor* fd, TRAPS);
+
+ // DCEVM: Creates symbol handles for the super class and the interfaces
+ void findSuperSymbols(Symbol* name,
+ Handle class_loader,
+ Handle protection_domain,
+ KlassHandle old_klass,
+ GrowableArray<Symbol*> &handles,
+ TRAPS);
+
// Verifier checks
static void check_super_class_access(instanceKlassHandle this_klass, TRAPS);
static void check_super_interface_access(instanceKlassHandle this_klass, TRAPS);
diff -r 882f6c762ac5 src/share/vm/classfile/classLoader.cpp
--- a/src/share/vm/classfile/classLoader.cpp Thu Jul 09 23:10:04 2015 -0700
+++ b/src/share/vm/classfile/classLoader.cpp Thu Jul 09 23:18:17 2015 -0700
@@ -915,6 +915,7 @@
instanceKlassHandle result = parser.parseClassFile(h_name,
class_loader,
protection_domain,
+ KlassHandle(),
parsed_name,
false,
CHECK_(h));
diff -r 882f6c762ac5 src/share/vm/classfile/dictionary.cpp
--- a/src/share/vm/classfile/dictionary.cpp Thu Jul 09 23:10:04 2015 -0700
+++ b/src/share/vm/classfile/dictionary.cpp Thu Jul 09 23:18:17 2015 -0700
@@ -326,6 +326,21 @@
}
}
+
+// DCEVM: Just the classes from defining class loaders
+void Dictionary::classes_do(ObjectClosure *closure) {
+ for (int index = 0; index < table_size(); index++) {
+ for (DictionaryEntry* probe = bucket(index);
+ probe != NULL;
+ probe = probe->next()) {
+ klassOop k = probe->klass();
+ if (probe->loader() == instanceKlass::cast(k)->class_loader()) {
+ closure->do_object(k);
+ }
+ }
+ }
+}
+
// Added for initialize_itable_for_klass to handle exceptions
// Just the classes from defining class loaders
void Dictionary::classes_do(void f(klassOop, TRAPS), TRAPS) {
@@ -433,6 +448,33 @@
add_entry(index, entry);
}
+// DCEVM: Updates the klass entry to point to the new klassOop. Necessary only for class redefinition.
+bool Dictionary::update_klass(int index, unsigned int hash, Symbol* name, Handle loader, KlassHandle k, KlassHandle old_class) {
+
+ // There are several entries for the same class in the dictionary: One extra entry for each parent classloader of the classloader of the class.
+ bool found = false;
+ for (int index = 0; index < table_size(); index++) {
+ for (DictionaryEntry* entry = bucket(index); entry != NULL; entry = entry->next()) {
+ if (entry->klass() == old_class()) {
+ entry->set_literal(k());
+ found = true;
+ }
+ }
+ }
+
+ return found;
+}
+
+// DCEVM: Undo previous updates to the system dictionary
+void Dictionary::rollback_redefinition() {
+ for (int index = 0; index < table_size(); index++) {
+ for (DictionaryEntry* entry = bucket(index); entry != NULL; entry = entry->next()) {
+ if (entry->klass()->klass_part()->is_redefining()) {
+ entry->set_literal(entry->klass()->klass_part()->old_version());
+ }
+ }
+ }
+}
// This routine does not lock the system dictionary.
//
@@ -459,12 +501,22 @@
return NULL;
}
+// DCEVM: return old version if we are not in the new universe?
+klassOop Dictionary::intercept_for_version(klassOop k) {
+ if (k == NULL) return k;
+
+ if (k->klass_part()->is_redefining() && !Thread::current()->pretend_new_universe()) {
+ return k->klass_part()->old_version();
+ }
+