[PATCH 1/4] jit: Flush the code for the runtime directives

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/4] jit: Flush the code for the runtime directives

Holger Freyther
From: Holger Hans Peter Freyther <[hidden email]>

On x86/amd64 this will call mprotect with PROT_EXEC on the
allocated memory. This is fixing an infinite recursion in the
segfault handler of the garbage collection.

2013-06-03  Holger Hans Peter Freyther  <[hidden email]>

        * xlat.c: Use jit_flush_code for the runtime code.
---
 libgst/ChangeLog |    4 ++++
 libgst/xlat.c    |    2 ++
 2 files changed, 6 insertions(+)

diff --git a/libgst/ChangeLog b/libgst/ChangeLog
index f5a77d7..56a044f 100644
--- a/libgst/ChangeLog
+++ b/libgst/ChangeLog
@@ -1,3 +1,7 @@
+2013-06-03  Holger Hans Peter Freyther  <[hidden email]>
+
+ * xlat.c: Use jit_flush_code for the runtime code.
+
 2013-06-14  Gwenael Casaccio <[hidden email]>
 
  * libgst/dict.c: Remove useless code: gst_ordered_collection structure.
diff --git a/libgst/xlat.c b/libgst/xlat.c
index e555cca..3f4a555 100644
--- a/libgst/xlat.c
+++ b/libgst/xlat.c
@@ -620,6 +620,8 @@ generate_run_time_code (void)
 
   jit_movi_i (JIT_RET, 0);
   jit_ret ();
+
+  jit_flush_code(_gst_run_native_code, jit_get_label() );
 }
 
 
--
1.7.10.4


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/4] jit: Fix the bootstrap of CharacterArray

Holger Freyther
From: Holger Hans Peter Freyther <[hidden email]>

CharacterArray>>#withWindowsShellEscapes has the following code
that will lead to execution during the bootstrap. The interpreter
is optimizing the calls for >>#value: but the JIT is not doing that.

Change the order of the bootstrap to load the BlockClosure and
related classes before the CharacterArray.

        table := ##(
            | t |
            t := ByteArray new: 256.
            #($% $" $< $> $| $& $^ $ ) do: [ :each | t at: each codePoint put: 1 ].
            t).

2013-06-03  Holger Hans Peter Freyther  <[hidden email]>

        * files.c: Make BlockClosure available before the CharacterArray.
---
 libgst/ChangeLog |    4 ++++
 libgst/files.c   |    8 ++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libgst/ChangeLog b/libgst/ChangeLog
index 56a044f..44566ea 100644
--- a/libgst/ChangeLog
+++ b/libgst/ChangeLog
@@ -1,5 +1,9 @@
 2013-06-03  Holger Hans Peter Freyther  <[hidden email]>
 
+ * files.c: Make BlockClosure available before the CharacterArray.
+
+2013-06-03  Holger Hans Peter Freyther  <[hidden email]>
+
  * xlat.c: Use jit_flush_code for the runtime code.
 
 2013-06-14  Gwenael Casaccio <[hidden email]>
diff --git a/libgst/files.c b/libgst/files.c
index a7156f9..c3626ff 100644
--- a/libgst/files.c
+++ b/libgst/files.c
@@ -200,6 +200,10 @@ static const char standard_files[] = {
   "CompiledBlk.st\0"
   "Array.st\0"
   "ByteArray.st\0"
+  "ContextPart.st\0"
+  "MthContext.st\0"
+  "BlkContext.st\0"
+  "BlkClosure.st\0"
   "CharArray.st\0"
   "String.st\0"
   "Symbol.st\0"
@@ -225,10 +229,6 @@ static const char standard_files[] = {
   "RWStream.st\0"
   "UndefObject.st\0"
   "ProcSched.st\0"
-  "ContextPart.st\0"
-  "MthContext.st\0"
-  "BlkContext.st\0"
-  "BlkClosure.st\0"
   "Behavior.st\0"
   "ClassDesc.st\0"
   "Class.st\0"
--
1.7.10.4


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

[PATCH 3/4] jit: Fix test failures with Magritte, SUnit and other routines

Holger Freyther
In reply to this post by Holger Freyther
From: Holger Hans Peter Freyther <[hidden email]>

The tests crash when returning to a previous context. In the case of the
Magritte test it is crashing on return to Delay class>>#runDelayProcess.

This appears to occur when resuming an existing image. It is because
the F_XLAT and F_XLAT_REACHABLE flags are cleared on saving of the image.
On image resume the refresh_native_ips method will re-generate the
native code and set the F_XLAT flag for active contexts. As the native
code is not executed the F_XLAT_REACHABLE will not be set. This makes it
possible for maybe_release_xlat to release the native code without
updating the context. This will eventually cause a segmentation fault
as the native code is gone.

The solution appears to be easy. Once the native_ip is updated the
F_XLAT_REACHABLE is set. This way it is guaranteed that the native code
will not be collected.

2013-06-10  Holger Hans Peter Freyther  <[hidden email]>

        * interp-jit.inl: Set the F_XLAT_REACHABLE flag in refresh_native_ips.
---
 libgst/ChangeLog      |    4 ++++
 libgst/interp-jit.inl |    4 ++++
 2 files changed, 8 insertions(+)

diff --git a/libgst/ChangeLog b/libgst/ChangeLog
index 44566ea..4880a8f 100644
--- a/libgst/ChangeLog
+++ b/libgst/ChangeLog
@@ -1,3 +1,7 @@
+2013-06-10  Holger Hans Peter Freyther  <[hidden email]>
+
+ * interp-jit.inl: Set the F_XLAT_REACHABLE flag in refresh_native_ips.
+
 2013-06-03  Holger Hans Peter Freyther  <[hidden email]>
 
  * files.c: Make BlockClosure available before the CharacterArray.
diff --git a/libgst/interp-jit.inl b/libgst/interp-jit.inl
index 0e8fa27..78fa94c 100644
--- a/libgst/interp-jit.inl
+++ b/libgst/interp-jit.inl
@@ -353,6 +353,10 @@ refresh_native_ips (OOP contextOOP)
   virtualIP = TO_INT (context->ipOffset);
   native_ip =
     _gst_map_virtual_ip (context->method, receiverClass, virtualIP);
+  /* The above might have freshly translated the method for us
+     and the F_XLAT_REACHABLE is not set yet. Set the flag right
+     to assure we can safely return to this method. */
+  context->method->flags |= F_XLAT_REACHABLE;
 
 #ifndef OPTIMIZE
   if (!native_ip)
--
1.7.10.4


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

[PATCH 4/4] jit: The at: optimization is broken for ContextPart>>#at: -1

Holger Freyther
In reply to this post by Holger Freyther
From: Holger Hans Peter Freyther <[hidden email]>

The delays test is triggering this bug. Disable the inlined at
for now...

2013-06-27  Holger Hans Peter Freyther  <[hidden email]>

        * xlat.c: Disable the optimized version of the basicAt: primitive.
---
 libgst/ChangeLog |    4 ++++
 libgst/xlat.c    |    3 +++
 2 files changed, 7 insertions(+)

diff --git a/libgst/ChangeLog b/libgst/ChangeLog
index 4880a8f..38aec89 100644
--- a/libgst/ChangeLog
+++ b/libgst/ChangeLog
@@ -1,3 +1,7 @@
+2013-06-27  Holger Hans Peter Freyther  <[hidden email]>
+
+ * xlat.c: Disable the optimized version of the basicAt: primitive.
+
 2013-06-10  Holger Hans Peter Freyther  <[hidden email]>
 
  * interp-jit.inl: Set the F_XLAT_REACHABLE flag in refresh_native_ips.
diff --git a/libgst/xlat.c b/libgst/xlat.c
index 3f4a555..24fc847 100644
--- a/libgst/xlat.c
+++ b/libgst/xlat.c
@@ -2587,6 +2587,8 @@ emit_inlined_primitive (int primitive, int numArgs, int attr)
 {
   switch (primitive)
     {
+#if 0
+    /* delays.st is failing for index access at -1 */
     case 60:
       {
  jit_insn *fail1, *fail2;
@@ -2683,6 +2685,7 @@ emit_inlined_primitive (int primitive, int numArgs, int attr)
  return PRIM_FAIL | PRIM_SUCCEED | PRIM_INLINED;
       }
       break;
+#endif
 
     case 61:
       {
--
1.7.10.4


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 4/4] jit: The at: optimization is broken for ContextPart>>#at: -1

Paolo Bonzini-2
Il 27/06/2013 10:12, Holger Hans Peter Freyther ha scritto:

> From: Holger Hans Peter Freyther <[hidden email]>
>
> The delays test is triggering this bug. Disable the inlined at
> for now...
>
> 2013-06-27  Holger Hans Peter Freyther  <[hidden email]>
>
> * xlat.c: Disable the optimized version of the basicAt: primitive.
> ---
>  libgst/ChangeLog |    4 ++++
>  libgst/xlat.c    |    3 +++
>  2 files changed, 7 insertions(+)
>
> diff --git a/libgst/ChangeLog b/libgst/ChangeLog
> index 4880a8f..38aec89 100644
> --- a/libgst/ChangeLog
> +++ b/libgst/ChangeLog
> @@ -1,3 +1,7 @@
> +2013-06-27  Holger Hans Peter Freyther  <[hidden email]>
> +
> + * xlat.c: Disable the optimized version of the basicAt: primitive.
> +
>  2013-06-10  Holger Hans Peter Freyther  <[hidden email]>
>  
>   * interp-jit.inl: Set the F_XLAT_REACHABLE flag in refresh_native_ips.
> diff --git a/libgst/xlat.c b/libgst/xlat.c
> index 3f4a555..24fc847 100644
> --- a/libgst/xlat.c
> +++ b/libgst/xlat.c
> @@ -2587,6 +2587,8 @@ emit_inlined_primitive (int primitive, int numArgs, int attr)
>  {
>    switch (primitive)
>      {
> +#if 0
> +    /* delays.st is failing for index access at -1 */
>      case 60:
>        {
>   jit_insn *fail1, *fail2;
> @@ -2683,6 +2685,7 @@ emit_inlined_primitive (int primitive, int numArgs, int attr)
>   return PRIM_FAIL | PRIM_SUCCEED | PRIM_INLINED;
>        }
>        break;
> +#endif
>  
>      case 61:
>        {
>

Since you said it happens also with the interpreter, and it is a clear
bug in classes that have both fixed and indexed instance variables,
let's leave this one aside for now.

st> thisContext basicAt: -1
UndefinedObject>>executeStatements

Please apply the other three.

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 4/4] jit: The at: optimization is broken for ContextPart>>#at: -1

Paolo Bonzini-2
Il 27/06/2013 11:07, Paolo Bonzini ha scritto:
> Since you said it happens also with the interpreter, and it is a clear
> bug in classes that have both fixed and indexed instance variables,
> let's leave this one aside for now.
>
> st> thisContext basicAt: -1
> UndefinedObject>>executeStatements

I started debugging this one.  One problem is that the

    PUSH_LITERAL (arg);
    MAKE_DIRTY_BLOCK ();

bytecode does not update sp (via PREPARE_STACK) before MAKE_DIRTY_BLOCK
invokes _gst_make_block_closure.  This is a bug in vm.def, and I have a
patch for it.  However, alone it does not fix the bug.  I'll keep looking.

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk