Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ztzg
Copy link
Contributor

@ztzg ztzg commented Feb 10, 2011

As discussed on Mono-devel-list:

http://thread.gmane.org/gmane.comp.gnome.mono.devel/36721

(This is a subset of the commits submitted for master, as the IMT-related changes are not directly applicable to this branch.)

Rebased on mono-2-6, and contributed under the MIT/X11 license.

ztzg added 4 commits February 11, 2011 00:14
Without this, the code throws the more general ArithmeticException
when the divisor is -1, independently of the dividend.  The check is
necessary because -Int32.MinValue does not fit into a 32-bit two's
complement integer.

Commit contributed under the MIT/X11 license.
The current code generator uses a SUBU/BLEZ combination, but this
breaks for non-zero-based arrays.  Given a lower bound 'b', length
'l', and an index 'i', Mini generates:

  real_i = i - b;
  COND_EXC_LE_UN(l, real_i);

Without this patch, the backend generates for e.g. b=42, l=1 and i=0:

  SUBU real_i, 0, 42     => -42
  SUBU at, 1, real_i     => 43 (U only means "no trap.")
  BLEZ at, throw         => No throw because at is positive!

This causes the following sequence to be used instead:

  SUBU real_i, 0, 42     => -42
  SLTU at, real_i, 1     => 0 (Unsigned '<'; real_i is a large value)
  BEQ  at, zero, throw   => Throw.

Commit contributed under the MIT/X11 license.
Generated methods always place 'this' in a0, but unboxing trampolines
currently bump a1 for functions returning value types (the register
assignments for 'this' and return area pointers probably got swapped
at some point, but the trampoline generator was not updated).

Fix that by always bumping a0.

Commit contributed under the MIT/X11 license.
From the comment:

$TARGET handles overflow by clipping, but this test assumes no overflow
handling.  According to ECMA the result of float->int conversion is undefined
if overflow occurs, so both behaviours are valid.

Commit contributed under the MIT/X11 license.
@vargaz
Copy link
Contributor

vargaz commented Feb 10, 2011

Applied these too.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants