Changeset 182661 in webkit
- Timestamp:
- Apr 11, 2015 12:43:34 PM (9 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/tests/testapi.mm
r182336 r182661 485 485 } 486 486 487 void testObjectiveCAPI() 488 { 489 NSLog(@"Testing Objective-C API"); 487 // This test is flaky. Since GC marks C stack and registers as roots conservatively, 488 // objects not referenced logically can be accidentally marked and alive. 489 // To avoid this situation as possible as we can, 490 // 1. run this test first before stack is polluted, 491 // 2. extract this test as a function to suppress stack height. 492 static void testWeakValue() 493 { 494 @autoreleasepool { 495 JSVirtualMachine *vm = [[JSVirtualMachine alloc] init]; 496 TestObject *testObject = [TestObject testObject]; 497 JSManagedValue *weakValue; 498 @autoreleasepool { 499 JSContext *context = [[JSContext alloc] initWithVirtualMachine:vm]; 500 context[@"testObject"] = testObject; 501 weakValue = [[JSManagedValue alloc] initWithValue:context[@"testObject"]]; 502 } 503 504 @autoreleasepool { 505 JSContext *context = [[JSContext alloc] initWithVirtualMachine:vm]; 506 context[@"testObject"] = testObject; 507 JSSynchronousGarbageCollectForDebugging([context JSGlobalContextRef]); 508 checkResult(@"weak value == nil", ![weakValue value]); 509 checkResult(@"root is still alive", !context[@"testObject"].isUndefined); 510 } 511 } 512 } 513 514 static void testObjectiveCAPIMain() 515 { 490 516 @autoreleasepool { 491 517 JSVirtualMachine* vm = [[JSVirtualMachine alloc] init]; … … 1060 1086 JSValue *result = [context evaluateScript:@"didClick"]; 1061 1087 checkResult(@"Event handler onclick doesn't fire", ![result toBool]); 1062 }1063 }1064 1065 @autoreleasepool {1066 JSVirtualMachine *vm = [[JSVirtualMachine alloc] init];1067 TestObject *testObject = [TestObject testObject];1068 JSManagedValue *weakValue;1069 @autoreleasepool {1070 JSContext *context = [[JSContext alloc] initWithVirtualMachine:vm];1071 context[@"testObject"] = testObject;1072 weakValue = [[JSManagedValue alloc] initWithValue:context[@"testObject"]];1073 }1074 1075 @autoreleasepool {1076 JSContext *context = [[JSContext alloc] initWithVirtualMachine:vm];1077 context[@"testObject"] = testObject;1078 JSSynchronousGarbageCollectForDebugging([context JSGlobalContextRef]);1079 checkResult(@"weak value == nil", ![weakValue value]);1080 checkResult(@"root is still alive", !context[@"testObject"].isUndefined);1081 1088 } 1082 1089 } … … 1410 1417 } 1411 1418 1419 void testObjectiveCAPI() 1420 { 1421 NSLog(@"Testing Objective-C API"); 1422 testWeakValue(); 1423 testObjectiveCAPIMain(); 1424 } 1425 1412 1426 #else 1413 1427 -
trunk/Source/JavaScriptCore/ChangeLog
r182660 r182661 1 2015-04-11 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 Run flaky conservative GC related test first before polluting stack and registers 4 https://bugs.webkit.org/show_bug.cgi?id=143634 5 6 Reviewed by Ryosuke Niwa. 7 8 After r182653, JSC API tests fail. However, it's not related to the change. 9 After investigating the cause of this failure, I've found that the failed test is flaky 10 because JSC's GC is conservative. If previously allocated JSGlobalObject is accidentally alive 11 due to conservative roots in C stack and registers, this test fails. 12 13 Since GC marks C stack and registers as roots conservatively, 14 objects not referenced logically can be accidentally marked and alive. 15 To avoid this situation as possible as we can, 16 1. run this test first before stack is polluted, 17 2. extract this test as a function to suppress stack height. 18 19 * API/tests/testapi.mm: 20 (testWeakValue): 21 (testObjectiveCAPIMain): 22 (testObjectiveCAPI): 23 1 24 2015-04-11 Matt Baker <mattbaker@apple.com> 2 25
Note: See TracChangeset
for help on using the changeset viewer.