Debian Codegraph @

src/3rdparty/javascriptcore/JavaScriptCore/API/JSContextRef.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #include "config.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/config.h`/
27 #include "JSContextRef.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/API/JSContextRef.h`/
28 #include "JSContextRefPrivate.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/API/JSContextRefPrivate.h`/
29
30 #include "APICast.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/API/APICast.h`/
31 #include "InitializeThreading.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/InitializeThreading.h`/
32 #include "JSCallbackObject.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackObject.h`/
33 #include "JSClassRef.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/API/JSClassRef.h`/
34 #include "JSGlobalObject.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObject.h`/
35 #include "JSObject.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSObject.h`/
36 #include <wtf/Platform.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h`/
37
38 #if OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(DARWIN)
39 #include <mach-o/dyld.h>
40
41 static const int32_t webkitFirstVersionWithConcurrentGlobalContexts = 0x2100500; // 528.5.0
42 #endif
43
44 using namespace JSCcxx . . $ `<built-in>:463:9`!;
45
46 JSContextGroupRefcxx . . $ JSContextGroupRef# JSContextGroupCreatecxx . . $ JSContextGroupCreate(3786b7b0c7c5013c).()
47 {
48 initializeThreadingcxx . . $ QTJSC/initializeThreading(49f6e7a06ebc5aa8).();
49 return toRefcxx . . $ toRef(c44cefdcd7666f07).(JSGlobalDatacxx . . $ QTJSC/JSGlobalData#::createNonDefaultcxx . . $ QTJSC/JSGlobalData#createNonDefault(a01f03c419565429).().releaseRef());
50 }
51
52 JSContextGroupRefcxx . . $ JSContextGroupRef# JSContextGroupRetaincxx . . $ JSContextGroupRetain(49b42dc1bd32b006).(JSContextGroupRefcxx . . $ JSContextGroupRef# group)
53 {
54 toJScxx . . $ toJS(dd2920ba27487f28).(group)->ref();
55 return group;
56 }
57
58 void JSContextGroupReleasecxx . . $ JSContextGroupRelease(a0b1b5247e58fc29).(JSContextGroupRefcxx . . $ JSContextGroupRef# group)
59 {
60 toJScxx . . $ toJS(dd2920ba27487f28).(group)->deref();
61 }
62
63 JSGlobalContextRefcxx . . $ JSGlobalContextRef# JSGlobalContextCreatecxx . . $ JSGlobalContextCreate(81cd0d69b93bf733).(JSClassRefcxx . . $ JSClassRef# globalObjectClass)
64 {
65 initializeThreadingcxx . . $ QTJSC/initializeThreading(49f6e7a06ebc5aa8).();
66 #if OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(DARWIN)
67 // When running on Tiger or Leopard, or if the application was linked before JSGlobalContextCreate was changed
68 // to use a unique JSGlobalData, we use a shared one for compatibility.
69 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
70 if (NSVersionOfLinkTimeLibrary("JavaScriptCore") <= webkitFirstVersionWithConcurrentGlobalContexts) {
71 #else
72 {
73 #endif
74 JSLock lock(LockForReal);
75 return JSGlobalContextCreateInGroup(toRef(&JSGlobalData::sharedInstance()), globalObjectClass);
76 }
77 #endif // OS(DARWIN)
78
79 return JSGlobalContextCreateInGroup(0, globalObjectClass);
80 }
81
82 JSGlobalContextRefcxx . . $ JSGlobalContextRef# JSGlobalContextCreateInGroupcxx . . $ JSGlobalContextCreateInGroup(17ad67137ee6a1cd).(JSContextGroupRefcxx . . $ JSContextGroupRef# group, JSClassRefcxx . . $ JSClassRef# globalObjectClass)
83 {
84 initializeThreadingcxx . . $ QTJSC/initializeThreading(49f6e7a06ebc5aa8).();
85
86 JSLockcxx . . $ QTJSC/JSLock# lockcxx . . $ QTJSC/JSLock#JSLock(a237af5886395a97).(LockForRealcxx . . $ QTJSC/LockForReal.);
87 RefPtrcxx . . $ RefPtr#<JSGlobalDatacxx . . $ QTJSC/JSGlobalData#> globalData = group ? PassRefPtr<JSGlobalData>(toJS(group)) : JSGlobalData::createNonDefault();
88
89 APIEntryShimcxx . . $ QTJSC/APIEntryShim# entryShim(globalData.get(), false);
90
91 #if ENABLEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:57:9`!(JSC_MULTIPLE_THREADS)
92 globalData->makeUsableFromMultipleThreads();
93 #endif
94
95 if (!globalObjectClass) {
96 JSGlobalObjectcxx . . $ QTJSC/JSGlobalObject#* globalObject = new (globalData.get()) JSGlobalObjectcxx . . $ QTJSC/JSGlobalObject#JSGlobalObject(49f6e7a06ebc5aa8).;
97 return JSGlobalContextRetain(toGlobalRefcxx . . $ toGlobalRef(7c36b1a9a86a63ea).(globalObject->globalExeccxx . . $ QTJSC/JSGlobalObject#globalExec(27c3d7386a195136).()));
98 }
99
100 JSGlobalObjectcxx . . $ QTJSC/JSGlobalObject#* globalObject = new (globalData.get()) JSCallbackObject<JSGlobalObject>(globalObjectClass);
101 ExecStatecxx . . $ QTJSC/ExecState#* exec = globalObject->globalExeccxx . . $ QTJSC/JSGlobalObject#globalExec(27c3d7386a195136).();
102 JSValuecxx . . $ QTJSC/JSValue# prototype = globalObjectClass->prototypecxx . . $ OpaqueJSClass#prototype(dc025d143f56633c).(exec);
103 if (!prototype)
104 prototype =cxx . . $ QTJSC/JSValue#`operator=`(5dfb8b6405afb35f). jsNullcxx . . $ QTJSC/jsNull(ad9afe69d7bf6378).();
105 globalObject->resetPrototypecxx . . $ QTJSC/JSGlobalObject#resetPrototype(5c2ac18db087b3e6).(prototype);
106 return JSGlobalContextRetain(toGlobalRefcxx . . $ toGlobalRef(7c36b1a9a86a63ea).(exec));
107 }
108
109 JSGlobalContextRefcxx . . $ JSGlobalContextRef# JSGlobalContextRetaincxx . . $ JSGlobalContextRetain(fbc2faca2d87e5d0).(JSGlobalContextRefcxx . . $ JSGlobalContextRef# ctx)
110 {
111 ExecStatecxx . . $ QTJSC/ExecState#* exec = toJScxx . . $ toJS(9aa0b3d2bc733a67).(ctx);
112 APIEntryShimcxx . . $ QTJSC/APIEntryShim# entryShimcxx . . $ QTJSC/APIEntryShim#APIEntryShim(8ab7e31759e06129).(exec);
113
114 JSGlobalDatacxx . . $ QTJSC/JSGlobalData#& globalData = exec->globalDatacxx . . $ QTJSC/ExecState#globalData(ae00a65ac2fd4a61).();
115 gcProtectcxx . . $ QTJSC/gcProtect(c6d88d3bdacccd64).(exec->dynamicGlobalObjectcxx . . $ QTJSC/ExecState#dynamicGlobalObject(4418983463e2bc6a).());
116 globalData.ref();
117 return ctx;
118 }
119
120 void JSGlobalContextReleasecxx . . $ JSGlobalContextRelease(85ea12e6f88fea4c).(JSGlobalContextRefcxx . . $ JSGlobalContextRef# ctx)
121 {
122 ExecStatecxx . . $ QTJSC/ExecState#* exec = toJScxx . . $ toJS(9aa0b3d2bc733a67).(ctx);
123 APIEntryShimcxx . . $ QTJSC/APIEntryShim# entryShimcxx . . $ QTJSC/APIEntryShim#APIEntryShim(8ab7e31759e06129).(exec, false);
124
125 gcUnprotectcxx . . $ QTJSC/gcUnprotect(c6d88d3bdacccd64).(exec->dynamicGlobalObjectcxx . . $ QTJSC/ExecState#dynamicGlobalObject(4418983463e2bc6a).());
126
127 JSGlobalDatacxx . . $ QTJSC/JSGlobalData#& globalData = exec->globalDatacxx . . $ QTJSC/ExecState#globalData(ae00a65ac2fd4a61).();
128 if (globalData.refCount() ==cxx . . $ `operator==`(8f8a8e6a6f1fc74b). 2) { // One reference is held by JSGlobalObject, another added by JSGlobalContextRetain().
129 // The last reference was released, this is our last chance to collect.
130 globalData.heap.destroy();
131 } else
132 globalData.heap.collectAllGarbage();
133
134 globalData.deref();
135 }
136
137 JSObjectRefcxx . . $ JSObjectRef# JSContextGetGlobalObjectcxx . . $ JSContextGetGlobalObject(6b3e98187579417c).(JSContextRefcxx . . $ JSContextRef# ctx)
138 {
139 ExecStatecxx . . $ QTJSC/ExecState#* exec = toJScxx . . $ toJS(f59d9eed7d59fe2c).(ctx);
140 APIEntryShimcxx . . $ QTJSC/APIEntryShim# entryShimcxx . . $ QTJSC/APIEntryShim#APIEntryShim(8ab7e31759e06129).(exec);
141
142 // It is necessary to call toThisObject to get the wrapper object when used with WebCore.
143 return toRefcxx . . $ toRef(c44cefdcd7666f07).(exec->lexicalGlobalObjectcxx . . $ QTJSC/ExecState#lexicalGlobalObject(3d50c730b5e26899).()->toThisObjectcxx . . $ QTJSC/JSObject#toThisObject(8709ed4849a165ab).(exec));
144 }
145
146 JSContextGroupRefcxx . . $ JSContextGroupRef# JSContextGetGroupcxx . . $ JSContextGetGroup(b09bf87ec7282a55).(JSContextRefcxx . . $ JSContextRef# ctx)
147 {
148 ExecStatecxx . . $ QTJSC/ExecState#* exec = toJScxx . . $ toJS(f59d9eed7d59fe2c).(ctx);
149 return toRefcxx . . $ toRef(c44cefdcd7666f07).(&exec->globalDatacxx . . $ QTJSC/ExecState#globalData(ae00a65ac2fd4a61).());
150 }
151
152 JSGlobalContextRefcxx . . $ JSGlobalContextRef# JSContextGetGlobalContextcxx . . $ JSContextGetGlobalContext(43c29c1e1a0697c3).(JSContextRefcxx . . $ JSContextRef# ctx)
153 {
154 ExecStatecxx . . $ QTJSC/ExecState#* exec = toJScxx . . $ toJS(f59d9eed7d59fe2c).(ctx);
155 APIEntryShimcxx . . $ QTJSC/APIEntryShim# entryShimcxx . . $ QTJSC/APIEntryShim#APIEntryShim(8ab7e31759e06129).(exec);
156
157 return toGlobalRefcxx . . $ toGlobalRef(7c36b1a9a86a63ea).(exec->lexicalGlobalObjectcxx . . $ QTJSC/ExecState#lexicalGlobalObject(3d50c730b5e26899).()->globalExeccxx . . $ QTJSC/JSGlobalObject#globalExec(27c3d7386a195136).());
158 }