From ad507345be2f74637b1728ba1adbfb44e185f95d Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 11 Sep 2013 09:23:22 +1000 Subject: [PATCH] Bug 914508 (attempt 2) - Move more stuff out of inlines.h/-inl.h files, and remove some unnecessary #include statements. r=terrence. --HG-- extra : rebase_source : abf63fa6f680266c8c53a630174989f33be06a32 --- js/src/builtin/Intl.cpp | 2 + js/src/builtin/MapObject.cpp | 2 - js/src/builtin/Object.cpp | 2 + js/src/builtin/RegExp.cpp | 2 - js/src/builtin/TestingFunctions.cpp | 4 +- js/src/frontend/BytecodeCompiler.cpp | 1 - js/src/frontend/NameFunctions.cpp | 3 - js/src/frontend/Parser.cpp | 5 -- js/src/gc/Barrier-inl.h | 34 --------- js/src/gc/Barrier.cpp | 3 +- js/src/gc/Barrier.h | 9 --- js/src/gc/Nursery.cpp | 2 +- js/src/gc/StoreBuffer.cpp | 2 +- js/src/gc/Zone.cpp | 2 - js/src/jit/AsmJS.cpp | 1 - js/src/jit/AsmJSLink.cpp | 2 - js/src/jit/AsmJSSignalHandlers.cpp | 2 - js/src/jit/Bailouts.cpp | 3 +- js/src/jit/BaselineFrame.cpp | 2 - js/src/jit/CodeGenerator.cpp | 1 - js/src/jit/Ion.cpp | 3 - js/src/jit/IonAnalysis.cpp | 1 - js/src/jit/IonFrames.cpp | 1 - js/src/jit/IonMacroAssembler.cpp | 2 - js/src/jit/MIR.cpp | 2 - js/src/jit/ParallelFunctions.cpp | 2 - js/src/jsapi.cpp | 2 +- js/src/jsarray.cpp | 1 - js/src/jscntxtinlines.h | 2 +- js/src/jscompartment.cpp | 2 +- js/src/jsexn.cpp | 2 - js/src/jsfriendapi.cpp | 2 - js/src/jsgc.cpp | 1 - js/src/jsinfer.cpp | 2 - js/src/jsmemorymetrics.cpp | 2 - js/src/jsobj.cpp | 1 + js/src/jsobj.h | 103 ++++++++++++++++++++++++++- js/src/jsobjinlines.h | 57 --------------- js/src/jsproxy.cpp | 2 + js/src/jsscript.cpp | 2 - js/src/jswatchpoint.cpp | 1 - js/src/shell/js.cpp | 15 +--- js/src/vm/ArgumentsObject.cpp | 1 - js/src/vm/Debugger.cpp | 2 +- js/src/vm/GlobalObject.cpp | 2 + js/src/vm/ObjectImpl-inl.h | 4 -- js/src/vm/ObjectImpl.cpp | 2 - js/src/vm/ProxyObject.cpp | 6 +- js/src/vm/RegExpStatics-inl.h | 56 --------------- js/src/vm/RegExpStatics.cpp | 16 ++++- js/src/vm/RegExpStatics.h | 19 ++++- js/src/vm/Runtime-inl.h | 21 ------ js/src/vm/Runtime.h | 17 ++++- js/src/vm/Shape.cpp | 1 + js/src/vm/Stack-inl.h | 1 - js/src/vm/Stack.cpp | 2 + js/src/vm/Xdr.cpp | 2 - 57 files changed, 176 insertions(+), 268 deletions(-) delete mode 100644 js/src/vm/RegExpStatics-inl.h diff --git a/js/src/builtin/Intl.cpp b/js/src/builtin/Intl.cpp index 75c642792a62..e73b19599618 100644 --- a/js/src/builtin/Intl.cpp +++ b/js/src/builtin/Intl.cpp @@ -38,6 +38,8 @@ #include "jsobjinlines.h" +#include "vm/ObjectImpl-inl.h" + using namespace js; using mozilla::IsFinite; diff --git a/js/src/builtin/MapObject.cpp b/js/src/builtin/MapObject.cpp index 9390aa26c77a..2c1792f98863 100644 --- a/js/src/builtin/MapObject.cpp +++ b/js/src/builtin/MapObject.cpp @@ -19,8 +19,6 @@ #include "jsobjinlines.h" -#include "gc/Barrier-inl.h" - using namespace js; using mozilla::DoubleIsInt32; diff --git a/js/src/builtin/Object.cpp b/js/src/builtin/Object.cpp index c2970246e792..9f7098b581cf 100644 --- a/js/src/builtin/Object.cpp +++ b/js/src/builtin/Object.cpp @@ -15,6 +15,8 @@ #include "jsobjinlines.h" +#include "vm/ObjectImpl-inl.h" + using namespace js; using namespace js::types; diff --git a/js/src/builtin/RegExp.cpp b/js/src/builtin/RegExp.cpp index 47550535153e..3b83d8afc833 100644 --- a/js/src/builtin/RegExp.cpp +++ b/js/src/builtin/RegExp.cpp @@ -13,8 +13,6 @@ #include "jsobjinlines.h" -#include "vm/RegExpStatics-inl.h" - using namespace js; using namespace js::types; diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 5c18e2ad03cd..4bb6ca8a9505 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -19,9 +19,11 @@ #include "jit/AsmJS.h" #include "jit/AsmJSLink.h" #include "vm/ForkJoin.h" +#include "vm/GlobalObject.h" #include "vm/Interpreter.h" +#include "vm/ProxyObject.h" -#include "vm/ObjectImpl-inl.h" +#include "jscntxtinlines.h" using namespace js; using namespace JS; diff --git a/js/src/frontend/BytecodeCompiler.cpp b/js/src/frontend/BytecodeCompiler.cpp index f6767646ba97..a39b2503f9f4 100644 --- a/js/src/frontend/BytecodeCompiler.cpp +++ b/js/src/frontend/BytecodeCompiler.cpp @@ -19,7 +19,6 @@ #include "jsobjinlines.h" #include "jsscriptinlines.h" -#include "frontend/ParseMaps-inl.h" #include "frontend/Parser-inl.h" using namespace js; diff --git a/js/src/frontend/NameFunctions.cpp b/js/src/frontend/NameFunctions.cpp index 1258651e9ac2..3abecb0e2bbd 100644 --- a/js/src/frontend/NameFunctions.cpp +++ b/js/src/frontend/NameFunctions.cpp @@ -14,9 +14,6 @@ #include "frontend/SharedContext.h" #include "vm/StringBuffer.h" -#include "jsfuninlines.h" -#include "jsscriptinlines.h" - using namespace js; using namespace js::frontend; diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index c99e88c8e5ca..210d56f2ec88 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -33,17 +33,12 @@ #include "frontend/ParseMaps.h" #include "frontend/TokenStream.h" #include "jit/AsmJS.h" -#include "vm/RegExpStatics.h" #include "vm/Shape.h" #include "jsatominlines.h" -#include "jsfuninlines.h" -#include "jsobjinlines.h" #include "jsscriptinlines.h" -#include "frontend/ParseMaps-inl.h" #include "frontend/ParseNode-inl.h" -#include "vm/ScopeObject-inl.h" using namespace js; using namespace js::gc; diff --git a/js/src/gc/Barrier-inl.h b/js/src/gc/Barrier-inl.h index 3eeb3ff118cc..f55980a56be4 100644 --- a/js/src/gc/Barrier-inl.h +++ b/js/src/gc/Barrier-inl.h @@ -18,40 +18,6 @@ namespace js { -#ifdef JSGC_GENERATIONAL -class DenseRangeRef : public gc::BufferableRef -{ - JSObject *owner; - uint32_t start; - uint32_t end; - - public: - DenseRangeRef(JSObject *obj, uint32_t start, uint32_t end) - : owner(obj), start(start), end(end) - { - JS_ASSERT(start < end); - } - - void mark(JSTracer *trc) { - /* Apply forwarding, if we have already visited owner. */ - IsObjectMarked(&owner); - uint32_t initLen = owner->getDenseInitializedLength(); - uint32_t clampedStart = Min(start, initLen); - gc::MarkArraySlots(trc, Min(end, initLen) - clampedStart, - owner->getDenseElements() + clampedStart, "element"); - } -}; -#endif - -inline void -DenseRangeWriteBarrierPost(JSRuntime *rt, JSObject *obj, uint32_t start, uint32_t count) -{ -#ifdef JSGC_GENERATIONAL - if (count > 0) - rt->gcStoreBuffer.putGeneric(DenseRangeRef(obj, start, start + count)); -#endif -} - /* * This is a post barrier for HashTables whose key is a GC pointer. Any * insertion into a HashTable not marked as part of the runtime, with a GC diff --git a/js/src/gc/Barrier.cpp b/js/src/gc/Barrier.cpp index ca4786b432fc..ec47fcba04fe 100644 --- a/js/src/gc/Barrier.cpp +++ b/js/src/gc/Barrier.cpp @@ -6,9 +6,10 @@ #include "gc/Barrier.h" +#include "jscompartment.h" #include "jsobj.h" -#include "vm/ObjectImpl-inl.h" +#include "gc/Zone.h" namespace js { diff --git a/js/src/gc/Barrier.h b/js/src/gc/Barrier.h index 5eaefdb998ba..dfbb8200e511 100644 --- a/js/src/gc/Barrier.h +++ b/js/src/gc/Barrier.h @@ -782,15 +782,6 @@ class HeapSlot : public EncapsulatedValue } }; -/* - * NOTE: This is a placeholder for bug 619558. - * - * Run a post write barrier that encompasses multiple contiguous slots in a - * single step. - */ -inline void -DenseRangeWriteBarrierPost(JSRuntime *rt, JSObject *obj, uint32_t start, uint32_t count); - static inline const Value * Valueify(const EncapsulatedValue *array) { diff --git a/js/src/gc/Nursery.cpp b/js/src/gc/Nursery.cpp index f68d7deaf0a0..39331b8c4cf0 100644 --- a/js/src/gc/Nursery.cpp +++ b/js/src/gc/Nursery.cpp @@ -19,7 +19,7 @@ #include "vm/Debugger.h" #include "vm/TypedArrayObject.h" -#include "vm/ObjectImpl-inl.h" +#include "jsgcinlines.h" using namespace js; using namespace gc; diff --git a/js/src/gc/StoreBuffer.cpp b/js/src/gc/StoreBuffer.cpp index 6820b849f26c..9eb95a17a754 100644 --- a/js/src/gc/StoreBuffer.cpp +++ b/js/src/gc/StoreBuffer.cpp @@ -12,7 +12,7 @@ #include "vm/ForkJoin.h" -#include "vm/ObjectImpl-inl.h" +#include "jsgcinlines.h" using namespace js; using namespace js::gc; diff --git a/js/src/gc/Zone.cpp b/js/src/gc/Zone.cpp index 7dd002310256..027c04e6ee3a 100644 --- a/js/src/gc/Zone.cpp +++ b/js/src/gc/Zone.cpp @@ -18,8 +18,6 @@ #include "jsgcinlines.h" -#include "vm/ObjectImpl-inl.h" - using namespace js; using namespace js::gc; diff --git a/js/src/jit/AsmJS.cpp b/js/src/jit/AsmJS.cpp index 27686b8ddaeb..9a87e4721d28 100644 --- a/js/src/jit/AsmJS.cpp +++ b/js/src/jit/AsmJS.cpp @@ -31,7 +31,6 @@ #include "frontend/ParseNode-inl.h" #include "frontend/Parser-inl.h" -#include "gc/Barrier-inl.h" using namespace js; using namespace js::frontend; diff --git a/js/src/jit/AsmJSLink.cpp b/js/src/jit/AsmJSLink.cpp index 74214566c1b5..03829e42fc5c 100644 --- a/js/src/jit/AsmJSLink.cpp +++ b/js/src/jit/AsmJSLink.cpp @@ -19,9 +19,7 @@ #include "jit/Ion.h" #include "jit/PerfSpewer.h" -#include "jsfuninlines.h" #include "jsobjinlines.h" -#include "jsscriptinlines.h" using namespace js; using namespace js::jit; diff --git a/js/src/jit/AsmJSSignalHandlers.cpp b/js/src/jit/AsmJSSignalHandlers.cpp index bc1b01b61b58..95c07c448727 100644 --- a/js/src/jit/AsmJSSignalHandlers.cpp +++ b/js/src/jit/AsmJSSignalHandlers.cpp @@ -9,8 +9,6 @@ #include "assembler/assembler/MacroAssembler.h" #include "jit/AsmJSModule.h" -#include "vm/ObjectImpl-inl.h" - using namespace js; using namespace js::jit; using namespace mozilla; diff --git a/js/src/jit/Bailouts.cpp b/js/src/jit/Bailouts.cpp index a3c9d1ee41c0..18fe3ad4c37f 100644 --- a/js/src/jit/Bailouts.cpp +++ b/js/src/jit/Bailouts.cpp @@ -14,8 +14,7 @@ #include "jit/IonSpewer.h" #include "jit/SnapshotReader.h" -#include "jsobjinlines.h" - +#include "jit/IonFrameIterator-inl.h" #include "vm/Stack-inl.h" using namespace js; diff --git a/js/src/jit/BaselineFrame.cpp b/js/src/jit/BaselineFrame.cpp index 07f177e3a661..2368fcf94591 100644 --- a/js/src/jit/BaselineFrame.cpp +++ b/js/src/jit/BaselineFrame.cpp @@ -12,8 +12,6 @@ #include "vm/Debugger.h" #include "vm/ScopeObject.h" -#include "jsobjinlines.h" - #include "jit/IonFrames-inl.h" #include "vm/Stack-inl.h" diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index 6fece1a532ba..dcc62937ce93 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -28,7 +28,6 @@ #include "vm/ForkJoin.h" #include "jsboolinlines.h" -#include "jsscriptinlines.h" #include "jit/shared/CodeGenerator-shared-inl.h" #include "vm/Interpreter-inl.h" diff --git a/js/src/jit/Ion.cpp b/js/src/jit/Ion.cpp index 9f2c5f9f54da..4050372e78b1 100644 --- a/js/src/jit/Ion.cpp +++ b/js/src/jit/Ion.cpp @@ -53,9 +53,6 @@ #include "jscompartmentinlines.h" #include "jsgcinlines.h" #include "jsinferinlines.h" -#include "jsscriptinlines.h" - -#include "vm/Shape-inl.h" using namespace js; using namespace js::jit; diff --git a/js/src/jit/IonAnalysis.cpp b/js/src/jit/IonAnalysis.cpp index 60338a23b4bc..f20d19c40457 100644 --- a/js/src/jit/IonAnalysis.cpp +++ b/js/src/jit/IonAnalysis.cpp @@ -16,7 +16,6 @@ #include "jit/MIRGraph.h" #include "jsinferinlines.h" -#include "jsscriptinlines.h" using namespace js; using namespace js::jit; diff --git a/js/src/jit/IonFrames.cpp b/js/src/jit/IonFrames.cpp index fca2254d612e..c0318544a2c0 100644 --- a/js/src/jit/IonFrames.cpp +++ b/js/src/jit/IonFrames.cpp @@ -25,7 +25,6 @@ #include "vm/Interpreter.h" #include "jsfuninlines.h" -#include "jsscriptinlines.h" #include "jit/IonFrameIterator-inl.h" #include "vm/Probes-inl.h" diff --git a/js/src/jit/IonMacroAssembler.cpp b/js/src/jit/IonMacroAssembler.cpp index 34943a9a7e82..9453dea4b22f 100644 --- a/js/src/jit/IonMacroAssembler.cpp +++ b/js/src/jit/IonMacroAssembler.cpp @@ -22,8 +22,6 @@ #include "jsgcinlines.h" #include "jsinferinlines.h" -#include "vm/Shape-inl.h" - using namespace js; using namespace js::jit; diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index 5d8349bd8481..60e89cd45416 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -24,8 +24,6 @@ #include "jsatominlines.h" #include "jsinferinlines.h" -#include "vm/Shape-inl.h" - using namespace js; using namespace js::jit; diff --git a/js/src/jit/ParallelFunctions.cpp b/js/src/jit/ParallelFunctions.cpp index a443e235976a..724c73f9fed5 100644 --- a/js/src/jit/ParallelFunctions.cpp +++ b/js/src/jit/ParallelFunctions.cpp @@ -9,10 +9,8 @@ #include "jit/IonSpewer.h" #include "vm/ArrayObject.h" -#include "jsfuninlines.h" #include "jsgcinlines.h" #include "jsobjinlines.h" -#include "jsscriptinlines.h" using namespace js; using namespace jit; diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 45475d5e9b7d..442947c5f0bf 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -70,6 +70,7 @@ #include "vm/ErrorObject.h" #include "vm/Interpreter.h" #include "vm/NumericConversions.h" +#include "vm/RegExpStatics.h" #include "vm/Runtime.h" #include "vm/Shape.h" #include "vm/StopIterationObject.h" @@ -87,7 +88,6 @@ #include "vm/Interpreter-inl.h" #include "vm/ObjectImpl-inl.h" -#include "vm/RegExpStatics-inl.h" #include "vm/Shape-inl.h" #include "vm/String-inl.h" diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp index 1d4035cae14f..9700a6bb2198 100644 --- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -36,7 +36,6 @@ #include "vm/ArgumentsObject-inl.h" #include "vm/ArrayObject-inl.h" #include "vm/Interpreter-inl.h" -#include "vm/ObjectImpl-inl.h" #include "vm/Runtime-inl.h" using namespace js; diff --git a/js/src/jscntxtinlines.h b/js/src/jscntxtinlines.h index 466cb1b4cfca..19ca63009919 100644 --- a/js/src/jscntxtinlines.h +++ b/js/src/jscntxtinlines.h @@ -18,7 +18,7 @@ #include "vm/Interpreter.h" #include "vm/ProxyObject.h" -#include "vm/ObjectImpl-inl.h" +#include "gc/Barrier-inl.h" namespace js { diff --git a/js/src/jscompartment.cpp b/js/src/jscompartment.cpp index d258a491d536..707cce5e844a 100644 --- a/js/src/jscompartment.cpp +++ b/js/src/jscompartment.cpp @@ -24,10 +24,10 @@ #include "vm/StopIterationObject.h" #include "vm/WrapperObject.h" +#include "jsatominlines.h" #include "jsfuninlines.h" #include "jsgcinlines.h" #include "jsinferinlines.h" -#include "jsscriptinlines.h" #include "gc/Barrier-inl.h" diff --git a/js/src/jsexn.cpp b/js/src/jsexn.cpp index 1fd325ef386a..3f64e93eae9a 100644 --- a/js/src/jsexn.cpp +++ b/js/src/jsexn.cpp @@ -30,9 +30,7 @@ #include "vm/GlobalObject.h" #include "vm/StringBuffer.h" -#include "jsfuninlines.h" #include "jsobjinlines.h" -#include "jsscriptinlines.h" using namespace js; using namespace js::gc; diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index f90b00d04e69..de8e708ab89d 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -23,9 +23,7 @@ #include "builtin/TestingFunctions.h" #include "vm/WrapperObject.h" -#include "jsfuninlines.h" #include "jsobjinlines.h" -#include "jsscriptinlines.h" using namespace js; using namespace JS; diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 2f1161d6097e..92b8368b6544 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -81,7 +81,6 @@ #include "jsobjinlines.h" #include "jsscriptinlines.h" -#include "vm/Runtime-inl.h" #include "vm/Stack-inl.h" #include "vm/String-inl.h" diff --git a/js/src/jsinfer.cpp b/js/src/jsinfer.cpp index a69462f270a8..ae4bcb843eed 100644 --- a/js/src/jsinfer.cpp +++ b/js/src/jsinfer.cpp @@ -35,11 +35,9 @@ #include "js/MemoryMetrics.h" #include "vm/Shape.h" -#include "jsanalyzeinlines.h" #include "jsatominlines.h" #include "jsgcinlines.h" #include "jsobjinlines.h" -#include "jsopcodeinlines.h" #include "jsscriptinlines.h" using namespace js; diff --git a/js/src/jsmemorymetrics.cpp b/js/src/jsmemorymetrics.cpp index 2170bc7d0f96..48b96509ad84 100644 --- a/js/src/jsmemorymetrics.cpp +++ b/js/src/jsmemorymetrics.cpp @@ -22,8 +22,6 @@ #include "vm/String.h" #include "vm/WrapperObject.h" -#include "vm/ObjectImpl-inl.h" - using mozilla::DebugOnly; using mozilla::OldMove; using mozilla::MoveRef; diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 1b2c6c4e49a0..2265e71e12b0 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -54,6 +54,7 @@ #include "vm/ArrayObject-inl.h" #include "vm/BooleanObject-inl.h" #include "vm/NumberObject-inl.h" +#include "vm/ObjectImpl-inl.h" #include "vm/Runtime-inl.h" #include "vm/Shape-inl.h" #include "vm/StringObject-inl.h" diff --git a/js/src/jsobj.h b/js/src/jsobj.h index 8064eebae434..da39c16b2a69 100644 --- a/js/src/jsobj.h +++ b/js/src/jsobj.h @@ -18,6 +18,7 @@ #include "mozilla/MemoryReporting.h" +#include "gc/Marking.h" #include "vm/ObjectImpl.h" #include "vm/Shape.h" @@ -163,6 +164,41 @@ class NormalArgumentsObject; class SetObject; class StrictArgumentsObject; +#ifdef JSGC_GENERATIONAL +class DenseRangeRef : public gc::BufferableRef +{ + JSObject *owner; + uint32_t start; + uint32_t end; + + public: + DenseRangeRef(JSObject *obj, uint32_t start, uint32_t end) + : owner(obj), start(start), end(end) + { + JS_ASSERT(start < end); + } + + inline void mark(JSTracer *trc); +}; +#endif + +/* + * NOTE: This is a placeholder for bug 619558. + * + * Run a post write barrier that encompasses multiple contiguous slots in a + * single step. + */ +inline void +DenseRangeWriteBarrierPost(JSRuntime *rt, JSObject *obj, uint32_t start, uint32_t count) +{ +#ifdef JSGC_GENERATIONAL + if (count > 0) { + JS::shadow::Runtime *shadowRuntime = JS::shadow::Runtime::asShadowRuntime(rt); + shadowRuntime->gcStoreBufferPtr()->putGeneric(DenseRangeRef(obj, start, start + count)); + } +#endif +} + } /* namespace js */ /* @@ -599,7 +635,13 @@ class JSObject : public js::ObjectImpl js::HandleObject obj, uint32_t index); static inline void removeDenseElementForSparseIndex(js::ExclusiveContext *cx, js::HandleObject obj, uint32_t index); - inline void copyDenseElements(uint32_t dstStart, const js::Value *src, uint32_t count); + + void copyDenseElements(uint32_t dstStart, const js::Value *src, uint32_t count) { + JS_ASSERT(dstStart + count <= getDenseCapacity()); + JS::Zone *zone = this->zone(); + for (uint32_t i = 0; i < count; ++i) + elements[dstStart + i].set(zone, this, js::HeapSlot::Element, dstStart + i, src[i]); + } void initDenseElements(uint32_t dstStart, const js::Value *src, uint32_t count) { JS_ASSERT(dstStart + count <= getDenseCapacity()); @@ -608,8 +650,50 @@ class JSObject : public js::ObjectImpl elements[dstStart + i].init(rt, this, js::HeapSlot::Element, dstStart + i, src[i]); } - inline void moveDenseElements(uint32_t dstStart, uint32_t srcStart, uint32_t count); - inline void moveDenseElementsUnbarriered(uint32_t dstStart, uint32_t srcStart, uint32_t count); + void moveDenseElements(uint32_t dstStart, uint32_t srcStart, uint32_t count) { + JS_ASSERT(dstStart + count <= getDenseCapacity()); + JS_ASSERT(srcStart + count <= getDenseInitializedLength()); + + /* + * Using memmove here would skip write barriers. Also, we need to consider + * an array containing [A, B, C], in the following situation: + * + * 1. Incremental GC marks slot 0 of array (i.e., A), then returns to JS code. + * 2. JS code moves slots 1..2 into slots 0..1, so it contains [B, C, C]. + * 3. Incremental GC finishes by marking slots 1 and 2 (i.e., C). + * + * Since normal marking never happens on B, it is very important that the + * write barrier is invoked here on B, despite the fact that it exists in + * the array before and after the move. + */ + JS::Zone *zone = this->zone(); + JS::shadow::Zone *shadowZone = JS::shadow::Zone::asShadowZone(zone); + if (shadowZone->needsBarrier()) { + if (dstStart < srcStart) { + js::HeapSlot *dst = elements + dstStart; + js::HeapSlot *src = elements + srcStart; + for (uint32_t i = 0; i < count; i++, dst++, src++) + dst->set(zone, this, js::HeapSlot::Element, dst - elements, *src); + } else { + js::HeapSlot *dst = elements + dstStart + count - 1; + js::HeapSlot *src = elements + srcStart + count - 1; + for (uint32_t i = 0; i < count; i++, dst--, src--) + dst->set(zone, this, js::HeapSlot::Element, dst - elements, *src); + } + } else { + memmove(elements + dstStart, elements + srcStart, count * sizeof(js::HeapSlot)); + DenseRangeWriteBarrierPost(runtimeFromMainThread(), this, dstStart, count); + } + } + + void moveDenseElementsUnbarriered(uint32_t dstStart, uint32_t srcStart, uint32_t count) { + JS_ASSERT(!shadowZone()->needsBarrier()); + + JS_ASSERT(dstStart + count <= getDenseCapacity()); + JS_ASSERT(srcStart + count <= getDenseCapacity()); + + memmove(elements + dstStart, elements + srcStart, count * sizeof(js::Value)); + } bool shouldConvertDoubleElements() { JS_ASSERT(isNative()); @@ -1088,6 +1172,19 @@ class ValueArray { namespace js { +#ifdef JSGC_GENERATIONAL +inline void +DenseRangeRef::mark(JSTracer *trc) +{ + /* Apply forwarding, if we have already visited owner. */ + js::gc::IsObjectMarked(&owner); + uint32_t initLen = owner->getDenseInitializedLength(); + uint32_t clampedStart = Min(start, initLen); + gc::MarkArraySlots(trc, Min(end, initLen) - clampedStart, + owner->getDenseElements() + clampedStart, "element"); +} +#endif + template extern bool HasOwnProperty(JSContext *cx, LookupGenericOp lookup, diff --git a/js/src/jsobjinlines.h b/js/src/jsobjinlines.h index 488447132de8..b9770dd23062 100644 --- a/js/src/jsobjinlines.h +++ b/js/src/jsobjinlines.h @@ -171,63 +171,6 @@ JSObject::removeDenseElementForSparseIndex(js::ExclusiveContext *cx, obj->setDenseElement(index, js::MagicValue(JS_ELEMENTS_HOLE)); } -inline void -JSObject::copyDenseElements(uint32_t dstStart, const js::Value *src, uint32_t count) -{ - JS_ASSERT(dstStart + count <= getDenseCapacity()); - JS::Zone *zone = this->zone(); - for (uint32_t i = 0; i < count; ++i) - elements[dstStart + i].set(zone, this, js::HeapSlot::Element, dstStart + i, src[i]); -} - -inline void -JSObject::moveDenseElements(uint32_t dstStart, uint32_t srcStart, uint32_t count) -{ - JS_ASSERT(dstStart + count <= getDenseCapacity()); - JS_ASSERT(srcStart + count <= getDenseInitializedLength()); - - /* - * Using memmove here would skip write barriers. Also, we need to consider - * an array containing [A, B, C], in the following situation: - * - * 1. Incremental GC marks slot 0 of array (i.e., A), then returns to JS code. - * 2. JS code moves slots 1..2 into slots 0..1, so it contains [B, C, C]. - * 3. Incremental GC finishes by marking slots 1 and 2 (i.e., C). - * - * Since normal marking never happens on B, it is very important that the - * write barrier is invoked here on B, despite the fact that it exists in - * the array before and after the move. - */ - JS::Zone *zone = this->zone(); - if (zone->needsBarrier()) { - if (dstStart < srcStart) { - js::HeapSlot *dst = elements + dstStart; - js::HeapSlot *src = elements + srcStart; - for (uint32_t i = 0; i < count; i++, dst++, src++) - dst->set(zone, this, js::HeapSlot::Element, dst - elements, *src); - } else { - js::HeapSlot *dst = elements + dstStart + count - 1; - js::HeapSlot *src = elements + srcStart + count - 1; - for (uint32_t i = 0; i < count; i++, dst--, src--) - dst->set(zone, this, js::HeapSlot::Element, dst - elements, *src); - } - } else { - memmove(elements + dstStart, elements + srcStart, count * sizeof(js::HeapSlot)); - DenseRangeWriteBarrierPost(runtimeFromMainThread(), this, dstStart, count); - } -} - -inline void -JSObject::moveDenseElementsUnbarriered(uint32_t dstStart, uint32_t srcStart, uint32_t count) -{ - JS_ASSERT(!zone()->needsBarrier()); - - JS_ASSERT(dstStart + count <= getDenseCapacity()); - JS_ASSERT(srcStart + count <= getDenseCapacity()); - - memmove(elements + dstStart, elements + srcStart, count * sizeof(js::Value)); -} - inline void JSObject::markDenseElementsNotPacked(js::ExclusiveContext *cx) { diff --git a/js/src/jsproxy.cpp b/js/src/jsproxy.cpp index 898b65e1aa12..fda7058ce03f 100644 --- a/js/src/jsproxy.cpp +++ b/js/src/jsproxy.cpp @@ -21,6 +21,8 @@ #include "jsinferinlines.h" #include "jsobjinlines.h" +#include "vm/ObjectImpl-inl.h" + using namespace js; using namespace js::gc; using mozilla::ArrayLength; diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index 7742763644f4..67e7e0d1d928 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -33,7 +33,6 @@ #include "js/OldDebugAPI.h" #include "vm/ArgumentsObject.h" #include "vm/Debugger.h" -#include "vm/Interpreter.h" #include "vm/Shape.h" #include "vm/Xdr.h" @@ -41,7 +40,6 @@ #include "jsinferinlines.h" #include "jsobjinlines.h" -#include "vm/Runtime-inl.h" #include "vm/ScopeObject-inl.h" #include "vm/Stack-inl.h" diff --git a/js/src/jswatchpoint.cpp b/js/src/jswatchpoint.cpp index 504328554d61..2a83ae3ea61b 100644 --- a/js/src/jswatchpoint.cpp +++ b/js/src/jswatchpoint.cpp @@ -15,7 +15,6 @@ #include "jsgcinlines.h" #include "gc/Barrier-inl.h" -#include "vm/ObjectImpl-inl.h" using namespace js; using namespace js::gc; diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 3a507a45874f..27d8904ecd2a 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -32,18 +32,12 @@ #include "jsarray.h" #include "jsatom.h" #include "jscntxt.h" -#include "jsdate.h" #include "jsfun.h" -#include "jsgc.h" -#include "jsiter.h" #ifdef JS_THREADSAFE #include "jslock.h" #endif -#include "jsnum.h" #include "jsobj.h" -#include "json.h" #include "jsprf.h" -#include "jsreflect.h" #include "jsscript.h" #include "jstypes.h" #include "jsutil.h" @@ -58,7 +52,6 @@ #endif #include "builtin/TestingFunctions.h" -#include "frontend/BytecodeEmitter.h" #include "frontend/Parser.h" #include "jit/Ion.h" #include "js/OldDebugAPI.h" @@ -66,15 +59,13 @@ #include "perf/jsperf.h" #include "shell/jsheaptools.h" #include "shell/jsoptparse.h" +#include "vm/ArgumentsObject.h" #include "vm/Shape.h" #include "vm/TypedArrayObject.h" #include "vm/WrapperObject.h" -#include "jsfuninlines.h" -#include "jsinferinlines.h" -#include "jsscriptinlines.h" - -#include "vm/Interpreter-inl.h" +#include "jscompartmentinlines.h" +#include "jsobjinlines.h" #ifdef XP_WIN # define PATH_MAX (MAX_PATH > _MAX_DIR ? MAX_PATH : _MAX_DIR) diff --git a/js/src/vm/ArgumentsObject.cpp b/js/src/vm/ArgumentsObject.cpp index 0017d996cf74..236232adc9c3 100644 --- a/js/src/vm/ArgumentsObject.cpp +++ b/js/src/vm/ArgumentsObject.cpp @@ -16,7 +16,6 @@ #include "jsobjinlines.h" -#include "gc/Barrier-inl.h" #include "vm/Stack-inl.h" using namespace js; diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index ffbf765a7829..c2ef44011800 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -20,12 +20,12 @@ #include "vm/ArgumentsObject.h" #include "vm/WrapperObject.h" -#include "jsfuninlines.h" #include "jsgcinlines.h" #include "jsobjinlines.h" #include "jsopcodeinlines.h" #include "jsscriptinlines.h" +#include "vm/ObjectImpl-inl.h" #include "vm/Stack-inl.h" using namespace js; diff --git a/js/src/vm/GlobalObject.cpp b/js/src/vm/GlobalObject.cpp index 41951a51e53e..8eaabd3a7923 100644 --- a/js/src/vm/GlobalObject.cpp +++ b/js/src/vm/GlobalObject.cpp @@ -26,6 +26,8 @@ #include "jsobjinlines.h" #include "jsscriptinlines.h" +#include "vm/ObjectImpl-inl.h" + using namespace js; JSObject * diff --git a/js/src/vm/ObjectImpl-inl.h b/js/src/vm/ObjectImpl-inl.h index 201cafbc7431..3323b96521df 100644 --- a/js/src/vm/ObjectImpl-inl.h +++ b/js/src/vm/ObjectImpl-inl.h @@ -9,12 +9,8 @@ #include "vm/ObjectImpl.h" -#include "mozilla/Assertions.h" - -#include "jsgc.h" #include "jsproxy.h" -#include "gc/Marking.h" #include "vm/ProxyObject.h" #include "gc/Barrier-inl.h" diff --git a/js/src/vm/ObjectImpl.cpp b/js/src/vm/ObjectImpl.cpp index a0c41a900b87..949c313a2967 100644 --- a/js/src/vm/ObjectImpl.cpp +++ b/js/src/vm/ObjectImpl.cpp @@ -12,8 +12,6 @@ #include "jsobjinlines.h" -#include "gc/Barrier-inl.h" - using namespace js; PropDesc::PropDesc() diff --git a/js/src/vm/ProxyObject.cpp b/js/src/vm/ProxyObject.cpp index 8ed37f860d18..c9739abae3e9 100644 --- a/js/src/vm/ProxyObject.cpp +++ b/js/src/vm/ProxyObject.cpp @@ -6,11 +6,9 @@ #include "vm/ProxyObject.h" -#include "jsgcinlines.h" -#include "jsobjinlines.h" +#include "jscompartment.h" -#include "gc/Barrier-inl.h" -#include "vm/ObjectImpl-inl.h" +#include "jsgcinlines.h" using namespace js; diff --git a/js/src/vm/RegExpStatics-inl.h b/js/src/vm/RegExpStatics-inl.h deleted file mode 100644 index d6c42bf1731d..000000000000 --- a/js/src/vm/RegExpStatics-inl.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef vm_RegExpStatics_inl_h -#define vm_RegExpStatics_inl_h - -#include "vm/RegExpStatics.h" - -#include "jsinferinlines.h" - -namespace js { - -inline void -RegExpStatics::setMultiline(JSContext *cx, bool enabled) -{ - aboutToWrite(); - if (enabled) { - flags = RegExpFlag(flags | MultilineFlag); - markFlagsSet(cx); - } else { - flags = RegExpFlag(flags & ~MultilineFlag); - } -} - -inline void -RegExpStatics::markFlagsSet(JSContext *cx) -{ - /* - * Flags set on the RegExp function get propagated to constructed RegExp - * objects, which interferes with optimizations that inline RegExp cloning - * or avoid cloning entirely. Scripts making this assumption listen to - * type changes on RegExp.prototype, so mark a state change to trigger - * recompilation of all such code (when recompiling, a stub call will - * always be performed). - */ - JS_ASSERT(this == cx->global()->getRegExpStatics()); - - types::MarkTypeObjectFlags(cx, cx->global(), types::OBJECT_FLAG_REGEXP_FLAGS_SET); -} - -inline void -RegExpStatics::reset(JSContext *cx, JSString *newInput, bool newMultiline) -{ - aboutToWrite(); - clear(); - pendingInput = newInput; - setMultiline(cx, newMultiline); - checkInvariants(); -} - -} /* namespace js */ - -#endif /* vm_RegExpStatics_inl_h */ diff --git a/js/src/vm/RegExpStatics.cpp b/js/src/vm/RegExpStatics.cpp index 59bf388acb76..23c21543154f 100644 --- a/js/src/vm/RegExpStatics.cpp +++ b/js/src/vm/RegExpStatics.cpp @@ -4,7 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "vm/RegExpStatics-inl.h" +#include "vm/RegExpStatics.h" #include "vm/RegExpStaticsObject.h" @@ -66,6 +66,20 @@ RegExpStatics::create(JSContext *cx, GlobalObject *parent) return obj; } +void +RegExpStatics::markFlagsSet(JSContext *cx) +{ + // Flags set on the RegExp function get propagated to constructed RegExp + // objects, which interferes with optimizations that inline RegExp cloning + // or avoid cloning entirely. Scripts making this assumption listen to + // type changes on RegExp.prototype, so mark a state change to trigger + // recompilation of all such code (when recompiling, a stub call will + // always be performed). + JS_ASSERT(this == cx->global()->getRegExpStatics()); + + types::MarkTypeObjectFlags(cx, cx->global(), types::OBJECT_FLAG_REGEXP_FLAGS_SET); +} + bool RegExpStatics::executeLazy(JSContext *cx) { diff --git a/js/src/vm/RegExpStatics.h b/js/src/vm/RegExpStatics.h index b0fd39bb3380..f0ed6024e38f 100644 --- a/js/src/vm/RegExpStatics.h +++ b/js/src/vm/RegExpStatics.h @@ -88,12 +88,27 @@ class RegExpStatics inline void updateLazily(JSContext *cx, JSLinearString *input, RegExpShared *shared, size_t lastIndex); inline bool updateFromMatchPairs(JSContext *cx, JSLinearString *input, MatchPairs &newPairs); - inline void setMultiline(JSContext *cx, bool enabled); + + void setMultiline(JSContext *cx, bool enabled) { + aboutToWrite(); + if (enabled) { + flags = RegExpFlag(flags | MultilineFlag); + markFlagsSet(cx); + } else { + flags = RegExpFlag(flags & ~MultilineFlag); + } + } inline void clear(); /* Corresponds to JSAPI functionality to set the pending RegExp input. */ - inline void reset(JSContext *cx, JSString *newInput, bool newMultiline); + void reset(JSContext *cx, JSString *newInput, bool newMultiline) { + aboutToWrite(); + clear(); + pendingInput = newInput; + setMultiline(cx, newMultiline); + checkInvariants(); + } inline void setPendingInput(JSString *newInput); diff --git a/js/src/vm/Runtime-inl.h b/js/src/vm/Runtime-inl.h index 7386c79d9888..8adbede98bcd 100644 --- a/js/src/vm/Runtime-inl.h +++ b/js/src/vm/Runtime-inl.h @@ -39,16 +39,6 @@ NewObjectCache::fillGlobal(EntryIndex entry, Class *clasp, js::GlobalObject *glo return fill(entry, clasp, global, kind, obj); } -inline void -NewObjectCache::copyCachedToObject(JSObject *dst, JSObject *src, gc::AllocKind kind) -{ - js_memcpy(dst, src, gc::Arena::thingSize(kind)); -#ifdef JSGC_GENERATIONAL - Shape::writeBarrierPost(dst->shape_, &dst->shape_); - types::TypeObject::writeBarrierPost(dst->type_, &dst->type_); -#endif -} - inline JSObject * NewObjectCache::newObjectFromHit(JSContext *cx, EntryIndex entry_, js::gc::InitialHeap heap) { @@ -68,17 +58,6 @@ NewObjectCache::newObjectFromHit(JSContext *cx, EntryIndex entry_, js::gc::Initi return NULL; } -inline -ThreadDataIter::ThreadDataIter(JSRuntime *rt) -{ -#ifdef JS_WORKER_THREADS - // Only allow iteration over a runtime's threads when those threads are - // paused, to avoid racing when reading data from the PerThreadData. - JS_ASSERT(rt->exclusiveThreadsPaused); -#endif - iter = rt->threadList.getFirst(); -} - } /* namespace js */ #endif /* vm_Runtime_inl_h */ diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h index 613d2fc5327f..818f766b9f3f 100644 --- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -386,7 +386,13 @@ class NewObjectCache js_memcpy(&entry->templateObject, obj, entry->nbytes); } - static inline void copyCachedToObject(JSObject *dst, JSObject *src, gc::AllocKind kind); + static void copyCachedToObject(JSObject *dst, JSObject *src, gc::AllocKind kind) { + js_memcpy(dst, src, gc::Arena::thingSize(kind)); +#ifdef JSGC_GENERATIONAL + Shape::writeBarrierPost(dst->shape_, &dst->shape_); + types::TypeObject::writeBarrierPost(dst->type_, &dst->type_); +#endif + } }; /* @@ -1870,7 +1876,14 @@ class ThreadDataIter { PerThreadData *iter; public: - explicit inline ThreadDataIter(JSRuntime *rt); + explicit ThreadDataIter(JSRuntime *rt) { +#ifdef JS_WORKER_THREADS + // Only allow iteration over a runtime's threads when those threads are + // paused, to avoid racing when reading data from the PerThreadData. + JS_ASSERT(rt->exclusiveThreadsPaused); +#endif + iter = rt->threadList.getFirst(); + } bool done() const { return !iter; diff --git a/js/src/vm/Shape.cpp b/js/src/vm/Shape.cpp index 4ea9e3e232bf..66843e1c23ce 100644 --- a/js/src/vm/Shape.cpp +++ b/js/src/vm/Shape.cpp @@ -22,6 +22,7 @@ #include "jscntxtinlines.h" #include "jsobjinlines.h" +#include "vm/ObjectImpl-inl.h" #include "vm/Runtime-inl.h" using namespace js; diff --git a/js/src/vm/Stack-inl.h b/js/src/vm/Stack-inl.h index 00a347662859..023bfd2bb915 100644 --- a/js/src/vm/Stack-inl.h +++ b/js/src/vm/Stack-inl.h @@ -19,7 +19,6 @@ #include "jsobjinlines.h" #include "jit/BaselineFrame-inl.h" -#include "jit/IonFrameIterator-inl.h" namespace js { diff --git a/js/src/vm/Stack.cpp b/js/src/vm/Stack.cpp index d8eba1ccc570..a7e4f5bcb778 100644 --- a/js/src/vm/Stack.cpp +++ b/js/src/vm/Stack.cpp @@ -16,6 +16,8 @@ #include "jit/BaselineFrame.h" #include "jit/IonCompartment.h" #endif + +#include "jit/IonFrameIterator-inl.h" #include "vm/Interpreter-inl.h" #include "vm/Probes-inl.h" diff --git a/js/src/vm/Xdr.cpp b/js/src/vm/Xdr.cpp index e31159b2bb10..b9275e6cbd50 100644 --- a/js/src/vm/Xdr.cpp +++ b/js/src/vm/Xdr.cpp @@ -13,8 +13,6 @@ #include "vm/Debugger.h" -#include "vm/ObjectImpl-inl.h" - using namespace js; void