File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515#include "lj_err.h"
1616#include "lj_debug.h"
1717#include "lj_str.h"
18+ #include "lj_str_hash.h"
1819#include "lj_tab.h"
1920#include "lj_state.h"
2021#include "lj_bc.h"
@@ -156,6 +157,27 @@ LJLIB_CF(jit_prngstate)
156157 return 1 ;
157158}
158159
160+ LJLIB_CF (jit_crc32 )
161+ {
162+ #if LJ_OR_STRHASHCRC32
163+ setboolV (L -> top ++ , lj_check_crc32_support ());
164+ #else
165+ setboolV (L -> top ++ , 0 );
166+ #endif
167+ return 1 ;
168+ }
169+
170+ LJLIB_CF (jit_strhashcrc32 )
171+ {
172+ #if LJ_OR_STRHASHCRC32
173+ global_State * g = G (L );
174+ setboolV (L -> top ++ , (g -> strhashfn != lj_str_hash_orig ) ? 1 : 0 );
175+ #else
176+ setboolV (L -> top ++ , 0 );
177+ #endif
178+ return 1 ;
179+ }
180+
159181LJLIB_PUSH (top - 5 ) LJLIB_SET (os )
160182LJLIB_PUSH (top - 4 ) LJLIB_SET (arch )
161183LJLIB_PUSH (top - 3 ) LJLIB_SET (version_num )
Original file line number Diff line number Diff line change 1+ # vim:set ts=4 sts=4 sw=4 et ft=:
2+
3+ use lib ' .' ;
4+ use t::TestLJ;
5+
6+ plan tests => 3 * blocks();
7+
8+ run_tests();
9+
10+ __DATA__
11+
12+ === TEST 1: interpreted (sanity)
13+ flag.
14+ --- lua
15+ jit.off()
16+
17+ jit.crc32()
18+
19+ print("ok")
20+ --- out
21+ ok
22+ --- err
23+
24+
25+
26+ === TEST 2: JIT (sanity)
27+ --- lua
28+ jit.opt.start("minstitch=100000", "hotloop=2")
29+
30+ for i = 1, 50 do
31+ jit.crc32()
32+ end
33+
34+ print("ok")
35+ --- out
36+ ok
37+ --- jv
38+ --- err eval
39+ qr/trace too short at jit\.crc32/
Original file line number Diff line number Diff line change 1+ # vim:set ts=4 sts=4 sw=4 et ft=:
2+
3+ use lib ' .' ;
4+ use t::TestLJ;
5+
6+ plan tests => 3 * blocks();
7+
8+ run_tests();
9+
10+ __DATA__
11+
12+ === TEST 1: interpreted (sanity)
13+ --- lua
14+ jit.off()
15+
16+ if jit.crc32() then
17+ assert(jit.strhashcrc32() == true, "strhashcrc32 should be enabled")
18+ else
19+ assert(jit.strhashcrc32() == false, "strhashcrc32 should be disabled")
20+ end
21+
22+ print("ok")
23+ --- out
24+ ok
25+ --- err
26+
27+
28+
29+ === TEST 2: JIT (sanity)
30+ --- lua
31+ jit.opt.start("minstitch=100000", "hotloop=2")
32+
33+ for i = 1, 50 do
34+ jit.strhashcrc32()
35+ end
36+
37+ print("ok")
38+ --- out
39+ ok
40+ --- jv
41+ --- err eval
42+ qr/trace too short at jit\.strhashcrc32/
You can’t perform that action at this time.
0 commit comments