The difference between the ceq MSIL command and the object. InternalEquals

I searched in ILDASM and Reflector for what I found:

  • == compiled into the "ceq" msil command
  • object.Equals stays as it is
  • object.Equals calls object.InternalEquals

This question showed me how to find out how InternalEquals functions can be implemented, i.e. in the .cpp class (or something else in the CLR).

My question is:

What is ceq? Another method in another .cpp class? That is, they are completely different points in the code? So, although the default behavior of == and Equals is the same, is this different code?

+3
source share
3 answers

== ceq. ==(). System.Decimal , , , , ( ).

Reflector Decimal.op_Equality(). FCallCompare, , MethodImplOptions.InternalCall. , . clr/src/vm/ecall.cpp Rotor. , . ++, , . , , FCallAdd, . COMDecimal:: Compare. comdecimal.cpp.

x86 x64 , ceq , inline. . , x64 SSE, x86 FPU . -, , .

Object.InternalEquals() , FCallCompare. , .

+18

ceq, == - . , , ; , .

object.Equals ; :

x.Equals(y) - , . , , .

object.Equals(x, y) - , null; 2 nulls = true, 1 null = false, 0 nulls - x.Equals(y).

, , == native ints; JIT , == (, ), JIT ( ) - MF ).

+4

Yes, they run different codes.

  • Equals is an instance method.
  • == is a static operator.

Both can be overridden for custom types.

+2
source

All Articles