mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Recompile without method inlining
if cancel happens in an inlined method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									d71b78575b
								
							
						
					
					
						commit
						fcd679ed11
					
				
					 3 changed files with 14 additions and 8 deletions
				
			
		
							
								
								
									
										2
									
								
								mjit.h
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								mjit.h
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -61,6 +61,8 @@ struct rb_mjit_compile_info {
 | 
			
		|||
    bool disable_ivar_cache;
 | 
			
		||||
    // Disable send/opt_send_without_block optimizations based on inline cache
 | 
			
		||||
    bool disable_send_cache;
 | 
			
		||||
    // Disable method inlining
 | 
			
		||||
    bool disable_inlining;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef VALUE (*mjit_func_t)(rb_execution_context_t *, rb_control_frame_t *);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -202,6 +202,8 @@ compile_inlined_cancel_handler(FILE *f, const struct rb_iseq_constant_body *body
 | 
			
		|||
{
 | 
			
		||||
    fprintf(f, "\ncancel:\n");
 | 
			
		||||
    fprintf(f, "    RB_DEBUG_COUNTER_INC(mjit_cancel);\n");
 | 
			
		||||
    fprintf(f, "    rb_mjit_iseq_compile_info(original_iseq->body)->disable_inlining = true;\n");
 | 
			
		||||
    fprintf(f, "    rb_mjit_recompile_iseq(original_iseq);\n");
 | 
			
		||||
 | 
			
		||||
    // Swap pc/sp set on cancel with original pc/sp.
 | 
			
		||||
    fprintf(f, "    const VALUE current_pc = reg_cfp->pc;\n");
 | 
			
		||||
| 
						 | 
				
			
			@ -276,7 +278,8 @@ mjit_compile_body(FILE *f, const rb_iseq_t *iseq, struct compile_status *status)
 | 
			
		|||
    else {
 | 
			
		||||
        fprintf(f, "    VALUE *stack = reg_cfp->sp;\n");
 | 
			
		||||
    }
 | 
			
		||||
    fprintf(f, "    static const rb_iseq_t *original_iseq = 0x%"PRIxVALUE";\n", (VALUE)iseq);
 | 
			
		||||
    if (status->inlined_iseqs != NULL) // i.e. compile root
 | 
			
		||||
        fprintf(f, "    static const rb_iseq_t *original_iseq = 0x%"PRIxVALUE";\n", (VALUE)iseq);
 | 
			
		||||
    fprintf(f, "    static const VALUE *const original_body_iseq = (VALUE *)0x%"PRIxVALUE";\n",
 | 
			
		||||
            (VALUE)body->iseq_encoded);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -396,8 +399,8 @@ precompile_inlinable_iseqs(FILE *f, const rb_iseq_t *iseq, struct compile_status
 | 
			
		|||
                        && !mjit_copy_cache_from_main_thread(child_iseq, child_status.cc_entries, child_status.is_entries))
 | 
			
		||||
                    return false;
 | 
			
		||||
 | 
			
		||||
                fprintf(f, "ALWAYS_INLINE(static VALUE _mjit_inlined_%d(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const VALUE orig_self));\n", pos);
 | 
			
		||||
                fprintf(f, "static inline VALUE\n_mjit_inlined_%d(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const VALUE orig_self)\n{\n", pos);
 | 
			
		||||
                fprintf(f, "ALWAYS_INLINE(static VALUE _mjit_inlined_%d(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const VALUE orig_self, const rb_iseq_t *original_iseq));\n", pos);
 | 
			
		||||
                fprintf(f, "static inline VALUE\n_mjit_inlined_%d(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const VALUE orig_self, const rb_iseq_t *original_iseq)\n{\n", pos);
 | 
			
		||||
                fprintf(f, "    const VALUE *orig_pc = reg_cfp->pc;\n");
 | 
			
		||||
                fprintf(f, "    const VALUE *orig_sp = reg_cfp->sp;\n");
 | 
			
		||||
                bool success = mjit_compile_body(f, child_iseq, &child_status);
 | 
			
		||||
| 
						 | 
				
			
			@ -428,15 +431,16 @@ mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname)
 | 
			
		|||
            && !mjit_copy_cache_from_main_thread(iseq, status.cc_entries, status.is_entries))
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    bool success = precompile_inlinable_iseqs(f, iseq, &status);
 | 
			
		||||
    if (!success)
 | 
			
		||||
        return false;
 | 
			
		||||
    if (!status.compile_info->disable_send_cache && !status.compile_info->disable_inlining) {
 | 
			
		||||
        if (!precompile_inlinable_iseqs(f, iseq, &status))
 | 
			
		||||
            return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
    fprintf(f, "__declspec(dllexport)\n");
 | 
			
		||||
#endif
 | 
			
		||||
    fprintf(f, "VALUE\n%s(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp)\n{\n", funcname);
 | 
			
		||||
    success = mjit_compile_body(f, iseq, &status);
 | 
			
		||||
    bool success = mjit_compile_body(f, iseq, &status);
 | 
			
		||||
    fprintf(f, "\n} // end of %s\n", funcname);
 | 
			
		||||
    return success;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,7 +49,7 @@
 | 
			
		|||
                fprintf(f, "    {\n");
 | 
			
		||||
                fprintf(f, "        VALUE orig_self = reg_cfp->self;\n");
 | 
			
		||||
                fprintf(f, "        reg_cfp->self = stack[%d];\n", b->stack_size - argc - 1);
 | 
			
		||||
                fprintf(f, "        stack[%d] = _mjit_inlined_%d(ec, reg_cfp, orig_self);\n", b->stack_size - argc - 1, pos);
 | 
			
		||||
                fprintf(f, "        stack[%d] = _mjit_inlined_%d(ec, reg_cfp, orig_self, original_iseq);\n", b->stack_size - argc - 1, pos);
 | 
			
		||||
                fprintf(f, "        reg_cfp->self = orig_self;\n");
 | 
			
		||||
                fprintf(f, "    }\n");
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue