提交 e2a4ba52 编写于 作者: R Rodrigo Kumpera

Enable delegate .ctor optimization under sgen.

	* method-to-ir.c (handle_delegate_ctor): Emit write barriers
	under sgen.

	* method-to-ir.c (mono_method_to_ir): Enable delegate .ctor
	optimization under sgen.
上级 a16debc2
......@@ -3670,6 +3670,8 @@ handle_ccastclass (MonoCompile *cfg, MonoClass *klass, MonoInst *src)
static G_GNUC_UNUSED MonoInst*
handle_delegate_ctor (MonoCompile *cfg, MonoClass *klass, MonoInst *target, MonoMethod *method, int context_used)
{
MonoInst *ptr;
int dreg;
gpointer *trampoline;
MonoInst *obj, *method_ins, *tramp_ins;
MonoDomain *domain;
......@@ -3683,13 +3685,23 @@ handle_delegate_ctor (MonoCompile *cfg, MonoClass *klass, MonoInst *target, Mono
/* Set target field */
/* Optimize away setting of NULL target */
if (!(target->opcode == OP_PCONST && target->inst_p0 == 0))
if (!(target->opcode == OP_PCONST && target->inst_p0 == 0)) {
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, obj->dreg, G_STRUCT_OFFSET (MonoDelegate, target), target->dreg);
if (cfg->gen_write_barriers) {
dreg = alloc_preg (cfg);
EMIT_NEW_BIALU_IMM (cfg, ptr, OP_PADD_IMM, dreg, obj->dreg, G_STRUCT_OFFSET (MonoDelegate, target));
emit_write_barrier (cfg, ptr, target, 0);
}
}
/* Set method field */
method_ins = emit_get_rgctx_method (cfg, context_used, method, MONO_RGCTX_INFO_METHOD);
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, obj->dreg, G_STRUCT_OFFSET (MonoDelegate, method), method_ins->dreg);
if (cfg->gen_write_barriers) {
dreg = alloc_preg (cfg);
EMIT_NEW_BIALU_IMM (cfg, ptr, OP_PADD_IMM, dreg, obj->dreg, G_STRUCT_OFFSET (MonoDelegate, method));
emit_write_barrier (cfg, ptr, method_ins, 0);
}
/*
* To avoid looking up the compiled code belonging to the target method
* in mono_delegate_trampoline (), we allocate a per-domain memory slot to
......@@ -9667,7 +9679,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
#if defined(MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE)
/* FIXME: SGEN support */
if (!cfg->gen_write_barriers && invoke_context_used == 0) {
if (invoke_context_used == 0) {
ip += 6;
if (cfg->verbose_level > 3)
g_print ("converting (in B%d: stack: %d) %s", bblock->block_num, (int)(sp - stack_start), mono_disasm_code_one (NULL, method, ip, NULL));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册