414 break;
415 case Bytecodes::_ldc:
416 case Bytecodes::_ldc_w:
417 case Bytecodes::_ldc2_w:
418 {
419 // Avoid calling get_constant() which will try to allocate
420 // unloaded constant. We need only constant's type.
421 int index = s.get_constant_pool_index();
422 constantTag tag = s.get_constant_pool_tag(index);
423 if (tag.is_long() || tag.is_double()) {
424 // Only longs and doubles use 2 stack slots.
425 state.lpush();
426 } else if (tag.basic_type() == T_OBJECT) {
427 state.apush(unknown_obj);
428 } else {
429 state.spush();
430 }
431 break;
432 }
433 case Bytecodes::_aload:
434 case Bytecodes::_vload:
435 state.apush(state._vars[s.get_index()]);
436 break;
437 case Bytecodes::_iload:
438 case Bytecodes::_fload:
439 case Bytecodes::_iload_0:
440 case Bytecodes::_iload_1:
441 case Bytecodes::_iload_2:
442 case Bytecodes::_iload_3:
443 case Bytecodes::_fload_0:
444 case Bytecodes::_fload_1:
445 case Bytecodes::_fload_2:
446 case Bytecodes::_fload_3:
447 state.spush();
448 break;
449 case Bytecodes::_lload:
450 case Bytecodes::_dload:
451 case Bytecodes::_lload_0:
452 case Bytecodes::_lload_1:
453 case Bytecodes::_lload_2:
454 case Bytecodes::_lload_3:
468 state.apush(state._vars[2]);
469 break;
470 case Bytecodes::_aload_3:
471 state.apush(state._vars[3]);
472 break;
473 case Bytecodes::_iaload:
474 case Bytecodes::_faload:
475 case Bytecodes::_baload:
476 case Bytecodes::_caload:
477 case Bytecodes::_saload:
478 state.spop();
479 set_method_escape(state.apop());
480 state.spush();
481 break;
482 case Bytecodes::_laload:
483 case Bytecodes::_daload:
484 state.spop();
485 set_method_escape(state.apop());
486 state.lpush();
487 break;
488 case Bytecodes::_vaload:
489 case Bytecodes::_aaload:
490 { state.spop();
491 ArgumentMap array = state.apop();
492 set_method_escape(array);
493 state.apush(unknown_obj);
494 set_dirty(array);
495 }
496 break;
497 case Bytecodes::_istore:
498 case Bytecodes::_fstore:
499 case Bytecodes::_istore_0:
500 case Bytecodes::_istore_1:
501 case Bytecodes::_istore_2:
502 case Bytecodes::_istore_3:
503 case Bytecodes::_fstore_0:
504 case Bytecodes::_fstore_1:
505 case Bytecodes::_fstore_2:
506 case Bytecodes::_fstore_3:
507 state.spop();
508 break;
509 case Bytecodes::_lstore:
510 case Bytecodes::_dstore:
511 case Bytecodes::_lstore_0:
512 case Bytecodes::_lstore_1:
513 case Bytecodes::_lstore_2:
514 case Bytecodes::_lstore_3:
515 case Bytecodes::_dstore_0:
516 case Bytecodes::_dstore_1:
517 case Bytecodes::_dstore_2:
518 case Bytecodes::_dstore_3:
519 state.lpop();
520 break;
521 case Bytecodes::_astore:
522 case Bytecodes::_vstore:
523 state._vars[s.get_index()] = state.apop();
524 break;
525 case Bytecodes::_astore_0:
526 state._vars[0] = state.apop();
527 break;
528 case Bytecodes::_astore_1:
529 state._vars[1] = state.apop();
530 break;
531 case Bytecodes::_astore_2:
532 state._vars[2] = state.apop();
533 break;
534 case Bytecodes::_astore_3:
535 state._vars[3] = state.apop();
536 break;
537 case Bytecodes::_iastore:
538 case Bytecodes::_fastore:
539 case Bytecodes::_bastore:
540 case Bytecodes::_castore:
541 case Bytecodes::_sastore:
542 {
548 break;
549 }
550 case Bytecodes::_lastore:
551 case Bytecodes::_dastore:
552 {
553 state.lpop();
554 state.spop();
555 ArgumentMap arr = state.apop();
556 set_method_escape(arr);
557 set_modified(arr, OFFSET_ANY, type2size[T_LONG]*HeapWordSize);
558 break;
559 }
560 case Bytecodes::_aastore:
561 {
562 set_global_escape(state.apop());
563 state.spop();
564 ArgumentMap arr = state.apop();
565 set_modified(arr, OFFSET_ANY, type2size[T_OBJECT]*HeapWordSize);
566 break;
567 }
568 case Bytecodes::_vastore:
569 {
570 set_global_escape(state.apop());
571 state.spop();
572 ArgumentMap arr = state.apop();
573 // If the array is flattened, a larger part of it is modified than
574 // the size of a reference. However, if OFFSET_ANY is given as
575 // parameter to set_modified(), size is not taken into account.
576 set_modified(arr, OFFSET_ANY, type2size[T_VALUETYPE]*HeapWordSize);
577 break;
578 }
579 case Bytecodes::_pop:
580 state.raw_pop();
581 break;
582 case Bytecodes::_pop2:
583 state.raw_pop();
584 state.raw_pop();
585 break;
586 case Bytecodes::_dup:
587 { ArgumentMap w1 = state.raw_pop();
588 state.raw_push(w1);
589 state.raw_push(w1);
590 }
591 break;
592 case Bytecodes::_dup_x1:
593 { ArgumentMap w1 = state.raw_pop();
594 ArgumentMap w2 = state.raw_pop();
595 state.raw_push(w1);
596 state.raw_push(w2);
597 state.raw_push(w1);
598 }
847 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
848 successors.push(_methodBlocks->block_containing(dest_bci));
849 }
850 dest_bci = s.cur_bci() + sw.default_offset();
851 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
852 successors.push(_methodBlocks->block_containing(dest_bci));
853 fall_through = false;
854 break;
855 }
856 case Bytecodes::_ireturn:
857 case Bytecodes::_freturn:
858 state.spop();
859 fall_through = false;
860 break;
861 case Bytecodes::_lreturn:
862 case Bytecodes::_dreturn:
863 state.lpop();
864 fall_through = false;
865 break;
866 case Bytecodes::_areturn:
867 case Bytecodes::_vreturn:
868 set_returned(state.apop());
869 fall_through = false;
870 break;
871 case Bytecodes::_getstatic:
872 case Bytecodes::_getfield:
873 { bool ignored_will_link;
874 ciField* field = s.get_field(ignored_will_link);
875 BasicType field_type = field->type()->basic_type();
876 if (s.cur_bc() != Bytecodes::_getstatic) {
877 set_method_escape(state.apop());
878 }
879 if (field_type == T_OBJECT || field_type == T_ARRAY) {
880 state.apush(unknown_obj);
881 } else if (type2size[field_type] == 1) {
882 state.spush();
883 } else {
884 state.lpush();
885 }
886 }
887 break;
941 Bytecodes::has_optional_appendix(s.cur_bc_raw()) &&
942 target->intrinsic_id() != vmIntrinsics::_invokeBasic) {
943 state.apush(unknown_obj);
944 }
945 // Pass in raw bytecode because we need to see invokehandle instructions.
946 invoke(state, s.cur_bc_raw(), target, holder);
947 // We are using the return type of the declared signature here because
948 // it might be a more concrete type than the one from the target (for
949 // e.g. invokedynamic and invokehandle).
950 ciType* return_type = declared_signature->return_type();
951 if (!return_type->is_primitive_type()) {
952 state.apush(unknown_obj);
953 } else if (return_type->is_one_word()) {
954 state.spush();
955 } else if (return_type->is_two_word()) {
956 state.lpush();
957 }
958 }
959 break;
960 case Bytecodes::_new:
961 case Bytecodes::_vdefault:
962 state.apush(allocated_obj);
963 break;
964 case Bytecodes::_vwithfield: {
965 bool will_link;
966 ciField* field = s.get_field(will_link);
967 BasicType field_type = field->type()->basic_type();
968 if (field_type == T_OBJECT || field_type == T_ARRAY) {
969 set_global_escape(state.apop());
970 } else if (type2size[field_type] == 1) {
971 state.spop();
972 } else {
973 state.lpop();
974 }
975 set_method_escape(state.apop());
976 state.apush(allocated_obj);
977 break;
978 }
979 case Bytecodes::_newarray:
980 case Bytecodes::_anewarray:
981 state.spop();
982 state.apush(allocated_obj);
983 break;
984 case Bytecodes::_multianewarray:
1026 {
1027 int dest_bci = s.get_far_dest();
1028 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
1029 assert(s.next_bci() == limit_bci, "branch must end block");
1030 successors.push(_methodBlocks->block_containing(dest_bci));
1031 fall_through = false;
1032 break;
1033 }
1034 case Bytecodes::_jsr_w:
1035 {
1036 int dest_bci = s.get_far_dest();
1037 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
1038 assert(s.next_bci() == limit_bci, "branch must end block");
1039 state.apush(empty_map);
1040 successors.push(_methodBlocks->block_containing(dest_bci));
1041 fall_through = false;
1042 break;
1043 }
1044 case Bytecodes::_breakpoint:
1045 break;
1046 case Bytecodes::_vbox:
1047 case Bytecodes::_vunbox:
1048 set_method_escape(state.apop());
1049 state.apush(allocated_obj);
1050 break;
1051 default:
1052 ShouldNotReachHere();
1053 break;
1054 }
1055
1056 }
1057 if (fall_through) {
1058 int fall_through_bci = s.cur_bci();
1059 if (fall_through_bci < _method->code_size()) {
1060 assert(_methodBlocks->is_block_start(fall_through_bci), "must fall through to block start.");
1061 successors.push(_methodBlocks->block_containing(fall_through_bci));
1062 }
1063 }
1064 }
1065
1066 void BCEscapeAnalyzer::merge_block_states(StateInfo *blockstates, ciBlock *dest, StateInfo *s_state) {
1067 StateInfo *d_state = blockstates + dest->index();
1068 int nlocals = _method->max_locals();
1069
1070 // exceptions may cause transfer of control to handlers in the middle of a
|
414 break;
415 case Bytecodes::_ldc:
416 case Bytecodes::_ldc_w:
417 case Bytecodes::_ldc2_w:
418 {
419 // Avoid calling get_constant() which will try to allocate
420 // unloaded constant. We need only constant's type.
421 int index = s.get_constant_pool_index();
422 constantTag tag = s.get_constant_pool_tag(index);
423 if (tag.is_long() || tag.is_double()) {
424 // Only longs and doubles use 2 stack slots.
425 state.lpush();
426 } else if (tag.basic_type() == T_OBJECT) {
427 state.apush(unknown_obj);
428 } else {
429 state.spush();
430 }
431 break;
432 }
433 case Bytecodes::_aload:
434 state.apush(state._vars[s.get_index()]);
435 break;
436 case Bytecodes::_iload:
437 case Bytecodes::_fload:
438 case Bytecodes::_iload_0:
439 case Bytecodes::_iload_1:
440 case Bytecodes::_iload_2:
441 case Bytecodes::_iload_3:
442 case Bytecodes::_fload_0:
443 case Bytecodes::_fload_1:
444 case Bytecodes::_fload_2:
445 case Bytecodes::_fload_3:
446 state.spush();
447 break;
448 case Bytecodes::_lload:
449 case Bytecodes::_dload:
450 case Bytecodes::_lload_0:
451 case Bytecodes::_lload_1:
452 case Bytecodes::_lload_2:
453 case Bytecodes::_lload_3:
467 state.apush(state._vars[2]);
468 break;
469 case Bytecodes::_aload_3:
470 state.apush(state._vars[3]);
471 break;
472 case Bytecodes::_iaload:
473 case Bytecodes::_faload:
474 case Bytecodes::_baload:
475 case Bytecodes::_caload:
476 case Bytecodes::_saload:
477 state.spop();
478 set_method_escape(state.apop());
479 state.spush();
480 break;
481 case Bytecodes::_laload:
482 case Bytecodes::_daload:
483 state.spop();
484 set_method_escape(state.apop());
485 state.lpush();
486 break;
487 case Bytecodes::_aaload:
488 { state.spop();
489 ArgumentMap array = state.apop();
490 set_method_escape(array);
491 state.apush(unknown_obj);
492 set_dirty(array);
493 }
494 break;
495 case Bytecodes::_istore:
496 case Bytecodes::_fstore:
497 case Bytecodes::_istore_0:
498 case Bytecodes::_istore_1:
499 case Bytecodes::_istore_2:
500 case Bytecodes::_istore_3:
501 case Bytecodes::_fstore_0:
502 case Bytecodes::_fstore_1:
503 case Bytecodes::_fstore_2:
504 case Bytecodes::_fstore_3:
505 state.spop();
506 break;
507 case Bytecodes::_lstore:
508 case Bytecodes::_dstore:
509 case Bytecodes::_lstore_0:
510 case Bytecodes::_lstore_1:
511 case Bytecodes::_lstore_2:
512 case Bytecodes::_lstore_3:
513 case Bytecodes::_dstore_0:
514 case Bytecodes::_dstore_1:
515 case Bytecodes::_dstore_2:
516 case Bytecodes::_dstore_3:
517 state.lpop();
518 break;
519 case Bytecodes::_astore:
520 state._vars[s.get_index()] = state.apop();
521 break;
522 case Bytecodes::_astore_0:
523 state._vars[0] = state.apop();
524 break;
525 case Bytecodes::_astore_1:
526 state._vars[1] = state.apop();
527 break;
528 case Bytecodes::_astore_2:
529 state._vars[2] = state.apop();
530 break;
531 case Bytecodes::_astore_3:
532 state._vars[3] = state.apop();
533 break;
534 case Bytecodes::_iastore:
535 case Bytecodes::_fastore:
536 case Bytecodes::_bastore:
537 case Bytecodes::_castore:
538 case Bytecodes::_sastore:
539 {
545 break;
546 }
547 case Bytecodes::_lastore:
548 case Bytecodes::_dastore:
549 {
550 state.lpop();
551 state.spop();
552 ArgumentMap arr = state.apop();
553 set_method_escape(arr);
554 set_modified(arr, OFFSET_ANY, type2size[T_LONG]*HeapWordSize);
555 break;
556 }
557 case Bytecodes::_aastore:
558 {
559 set_global_escape(state.apop());
560 state.spop();
561 ArgumentMap arr = state.apop();
562 set_modified(arr, OFFSET_ANY, type2size[T_OBJECT]*HeapWordSize);
563 break;
564 }
565 // the vastore case below should be refactored to the aastore case above
566 // case Bytecodes::_vastore:
567 // {
568 // set_global_escape(state.apop());
569 // state.spop();
570 // ArgumentMap arr = state.apop();
571 // // If the array is flattened, a larger part of it is modified than
572 // // the size of a reference. However, if OFFSET_ANY is given as
573 // // parameter to set_modified(), size is not taken into account.
574 // set_modified(arr, OFFSET_ANY, type2size[T_VALUETYPE]*HeapWordSize);
575 // break;
576 // }
577 case Bytecodes::_pop:
578 state.raw_pop();
579 break;
580 case Bytecodes::_pop2:
581 state.raw_pop();
582 state.raw_pop();
583 break;
584 case Bytecodes::_dup:
585 { ArgumentMap w1 = state.raw_pop();
586 state.raw_push(w1);
587 state.raw_push(w1);
588 }
589 break;
590 case Bytecodes::_dup_x1:
591 { ArgumentMap w1 = state.raw_pop();
592 ArgumentMap w2 = state.raw_pop();
593 state.raw_push(w1);
594 state.raw_push(w2);
595 state.raw_push(w1);
596 }
845 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
846 successors.push(_methodBlocks->block_containing(dest_bci));
847 }
848 dest_bci = s.cur_bci() + sw.default_offset();
849 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
850 successors.push(_methodBlocks->block_containing(dest_bci));
851 fall_through = false;
852 break;
853 }
854 case Bytecodes::_ireturn:
855 case Bytecodes::_freturn:
856 state.spop();
857 fall_through = false;
858 break;
859 case Bytecodes::_lreturn:
860 case Bytecodes::_dreturn:
861 state.lpop();
862 fall_through = false;
863 break;
864 case Bytecodes::_areturn:
865 set_returned(state.apop());
866 fall_through = false;
867 break;
868 case Bytecodes::_getstatic:
869 case Bytecodes::_getfield:
870 { bool ignored_will_link;
871 ciField* field = s.get_field(ignored_will_link);
872 BasicType field_type = field->type()->basic_type();
873 if (s.cur_bc() != Bytecodes::_getstatic) {
874 set_method_escape(state.apop());
875 }
876 if (field_type == T_OBJECT || field_type == T_ARRAY) {
877 state.apush(unknown_obj);
878 } else if (type2size[field_type] == 1) {
879 state.spush();
880 } else {
881 state.lpush();
882 }
883 }
884 break;
938 Bytecodes::has_optional_appendix(s.cur_bc_raw()) &&
939 target->intrinsic_id() != vmIntrinsics::_invokeBasic) {
940 state.apush(unknown_obj);
941 }
942 // Pass in raw bytecode because we need to see invokehandle instructions.
943 invoke(state, s.cur_bc_raw(), target, holder);
944 // We are using the return type of the declared signature here because
945 // it might be a more concrete type than the one from the target (for
946 // e.g. invokedynamic and invokehandle).
947 ciType* return_type = declared_signature->return_type();
948 if (!return_type->is_primitive_type()) {
949 state.apush(unknown_obj);
950 } else if (return_type->is_one_word()) {
951 state.spush();
952 } else if (return_type->is_two_word()) {
953 state.lpush();
954 }
955 }
956 break;
957 case Bytecodes::_new:
958 case Bytecodes::_defaultvalue:
959 state.apush(allocated_obj);
960 break;
961 case Bytecodes::_withfield: {
962 bool will_link;
963 ciField* field = s.get_field(will_link);
964 BasicType field_type = field->type()->basic_type();
965 if (field_type == T_OBJECT || field_type == T_ARRAY) {
966 set_global_escape(state.apop());
967 } else if (type2size[field_type] == 1) {
968 state.spop();
969 } else {
970 state.lpop();
971 }
972 set_method_escape(state.apop());
973 state.apush(allocated_obj);
974 break;
975 }
976 case Bytecodes::_newarray:
977 case Bytecodes::_anewarray:
978 state.spop();
979 state.apush(allocated_obj);
980 break;
981 case Bytecodes::_multianewarray:
1023 {
1024 int dest_bci = s.get_far_dest();
1025 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
1026 assert(s.next_bci() == limit_bci, "branch must end block");
1027 successors.push(_methodBlocks->block_containing(dest_bci));
1028 fall_through = false;
1029 break;
1030 }
1031 case Bytecodes::_jsr_w:
1032 {
1033 int dest_bci = s.get_far_dest();
1034 assert(_methodBlocks->is_block_start(dest_bci), "branch destination must start a block");
1035 assert(s.next_bci() == limit_bci, "branch must end block");
1036 state.apush(empty_map);
1037 successors.push(_methodBlocks->block_containing(dest_bci));
1038 fall_through = false;
1039 break;
1040 }
1041 case Bytecodes::_breakpoint:
1042 break;
1043 default:
1044 ShouldNotReachHere();
1045 break;
1046 }
1047
1048 }
1049 if (fall_through) {
1050 int fall_through_bci = s.cur_bci();
1051 if (fall_through_bci < _method->code_size()) {
1052 assert(_methodBlocks->is_block_start(fall_through_bci), "must fall through to block start.");
1053 successors.push(_methodBlocks->block_containing(fall_through_bci));
1054 }
1055 }
1056 }
1057
1058 void BCEscapeAnalyzer::merge_block_states(StateInfo *blockstates, ciBlock *dest, StateInfo *s_state) {
1059 StateInfo *d_state = blockstates + dest->index();
1060 int nlocals = _method->max_locals();
1061
1062 // exceptions may cause transfer of control to handlers in the middle of a
|