ソースを参照

[hl] added HVirtual vid to prevent some OutOfMemory in PMap of types (see #8243)

Nicolas Cannasse 6 年 前
コミット
a3ad9367ca

+ 6 - 0
src/generators/genhl.ml

@@ -352,6 +352,10 @@ let fake_tnull =
 		a_params = ["T",t_dynamic];
 	}
 
+let alloc_vid =
+	let vid = ref 0 in
+	(fun() -> incr vid; !vid)
+
 let rec to_type ?tref ctx t =
 	match t with
 	| TMono r ->
@@ -395,6 +399,7 @@ let rec to_type ?tref ctx t =
 			PMap.find a ctx.anons_cache
 		with Not_found ->
 			let vp = {
+				vid = alloc_vid();
 				vfields = [||];
 				vindex = PMap.empty;
 			} in
@@ -541,6 +546,7 @@ and class_type ?(tref=None) ctx c pl statics =
 		PMap.find key_path ctx.cached_types
 	with Not_found when c.cl_interface && not statics ->
 		let vp = {
+			vid = alloc_vid();
 			vfields = [||];
 			vindex = PMap.empty;
 		} in

+ 1 - 1
src/generators/hl2c.ml

@@ -113,7 +113,7 @@ let s_comp = function
 	| CNeq -> "!="
 
 let core_types =
-	let vp = { vfields = [||]; vindex = PMap.empty } in
+	let vp = { vid = -1; vfields = [||]; vindex = PMap.empty } in
 	let ep = { ename = ""; eid = 0; eglobal = None; efields = [||] } in
 	[HVoid;HUI8;HUI16;HI32;HI64;HF32;HF64;HBool;HBytes;HDyn;HFun ([],HVoid);HObj null_proto;HArray;HType;HRef HVoid;HVirtual vp;HDynObj;HAbstract ("",0);HEnum ep;HNull HVoid;HMethod ([],HVoid);HStruct null_proto]
 

+ 4 - 3
src/generators/hlcode.ml

@@ -50,8 +50,8 @@ type ttype =
 	| HStruct of class_proto
 
 and class_proto = {
-	pname : string;
 	pid : int;
+	pname : string;
 	mutable pclassglobal : int option;
 	mutable psuper : class_proto option;
 	mutable pvirtuals : int array;
@@ -65,20 +65,21 @@ and class_proto = {
 }
 
 and enum_proto = {
-	ename : string;
 	eid : int;
+	ename : string;
 	mutable eglobal : int option;
 	mutable efields : (string * string index * ttype array) array;
 }
 
 and field_proto = {
-	fname : string;
 	fid : int;
+	fname : string;
 	fmethod : functable index;
 	fvirtual : int option;
 }
 
 and virtual_proto = {
+	vid : int;
 	mutable vfields : (string * string index * ttype) array;
 	mutable vindex : (string, int) PMap.t;
 }

+ 1 - 1
src/generators/hlinterp.ml

@@ -2484,7 +2484,7 @@ let check code macros =
 			| OToVirtual (r,v) ->
 				(match rtype r with
 				| HVirtual _ -> ()
-				| _ -> reg r (HVirtual {vfields=[||];vindex=PMap.empty;}));
+				| _ -> reg r (HVirtual {vid=(-1);vfields=[||];vindex=PMap.empty;}));
 				(match rtype v with
 				| HObj _ | HDynObj | HDyn | HVirtual _ -> ()
 				| _ -> reg v HDynObj)