Skip to content

Commit

Permalink
[jvm] Port fix for clearing old VMArray elements
Browse files Browse the repository at this point in the history
This ports a bug fix for MoarVM and resolves RT #127756 for the JVM backend.

See MoarVM/MoarVM@43c926f9e0 which has a detailed
commit message (Zoffix++).
  • Loading branch information
usev6 committed Dec 30, 2017
1 parent 659ced5 commit cccaf20
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 20 deletions.
Expand Up @@ -51,9 +51,9 @@ private void set_size_internal(ThreadContext tc, long n) {
if (n == elems)
return;

/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (start > 0 && n + start > ssize) {
/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (elems > 0)
memmove(slots, 0, start, elems);
this.start = 0;
Expand All @@ -63,6 +63,13 @@ private void set_size_internal(ThreadContext tc, long n) {
elems++;
}
}
else if (n < elems) {
/* we're downsizing; clear off extra slots */
while (n < elems) {
elems--;
slots[(int)(start + elems)] = null;
}
}

this.elems = (int)n;
if (n <= ssize) {
Expand Down
Expand Up @@ -49,9 +49,9 @@ private void set_size_internal(ThreadContext tc, long n) {
if (n == elems)
return;

/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (start > 0 && n + start > ssize) {
/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (elems > 0)
memmove(slots, 0, start, elems);
this.start = 0;
Expand All @@ -61,6 +61,13 @@ private void set_size_internal(ThreadContext tc, long n) {
elems++;
}
}
else if (n < elems) {
/* we're downsizing; clear off extra slots */
while (n < elems) {
elems--;
slots[(int)(start + elems)] = 0;
}
}

this.elems = (int)n;
if (n <= ssize) {
Expand Down
Expand Up @@ -49,9 +49,9 @@ private void set_size_internal(ThreadContext tc, long n) {
if (n == elems)
return;

/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (start > 0 && n + start > ssize) {
/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (elems > 0)
memmove(slots, 0, start, elems);
this.start = 0;
Expand All @@ -61,6 +61,13 @@ private void set_size_internal(ThreadContext tc, long n) {
elems++;
}
}
else if (n < elems) {
/* we're downsizing; clear off extra slots */
while (n < elems) {
elems--;
slots[(int)(start + elems)] = 0;
}
}

this.elems = (int)n;
if (n <= ssize) {
Expand Down
Expand Up @@ -49,9 +49,9 @@ private void set_size_internal(ThreadContext tc, long n) {
if (n == elems)
return;

/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (start > 0 && n + start > ssize) {
/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (elems > 0)
memmove(slots, 0, start, elems);
this.start = 0;
Expand All @@ -61,6 +61,13 @@ private void set_size_internal(ThreadContext tc, long n) {
elems++;
}
}
else if (n < elems) {
/* we're downsizing; clear off extra slots */
while (n < elems) {
elems--;
slots[(int)(start + elems)] = 0;
}
}

this.elems = (int)n;
if (n <= ssize) {
Expand Down
Expand Up @@ -49,9 +49,9 @@ private void set_size_internal(ThreadContext tc, long n) {
if (n == elems)
return;

/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (start > 0 && n + start > ssize) {
/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (elems > 0)
memmove(slots, 0, start, elems);
this.start = 0;
Expand All @@ -61,6 +61,13 @@ private void set_size_internal(ThreadContext tc, long n) {
elems++;
}
}
else if (n < elems) {
/* we're downsizing; clear off extra slots */
while (n < elems) {
elems--;
slots[(int)(start + elems)] = 0;
}
}

this.elems = (int)n;
if (n <= ssize) {
Expand Down
Expand Up @@ -49,9 +49,9 @@ private void set_size_internal(ThreadContext tc, long n) {
if (n == elems)
return;

/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (start > 0 && n + start > ssize) {
/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (elems > 0)
memmove(slots, 0, start, elems);
this.start = 0;
Expand All @@ -61,6 +61,13 @@ private void set_size_internal(ThreadContext tc, long n) {
elems++;
}
}
else if (n < elems) {
/* we're downsizing; clear off extra slots */
while (n < elems) {
elems--;
slots[(int)(start + elems)] = 0.0;
}
}

this.elems = (int)n;
if (n <= ssize) {
Expand Down
Expand Up @@ -49,9 +49,9 @@ private void set_size_internal(ThreadContext tc, long n) {
if (n == elems)
return;

/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (start > 0 && n + start > ssize) {
/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (elems > 0)
memmove(slots, 0, start, elems);
this.start = 0;
Expand All @@ -61,6 +61,13 @@ private void set_size_internal(ThreadContext tc, long n) {
elems++;
}
}
else if (n < elems) {
/* we're downsizing; clear off extra slots */
while (n < elems) {
elems--;
slots[(int)(start + elems)] = null;
}
}

this.elems = (int)n;
if (n <= ssize) {
Expand Down
Expand Up @@ -53,9 +53,9 @@ private void set_size_internal(ThreadContext tc, long n) {
if (n == elems)
return;

/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (start > 0 && n + start > ssize) {
/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (elems > 0)
memmove(slots, 0, start, elems);
this.start = 0;
Expand All @@ -65,6 +65,13 @@ private void set_size_internal(ThreadContext tc, long n) {
elems++;
}
}
else if (n < elems) {
/* we're downsizing; clear off extra slots */
while (n < elems) {
elems--;
slots[(int)(start + elems)] = 0;
}
}

this.elems = (int)n;
if (n <= ssize) {
Expand Down
Expand Up @@ -53,9 +53,9 @@ private void set_size_internal(ThreadContext tc, long n) {
if (n == elems)
return;

/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (start > 0 && n + start > ssize) {
/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (elems > 0)
memmove(slots, 0, start, elems);
this.start = 0;
Expand All @@ -65,6 +65,13 @@ private void set_size_internal(ThreadContext tc, long n) {
elems++;
}
}
else if (n < elems) {
/* we're downsizing; clear off extra slots */
while (n < elems) {
elems--;
slots[(int)(start + elems)] = 0;
}
}

this.elems = (int)n;
if (n <= ssize) {
Expand Down
Expand Up @@ -53,9 +53,9 @@ private void set_size_internal(ThreadContext tc, long n) {
if (n == elems)
return;

/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (start > 0 && n + start > ssize) {
/* if there aren't enough slots at the end, shift off empty slots
* from the beginning first */
if (elems > 0)
memmove(slots, 0, start, elems);
this.start = 0;
Expand All @@ -65,6 +65,13 @@ private void set_size_internal(ThreadContext tc, long n) {
elems++;
}
}
else if (n < elems) {
/* we're downsizing; clear off extra slots */
while (n < elems) {
elems--;
slots[(int)(start + elems)] = 0;
}
}

this.elems = (int)n;
if (n <= ssize) {
Expand Down

0 comments on commit cccaf20

Please sign in to comment.