Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * vim: set ts=8 sts=4 et sw=4 tw=99: |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef jit_CompilerRoot_h |
michael@0 | 8 | #define jit_CompilerRoot_h |
michael@0 | 9 | |
michael@0 | 10 | #ifdef JS_ION |
michael@0 | 11 | |
michael@0 | 12 | #include "jscntxt.h" |
michael@0 | 13 | |
michael@0 | 14 | #include "jit/Ion.h" |
michael@0 | 15 | #include "jit/IonAllocPolicy.h" |
michael@0 | 16 | #include "js/RootingAPI.h" |
michael@0 | 17 | |
michael@0 | 18 | namespace js { |
michael@0 | 19 | namespace jit { |
michael@0 | 20 | |
michael@0 | 21 | // Roots a read-only GCThing for the lifetime of a single compilation. |
michael@0 | 22 | // Each root is maintained in a linked list that is walked over during tracing. |
michael@0 | 23 | // The CompilerRoot must be heap-allocated and may not go out of scope. |
michael@0 | 24 | template <typename T> |
michael@0 | 25 | class CompilerRoot : public CompilerRootNode |
michael@0 | 26 | { |
michael@0 | 27 | public: |
michael@0 | 28 | CompilerRoot(T ptr) |
michael@0 | 29 | : CompilerRootNode(nullptr) |
michael@0 | 30 | { |
michael@0 | 31 | if (ptr) { |
michael@0 | 32 | JS_ASSERT(!GetIonContext()->runtime->isInsideNursery(ptr)); |
michael@0 | 33 | setRoot(ptr); |
michael@0 | 34 | } |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | public: |
michael@0 | 38 | // Sets the pointer and inserts into root list. The pointer becomes read-only. |
michael@0 | 39 | void setRoot(T root) { |
michael@0 | 40 | CompilerRootNode *&rootList = GetIonContext()->temp->rootList(); |
michael@0 | 41 | |
michael@0 | 42 | JS_ASSERT(!ptr_); |
michael@0 | 43 | ptr_ = root; |
michael@0 | 44 | next = rootList; |
michael@0 | 45 | rootList = this; |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | public: |
michael@0 | 49 | operator T () const { return static_cast<T>(ptr_); } |
michael@0 | 50 | T operator ->() const { return static_cast<T>(ptr_); } |
michael@0 | 51 | |
michael@0 | 52 | private: |
michael@0 | 53 | CompilerRoot() MOZ_DELETE; |
michael@0 | 54 | CompilerRoot(const CompilerRoot<T> &) MOZ_DELETE; |
michael@0 | 55 | CompilerRoot<T> &operator =(const CompilerRoot<T> &) MOZ_DELETE; |
michael@0 | 56 | }; |
michael@0 | 57 | |
michael@0 | 58 | typedef CompilerRoot<JSObject*> CompilerRootObject; |
michael@0 | 59 | typedef CompilerRoot<JSFunction*> CompilerRootFunction; |
michael@0 | 60 | typedef CompilerRoot<JSScript*> CompilerRootScript; |
michael@0 | 61 | typedef CompilerRoot<PropertyName*> CompilerRootPropertyName; |
michael@0 | 62 | typedef CompilerRoot<Shape*> CompilerRootShape; |
michael@0 | 63 | typedef CompilerRoot<Value> CompilerRootValue; |
michael@0 | 64 | |
michael@0 | 65 | } // namespace jit |
michael@0 | 66 | } // namespace js |
michael@0 | 67 | |
michael@0 | 68 | #endif // JS_ION |
michael@0 | 69 | |
michael@0 | 70 | #endif /* jit_CompilerRoot_h */ |