X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Fl2JIT.ml;h=efe785453cd08e4cae96848a97c1e7e9110f5500;hb=4309f9456521bffcab5ff79abe1ed826744c3a57;hp=d01d4806d0cefd9a732cb58a14d5543affddbcee;hpb=0c50360a781f9c1048ac84d90561cdd5a6fb34ac;p=SXSI%2Fxpathcomp.git diff --git a/src/l2JIT.ml b/src/l2JIT.ml index d01d480..efe7854 100644 --- a/src/l2JIT.ml +++ b/src/l2JIT.ml @@ -86,18 +86,19 @@ let jump_stat_summary fmt = type opcode = - | CACHE - | RETURN + | RETURN of unit | LEFT of Translist.t * jump | RIGHT of Translist.t * jump | BOTH of Translist.t * jump * jump + | CACHE of unit type t = opcode Cache.Lvl2.t -let dummy = CACHE +let dummy = CACHE () +let return = RETURN () let print_opcode fmt o = match o with - | CACHE -> fprintf fmt "CACHE" - | RETURN -> fprintf fmt "RETURN" + | CACHE _ -> fprintf fmt "CACHE" + | RETURN _ -> fprintf fmt "RETURN" | LEFT (tl, j) -> fprintf fmt "LEFT(\n[%a], %a)" Translist.print tl print_jump j | RIGHT (tl, j) -> fprintf fmt "RIGHT(\n[%a], %a)" Translist.print tl print_jump j | BOTH (tl, j1, j2) -> fprintf fmt "BOTH(\n[%a], %a, %a)" Translist.print tl print_jump j1 print_jump j2 @@ -145,6 +146,12 @@ let has_text l = Ptset.Int.mem Tag.pcdata l let rec translate_jump tree tag (jkind:Ata.jump_kind) dir s = let child, desc, sib, fol = Tree.tags tree tag in + let not_elements = + Ptset.Int.add Tag.pcdata + (Ptset.Int.add Tag.attribute + (Ptset.Int.add Tag.attribute_data + (Tree.attribute_tags tree))) + in match jkind, dir with | NIL, _ -> _nop | NODE, DIR_LEFT -> FIRST_CHILD s @@ -178,9 +185,21 @@ let rec translate_jump tree tag (jkind:Ata.jump_kind) dir s = let labels = Ptset.Int.inter l_many t in let c = Ptset.Int.cardinal labels in if c == 0 then _nop - else if c == 1 then tagged_many s (Ptset.Int.choose labels) - else if c > 5 then if has_text labels then any s else any_notext s - else select_many s labels + else + let not_t = Ptset.Int.diff l_many labels in + let () = + LOG(__ "level2-jit" 3 "Would jump for tag %s to labels %a, not relevant tags: %a" + (Tag.to_string tag) + TagSet.print (TagSet.inj_positive labels) + TagSet.print (TagSet.inj_positive not_t)) + in + if Ptset.Int.subset not_t not_elements then + if has_text labels then any s else any_notext s + else if c == 1 then tagged_many s (Ptset.Int.choose labels) + else + if c >= 5 then + if has_text labels then any s else any_notext s + else select_many s labels | CAPTURE_MANY (t), DIR_LEFT -> if Ptset.Int.is_singleton t then TAGGED_SUBTREE(s, Ptset.Int.choose t) @@ -212,7 +231,7 @@ let compile cache2 auto tree tag states = let op = let empty_s1 = StateSet.is_empty states1 in let empty_s2 = StateSet.is_empty states2 in - if empty_s1 && empty_s2 then RETURN + if empty_s1 && empty_s2 then return else if empty_s1 then RIGHT (tr_list, compute_jump auto tree tag states2 DIR_RIGHT) @@ -235,7 +254,7 @@ let compile cache2 auto tree tag states = op let get_transitions = function - | CACHE | RETURN -> failwith "get_transitions" + | CACHE _ | RETURN _ -> failwith "get_transitions" | LEFT (tr, _) | RIGHT (tr, _) | BOTH (tr, _, _) -> tr