Skip to content

Commit

Permalink
Fix a regression introduced by mono/mono@e05343d: Disable the ldobj+s…
Browse files Browse the repository at this point in the history
…tobj optimization

for reference types.

Fixes mono/mono#6777.


Commit migrated from mono/mono@73eb0cc
  • Loading branch information
vargaz authored and marek-safar committed Feb 4, 2018
1 parent ad3b2d6 commit d030719
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/mono/mono/mini/generics.cs
Expand Up @@ -1391,6 +1391,24 @@ struct AStruct3<T1, T2, T3> {

return 0;
}

class LdobjStobj {
public int counter;
public LdobjStobj buffer1;
public LdobjStobj buffer2;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void swap<T>(ref T first, ref T second) {
second = first;
}

public static int test_42_ldobj_stobj_ref () {
var obj = new LdobjStobj ();
obj.counter = 42;
swap (ref obj.buffer1, ref obj.buffer2);
return obj.counter;
}
}

#if !__MOBILE__
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/method-to-ir.c
Expand Up @@ -9763,7 +9763,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
}

/* Optimize the ldobj+stobj combination */
if (((ip [5] == CEE_STOBJ) && ip_in_bb (cfg, cfg->cbb, ip + 5) && read32 (ip + 6) == token)) {
if (((ip [5] == CEE_STOBJ) && ip_in_bb (cfg, cfg->cbb, ip + 5) && read32 (ip + 6) == token) && !generic_class_is_reference_type (cfg, klass)) {
CHECK_STACK (1);

sp --;
Expand Down

0 comments on commit d030719

Please sign in to comment.