Browse Source

add v_meta (and remove snd v_extra to even out memory consumption)

Simon Krajewski 12 years ago
parent
commit
23f5f4a713
4 changed files with 9 additions and 9 deletions
  1. 3 3
      optimizer.ml
  2. 3 3
      type.ml
  3. 1 1
      typeload.ml
  4. 2 2
      typer.ml

+ 3 - 3
optimizer.ml

@@ -358,16 +358,16 @@ let rec type_inline ctx cf f ethis params tret config p force =
 	let force = ref force in
 	let vars = List.fold_left (fun acc (i,e) ->
 		let flag = not i.i_force_temp && (match e.eexpr with
-			| TLocal {v_extra = _,true} -> true
+			| TLocal v when Meta.has Meta.This v.v_meta -> true
 			| TLocal _ | TConst _ -> not i.i_write
 			| TFunction _ -> if i.i_write then error "Cannot modify a closure parameter inside inline method" p; true
 			| _ -> not i.i_write && i.i_read <= 1
 		) in
 		let flag = flag && (not i.i_captured || is_constant e) in
 		(* force inlining if we modify 'this' *)
-		if i.i_write && snd i.i_var.v_extra then force := true;
+		if i.i_write && (Meta.has Meta.This i.i_var.v_meta) then force := true;
 		(* force inlining of 'this' variable if it is written *)
-		let flag = if not flag && snd i.i_var.v_extra && i.i_write then begin
+		let flag = if not flag && (Meta.has Meta.This i.i_var.v_meta) && i.i_write then begin
 			if not (is_writable e) then error "Cannot modify the abstract value, store it into a local first" p;
 			true
 		end else flag in

+ 3 - 3
type.ml

@@ -77,8 +77,8 @@ and tvar = {
 	mutable v_name : string;
 	mutable v_type : t;
 	mutable v_capture : bool;
-	(* snd = true if abstract "this" argument *)
-	mutable v_extra : (type_params * texpr option) option * bool;
+	mutable v_extra : (type_params * texpr option) option;
+	mutable v_meta : metadata;
 }
 
 and tfunc = {
@@ -311,7 +311,7 @@ and decision_tree = {
 
 let alloc_var =
 	let uid = ref 0 in
-	(fun n t -> incr uid; { v_name = n; v_type = t; v_id = !uid; v_capture = false; v_extra = None,false })
+	(fun n t -> incr uid; { v_name = n; v_type = t; v_id = !uid; v_capture = false; v_extra = None; v_meta = [] })
 
 let alloc_mid =
 	let mid = ref 0 in

+ 1 - 1
typeload.ml

@@ -1136,7 +1136,7 @@ let type_function ctx args ret fmode f do_display p =
 				| _ -> display_error ctx "Parameter default value should be constant" p; None
 		) in
 		let v,c = add_local ctx n t, c in
-		if n = "this" then v.v_extra <- None,true;
+		if n = "this" then v.v_meta <- (Meta.This,[],p) :: v.v_meta;
 		v,c
 	) args in
 	let old_ret = ctx.ret in

+ 2 - 2
typer.ml

@@ -1045,7 +1045,7 @@ let rec type_ident_raise ?(imported_enums=true) ctx i p mode =
 	| _ ->
 	try
 		let v = PMap.find i ctx.locals in
-		(match fst v.v_extra with
+		(match v.v_extra with
 		| Some (params,e) ->
 			let t = monomorphs params v.v_type in
 			(match e with
@@ -2876,7 +2876,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
 		(match v with
 		| None -> e
 		| Some v ->
-			if params <> [] || inline then v.v_extra <- Some (params,if inline then Some e else None),snd v.v_extra;
+			if params <> [] || inline then v.v_extra <- Some (params,if inline then Some e else None);
 			let rec loop = function
 				| Codegen.Block f | Codegen.Loop f | Codegen.Function f -> f loop
 				| Codegen.Use v2 when v == v2 -> raise Exit