1. 30 6月, 2017 7 次提交
    • V
      CR feedback · 6ffc9473
      vsadov 提交于
      6ffc9473
    • V
      Added a comment on ObjectToPointer conversion · e71557b5
      vsadov 提交于
      e71557b5
    • V
      In some cases `fixed` statement used a peculiar codegen strategy. · f692ac46
      vsadov 提交于
      Instead of mapping the pointer to a pointer temp, it was mapped to the managed pinned reference (which does not even have the same type).
      At all the places where the pointer was used, the actual reference was converted to the pointer, repeatedly.
      
      I.E.
      
      ```C#
      fixed(int * p = &v)
      {
          Use(p);
          Use(p);
          Use(p);
      }
      ```
      was emitted as
      
      ```C#
      try
      {
           pinned ref int refTemp = ref v;
      
          Use((int*)refTemp);      // unsafely cast pinned ref
          Use((int*)refTemp);      // unsafely cast pinned ref
          Use((int*)refTemp);      // unsafely cast pinned ref
      }
      finally
      {
            // zero-out refTemp
      }
      ```
      instead of logical pattern matching the semantics:
      ```C#
      try
      {
           pinned ref int refTemp = ref v;
           int * p = (int*)refTemp;  // unsafely cast pinned ref
      
          Use(p);
          Use(p);
          Use(p);
      }
      finally
      {
            // zero-out refTemp
      }
      ```
      
      The reason for the strange emit was never truly understood. In fact, in other cases, like fixed string, the more obvious variant was used.
      One theory was that this codegen was just because of the lack of internal expressiveness in the old compiler around byref locals and we simply carried it forward.
      The inconsistency required special casing of such `fixed` statements  in binding, lowering, codegen and in the semantical model, which must expose the "logical" shape of the statement.
      
      Another guess was that this kind of emit was better for JIT.
      That turned out to be not true. To the contrary - while a pointer temp would be very optimizable, repeated accesses to the pinned ref actually results in noticeable overhead in the JITted code, forcing users to use workarounds like:
      
      ```C#
      fixed(int * p = &v)
      {
          // PERF: accessing p has additional expenses, so store it in another temp;
          int * cheapP = p;
          Use(cheapP);
          Use(cheapP);
          Use(cheapP);
      }
      ```
      
      Users should not need to do the above. Compiler should do that in the first place.
      
      Fixes: #18615
      f692ac46
    • J
      Merge pull request #20499 from dotnet/merges/master-to-dev15.6-20170628-070011 · 463d2fcd
      Jason Malinowski 提交于
      Merge master to dev15.6
      463d2fcd
    • A
      Merge pull request #20521 from amcasey/OptionalToString · 6e3d4540
      Andrew Casey 提交于
      Override object.ToString in Optional<T>
      6e3d4540
    • T
    • A
      Handle null _value · 809fc29b
      Andrew Casey 提交于
      809fc29b
  2. 29 6月, 2017 20 次提交
  3. 28 6月, 2017 13 次提交