Skip to content

Commit aa00846

Browse files
LiedtkeV8-internal LUCI CQ
authored andcommitted
[v8] Improve registration of Worker builtins
Bug: 487347678 Change-Id: I00083540222506cfb09d7b1dfe5d040b7818a58b Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/9081256 Commit-Queue: Danylo Mocherniuk <mdanylo@google.com> Reviewed-by: Danylo Mocherniuk <mdanylo@google.com> Auto-Submit: Matthias Liedtke <mliedtke@google.com> Commit-Queue: Matthias Liedtke <mliedtke@google.com>
1 parent b9dd5cd commit aa00846

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

Sources/Fuzzilli/Profiles/V8CommonProfile.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public extension ILType {
2424

2525
static let gcTypeEnum = ILType.enumeration(ofName: "gcType", withValues: ["minor", "major"])
2626
static let gcExecutionEnum = ILType.enumeration(ofName: "gcExecution", withValues: ["async", "sync"])
27+
28+
static let jsWorker = object(ofGroup: "Worker", withMethods: ["postMessage","getMessage", "terminate", "terminateAndWait"])
29+
static let jsWorkerConstructor = constructor([.jsAnything, .object()] => jsWorker)
30+
+ object(ofGroup: "WorkerConstructor", withProperties: ["prototype"])
2731
}
2832

2933
public let gcOptions = ObjectGroup(
@@ -33,6 +37,33 @@ public let gcOptions = ObjectGroup(
3337
"execution": .gcExecutionEnum],
3438
methods: [:])
3539

40+
public extension ObjectGroup {
41+
static let jsWorkers = ObjectGroup(
42+
name: "Worker",
43+
instanceType: .jsWorker,
44+
properties: [:],
45+
methods: [
46+
"postMessage": [.jsAnything] => .undefined,
47+
"getMessage": [] => .jsAnything,
48+
"terminate": [] => .undefined,
49+
"terminateAndWait": [] => .undefined
50+
]
51+
)
52+
53+
static let jsWorkerPrototype =
54+
ObjectGroup.createPrototypeObjectGroup(jsWorkers, constructor: .jsWorkerConstructor)
55+
56+
static let jsWorkerConstructors = ObjectGroup(
57+
name: "WorkerConstructor",
58+
constructorPath: "Worker",
59+
instanceType: .jsWorkerConstructor,
60+
properties: [
61+
"prototype" : jsWorkerPrototype.instanceType,
62+
],
63+
methods: [:]
64+
)
65+
}
66+
3667
public let fastCallables : [(group: ILType, method: String)] = [
3768
(group: .jsD8FastCAPI, method: "throw_no_fallback"),
3869
(group: .jsD8FastCAPI, method: "add_32bit_int"),

Sources/Fuzzilli/Profiles/V8Profile.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ public let v8Profile = Profile(
9797
additionalBuiltins: [
9898
"gc" : .function([.opt(gcOptions.instanceType)] => (.undefined | .jsPromise)),
9999
"d8" : .jsD8,
100-
"Worker": .constructor([.jsAnything, .object()] => .object(withMethods: ["postMessage","getMessage"])),
100+
"Worker": .jsWorkerConstructor,
101101
// via --expose-externalize-string:
102102
"externalizeString": .function([.plain(.jsString)] => .jsString),
103103
"isOneByteString": .function([.plain(.jsString)] => .boolean),
104104
"createExternalizableString": .function([.plain(.jsString)] => .jsString),
105105
"createExternalizableTwoByteString": .function([.plain(.jsString)] => .jsString),
106106
],
107107

108-
additionalObjectGroups: [jsD8, jsD8Test, jsD8FastCAPI, gcOptions],
108+
additionalObjectGroups: [jsD8, jsD8Test, jsD8FastCAPI, gcOptions, .jsWorkers, .jsWorkerPrototype, .jsWorkerConstructors],
109109

110110
additionalEnumerations: [.gcTypeEnum, .gcExecutionEnum],
111111

0 commit comments

Comments
 (0)