]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
do not start new basic block on the bytecode mark
authorAleksey Demakov <ademakov@gmail.com>
Sat, 17 Nov 2007 02:12:36 +0000 (02:12 +0000)
committerAleksey Demakov <ademakov@gmail.com>
Sat, 17 Nov 2007 02:12:36 +0000 (02:12 +0000)
fix offset for the last mark

ChangeLog
jit/jit-cache.c
jit/jit-insn.c

index 3688352097ff61f592366dc622225ec4567aee5f..e4704d54c7d842d4b839580e90f01f2487ca94cd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-11-17  Aleksey Demakov  <ademakov@gmail.com>
+
+       * jit/jit-insn.c (jit_insn_mark_offset): do not start new block
+       on the bytecode mark. If a mark goes just after another mark then
+       replace the old mark rather than add the new.
+
+       * jit/jit-cache.c (_jit_cache_get_bytecode)
+       (_jit_cache_get_native): fix offset for the last bytecode mark.
+
 2007-11-13  Aleksey Demakov  <ademakov@gmail.com>
 
        * tools/Makefile.am (noinst_HEADERS): add gen-apply-macosx.h
index 5060b0abfc7d07d59b97cbe4139ee7ad804c6c86..6e37a25f3a746b2a7a23e5f3f3cf2073144e0316 100644 (file)
@@ -1323,7 +1323,8 @@ unsigned long _jit_cache_get_native(jit_cache_t cache, void *start,
                }
                prevNativeOfs = nativeOfs;
        }
-       return JIT_CACHE_NO_OFFSET;
+
+       return exact ? JIT_CACHE_NO_OFFSET : prevNativeOfs;
 }
 
 unsigned long _jit_cache_get_bytecode(jit_cache_t cache, void *start,
@@ -1350,7 +1351,8 @@ unsigned long _jit_cache_get_bytecode(jit_cache_t cache, void *start,
                }
                prevOfs = ofs;
        }
-       return JIT_CACHE_NO_OFFSET;
+
+       return exact ? JIT_CACHE_NO_OFFSET : prevOfs;
 }
 
 unsigned long _jit_cache_get_size(jit_cache_t cache)
index d0fa3d03b072cd7b6162741ac8c46a02c38314d6..d51dcc4bcde2877a53675668d1764a73dcc0cd26 100644 (file)
@@ -8013,15 +8013,35 @@ int jit_insn_move_blocks_to_start
 @*/
 int jit_insn_mark_offset(jit_function_t func, jit_int offset)
 {
-#if 1
-       if(!jit_insn_new_block(func))
+       jit_block_t block;
+       jit_insn_t last;
+       jit_value_t value;
+
+       /* Ensure that we have a builder for this function */
+       if(!_jit_function_ensure_builder(func))
        {
                return 0;
        }
-#endif
-       return create_unary_note(func, JIT_OP_MARK_OFFSET,
-                                                    jit_value_create_nint_constant
-                                                               (func, jit_type_int, offset));
+
+       value = jit_value_create_nint_constant(func, jit_type_int, offset);
+       if (!value)
+       {
+               return 0;
+       }
+
+       /* If the previous instruction is mark offset too
+          then just replace the offset value in place --
+          we are not interested in bytecodes that produce
+          no real code. */
+       block = func->builder->current_block;
+       last = _jit_block_get_last(block);
+       if (last && last->opcode == JIT_OP_MARK_OFFSET)
+       {
+               last->value1 = value;
+               return 1;
+       }
+
+       return create_unary_note(func, JIT_OP_MARK_OFFSET, value);
 }
 
 /* Documentation is in jit-debugger.c */