src/share/vm/runtime/sharedRuntime.cpp

Print this page
rev 4267 : 8009981: nashorn tests fail with -XX:+VerifyStack
Summary: nmethod::preserve_callee_argument_oops() must take appendix into account.
Reviewed-by:


2711   assert(TypeArrayKlass::cast(jlsValue->klass())->element_type() == T_CHAR, "compressed string");
2712   (void) UNICODE::as_utf8(jlsPos, jlsLen, (char *)dst, max_dtrace_string_size);
2713 }
2714 #endif // ndef HAVE_DTRACE_H
2715 
2716 // -------------------------------------------------------------------------
2717 // Java-Java calling convention
2718 // (what you use when Java calls Java)
2719 
2720 //------------------------------name_for_receiver----------------------------------
2721 // For a given signature, return the VMReg for parameter 0.
2722 VMReg SharedRuntime::name_for_receiver() {
2723   VMRegPair regs;
2724   BasicType sig_bt = T_OBJECT;
2725   (void) java_calling_convention(&sig_bt, &regs, 1, true);
2726   // Return argument 0 register.  In the LP64 build pointers
2727   // take 2 registers, but the VM wants only the 'main' name.
2728   return regs.first();
2729 }
2730 
2731 VMRegPair *SharedRuntime::find_callee_arguments(Symbol* sig, bool has_receiver, int* arg_size) {
2732   // This method is returning a data structure allocating as a
2733   // ResourceObject, so do not put any ResourceMarks in here.
2734   char *s = sig->as_C_string();
2735   int len = (int)strlen(s);
2736   *s++; len--;                  // Skip opening paren
2737   char *t = s+len;
2738   while( *(--t) != ')' ) ;      // Find close paren
2739 
2740   BasicType *sig_bt = NEW_RESOURCE_ARRAY( BasicType, 256 );
2741   VMRegPair *regs = NEW_RESOURCE_ARRAY( VMRegPair, 256 );
2742   int cnt = 0;
2743   if (has_receiver) {
2744     sig_bt[cnt++] = T_OBJECT; // Receiver is argument 0; not in signature
2745   }
2746 
2747   while( s < t ) {
2748     switch( *s++ ) {            // Switch on signature character
2749     case 'B': sig_bt[cnt++] = T_BYTE;    break;
2750     case 'C': sig_bt[cnt++] = T_CHAR;    break;
2751     case 'D': sig_bt[cnt++] = T_DOUBLE;  sig_bt[cnt++] = T_VOID; break;


2755     case 'S': sig_bt[cnt++] = T_SHORT;   break;
2756     case 'Z': sig_bt[cnt++] = T_BOOLEAN; break;
2757     case 'V': sig_bt[cnt++] = T_VOID;    break;
2758     case 'L':                   // Oop
2759       while( *s++ != ';'  ) ;   // Skip signature
2760       sig_bt[cnt++] = T_OBJECT;
2761       break;
2762     case '[': {                 // Array
2763       do {                      // Skip optional size
2764         while( *s >= '0' && *s <= '9' ) s++;
2765       } while( *s++ == '[' );   // Nested arrays?
2766       // Skip element type
2767       if( s[-1] == 'L' )
2768         while( *s++ != ';'  ) ; // Skip signature
2769       sig_bt[cnt++] = T_ARRAY;
2770       break;
2771     }
2772     default : ShouldNotReachHere();
2773     }
2774   }





2775   assert( cnt < 256, "grow table size" );
2776 
2777   int comp_args_on_stack;
2778   comp_args_on_stack = java_calling_convention(sig_bt, regs, cnt, true);
2779 
2780   // the calling convention doesn't count out_preserve_stack_slots so
2781   // we must add that in to get "true" stack offsets.
2782 
2783   if (comp_args_on_stack) {
2784     for (int i = 0; i < cnt; i++) {
2785       VMReg reg1 = regs[i].first();
2786       if( reg1->is_stack()) {
2787         // Yuck
2788         reg1 = reg1->bias(out_preserve_stack_slots());
2789       }
2790       VMReg reg2 = regs[i].second();
2791       if( reg2->is_stack()) {
2792         // Yuck
2793         reg2 = reg2->bias(out_preserve_stack_slots());
2794       }




2711   assert(TypeArrayKlass::cast(jlsValue->klass())->element_type() == T_CHAR, "compressed string");
2712   (void) UNICODE::as_utf8(jlsPos, jlsLen, (char *)dst, max_dtrace_string_size);
2713 }
2714 #endif // ndef HAVE_DTRACE_H
2715 
2716 // -------------------------------------------------------------------------
2717 // Java-Java calling convention
2718 // (what you use when Java calls Java)
2719 
2720 //------------------------------name_for_receiver----------------------------------
2721 // For a given signature, return the VMReg for parameter 0.
2722 VMReg SharedRuntime::name_for_receiver() {
2723   VMRegPair regs;
2724   BasicType sig_bt = T_OBJECT;
2725   (void) java_calling_convention(&sig_bt, &regs, 1, true);
2726   // Return argument 0 register.  In the LP64 build pointers
2727   // take 2 registers, but the VM wants only the 'main' name.
2728   return regs.first();
2729 }
2730 
2731 VMRegPair *SharedRuntime::find_callee_arguments(Symbol* sig, bool has_receiver, bool has_appendix, int* arg_size) {
2732   // This method is returning a data structure allocating as a
2733   // ResourceObject, so do not put any ResourceMarks in here.
2734   char *s = sig->as_C_string();
2735   int len = (int)strlen(s);
2736   *s++; len--;                  // Skip opening paren
2737   char *t = s+len;
2738   while( *(--t) != ')' ) ;      // Find close paren
2739 
2740   BasicType *sig_bt = NEW_RESOURCE_ARRAY( BasicType, 256 );
2741   VMRegPair *regs = NEW_RESOURCE_ARRAY( VMRegPair, 256 );
2742   int cnt = 0;
2743   if (has_receiver) {
2744     sig_bt[cnt++] = T_OBJECT; // Receiver is argument 0; not in signature
2745   }
2746 
2747   while( s < t ) {
2748     switch( *s++ ) {            // Switch on signature character
2749     case 'B': sig_bt[cnt++] = T_BYTE;    break;
2750     case 'C': sig_bt[cnt++] = T_CHAR;    break;
2751     case 'D': sig_bt[cnt++] = T_DOUBLE;  sig_bt[cnt++] = T_VOID; break;


2755     case 'S': sig_bt[cnt++] = T_SHORT;   break;
2756     case 'Z': sig_bt[cnt++] = T_BOOLEAN; break;
2757     case 'V': sig_bt[cnt++] = T_VOID;    break;
2758     case 'L':                   // Oop
2759       while( *s++ != ';'  ) ;   // Skip signature
2760       sig_bt[cnt++] = T_OBJECT;
2761       break;
2762     case '[': {                 // Array
2763       do {                      // Skip optional size
2764         while( *s >= '0' && *s <= '9' ) s++;
2765       } while( *s++ == '[' );   // Nested arrays?
2766       // Skip element type
2767       if( s[-1] == 'L' )
2768         while( *s++ != ';'  ) ; // Skip signature
2769       sig_bt[cnt++] = T_ARRAY;
2770       break;
2771     }
2772     default : ShouldNotReachHere();
2773     }
2774   }
2775 
2776   if (has_appendix) {
2777     sig_bt[cnt++] = T_OBJECT;
2778   }
2779 
2780   assert( cnt < 256, "grow table size" );
2781 
2782   int comp_args_on_stack;
2783   comp_args_on_stack = java_calling_convention(sig_bt, regs, cnt, true);
2784 
2785   // the calling convention doesn't count out_preserve_stack_slots so
2786   // we must add that in to get "true" stack offsets.
2787 
2788   if (comp_args_on_stack) {
2789     for (int i = 0; i < cnt; i++) {
2790       VMReg reg1 = regs[i].first();
2791       if( reg1->is_stack()) {
2792         // Yuck
2793         reg1 = reg1->bias(out_preserve_stack_slots());
2794       }
2795       VMReg reg2 = regs[i].second();
2796       if( reg2->is_stack()) {
2797         // Yuck
2798         reg2 = reg2->bias(out_preserve_stack_slots());
2799       }