Changeset 232936 in webkit
- Timestamp:
- Jun 18, 2018 11:49:01 AM (6 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSWrapperMap.mm
r229410 r232936 368 368 JSC::Weak<JSC::JSObject> m_prototype; 369 369 JSC::Weak<JSC::JSObject> m_constructor; 370 JSC::Weak<JSC::Structure> m_structure; 370 371 } 371 372 … … 518 519 } 519 520 520 JSC::JSObject* prototype = [self prototypeInContext:context]; 521 522 JSC::JSObject* wrapper = makeWrapper([context JSGlobalContextRef], m_classRef, object); 523 JSObjectSetPrototype([context JSGlobalContextRef], toRef(wrapper), toRef(prototype)); 521 JSC::Structure* structure = [self structureInContext:context]; 522 523 JSC::ExecState* exec = toJS([context JSGlobalContextRef]); 524 JSC::VM& vm = exec->vm(); 525 JSC::JSLockHolder locker(vm); 526 527 JSC::JSCallbackObject<JSC::JSAPIWrapperObject>* wrapper = JSC::JSCallbackObject<JSC::JSAPIWrapperObject>::create(exec, exec->lexicalGlobalObject(), structure, m_classRef, 0); 528 wrapper->setWrappedObject(object); 524 529 return wrapper; 525 530 } … … 541 546 ASSERT(!!prototype); 542 547 return prototype; 548 } 549 550 - (JSC::Structure*)structureInContext:(JSContext *)context 551 { 552 JSC::Structure* structure = m_structure.get(); 553 if (structure) 554 return structure; 555 556 JSC::ExecState* exec = toJS([context JSGlobalContextRef]); 557 JSC::JSGlobalObject* globalObject = toJSGlobalObject([context JSGlobalContextRef]); 558 JSC::JSObject* prototype = [self prototypeInContext:context]; 559 m_structure = JSC::JSCallbackObject<JSC::JSAPIWrapperObject>::createStructure(exec->vm(), globalObject, prototype); 560 561 return m_structure.get(); 543 562 } 544 563 -
trunk/Source/JavaScriptCore/API/tests/testapi.mm
r231938 r232936 30 30 #import "JSExportTests.h" 31 31 #import "JSVirtualMachinePrivate.h" 32 #import "JSWrapperMapTests.h" 32 33 #import "Regress141275.h" 33 34 #import "Regress141809.h" … … 1476 1477 runDateTests(); 1477 1478 runJSExportTests(); 1479 runJSWrapperMapTests(); 1478 1480 runRegress141275(); 1479 1481 runRegress141809(); -
trunk/Source/JavaScriptCore/ChangeLog
r232934 r232936 1 2018-06-18 Tadeu Zagallo <tzagallo@apple.com> 2 3 Share structure across instances of classes exported through the ObjC API 4 https://bugs.webkit.org/show_bug.cgi?id=186579 5 <rdar://problem/40969212> 6 7 Reviewed by Saam Barati. 8 9 A new structure was being created for each instance of exported ObjC 10 classes due to setting the prototype in the structure for every object, 11 since prototype transitions are not cached by the structure. Cache the 12 Structure in the JSObjcClassInfo to avoid the transition. 13 14 * API/JSWrapperMap.mm: 15 (-[JSObjCClassInfo wrapperForObject:inContext:]): 16 (-[JSObjCClassInfo structureInContext:]): 17 * API/tests/JSWrapperMapTests.h: Added. 18 * API/tests/JSWrapperMapTests.mm: Added. 19 (+[JSWrapperMapTests testStructureIdentity]): 20 (runJSWrapperMapTests): 21 * API/tests/testapi.mm: 22 (testObjectiveCAPIMain): 23 * JavaScriptCore.xcodeproj/project.pbxproj: 24 1 25 2018-06-18 Michael Saboff <msaboff@apple.com> 2 26 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r232664 r232936 763 763 144836E7132DA7BE005BE785 /* ConservativeRoots.h in Headers */ = {isa = PBXBuildFile; fileRef = 149DAAF212EB559D0083B12B /* ConservativeRoots.h */; settings = {ATTRIBUTES = (Private, ); }; }; 764 764 145722861437E140005FDE26 /* StrongInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 145722851437E140005FDE26 /* StrongInlines.h */; settings = {ATTRIBUTES = (Private, ); }; }; 765 1471483020D323D30090E630 /* JSWrapperMapTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1471482F20D323650090E630 /* JSWrapperMapTests.mm */; }; 765 766 147341CC1DC02D7200AA29BA /* ExecutableBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 147341CB1DC02D7200AA29BA /* ExecutableBase.h */; settings = {ATTRIBUTES = (Private, ); }; }; 766 767 147341CE1DC02D7900AA29BA /* ScriptExecutable.h in Headers */ = {isa = PBXBuildFile; fileRef = 147341CD1DC02D7900AA29BA /* ScriptExecutable.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 3084 3085 146FA5A81378F6B0003627A3 /* HandleTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HandleTypes.h; sourceTree = "<group>"; }; 3085 3086 146FE51111A710430087AE66 /* JITCall32_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITCall32_64.cpp; sourceTree = "<group>"; }; 3087 1471482E20D323640090E630 /* JSWrapperMapTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSWrapperMapTests.h; path = API/tests/JSWrapperMapTests.h; sourceTree = "<group>"; }; 3088 1471482F20D323650090E630 /* JSWrapperMapTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = JSWrapperMapTests.mm; path = API/tests/JSWrapperMapTests.mm; sourceTree = "<group>"; }; 3086 3089 147341CB1DC02D7200AA29BA /* ExecutableBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExecutableBase.h; sourceTree = "<group>"; }; 3087 3090 147341CD1DC02D7900AA29BA /* ScriptExecutable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptExecutable.h; sourceTree = "<group>"; }; … … 5433 5436 5C4E8E941DBEBDA20036F1FC /* JSONParseTest.cpp */, 5434 5437 5C4E8E951DBEBDA20036F1FC /* JSONParseTest.h */, 5438 1471482E20D323640090E630 /* JSWrapperMapTests.h */, 5439 1471482F20D323650090E630 /* JSWrapperMapTests.mm */, 5435 5440 144005170A531CB50005F061 /* minidom */, 5436 5441 FEF49AA91EB947FE00653BDB /* MultithreadedMultiVMExecutionTest.cpp */, … … 10155 10160 0FF47C5A1EBFE84600F280B7 /* JSObjectGetProxyTargetTest.cpp in Sources */, 10156 10161 5C4E8E961DBEBE620036F1FC /* JSONParseTest.cpp in Sources */, 10162 1471483020D323D30090E630 /* JSWrapperMapTests.mm in Sources */, 10157 10163 FEF49AAB1EB9484B00653BDB /* MultithreadedMultiVMExecutionTest.cpp in Sources */, 10158 10164 FE7C41961B97FC4B00F4D598 /* PingPongStackOverflowTest.cpp in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.