Changeset 270659 in webkit
- Timestamp:
- Dec 10, 2020 3:10:36 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 16 edited
- 2 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/PerformanceTests/APIBench/CurrentAPI/RichardsMostlyC/RichardsMostlyC/richards.c
r270277 r270659 11 11 #include <stdio.h> 12 12 #include <stdlib.h> 13 14 13 #include <JavaScriptCore/JavaScriptCore.h> 15 #i mport<QuartzCore/QuartzCore.h>14 #include <QuartzCore/QuartzCore.h> 16 15 17 16 #if 1 -
trunk/PerformanceTests/APIBench/References/RichardsC/RichardsC/richards.c
r270277 r270659 11 11 #include <stdio.h> 12 12 #include <stdlib.h> 13 14 13 #include <JavaScriptCore/JavaScriptCore.h> 15 #i mport<QuartzCore/QuartzCore.h>14 #include <QuartzCore/QuartzCore.h> 16 15 17 16 #if 1 -
trunk/PerformanceTests/APIBench/UpcomingAPI/RichardsMostlyC/RichardsMostlyC/richards.c
r270277 r270659 11 11 #include <stdio.h> 12 12 #include <stdlib.h> 13 13 #include <JavaScriptCore/JSLockRefPrivate.h> 14 14 #include <JavaScriptCore/JavaScriptCore.h> 15 #i mport<QuartzCore/QuartzCore.h>15 #include <QuartzCore/QuartzCore.h> 16 16 17 17 #if 1 … … 323 323 dispatch_once(&onceToken, ^{ 324 324 ctx = JSGlobalContextCreate(NULL); 325 JSLock(ctx); 325 326 JSObjectRef globalObject = JSContextGetGlobalObject(ctx); 326 327 -
trunk/PerformanceTests/APIBench/UpcomingAPI/RichardsMostlyObjC/RichardsMostlyObjC/WorkerTask.m
r270277 r270659 26 26 #import "WorkerTask.h" 27 27 28 #import <JavaScriptCore/JSLockRefPrivate.h> 28 29 #import <JavaScriptCore/JavaScriptCore.h> 29 30 … … 45 46 dispatch_once(&onceToken, ^{ 46 47 context = [[JSContext alloc] init]; 48 JSLock(context.JSGlobalContextRef); 47 49 [context setExceptionHandler:^(JSContext *context, JSValue *exception) { 48 50 NSLog(@"%@", exception.toString); -
trunk/PerformanceTests/APIBench/UpcomingAPI/RichardsMostlySwift/RichardsMostlySwift.xcodeproj/project.pbxproj
r270277 r270659 45 45 1415AD222499BC5C005BB2E4 /* RichardsMostlySwift */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = RichardsMostlySwift; sourceTree = BUILT_PRODUCTS_DIR; }; 46 46 1415AD252499BC5C005BB2E4 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; }; 47 145087E92580581900D94197 /* BridgingHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BridgingHeader.h; sourceTree = "<group>"; }; 47 48 /* End PBXFileReference section */ 48 49 … … 77 78 isa = PBXGroup; 78 79 children = ( 80 145087E92580581900D94197 /* BridgingHeader.h */, 79 81 140AAC3F249B01D10001F11E /* DeviceTask.swift */, 80 82 140AAC3D249B01D10001F11E /* HandlerTask.swift */, … … 283 285 CODE_SIGN_STYLE = Automatic; 284 286 PRODUCT_NAME = "$(TARGET_NAME)"; 287 SWIFT_OBJC_BRIDGING_HEADER = RichardsMostlySwift/BridgingHeader.h; 285 288 SWIFT_VERSION = 5.0; 286 289 }; … … 292 295 CODE_SIGN_STYLE = Automatic; 293 296 PRODUCT_NAME = "$(TARGET_NAME)"; 297 SWIFT_OBJC_BRIDGING_HEADER = RichardsMostlySwift/BridgingHeader.h; 294 298 SWIFT_VERSION = 5.0; 295 299 }; -
trunk/PerformanceTests/APIBench/UpcomingAPI/RichardsMostlySwift/RichardsMostlySwift/BridgingHeader.h
r270658 r270659 24 24 */ 25 25 26 import JavaScriptCore26 #pragma once 27 27 28 class WorkerTask : Task { 29 private var js : JSValue 30 31 private static let context : JSContext = { 32 let context = JSContext()! 33 let source = try! String(contentsOfFile: "richards.js") 34 context.evaluateScript(source) 35 context.exceptionHandler = { context, exception in 36 print(exception!.toString()!) 37 exit(2) 38 } 39 return context 40 }() 41 private static let constructor : JSValue = { 42 return context.objectForKeyedSubscript("createWorkerTask").call(withArguments: [Device.A.rawValue, Device.B.rawValue, WorkPacket.SIZE]) 43 }() 44 45 static func create(scheduler: Scheduler, priority: Priority, queue: Packet) 46 { 47 let task = WorkerTask(scheduler: scheduler, priority: priority, queue: queue) 48 scheduler.add(task: task) 49 } 50 51 override func run(packet: Packet?) -> Task? 52 { 53 return self.js.invokeMethod("run", withArguments: [packet]).toObject() as! Task? 54 } 55 56 private init(scheduler: Scheduler, priority: Priority, queue: Packet) 57 { 58 self.js = WorkerTask.constructor.construct(withArguments: [scheduler]) 59 super.init(scheduler: scheduler, priority: priority, queue: queue) 60 } 61 } 28 #include <JavaScriptCore/JSLockRefPrivate.h> -
trunk/PerformanceTests/APIBench/UpcomingAPI/RichardsMostlySwift/RichardsMostlySwift/WorkerTask.swift
r270277 r270659 32 32 let context = JSContext()! 33 33 let source = try! String(contentsOfFile: "richards.js") 34 JSLock(context.jsGlobalContextRef) 34 35 context.evaluateScript(source) 35 36 context.exceptionHandler = { context, exception in -
trunk/PerformanceTests/APIBench/UpcomingAPI/RichardsSomeC/RichardsSomeC/main.m
r270277 r270659 25 25 26 26 #import <Foundation/Foundation.h> 27 #import <JavaScriptCore/JSLockRefPrivate.h> 27 28 #import <JavaScriptCore/JavaScriptCore.h> 28 29 #import <QuartzCore/QuartzCore.h> … … 133 134 if (!context) 134 135 exit(1); 135 136 JSLock(context); 136 137 JSValueRef exception = NULL; 137 138 JSObjectRef globalObject = JSContextGetGlobalObject(context); -
trunk/PerformanceTests/APIBench/UpcomingAPI/RichardsSomeObjC/RichardsSomeObjC/main.m
r270277 r270659 25 25 26 26 #import <Foundation/Foundation.h> 27 #import <JavaScriptCore/JSLockRefPrivate.h> 27 28 #import <JavaScriptCore/JavaScriptCore.h> 28 29 #import <QuartzCore/QuartzCore.h> … … 94 95 if (!context) 95 96 exit(1); 96 97 JSLock(context.JSGlobalContextRef); 97 98 [context setObject:WorkerTask.self forKeyedSubscript:@"WorkerTask"]; 98 99 [context setExceptionHandler:^(JSContext *context, JSValue *exception) { -
trunk/PerformanceTests/APIBench/UpcomingAPI/RichardsSomeSwift/RichardsSomeSwift.xcodeproj/project.pbxproj
r270277 r270659 29 29 1401181B24998517003987A9 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; }; 30 30 1415AD1624998605005BB2E4 /* richards.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = richards.js; sourceTree = "<group>"; }; 31 145087EC258058B800D94197 /* BridgingHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BridgingHeader.h; sourceTree = "<group>"; }; 31 32 /* End PBXFileReference section */ 32 33 … … 61 62 isa = PBXGroup; 62 63 children = ( 64 145087EC258058B800D94197 /* BridgingHeader.h */, 63 65 1401181B24998517003987A9 /* main.swift */, 64 66 1415AD1624998605005BB2E4 /* richards.js */, … … 251 253 CODE_SIGN_STYLE = Automatic; 252 254 PRODUCT_NAME = "$(TARGET_NAME)"; 255 SWIFT_OBJC_BRIDGING_HEADER = RichardsSomeSwift/BridgingHeader.h; 253 256 SWIFT_VERSION = 5.0; 254 257 }; … … 260 263 CODE_SIGN_STYLE = Automatic; 261 264 PRODUCT_NAME = "$(TARGET_NAME)"; 265 SWIFT_OBJC_BRIDGING_HEADER = RichardsSomeSwift/BridgingHeader.h; 262 266 SWIFT_VERSION = 5.0; 263 267 }; -
trunk/PerformanceTests/APIBench/UpcomingAPI/RichardsSomeSwift/RichardsSomeSwift/BridgingHeader.h
r270658 r270659 24 24 */ 25 25 26 import JavaScriptCore26 #pragma once 27 27 28 class WorkerTask : Task { 29 private var js : JSValue 30 31 private static let context : JSContext = { 32 let context = JSContext()! 33 let source = try! String(contentsOfFile: "richards.js") 34 context.evaluateScript(source) 35 context.exceptionHandler = { context, exception in 36 print(exception!.toString()!) 37 exit(2) 38 } 39 return context 40 }() 41 private static let constructor : JSValue = { 42 return context.objectForKeyedSubscript("createWorkerTask").call(withArguments: [Device.A.rawValue, Device.B.rawValue, WorkPacket.SIZE]) 43 }() 44 45 static func create(scheduler: Scheduler, priority: Priority, queue: Packet) 46 { 47 let task = WorkerTask(scheduler: scheduler, priority: priority, queue: queue) 48 scheduler.add(task: task) 49 } 50 51 override func run(packet: Packet?) -> Task? 52 { 53 return self.js.invokeMethod("run", withArguments: [packet]).toObject() as! Task? 54 } 55 56 private init(scheduler: Scheduler, priority: Priority, queue: Packet) 57 { 58 self.js = WorkerTask.constructor.construct(withArguments: [scheduler]) 59 super.init(scheduler: scheduler, priority: priority, queue: queue) 60 } 61 } 28 #include <JavaScriptCore/JSLockRefPrivate.h> -
trunk/PerformanceTests/APIBench/UpcomingAPI/RichardsSomeSwift/RichardsSomeSwift/main.swift
r270277 r270659 84 84 } 85 85 86 JSLock(context.jsGlobalContextRef) 87 86 88 context.setObject(WorkerTask.self, forKeyedSubscript: "WorkerTask" as NSString) 87 89 context.exceptionHandler = { context, exception in -
trunk/PerformanceTests/APIBench/api-bench
r270277 r270659 37 37 CURRENT_API=() 38 38 UPCOMING_API=() 39 ARCHS=${ARCHS:-$(uname -m)} 39 40 40 41 shouldBuild=true … … 147 148 fi 148 149 149 log "Building $BENCHMARK_NAME... "150 xcodebuild -project "$project" -target "$BENCHMARK_NAME" -configuration Release build 150 log "Building $BENCHMARK_NAME... (FRAMEWORK_SEARCH_PATHS='$BUILD_DIRECTORY')" 151 xcodebuild -project "$project" -target "$BENCHMARK_NAME" -configuration Release build "FRAMEWORK_SEARCH_PATHS='$BUILD_DIRECTORY'" "ARCHS='$ARCHS'" 151 152 } 152 153 153 154 build() { 155 BUILD_DIRECTORY=$1 154 156 forEachBenchmark "buildBenchmark" 155 157 } … … 224 226 225 227 local score count 226 score= 1228 score=0 227 229 count=0 228 230 … … 238 240 printAverage "$benchmarkID" "$avg" 239 241 count=$((count + 1)) 240 score=$( (score * avg))242 score=$(echo "$score" "$avg" | awk '{print ($1 + log($2)) }') 241 243 done 242 244 } 243 245 printCategory "CURRENT_API" 244 246 printCategory "UPCOMING_API" 245 score=$(echo "$score" "$count" | awk '{ print(5000.0 / ($1.0 ^ (1.0 / $2))) }')247 score=$(echo "$score" "$count" | awk '{ print(5000.0 / exp($1 / $2)) }') 246 248 247 249 echo "" … … 266 268 collectFlags "$@" 267 269 collectBenchmarks 268 if [ "$shouldBuild" == true ]; then269 build270 fi271 272 270 for buildDirectory in "${BUILD_DIRECTORIES[@]}"; do 271 if [ "$shouldBuild" == true ]; then 272 build "$buildDirectory" 273 fi 274 273 275 run "$buildDirectory" 274 276 done -
trunk/PerformanceTests/ChangeLog
r270516 r270659 1 2020-12-10 Tadeu Zagallo <tzagallo@apple.com> 2 3 Add a JSC API to allow acquiring the JSLock 4 https://bugs.webkit.org/show_bug.cgi?id=219663 5 6 Reviewed by Filip Pizlo. 7 8 This patch does 3 things: 9 - Change how the geomean is calculated in api-bench to avoid overflowing 10 - Allow linking against the local build we're benchmarking 11 - Adopt the new JSLock API in the UpcomingAPI subtests 12 13 Using the new API the score improves by ~13.5%. Here are the results for each 14 of the "UpcomingAPI" subtests plus the total score: 15 16 Before After 17 RichardsMostlyC: 77ms 23ms 18 RichardsMostlyObjC: 309ms 282ms 19 RichardsMostlySwift 305ms 280ms 20 RichardsSomeC: 101ms 95ms 21 RichardsSomeObjC: 160ms 157ms 22 RichardsSomeSwift: 201ms 202ms 23 ------------------------------------------ 24 Score: 29.5974 33.6404 25 26 * APIBench/UpcomingAPI/RichardsMostlyC/RichardsMostlyC/richards.c: 27 (workfn): 28 * APIBench/UpcomingAPI/RichardsMostlyObjC/RichardsMostlyObjC.xcodeproj/xcshareddata/xcschemes/RichardsMostlyObjC.xcscheme: Renamed from PerformanceTests/APIBench/UpcomingAPI/RichardsMostlyObjC/RichardsMostlyObjC.xcodeproj/xcshareddata/xcschemes/RichardsMostlySwift.xcscheme. 29 * APIBench/UpcomingAPI/RichardsMostlyObjC/RichardsMostlyObjC/WorkerTask.m: 30 (+[WorkerTask context]): 31 * APIBench/UpcomingAPI/RichardsMostlySwift/RichardsMostlySwift.xcodeproj/project.pbxproj: 32 * APIBench/UpcomingAPI/RichardsMostlySwift/RichardsMostlySwift/BridgingHeader.h: Copied from PerformanceTests/APIBench/UpcomingAPI/RichardsMostlySwift/RichardsMostlySwift/WorkerTask.swift. 33 * APIBench/UpcomingAPI/RichardsMostlySwift/RichardsMostlySwift/WorkerTask.swift: 34 * APIBench/UpcomingAPI/RichardsSomeC/RichardsSomeC/main.m: 35 (main): 36 * APIBench/UpcomingAPI/RichardsSomeObjC/RichardsSomeObjC/main.m: 37 (main): 38 * APIBench/UpcomingAPI/RichardsSomeSwift/RichardsSomeSwift.xcodeproj/project.pbxproj: 39 * APIBench/UpcomingAPI/RichardsSomeSwift/RichardsSomeSwift/BridgingHeader.h: Copied from PerformanceTests/APIBench/UpcomingAPI/RichardsMostlySwift/RichardsMostlySwift/WorkerTask.swift. 40 * APIBench/UpcomingAPI/RichardsSomeSwift/RichardsSomeSwift/main.swift: 41 * APIBench/api-bench: 42 1 43 2020-12-07 Don Olmstead <don.olmstead@sony.com> 2 44 -
trunk/Source/JavaScriptCore/API/JSValueRef.cpp
r261895 r270659 30 30 #include "APIUtils.h" 31 31 #include "DateInstance.h" 32 #include "JSAPIWrapperObject.h" 32 33 #include "JSCInlines.h" 33 34 #include "JSCallbackObject.h" -
trunk/Source/JavaScriptCore/ChangeLog
r270652 r270659 1 2020-12-10 Tadeu Zagallo <tzagallo@apple.com> 2 3 Add a JSC API to allow acquiring the JSLock 4 https://bugs.webkit.org/show_bug.cgi?id=219663 5 6 Reviewed by Filip Pizlo. 7 8 Introduce two new functions to the C API: JSLock and JSUnlock. These 9 functions allow users to take control of the JSContext's lock, which 10 can greatly reduce the overhead of bridging between JS and native. 11 12 * API/JSLockRef.cpp: Added. 13 (JSLock): 14 (JSUnlock): 15 * API/JSLockRefPrivate.h: Added. 16 * API/JSValueRef.cpp: 17 * JavaScriptCore.xcodeproj/project.pbxproj: 18 * Sources.txt: 19 1 20 2020-12-10 Don Olmstead <don.olmstead@sony.com> 2 21 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r270552 r270659 810 810 147B83AC0E6DB8C9004775A4 /* BatchedTransitionOptimizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 147B83AA0E6DB8C9004775A4 /* BatchedTransitionOptimizer.h */; settings = {ATTRIBUTES = (Private, ); }; }; 811 811 147B84630E6DE6B1004775A4 /* PutPropertySlot.h in Headers */ = {isa = PBXBuildFile; fileRef = 147B84620E6DE6B1004775A4 /* PutPropertySlot.h */; settings = {ATTRIBUTES = (Private, ); }; }; 812 1486A8C024ABED480073922D /* JSLockRefPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1486A8BF24ABED3C0073922D /* JSLockRefPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 812 813 14874AE615EBDE4A002E3587 /* JSScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 14874AE215EBDE4A002E3587 /* JSScope.h */; settings = {ATTRIBUTES = (Private, ); }; }; 813 814 148A7BF01B82975A002D9157 /* InlineCallFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 148A7BEE1B82975A002D9157 /* InlineCallFrame.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 3416 3417 1482B7E10A43076000517CFC /* JSObjectRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSObjectRef.h; sourceTree = "<group>"; }; 3417 3418 1482B7E20A43076000517CFC /* JSObjectRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSObjectRef.cpp; sourceTree = "<group>"; }; 3419 1486A8BE24ABED3B0073922D /* JSLockRef.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSLockRef.cpp; sourceTree = "<group>"; }; 3420 1486A8BF24ABED3C0073922D /* JSLockRefPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSLockRefPrivate.h; sourceTree = "<group>"; }; 3418 3421 14874AE115EBDE4A002E3587 /* JSScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScope.cpp; sourceTree = "<group>"; }; 3419 3422 14874AE215EBDE4A002E3587 /* JSScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScope.h; sourceTree = "<group>"; }; … … 6486 6489 0F0CAEF91EC4DA6200970D12 /* JSHeapFinalizerPrivate.cpp */, 6487 6490 0F0CAEFA1EC4DA6200970D12 /* JSHeapFinalizerPrivate.h */, 6491 1486A8BE24ABED3B0073922D /* JSLockRef.cpp */, 6492 1486A8BF24ABED3C0073922D /* JSLockRefPrivate.h */, 6488 6493 C25D709A16DE99F400FCA6BC /* JSManagedValue.h */, 6489 6494 C25D709916DE99F400FCA6BC /* JSManagedValue.mm */, … … 10043 10048 BC18C4160E16F5CD00B34460 /* JSLexicalEnvironment.h in Headers */, 10044 10049 BC18C4230E16F5CD00B34460 /* JSLock.h in Headers */, 10050 1486A8C024ABED480073922D /* JSLockRefPrivate.h in Headers */, 10045 10051 C25D709C16DE99F400FCA6BC /* JSManagedValue.h in Headers */, 10046 10052 2A4BB7F318A41179008A0FCD /* JSManagedValueInternal.h in Headers */, -
trunk/Source/JavaScriptCore/Sources.txt
r269706 r270659 32 32 API/JSContextRef.cpp 33 33 API/JSHeapFinalizerPrivate.cpp 34 API/JSLockRef.cpp 34 35 API/JSMarkingConstraintPrivate.cpp 35 36 API/JSObjectRef.cpp
Note: See TracChangeset
for help on using the changeset viewer.