comparison src/share/vm/classfile/stackMapTableFormat.hpp @ 24059:72a298cbc071

8159511: Stack map validation Reviewed-by: acorn, mschoene Contributed-by: harold.seigel@oracle.com
author hseigel
date Thu, 30 Jun 2016 08:11:30 -0400
parents 4ee06e614636
children
comparison
equal deleted inserted replaced
23958:28ce1b5f0c2e 24059:72a298cbc071
1 /* 1 /*
2 * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2010, 2016, 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.
201 // that we don't read past a particular memory limit. It returns false 201 // that we don't read past a particular memory limit. It returns false
202 // if any part of the data structure is outside the specified memory bounds. 202 // if any part of the data structure is outside the specified memory bounds.
203 inline bool verify(address start, address end) const; 203 inline bool verify(address start, address end) const;
204 204
205 inline void print_on(outputStream* st, int current_offset) const; 205 inline void print_on(outputStream* st, int current_offset) const;
206 inline void print_truncated(outputStream* st, int current_offset) const;
206 207
207 // Create as_xxx and is_xxx methods for the subtypes 208 // Create as_xxx and is_xxx methods for the subtypes
208 #define FRAME_TYPE_DECL(stackmap_frame_type, arg1, arg2) \ 209 #define FRAME_TYPE_DECL(stackmap_frame_type, arg1, arg2) \
209 inline stackmap_frame_type* as_##stackmap_frame_type() const; \ 210 inline stackmap_frame_type* as_##stackmap_frame_type() const; \
210 bool is_##stackmap_frame_type() { \ 211 bool is_##stackmap_frame_type() { \
261 } 262 }
262 263
263 void print_on(outputStream* st, int current_offset = -1) const { 264 void print_on(outputStream* st, int current_offset = -1) const {
264 st->print("same_frame(@%d)", offset_delta() + current_offset); 265 st->print("same_frame(@%d)", offset_delta() + current_offset);
265 } 266 }
267
268 void print_truncated(outputStream* st, int current_offset = -1) const {
269 print_on(st, current_offset);
270 }
266 }; 271 };
267 272
268 class same_frame_extended : public stack_map_frame { 273 class same_frame_extended : public stack_map_frame {
269 private: 274 private:
270 enum { _frame_id = 251 }; 275 enum { _frame_id = 251 };
306 return frame_type_addr() + size() <= end; 311 return frame_type_addr() + size() <= end;
307 } 312 }
308 313
309 void print_on(outputStream* st, int current_offset = -1) const { 314 void print_on(outputStream* st, int current_offset = -1) const {
310 st->print("same_frame_extended(@%d)", offset_delta() + current_offset); 315 st->print("same_frame_extended(@%d)", offset_delta() + current_offset);
316 }
317
318 void print_truncated(outputStream* st, int current_offset = -1) const {
319 print_on(st, current_offset);
311 } 320 }
312 }; 321 };
313 322
314 class same_locals_1_stack_item_frame : public stack_map_frame { 323 class same_locals_1_stack_item_frame : public stack_map_frame {
315 private: 324 private:
378 void print_on(outputStream* st, int current_offset = -1) const { 387 void print_on(outputStream* st, int current_offset = -1) const {
379 st->print("same_locals_1_stack_item_frame(@%d,", 388 st->print("same_locals_1_stack_item_frame(@%d,",
380 offset_delta() + current_offset); 389 offset_delta() + current_offset);
381 types()->print_on(st); 390 types()->print_on(st);
382 st->print(")"); 391 st->print(")");
392 }
393
394 void print_truncated(outputStream* st, int current_offset = -1) const {
395 st->print("same_locals_1_stack_item_frame(@%d), output truncated, Stackmap exceeds table size.",
396 offset_delta() + current_offset);
383 } 397 }
384 }; 398 };
385 399
386 class same_locals_1_stack_item_extended : public stack_map_frame { 400 class same_locals_1_stack_item_extended : public stack_map_frame {
387 private: 401 private:
444 st->print("same_locals_1_stack_item_extended(@%d,", 458 st->print("same_locals_1_stack_item_extended(@%d,",
445 offset_delta() + current_offset); 459 offset_delta() + current_offset);
446 types()->print_on(st); 460 types()->print_on(st);
447 st->print(")"); 461 st->print(")");
448 } 462 }
463
464 void print_truncated(outputStream* st, int current_offset = -1) const {
465 st->print("same_locals_1_stack_item_extended(@%d), output truncated, Stackmap exceeds table size.",
466 offset_delta() + current_offset);
467 }
449 }; 468 };
450 469
451 class chop_frame : public stack_map_frame { 470 class chop_frame : public stack_map_frame {
452 private: 471 private:
453 address offset_delta_addr() const { return frame_type_addr() + sizeof(u1); } 472 address offset_delta_addr() const { return frame_type_addr() + sizeof(u1); }
508 return frame_type_addr() + size() <= end; 527 return frame_type_addr() + size() <= end;
509 } 528 }
510 529
511 void print_on(outputStream* st, int current_offset = -1) const { 530 void print_on(outputStream* st, int current_offset = -1) const {
512 st->print("chop_frame(@%d,%d)", offset_delta() + current_offset, chops()); 531 st->print("chop_frame(@%d,%d)", offset_delta() + current_offset, chops());
532 }
533
534 void print_truncated(outputStream* st, int current_offset = -1) const {
535 print_on(st, current_offset);
513 } 536 }
514 }; 537 };
515 538
516 class append_frame : public stack_map_frame { 539 class append_frame : public stack_map_frame {
517 private: 540 private:
616 st->print(","); 639 st->print(",");
617 } 640 }
618 vti = vti->next(); 641 vti = vti->next();
619 } 642 }
620 st->print(")"); 643 st->print(")");
644 }
645
646 void print_truncated(outputStream* st, int current_offset = -1) const {
647 st->print("append_frame(@%d), output truncated, Stackmap exceeds table size.",
648 offset_delta() + current_offset);
621 } 649 }
622 }; 650 };
623 651
624 class full_frame : public stack_map_frame { 652 class full_frame : public stack_map_frame {
625 private: 653 private:
782 } 810 }
783 vti = vti->next(); 811 vti = vti->next();
784 } 812 }
785 st->print("})"); 813 st->print("})");
786 } 814 }
815
816 void print_truncated(outputStream* st, int current_offset = -1) const {
817 st->print("full_frame(@%d), output truncated, Stackmap exceeds table size.",
818 offset_delta() + current_offset);
819 }
787 }; 820 };
788 821
789 #define VIRTUAL_DISPATCH(stack_frame_type, func_name, args) \ 822 #define VIRTUAL_DISPATCH(stack_frame_type, func_name, args) \
790 stack_frame_type* item_##stack_frame_type = as_##stack_frame_type(); \ 823 stack_frame_type* item_##stack_frame_type = as_##stack_frame_type(); \
791 if (item_##stack_frame_type != NULL) { \ 824 if (item_##stack_frame_type != NULL) { \
837 return false; 870 return false;
838 } 871 }
839 872
840 void stack_map_frame::print_on(outputStream* st, int offs = -1) const { 873 void stack_map_frame::print_on(outputStream* st, int offs = -1) const {
841 FOR_EACH_STACKMAP_FRAME_TYPE(VOID_VIRTUAL_DISPATCH, print_on, (st, offs)); 874 FOR_EACH_STACKMAP_FRAME_TYPE(VOID_VIRTUAL_DISPATCH, print_on, (st, offs));
875 }
876
877 void stack_map_frame::print_truncated(outputStream* st, int offs = -1) const {
878 FOR_EACH_STACKMAP_FRAME_TYPE(VOID_VIRTUAL_DISPATCH, print_truncated, (st, offs));
842 } 879 }
843 880
844 #undef VIRTUAL_DISPATCH 881 #undef VIRTUAL_DISPATCH
845 #undef VOID_VIRTUAL_DISPATCH 882 #undef VOID_VIRTUAL_DISPATCH
846 883