source: webkit/trunk/Source/JavaScriptCore/Target.pri@ 113141

Last change on this file since 113141 was 113141, checked in by [email protected], 13 years ago

First step toward incremental Weak<T> finalization
https://bugs.webkit.org/show_bug.cgi?id=82670

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

This patch implements a Weak<T> heap that is compatible with incremental
finalization, while making as few behavior changes as possible. The behavior
changes it makes are:

(*) Weak<T>'s raw JSValue no longer reverts to JSValue() automatically --
instead, a separate flag indicates that the JSValue is no longer valid.
(This is required so that the JSValue can be preserved for later finalization.)
Objects dealing with WeakImpls directly must change to check the flag.

(*) Weak<T> is no longer a subclass of Handle<T>.

(*) DOM GC performance is different -- 9% faster in the geometric mean,
but 15% slower in one specific case:

gc-dom1.html: 6% faster
gc-dom2.html: 23% faster
gc-dom3.html: 17% faster
gc-dom4.html: 15% *slower*

The key features of this new heap are:

(*) Each block knows its own state, independent of any other blocks.

(*) Each block caches its own sweep result.

(*) The heap visits dead Weak<T>s at the end of GC. (It doesn't
mark them yet, since that would be a behavior change.)

  • API/JSCallbackObject.cpp:

(JSC::JSCallbackObjectData::finalize):

  • API/JSCallbackObjectFunctions.h:

(JSC::::init): Updated to use the new WeakHeap API.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • JavaScriptCore.gypi:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Target.pri: Paid the build system tax since I added some new files.
  • heap/Handle.h: Made WeakBlock a friend and exposed slot() as public,

so we can keep passing a Handle<T> to finalizers, to avoid more surface
area change in this patch. A follow-up patch should change the type we
pass to finalizers.

  • heap/HandleHeap.cpp:

(JSC):
(JSC::HandleHeap::writeBarrier):
(JSC::HandleHeap::isLiveNode):

  • heap/HandleHeap.h:

(JSC):
(HandleHeap):
(Node):
(JSC::HandleHeap::Node::Node): Removed all code related to Weak<T>, since
we have a separate WeakHeap now.

  • heap/Heap.cpp:

(JSC::Heap::Heap): Removed m_extraCost because extra cost is accounted
for through our watermark now. Removed m_waterMark because it was unused.

(JSC::Heap::destroy): Updated for addition of WeakHeap.

(JSC::Heap::reportExtraMemoryCostSlowCase): Changed from using its own
variable to participating in the watermark strategy. I wanted to standardize
WeakHeap and all other Heap clients on this strategy, to make sure it's
accurate.

(JSC::Heap::markRoots): Updated for addition of WeakHeap. Added WeakHeap
dead visit pass, as explained above.

(JSC::Heap::collect):
(JSC::Heap::resetAllocators): Updated for addition of WeakHeap.

(JSC::Heap::addFinalizer):
(JSC::Heap::FinalizerOwner::finalize): Updated for new Weak<T> API.

  • heap/Heap.h:

(JSC::Heap::weakHeap):
(Heap):
(JSC::Heap::addToWaterMark): Added a way to participate in the watermarking
strategy, since this is the best way for WeakHeap to report its memory
cost. (I plan to update this in a follow-up patch to make it more accurate,
but for now it is not less accurate than it used to be.)

  • heap/MarkedSpace.cpp:

(JSC::MarkedSpace::MarkedSpace):
(JSC::MarkedSpace::resetAllocators):

  • heap/MarkedSpace.h:

(MarkedSpace):
(JSC::MarkedSpace::addToWaterMark):
(JSC::MarkedSpace::didConsumeFreeList): Removed m_nurseryWaterMark because
it was unused, and I didn't want to update WeakHeap to keep an usused
variable working. Added API for above.

  • heap/PassWeak.h:

(JSC):
(WeakImplAccessor):
(PassWeak):
(JSC::::operator):
(JSC::::get):
(JSC::::was):
(JSC::::PassWeak):
(JSC::::~PassWeak):
(JSC::UnspecifiedBoolType):
(JSC::::leakImpl):
(JSC::adoptWeak):

  • heap/Strong.h:

(JSC::Strong::operator!):
(Strong):
(JSC::Strong::operator UnspecifiedBoolType*):
(JSC::Strong::get):

  • heap/Weak.h:

(Weak):
(JSC::::Weak):
(JSC):
(JSC::::isHashTableDeletedValue):
(JSC::::~Weak):
(JSC::::swap):
(JSC::=):
(JSC::::operator):
(JSC::UnspecifiedBoolType):
(JSC::::release):
(JSC::::clear):
(JSC::::hashTableDeletedValue): Lots of code changes here, but they boil
down to two things:

(*) Allocate WeakImpls from the WeakHeap instead of Handles from the HandleHeap.

(*) Explicitly check WeakImpl::state() for non-liveness before returning
a value (explained above).

These files implement the new Weak<T> heap behavior described above:

  • heap/WeakBlock.cpp: Added.
  • heap/WeakBlock.h: Added.
  • heap/WeakHandleOwner.cpp: Added.
  • heap/WeakHandleOwner.h: Added.
  • heap/WeakHeap.cpp: Added.
  • heap/WeakHeap.h: Added.
  • heap/WeakImpl.h: Added.

One interesting difference from the old heap is that we don't allow
clients to overwrite a WeakImpl after allocating it, and we don't recycle
WeakImpls prior to garbage collection. This is required for lazy finalization,
but it will also help us esablish a useful invariant in the future: allocating
a WeakImpl will be a binding contract to run a finalizer at some point in the
future, even if the WeakImpl is later deallocated.

  • jit/JITStubs.cpp:

(JSC::JITThunks::hostFunctionStub): Check the Weak<T> for ! instead of
its JSValue, since that's our API contract now, and the JSValue might
be stale.

  • runtime/JSCell.h:

(JSC::jsCast): Allow casting NULL pointers because it's useful and harmless.

  • runtime/Structure.cpp:

(JSC::StructureTransitionTable::add): I can't remember why I did this.

  • runtime/StructureTransitionTable.h:
  • runtime/WeakGCMap.h: I had to update these classes because they allocate

and deallocate weak pointers manually. They should probably stop doing that.

Source/WebCore:

Updated WebCore for Weak<T> API changes.

  • bindings/js/DOMWrapperWorld.cpp:

(WebCore::JSStringOwner::finalize): We're not allowed to get() a dead Weak<T>
anymore, so use the debug-only was() helper function instead.

  • bindings/js/JSDOMBinding.h:

(WebCore::uncacheWrapper): Ditto.

  • bindings/js/JSNodeCustom.h:

(WebCore::setInlineCachedWrapper):
(WebCore::clearInlineCachedWrapper): We're not allowed to get() a dead
Weak<T>, so I had to push down these ASSERTs into ScriptWrappable.

  • bindings/js/JSNodeFilterCondition.cpp:

(WebCore::JSNodeFilterCondition::acceptNode): Updated for non-Handle-ness
of Weak<T>.

  • bindings/js/ScriptWrappable.h:

(WebCore::ScriptWrappable::setWrapper):
(WebCore::ScriptWrappable::clearWrapper): Use was(), as above.

Source/WebKit2:

Updated for API change.

  • WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:

(WebKit::NPRuntimeObjectMap::finalize):

File size: 7.6 KB
Line 
1# -------------------------------------------------------------------
2# Target file for the JavaScriptSource library
3#
4# See 'Tools/qmake/README' for an overview of the build system
5# -------------------------------------------------------------------
6
7TEMPLATE = lib
8TARGET = JavaScriptCore
9
10include(JavaScriptCore.pri)
11
12WEBKIT += wtf
13QT += core
14QT -= gui
15
16CONFIG += staticlib
17
18*-g++*:QMAKE_CXXFLAGS_RELEASE -= -O2
19*-g++*:QMAKE_CXXFLAGS_RELEASE += -O3
20
21# Rules when JIT enabled (not disabled)
22!contains(DEFINES, ENABLE_JIT=0) {
23 linux*-g++*:greaterThan(QT_GCC_MAJOR_VERSION,3):greaterThan(QT_GCC_MINOR_VERSION,0) {
24 QMAKE_CXXFLAGS += -fno-stack-protector
25 QMAKE_CFLAGS += -fno-stack-protector
26 }
27}
28
29wince* {
30 SOURCES += $$QT_SOURCE_TREE/src/3rdparty/ce-compat/ce_time.c
31}
32
33include(yarr/yarr.pri)
34
35INSTALLDEPS += all
36
37SOURCES += \
38 API/JSBase.cpp \
39 API/JSCallbackConstructor.cpp \
40 API/JSCallbackFunction.cpp \
41 API/JSCallbackObject.cpp \
42 API/JSClassRef.cpp \
43 API/JSContextRef.cpp \
44 API/JSObjectRef.cpp \
45 API/JSStringRef.cpp \
46 API/JSValueRef.cpp \
47 API/OpaqueJSString.cpp \
48 assembler/ARMAssembler.cpp \
49 assembler/ARMv7Assembler.cpp \
50 assembler/MacroAssemblerARM.cpp \
51 assembler/MacroAssemblerSH4.cpp \
52 bytecode/CallLinkInfo.cpp \
53 bytecode/CallLinkStatus.cpp \
54 bytecode/CodeBlock.cpp \
55 bytecode/DFGExitProfile.cpp \
56 bytecode/ExecutionCounter.cpp \
57 bytecode/GetByIdStatus.cpp \
58 bytecode/JumpTable.cpp \
59 bytecode/LazyOperandValueProfile.cpp \
60 bytecode/MethodCallLinkInfo.cpp \
61 bytecode/MethodCallLinkStatus.cpp \
62 bytecode/MethodOfGettingAValueProfile.cpp \
63 bytecode/Opcode.cpp \
64 bytecode/PolymorphicPutByIdList.cpp \
65 bytecode/PredictedType.cpp \
66 bytecode/PutByIdStatus.cpp \
67 bytecode/SamplingTool.cpp \
68 bytecode/StructureStubInfo.cpp \
69 bytecompiler/BytecodeGenerator.cpp \
70 bytecompiler/NodesCodegen.cpp \
71 heap/CopiedSpace.cpp \
72 heap/ConservativeRoots.cpp \
73 heap/DFGCodeBlocks.cpp \
74 heap/WeakHeap.cpp \
75 heap/WeakHandleOwner.cpp \
76 heap/WeakBlock.cpp \
77 heap/HandleHeap.cpp \
78 heap/HandleStack.cpp \
79 heap/Heap.cpp \
80 heap/MachineStackMarker.cpp \
81 heap/MarkStack.cpp \
82 heap/MarkedAllocator.cpp \
83 heap/MarkedBlock.cpp \
84 heap/MarkedSpace.cpp \
85 heap/VTableSpectrum.cpp \
86 heap/WriteBarrierSupport.cpp \
87 debugger/DebuggerActivation.cpp \
88 debugger/DebuggerCallFrame.cpp \
89 debugger/Debugger.cpp \
90 dfg/DFGAbstractState.cpp \
91 dfg/DFGAssemblyHelpers.cpp \
92 dfg/DFGByteCodeParser.cpp \
93 dfg/DFGCapabilities.cpp \
94 dfg/DFGCFAPhase.cpp \
95 dfg/DFGCorrectableJumpPoint.cpp \
96 dfg/DFGCSEPhase.cpp \
97 dfg/DFGDriver.cpp \
98 dfg/DFGFixupPhase.cpp \
99 dfg/DFGGraph.cpp \
100 dfg/DFGJITCompiler.cpp \
101 dfg/DFGNodeFlags.cpp \
102 dfg/DFGOperations.cpp \
103 dfg/DFGOSREntry.cpp \
104 dfg/DFGOSRExit.cpp \
105 dfg/DFGOSRExitCompiler.cpp \
106 dfg/DFGOSRExitCompiler64.cpp \
107 dfg/DFGOSRExitCompiler32_64.cpp \
108 dfg/DFGPhase.cpp \
109 dfg/DFGPredictionPropagationPhase.cpp \
110 dfg/DFGRedundantPhiEliminationPhase.cpp \
111 dfg/DFGRepatch.cpp \
112 dfg/DFGSpeculativeJIT.cpp \
113 dfg/DFGSpeculativeJIT32_64.cpp \
114 dfg/DFGSpeculativeJIT64.cpp \
115 dfg/DFGThunks.cpp \
116 dfg/DFGVirtualRegisterAllocationPhase.cpp \
117 interpreter/AbstractPC.cpp \
118 interpreter/CallFrame.cpp \
119 interpreter/Interpreter.cpp \
120 interpreter/RegisterFile.cpp \
121 jit/ExecutableAllocatorFixedVMPool.cpp \
122 jit/ExecutableAllocator.cpp \
123 jit/HostCallReturnValue.cpp \
124 jit/JITArithmetic.cpp \
125 jit/JITArithmetic32_64.cpp \
126 jit/JITCall.cpp \
127 jit/JITCall32_64.cpp \
128 jit/JIT.cpp \
129 jit/JITExceptions.cpp \
130 jit/JITOpcodes.cpp \
131 jit/JITOpcodes32_64.cpp \
132 jit/JITPropertyAccess.cpp \
133 jit/JITPropertyAccess32_64.cpp \
134 jit/JITStubs.cpp \
135 jit/ThunkGenerators.cpp \
136 parser/Lexer.cpp \
137 parser/Nodes.cpp \
138 parser/ParserArena.cpp \
139 parser/Parser.cpp \
140 parser/SourceProviderCache.cpp \
141 profiler/Profile.cpp \
142 profiler/ProfileGenerator.cpp \
143 profiler/ProfileNode.cpp \
144 profiler/Profiler.cpp \
145 runtime/ArgList.cpp \
146 runtime/Arguments.cpp \
147 runtime/ArrayConstructor.cpp \
148 runtime/ArrayPrototype.cpp \
149 runtime/BooleanConstructor.cpp \
150 runtime/BooleanObject.cpp \
151 runtime/BooleanPrototype.cpp \
152 runtime/CallData.cpp \
153 runtime/CommonIdentifiers.cpp \
154 runtime/Completion.cpp \
155 runtime/ConstructData.cpp \
156 runtime/DateConstructor.cpp \
157 runtime/DateConversion.cpp \
158 runtime/DateInstance.cpp \
159 runtime/DatePrototype.cpp \
160 runtime/ErrorConstructor.cpp \
161 runtime/Error.cpp \
162 runtime/ErrorInstance.cpp \
163 runtime/ErrorPrototype.cpp \
164 runtime/ExceptionHelpers.cpp \
165 runtime/Executable.cpp \
166 runtime/FunctionConstructor.cpp \
167 runtime/FunctionPrototype.cpp \
168 runtime/GCActivityCallback.cpp \
169 runtime/GetterSetter.cpp \
170 runtime/Options.cpp \
171 runtime/Identifier.cpp \
172 runtime/InitializeThreading.cpp \
173 runtime/InternalFunction.cpp \
174 runtime/JSActivation.cpp \
175 runtime/JSAPIValueWrapper.cpp \
176 runtime/JSArray.cpp \
177 runtime/JSByteArray.cpp \
178 runtime/JSCell.cpp \
179 runtime/JSDateMath.cpp \
180 runtime/JSFunction.cpp \
181 runtime/JSBoundFunction.cpp \
182 runtime/JSGlobalData.cpp \
183 runtime/JSGlobalObject.cpp \
184 runtime/JSGlobalObjectFunctions.cpp \
185 runtime/JSGlobalThis.cpp \
186 runtime/JSLock.cpp \
187 runtime/JSNotAnObject.cpp \
188 runtime/JSObject.cpp \
189 runtime/JSONObject.cpp \
190 runtime/JSPropertyNameIterator.cpp \
191 runtime/JSStaticScopeObject.cpp \
192 runtime/JSString.cpp \
193 runtime/JSValue.cpp \
194 runtime/JSVariableObject.cpp \
195 runtime/JSWrapperObject.cpp \
196 runtime/LiteralParser.cpp \
197 runtime/Lookup.cpp \
198 runtime/MathObject.cpp \
199 runtime/NativeErrorConstructor.cpp \
200 runtime/NativeErrorPrototype.cpp \
201 runtime/NumberConstructor.cpp \
202 runtime/NumberObject.cpp \
203 runtime/NumberPrototype.cpp \
204 runtime/ObjectConstructor.cpp \
205 runtime/ObjectPrototype.cpp \
206 runtime/Operations.cpp \
207 runtime/PropertyDescriptor.cpp \
208 runtime/PropertyNameArray.cpp \
209 runtime/PropertySlot.cpp \
210 runtime/RegExpConstructor.cpp \
211 runtime/RegExpCachedResult.cpp \
212 runtime/RegExpMatchesArray.cpp \
213 runtime/RegExp.cpp \
214 runtime/RegExpObject.cpp \
215 runtime/RegExpPrototype.cpp \
216 runtime/RegExpCache.cpp \
217 runtime/SamplingCounter.cpp \
218 runtime/ScopeChain.cpp \
219 runtime/SmallStrings.cpp \
220 runtime/StrictEvalActivation.cpp \
221 runtime/StringConstructor.cpp \
222 runtime/StringObject.cpp \
223 runtime/StringPrototype.cpp \
224 runtime/StringRecursionChecker.cpp \
225 runtime/StructureChain.cpp \
226 runtime/Structure.cpp \
227 runtime/TimeoutChecker.cpp \
228 runtime/UString.cpp \
229 tools/CodeProfile.cpp \
230 tools/CodeProfiling.cpp \
231 yarr/YarrJIT.cpp \
232
233*sh4* {
234 QMAKE_CXXFLAGS += -mieee -w
235 QMAKE_CFLAGS += -mieee -w
236}
237
238lessThan(QT_GCC_MAJOR_VERSION, 5) {
239 # GCC 4.5 and before
240 lessThan(QT_GCC_MINOR_VERSION, 6) {
241 # Disable C++0x mode in JSC for those who enabled it in their Qt's mkspec.
242 *-g++*:QMAKE_CXXFLAGS -= -std=c++0x -std=gnu++0x
243 }
244
245 # GCC 4.6 and after.
246 greaterThan(QT_GCC_MINOR_VERSION, 5) {
247 if (!contains(QMAKE_CXXFLAGS, -std=c++0x) && !contains(QMAKE_CXXFLAGS, -std=gnu++0x)) {
248 # We need to deactivate those warnings because some names conflicts with upcoming c++0x types (e.g.nullptr).
249 QMAKE_CFLAGS_WARN_ON += -Wno-c++0x-compat
250 QMAKE_CXXFLAGS_WARN_ON += -Wno-c++0x-compat
251 QMAKE_CFLAGS += -Wno-c++0x-compat
252 QMAKE_CXXFLAGS += -Wno-c++0x-compat
253 }
254 }
255}
Note: See TracBrowser for help on using the repository browser.