//
// Moved value from instance into target of different type with no checks (JIT intristics)
//
+ // Restrictions:
+ //
+ // S and R must either:
+ // both be blitable valuetypes
+ // both be reference types (IOW, an unsafe cast)
+ // S and R cannot be float or double
+ // S and R must either:
+ // both be a struct
+ // both be a scalar
+ // S and R must either:
+ // be of same size
+ // both be a scalar of size <= 4
+ //
internal static R UnsafeMov<S,R> (S instance) {
return (R)(object) instance;
}
if (cfg->verbose_level > 3)
printf ("[UNSAFE-MOV-INTRISIC] %s <- %s\n", return_klass->name, param_klass->name);
- //Only allow for valuetypes
- if (!param_klass->valuetype || !return_klass->valuetype) {
+ //Don't allow mixing reference types with value types
+ if (param_klass->valuetype != return_klass->valuetype) {
if (cfg->verbose_level > 3)
- printf ("[UNSAFE-MOV-INTRISIC]\tone of the args is not a valuetype\n");
+ printf ("[UNSAFE-MOV-INTRISIC]\tone of the args is a valuetype and the other is not\n");
return FALSE;
}
+ if (!param_klass->valuetype) {
+ if (cfg->verbose_level > 3)
+ printf ("[UNSAFE-MOV-INTRISIC]\targs are reference types\n");
+ return TRUE;
+ }
+
//That are blitable
if (param_klass->has_references || return_klass->has_references)
return FALSE;