From b52aac9732c59e4303ccf2d25a9ceeaad99806ec Mon Sep 17 00:00:00 2001 From: Eric Lippert Date: Thu, 9 Mar 2017 09:35:48 -0800 Subject: [PATCH] Redo MemoGet / MemoSet instructions to use counts Summary: The MemoGet / MemoSet instructions take a range of locals. Turns out it is easier to have the first local and the number of locals in the range than the first and last locals in the range. Reviewed By: hubyrod Differential Revision: D4674537 fbshipit-source-id: 528f3149a728f92e2d9a1be289a342e2d4155be3 --- hphp/hack/src/hhbc/generate_memoized.ml | 6 +++--- hphp/hack/src/hhbc/hhbc_ast.ml | 4 ++-- hphp/hack/src/hhbc/hhbc_hhas.ml | 12 ++++++------ hphp/hack/src/hhbc/instruction_sequence.ml | 7 +++++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/hphp/hack/src/hhbc/generate_memoized.ml b/hphp/hack/src/hhbc/generate_memoized.ml index 14a5584262d..dd909a4d257 100644 --- a/hphp/hack/src/hhbc/generate_memoized.ml +++ b/hphp/hack/src/hhbc/generate_memoized.ml @@ -33,7 +33,7 @@ let memoized_body params = PopC *) instr_basel static_local Warn; - (* TODO: instr_memoget 0 lowest_unnamed highest_unnamed *) + (* TODO: instr_memoget 0 lowest_unnamed param_count *) instr_isuninit; instr_jmpnz label; instr_cgetcunop; @@ -47,7 +47,7 @@ let memoized_body params = (* TODO: instr_fcall param_count *) instr_unboxr; instr_basel static_local Define; - (* TODO: instr_memoset 0 lowest_unnamed highest_unnamed *) + (* TODO: instr_memoset 0 lowest_unnamed param_count *) instr_retc ] @@ -58,5 +58,5 @@ let memoize_function compiled = let params = Hhas_function.params compiled in let body = memoized_body params in let body = instr_seq_to_list body in - let memoized = Hhas_function.with_body compiled body in (* TODO *) + let memoized = Hhas_function.with_body compiled body in (renamed, memoized) diff --git a/hphp/hack/src/hhbc/hhbc_ast.ml b/hphp/hack/src/hhbc/hhbc_ast.ml index fa4e4ac19c6..215a00cd5be 100644 --- a/hphp/hack/src/hhbc/hhbc_ast.ml +++ b/hphp/hack/src/hhbc/hhbc_ast.ml @@ -505,8 +505,8 @@ type instruct_misc = | IsUninit | CGetCUNop | UGetCUNop - | MemoSet of int * local_id * local_id - | MemoGet of int * local_id * local_id + | MemoSet of int * local_id * int + | MemoGet of int * local_id * int type gen_creation_execution = | CreateCont diff --git a/hphp/hack/src/hhbc/hhbc_hhas.ml b/hphp/hack/src/hhbc/hhbc_hhas.ml index 3ee36e103f6..2f063b11424 100644 --- a/hphp/hack/src/hhbc/hhbc_hhas.ml +++ b/hphp/hack/src/hhbc/hhbc_hhas.ml @@ -413,14 +413,14 @@ let string_of_misc instruction = "StaticLoc " ^ (string_of_local_id local) ^ " " ^ (quote_str text) | StaticLocInit (local, text) -> (* TODO: The $ is unnecessarily escaped. *) "StaticLocInit " ^ (string_of_local_id local) ^ " " ^ (quote_str text) - | MemoGet (count, Local.Unnamed first, Local.Unnamed last) -> + | MemoGet (count, Local.Unnamed first, local_count) -> Printf.sprintf "MemoGet %s L:%d+%d" - (string_of_int count) first (last - first) - | MemoGet _ -> failwith "MemoGet needs two unnamed locals" - | MemoSet (count, Local.Unnamed first, Local.Unnamed last) -> + (string_of_int count) first (local_count - 1) + | MemoGet _ -> failwith "MemoGet needs an unnamed local" + | MemoSet (count, Local.Unnamed first, local_count) -> Printf.sprintf "MemoSet %s L:%d+%d" - (string_of_int count) first (last - first) - | MemoSet _ -> failwith "MemoSet needs two unnamed locals" + (string_of_int count) first (local_count - 1) + | MemoSet _ -> failwith "MemoSet needs an unnamed local" | _ -> failwith "instruct_misc Not Implemented" let string_of_iterator instruction = diff --git a/hphp/hack/src/hhbc/instruction_sequence.ml b/hphp/hack/src/hhbc/instruction_sequence.ml index d00f3ebc2e1..fe32de475da 100644 --- a/hphp/hack/src/hhbc/instruction_sequence.ml +++ b/hphp/hack/src/hhbc/instruction_sequence.ml @@ -104,8 +104,11 @@ let instr_fcall count = instr (ICall(FCall count)) let instr_isuninit = instr (IMisc IsUninit) let instr_cgetcunop = instr (IMisc CGetCUNop) let instr_ugetcunop = instr (IMisc UGetCUNop) -(* TODO: MemoGet 0 L:2+0 *) -(* TODO: MemoSet 0 L:2+0*) +let instr_memoget count local local_count = + instr (IMisc (MemoSet(count, local, local_count))) +let instr_memoset count local local_count = + instr (IMisc (MemoSet(count, local, local_count))) + (* TODO: GetMemoKeyL $n *) (* Functions on instr_seq that correspond to existing Core.List functions *) -- 2.11.4.GIT