From 32d3e81b81c94eb1116e8ca0a5635fa6ea846dd4 Mon Sep 17 00:00:00 2001 From: z30061262 Date: Sun, 9 Jun 2024 18:29:38 +0800 Subject: [PATCH 1/5] Added LightWeightMap API --- Sources/FuzzilliCli/Profiles/ArkProfile.swift | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/Sources/FuzzilliCli/Profiles/ArkProfile.swift b/Sources/FuzzilliCli/Profiles/ArkProfile.swift index aec2a76..64d0c37 100644 --- a/Sources/FuzzilliCli/Profiles/ArkProfile.swift +++ b/Sources/FuzzilliCli/Profiles/ArkProfile.swift @@ -27,7 +27,7 @@ fileprivate let RunNearStackLimitGenerator = CodeGenerator("RunNearStackLimitGen /// ArkTS Generators fileprivate let ArkTSObjectInstanceGenerator = ValueGenerator("ArkTSObjectInstanceGenerator") { b, n in - let builtin = chooseUniform(from: ["Stack", "HashMap", "HashSet", "ArrayList"]) + let builtin = chooseUniform(from: ["Stack", "HashMap", "HashSet", "ArrayList", "LightWeightMap"]) let constructor = b.loadBuiltin(builtin) b.construct(constructor) } @@ -40,6 +40,9 @@ fileprivate let arkTSHashMap = ILType.iterable + ILType.object(ofGroup: "HashMap fileprivate let arkTSHashSet = ILType.iterable + ILType.object(ofGroup: "HashSet", withProperties: ["length"], withMethods: ["isEmpty", "has", "add", "remove", "clear", "values", "forEach", "entries"]) /// Type of a ArkTS ArrayList object. fileprivate let arkTSArrayList = ILType.iterable + ILType.object(ofGroup: "ArrayList", withProperties: ["length"], withMethods: ["add", "insert", "has", "getIndexOf", "getLastIndexOf", "removeByIndex", "remove", "removeByRange", "replaceAllElements", "forEach", "sort", "subArrayList", "clear", "clone", "getCapacity", "convertToArray", "isEmpty", "increaseCapacityTo", "trimToCurrentLength"]) +/// Type of a ArkTS LightWeightMap object. +fileprivate let arkTSLightWeightMap = ILType.iterable + ILType.object(ofGroup: "LightWeightMap", withProperties: ["length"], withMethods: ["isEmpty", "hasAll", "hasKey", "hasValue", "increaseCapacityTo", "get", "getIndexOfKey", "getIndexOfValue", "getKeyAt", "setAll", "set", "remove", "removeAt", "setValueAt", "getValueAt", "clear", "keys", "values", "forEach", "entries", "toString"]) + /// Type of the ArkTS Stack constructor builtin. fileprivate let arkTSStackConstructor = ILType.constructor([] => arkTSStack) @@ -49,6 +52,8 @@ fileprivate let arkTSHashMapConstructor = ILType.constructor([] => arkTSHashMap) fileprivate let arkTSHashSetConstructor = ILType.constructor([] => arkTSHashSet) /// Type of the ArkTS ArrayList constructor builtin. fileprivate let arkTSArrayListConstructor = ILType.constructor([] => arkTSArrayList) +/// Type of the ArkTS LightWeightMap constructor builtin. +fileprivate let arkTSLightWeightMapConstructor = ILType.constructor([] => arkTSLightWeightMap) /// ObjectGroup modelling ArkTS Stack objects @@ -140,6 +145,37 @@ fileprivate let arrayLists = ObjectGroup( ] ) +fileprivate let arkTSLightWeightMaps = ObjectGroup( + name: "LightWeightMap", + instanceType: arkTSLightWeightMap, + properties: [ + "length" : .number, + ], + methods: [ + "isEmpty" : [] => .boolean, + "hasAll" : [.object(ofGroup: "LightWeightMap")] => .boolean, + "hasKey" : [.anything] => .boolean, + "hasValue" : [.anything] => .boolean, + "increaseCapacityTo" : [.number] => .undefined, + "get" : [.anything] => .anything, + "getIndexOfKey" : [.anything] => .number, + "getIndexOfValue" : [.anything] => .number, + "getKeyAt" : [.number] => .anything, + "setAll" : [.object(ofGroup: "LightWeightMap")] => .undefined, + "set" : [.anything, .anything] => .object(), + "remove" : [.anything] => .anything, + "removeAt" : [.number] => .boolean, + "setValueAt" : [.number, .anything] => .boolean, + "getValueAt" : [.number] => .anything, + "clear" : [] => .undefined, + "keys" : [] => .object(), + "values" : [] => .object(), + "forEach" : [.function([.opt(.anything), .opt(.anything), .opt(arkTSLightWeightMap)] => .undefined), .opt(.object())] => .undefined, + "entries" : [] => .object(), + "toString" : [] => .string + ] +) + let arkProfile = Profile( processArgs: { randomize in var args = [ @@ -161,6 +197,7 @@ let arkProfile = Profile( var HashMap = arkPrivate.Load(arkPrivate.HashMap); var HashSet = arkPrivate.Load(arkPrivate.HashSet); var ArrayList = arkPrivate.Load(arkPrivate.ArrayList); + var LightWeightMap = arkPrivate.Load(arkPrivate.LightWeightMap); function bgc() { for(let i=0; i<0x10000; i+=1) {new String();} @@ -207,6 +244,7 @@ let arkProfile = Profile( "HashMap" : arkTSHashMapConstructor, "HashSet" : arkTSHashSetConstructor, "ArrayList" : arkTSArrayListConstructor, + "LightWeightMap" : arkTSLightWeightMapConstructor, ], additionalObjectGroups: [ @@ -214,6 +252,7 @@ let arkProfile = Profile( arkTSHashMaps, arkTSHashSets, arrayLists, + arkTSLightWeightMaps, ], optionalPostProcessor: nil -- Gitee From 00389ba2b4de0b945b712addff1e4f83b5c03ef6 Mon Sep 17 00:00:00 2001 From: z30061262 Date: Tue, 11 Jun 2024 20:06:57 +0800 Subject: [PATCH 2/5] Added LightWeightSet API --- Sources/FuzzilliCli/Profiles/ArkProfile.swift | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/Sources/FuzzilliCli/Profiles/ArkProfile.swift b/Sources/FuzzilliCli/Profiles/ArkProfile.swift index 64d0c37..b6f44ad 100644 --- a/Sources/FuzzilliCli/Profiles/ArkProfile.swift +++ b/Sources/FuzzilliCli/Profiles/ArkProfile.swift @@ -27,7 +27,7 @@ fileprivate let RunNearStackLimitGenerator = CodeGenerator("RunNearStackLimitGen /// ArkTS Generators fileprivate let ArkTSObjectInstanceGenerator = ValueGenerator("ArkTSObjectInstanceGenerator") { b, n in - let builtin = chooseUniform(from: ["Stack", "HashMap", "HashSet", "ArrayList", "LightWeightMap"]) + let builtin = chooseUniform(from: ["Stack", "HashMap", "HashSet", "ArrayList", "LightWeightMap", "LightWeightSet"]) let constructor = b.loadBuiltin(builtin) b.construct(constructor) } @@ -42,7 +42,8 @@ fileprivate let arkTSHashSet = ILType.iterable + ILType.object(ofGroup: "HashSet fileprivate let arkTSArrayList = ILType.iterable + ILType.object(ofGroup: "ArrayList", withProperties: ["length"], withMethods: ["add", "insert", "has", "getIndexOf", "getLastIndexOf", "removeByIndex", "remove", "removeByRange", "replaceAllElements", "forEach", "sort", "subArrayList", "clear", "clone", "getCapacity", "convertToArray", "isEmpty", "increaseCapacityTo", "trimToCurrentLength"]) /// Type of a ArkTS LightWeightMap object. fileprivate let arkTSLightWeightMap = ILType.iterable + ILType.object(ofGroup: "LightWeightMap", withProperties: ["length"], withMethods: ["isEmpty", "hasAll", "hasKey", "hasValue", "increaseCapacityTo", "get", "getIndexOfKey", "getIndexOfValue", "getKeyAt", "setAll", "set", "remove", "removeAt", "setValueAt", "getValueAt", "clear", "keys", "values", "forEach", "entries", "toString"]) - +/// Type of a ArkTS LightWeightSet object. +fileprivate let arkTSLightWeightSet = ILType.iterable + ILType.object(ofGroup: "LightWeightSet", withProperties: ["length"], withMethods: ["isEmpty", "add", "addAll", "hasAll", "has", "equal", "increaseCapacityTo", "getIndexOf", "remove", "removeAt", "getValueAt", "clear", "toString", "toArray", "values", "forEach", "entries"]) /// Type of the ArkTS Stack constructor builtin. fileprivate let arkTSStackConstructor = ILType.constructor([] => arkTSStack) @@ -54,6 +55,8 @@ fileprivate let arkTSHashSetConstructor = ILType.constructor([] => arkTSHashSet) fileprivate let arkTSArrayListConstructor = ILType.constructor([] => arkTSArrayList) /// Type of the ArkTS LightWeightMap constructor builtin. fileprivate let arkTSLightWeightMapConstructor = ILType.constructor([] => arkTSLightWeightMap) +/// Type of the ArkTS LightWeightSet constructor builtin. +fileprivate let arkTSLightWeightSetConstructor = ILType.constructor([] => arkTSLightWeightSet) /// ObjectGroup modelling ArkTS Stack objects @@ -176,6 +179,35 @@ fileprivate let arkTSLightWeightMaps = ObjectGroup( ] ) +/// ObjectGroup modelling ArkTS LightWeightSet objects +fileprivate let arkTSLightWeightSets = ObjectGroup( + name: "LightWeightSet", + instanceType: arkTSLightWeightSet, + properties: [ + "length" : .number, + ], + methods: [ + "isEmpty" : [] => .boolean, + "add" : [.anything] => .boolean, + "addAll" : [.object(ofGroup: "LightWeightSet")] => .boolean, + "hasAll" : [.object(ofGroup: "LightWeightSet")] => .boolean, + "has" : [.anything] => .boolean, + "equal" : [.object()] => .boolean, + "increaseCapacityTo" : [.number] => .undefined, + "getIndexOf" : [.anything] => .number, + "remove" : [.anything] => .anything, + "removeAt" : [.number] => .boolean, + "getValueAt" : [.number] => .anything, + "clear" : [] => .undefined, + "toString" : [] => .string, + "toArray" : [] => .object(), + "values" : [] => .object(), + "forEach" : [.function([.opt(.anything), .opt(.anything), .opt(arkTSLightWeightSet)] => .undefined), .opt(.object())] => .undefined, + "entries" : [] => .object(), + ] +) + + let arkProfile = Profile( processArgs: { randomize in var args = [ @@ -198,6 +230,7 @@ let arkProfile = Profile( var HashSet = arkPrivate.Load(arkPrivate.HashSet); var ArrayList = arkPrivate.Load(arkPrivate.ArrayList); var LightWeightMap = arkPrivate.Load(arkPrivate.LightWeightMap); + var LightWeightSet = arkPrivate.Load(arkPrivate.LightWeightSet); function bgc() { for(let i=0; i<0x10000; i+=1) {new String();} @@ -245,6 +278,7 @@ let arkProfile = Profile( "HashSet" : arkTSHashSetConstructor, "ArrayList" : arkTSArrayListConstructor, "LightWeightMap" : arkTSLightWeightMapConstructor, + "LightWeightSet" : arkTSLightWeightSetConstructor, ], additionalObjectGroups: [ @@ -253,6 +287,7 @@ let arkProfile = Profile( arkTSHashSets, arrayLists, arkTSLightWeightMaps, + arkTSLightWeightSets, ], optionalPostProcessor: nil -- Gitee From 522ac9918b7cef4f4cfa79d124363ebd7a55edcb Mon Sep 17 00:00:00 2001 From: z30061262 Date: Thu, 13 Jun 2024 20:15:57 +0800 Subject: [PATCH 3/5] Fix merge problem --- Sources/FuzzilliCli/Profiles/ArkProfile.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sources/FuzzilliCli/Profiles/ArkProfile.swift b/Sources/FuzzilliCli/Profiles/ArkProfile.swift index fcfaabe..1e6bc89 100644 --- a/Sources/FuzzilliCli/Profiles/ArkProfile.swift +++ b/Sources/FuzzilliCli/Profiles/ArkProfile.swift @@ -32,6 +32,13 @@ fileprivate let ArkTSObjectInstanceGenerator = ValueGenerator("ArkTSObjectInstan b.construct(constructor) } +/// ArkTS Collections Generators +fileprivate let ArkTSCollectionsObjectInstanceGenerator = ValueGenerator("ArkTSCollectionsObjectInstanceGenerator") { b, n in + let builtin = chooseUniform(from: ["SharedMap"]) + let constructor = b.loadBuiltin(builtin) + b.construct(constructor) +} + /// Type of a ArkTS Stack object. fileprivate let arkTSStack = ILType.iterable + ILType.object(ofGroup: "Stack", withProperties: ["length"], withMethods: ["push", "pop", "peek", "locate", "forEach", "isEmpty"]) /// Type of a ArkTS HashMap object. -- Gitee From deda957a26325727ad2242d859b54dc80e2be3f5 Mon Sep 17 00:00:00 2001 From: z30061262 Date: Fri, 14 Jun 2024 11:58:44 +0800 Subject: [PATCH 4/5] Fix merge problem --- Sources/FuzzilliCli/Profiles/ArkProfile.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/FuzzilliCli/Profiles/ArkProfile.swift b/Sources/FuzzilliCli/Profiles/ArkProfile.swift index 606df05..d4e936c 100644 --- a/Sources/FuzzilliCli/Profiles/ArkProfile.swift +++ b/Sources/FuzzilliCli/Profiles/ArkProfile.swift @@ -27,7 +27,7 @@ fileprivate let RunNearStackLimitGenerator = CodeGenerator("RunNearStackLimitGen /// ArkTS Generators fileprivate let ArkTSObjectInstanceGenerator = ValueGenerator("ArkTSObjectInstanceGenerator") { b, n in - let builtin = chooseUniform(from: ["Stack", "HashMap", "HashSet", "List", "ArrayList", "LightWeightMap"]) + let builtin = chooseUniform(from: ["Stack", "HashMap", "HashSet", "LinkedList", "List", "ArrayList", "LightWeightMap"]) let constructor = b.loadBuiltin(builtin) b.construct(constructor) } @@ -353,7 +353,7 @@ let arkProfile = Profile( "LinkedList" : arkTSLinkedListConstructor, "List" : arkTSListConstructor, "ArrayList" : arkTSArrayListConstructor, - "LightWeightMap" : arkTSLightWeightMapConstructor, + "LightWeightMap" : arkTSLightWeightMapConstructor, ], additionalObjectGroups: [ -- Gitee From 5640590a6bf19269864d2c2f976620c34f75050e Mon Sep 17 00:00:00 2001 From: z30061262 Date: Fri, 14 Jun 2024 12:00:50 +0800 Subject: [PATCH 5/5] Fix merge problem --- Sources/FuzzilliCli/Profiles/ArkProfile.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/FuzzilliCli/Profiles/ArkProfile.swift b/Sources/FuzzilliCli/Profiles/ArkProfile.swift index 1e6bc89..50423e9 100644 --- a/Sources/FuzzilliCli/Profiles/ArkProfile.swift +++ b/Sources/FuzzilliCli/Profiles/ArkProfile.swift @@ -27,7 +27,7 @@ fileprivate let RunNearStackLimitGenerator = CodeGenerator("RunNearStackLimitGen /// ArkTS Generators fileprivate let ArkTSObjectInstanceGenerator = ValueGenerator("ArkTSObjectInstanceGenerator") { b, n in - let builtin = chooseUniform(from: ["Stack", "HashMap", "HashSet", "List", "ArrayList", "LightWeightMap", "LightWeightSet"]) + let builtin = chooseUniform(from: ["Stack", "HashMap", "HashSet", "LinkedList", "List", "ArrayList", "LightWeightMap", "LightWeightSet"]) let constructor = b.loadBuiltin(builtin) b.construct(constructor) } @@ -386,8 +386,8 @@ let arkProfile = Profile( "LinkedList" : arkTSLinkedListConstructor, "List" : arkTSListConstructor, "ArrayList" : arkTSArrayListConstructor, - "LightWeightMap" : arkTSLightWeightMapConstructor, - "LightWeightSet" : arkTSLightWeightSetConstructor, + "LightWeightMap" : arkTSLightWeightMapConstructor, + "LightWeightSet" : arkTSLightWeightSetConstructor, ], additionalObjectGroups: [ -- Gitee