140 switch (tag()) {
141 case ITEM_Top: st->print("Top"); break;
142 case ITEM_Integer: st->print("Integer"); break;
143 case ITEM_Float: st->print("Float"); break;
144 case ITEM_Double: st->print("Double"); break;
145 case ITEM_Long: st->print("Long"); break;
146 case ITEM_Null: st->print("Null"); break;
147 case ITEM_UninitializedThis:
148 st->print("UninitializedThis"); break;
149 case ITEM_Uninitialized:
150 st->print("Uninitialized[#%d]", bci()); break;
151 case ITEM_Object:
152 st->print("Object[#%d]", cpool_index()); break;
153 default:
154 st->print("BAD:%d", tag()); break;
155 }
156 }
157 };
158
159 #define FOR_EACH_STACKMAP_FRAME_TYPE(macro, arg1, arg2) \
160 macro(same_frame, arg1, arg2) \
161 macro(same_frame_extended, arg1, arg2) \
162 macro(same_locals_1_stack_item_frame, arg1, arg2) \
163 macro(same_locals_1_stack_item_extended, arg1, arg2) \
164 macro(chop_frame, arg1, arg2) \
165 macro(append_frame, arg1, arg2) \
166 macro(full_frame, arg1, arg2)
167
168 #define SM_FORWARD_DECL(type, arg1, arg2) class type;
169 FOR_EACH_STACKMAP_FRAME_TYPE(SM_FORWARD_DECL, x, x)
170 #undef SM_FORWARD_DECL
171
172 class stack_map_frame {
173 NONCOPYABLE(stack_map_frame);
174
175 protected:
176 address frame_type_addr() const { return (address)this; }
177
178 // No constructors - should be 'private', but GCC issues a warning if it is
179 stack_map_frame() {}
386 return is_frame_type(offset_delta_to_frame_type(offset_delta));
387 }
388
389 bool verify_subtype(address start, address end) const {
390 return types()->verify(start, end);
391 }
392
393 void print_on(outputStream* st, int current_offset = -1) const {
394 st->print("same_locals_1_stack_item_frame(@%d,",
395 offset_delta() + current_offset);
396 types()->print_on(st);
397 st->print(")");
398 }
399
400 void print_truncated(outputStream* st, int current_offset = -1) const {
401 st->print("same_locals_1_stack_item_frame(@%d), output truncated, Stackmap exceeds table size.",
402 offset_delta() + current_offset);
403 }
404 };
405
406 class same_locals_1_stack_item_extended : public stack_map_frame {
407 private:
408 address offset_delta_addr() const { return frame_type_addr() + sizeof(u1); }
409 address type_addr() const { return offset_delta_addr() + sizeof(u2); }
410
411 enum { _frame_id = 247 };
412
413 public:
414 static bool is_frame_type(u1 tag) {
415 return tag == _frame_id;
416 }
417
418 static same_locals_1_stack_item_extended* at(address addr) {
419 assert(is_frame_type(*addr), "Wrong frame id");
420 return (same_locals_1_stack_item_extended*)addr;
421 }
422
423 static same_locals_1_stack_item_extended* create_at(
424 address addr, int offset_delta, verification_type_info* vti) {
425 same_locals_1_stack_item_extended* sm =
|
140 switch (tag()) {
141 case ITEM_Top: st->print("Top"); break;
142 case ITEM_Integer: st->print("Integer"); break;
143 case ITEM_Float: st->print("Float"); break;
144 case ITEM_Double: st->print("Double"); break;
145 case ITEM_Long: st->print("Long"); break;
146 case ITEM_Null: st->print("Null"); break;
147 case ITEM_UninitializedThis:
148 st->print("UninitializedThis"); break;
149 case ITEM_Uninitialized:
150 st->print("Uninitialized[#%d]", bci()); break;
151 case ITEM_Object:
152 st->print("Object[#%d]", cpool_index()); break;
153 default:
154 st->print("BAD:%d", tag()); break;
155 }
156 }
157 };
158
159 #define FOR_EACH_STACKMAP_FRAME_TYPE(macro, arg1, arg2) \
160 macro(early_larval, arg1, arg2) \
161 macro(same_frame, arg1, arg2) \
162 macro(same_frame_extended, arg1, arg2) \
163 macro(same_locals_1_stack_item_frame, arg1, arg2) \
164 macro(same_locals_1_stack_item_extended, arg1, arg2) \
165 macro(chop_frame, arg1, arg2) \
166 macro(append_frame, arg1, arg2) \
167 macro(full_frame, arg1, arg2)
168
169 #define SM_FORWARD_DECL(type, arg1, arg2) class type;
170 FOR_EACH_STACKMAP_FRAME_TYPE(SM_FORWARD_DECL, x, x)
171 #undef SM_FORWARD_DECL
172
173 class stack_map_frame {
174 NONCOPYABLE(stack_map_frame);
175
176 protected:
177 address frame_type_addr() const { return (address)this; }
178
179 // No constructors - should be 'private', but GCC issues a warning if it is
180 stack_map_frame() {}
387 return is_frame_type(offset_delta_to_frame_type(offset_delta));
388 }
389
390 bool verify_subtype(address start, address end) const {
391 return types()->verify(start, end);
392 }
393
394 void print_on(outputStream* st, int current_offset = -1) const {
395 st->print("same_locals_1_stack_item_frame(@%d,",
396 offset_delta() + current_offset);
397 types()->print_on(st);
398 st->print(")");
399 }
400
401 void print_truncated(outputStream* st, int current_offset = -1) const {
402 st->print("same_locals_1_stack_item_frame(@%d), output truncated, Stackmap exceeds table size.",
403 offset_delta() + current_offset);
404 }
405 };
406
407 class early_larval : public stack_map_frame {
408 private:
409 static int frame_type_to_offset_delta(u1 frame_type) {
410 return 0;
411 }
412 static u1 offset_delta_to_frame_type(int offset_delta) {
413 return checked_cast<u1>(246);
414 }
415
416 address num_unset_fields_addr() const { return frame_type_addr() + sizeof(u1); }
417 int number_of_unset_fields() const { return Bytes::get_Java_u2(num_unset_fields_addr()); }
418
419 // EARLY_LARVAL frames wrap regular stack map frames
420 stack_map_frame* nested_frame() const { return (stack_map_frame*)(frame_type_addr() + calculate_size(number_of_unset_fields())); }
421
422 public:
423 static bool is_frame_type(u1 tag) {
424 return tag == 246;
425 }
426
427 static early_larval* at(address addr) {
428 assert(is_frame_type(*addr), "Wrong frame id");
429 return (early_larval*)addr;
430 }
431
432 static early_larval* create_at(address addr, int offset_delta) {
433 early_larval* sm = (early_larval*)addr;
434 return sm;
435 }
436
437 static size_t calculate_size(u2 num_unset_fields) { return sizeof(u1) + sizeof(u2) + (sizeof(u2) * num_unset_fields); }
438
439 size_t size() const { return calculate_size(number_of_unset_fields()) + nested_frame()->size(); }
440 int offset_delta() const { return nested_frame()->offset_delta(); }
441
442 void set_offset_delta(int offset_delta) {
443 assert(offset_delta == 0, "early_larval should not have an offset");
444 set_frame_type(offset_delta_to_frame_type(offset_delta));
445 }
446
447 int number_of_types() const { return 0; }
448 verification_type_info* types() const { return nullptr; }
449
450 bool is_valid_offset(int offset_delta) const {
451 return is_frame_type(offset_delta_to_frame_type(offset_delta));
452 }
453
454 bool verify_subtype(address start, address end) const {
455 return nested_frame()->verify(start, end);
456 }
457
458 void print_on(outputStream* st, int current_offset = -1) const {
459 st->print("early_larval(%d unset fields: ", number_of_unset_fields());
460 st->print("[ ");
461 address addr = num_unset_fields_addr() + sizeof(u2);
462 for (int i = 0; i < number_of_unset_fields(); i++) {
463 st->print("%u ", Bytes::get_Java_u2(addr + (i * sizeof(u2))));
464 }
465 st->print_cr("])");
466 st->print("\t");
467 nested_frame()->print_on(st, current_offset);
468 }
469
470 void print_truncated(outputStream* st, int current_offset = -1) const {
471 // If we fail to verify, we may have a nested early_larval
472 st->print("early_larval(%d unset fields), output truncated, Stackmap exceeds table size.", number_of_unset_fields());
473 }
474 };
475
476 class same_locals_1_stack_item_extended : public stack_map_frame {
477 private:
478 address offset_delta_addr() const { return frame_type_addr() + sizeof(u1); }
479 address type_addr() const { return offset_delta_addr() + sizeof(u2); }
480
481 enum { _frame_id = 247 };
482
483 public:
484 static bool is_frame_type(u1 tag) {
485 return tag == _frame_id;
486 }
487
488 static same_locals_1_stack_item_extended* at(address addr) {
489 assert(is_frame_type(*addr), "Wrong frame id");
490 return (same_locals_1_stack_item_extended*)addr;
491 }
492
493 static same_locals_1_stack_item_extended* create_at(
494 address addr, int offset_delta, verification_type_info* vti) {
495 same_locals_1_stack_item_extended* sm =
|