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_BaselineDebugModeOSR_h |
michael@0 | 8 | #define jit_BaselineDebugModeOSR_h |
michael@0 | 9 | |
michael@0 | 10 | #ifdef JS_ION |
michael@0 | 11 | |
michael@0 | 12 | #include "jit/BaselineFrame.h" |
michael@0 | 13 | #include "jit/BaselineIC.h" |
michael@0 | 14 | #include "jit/BaselineJIT.h" |
michael@0 | 15 | |
michael@0 | 16 | namespace js { |
michael@0 | 17 | namespace jit { |
michael@0 | 18 | |
michael@0 | 19 | // Note that this file and the corresponding .cpp implement debug mode |
michael@0 | 20 | // on-stack recompilation. This is to be distinguished from ordinary |
michael@0 | 21 | // Baseline->Ion OSR, which is used to jump into compiled loops. |
michael@0 | 22 | |
michael@0 | 23 | // |
michael@0 | 24 | // A volatile location due to recompilation of an on-stack baseline script |
michael@0 | 25 | // (e.g., for debug mode toggling). |
michael@0 | 26 | // |
michael@0 | 27 | // It is usually used in fallback stubs which may trigger on-stack |
michael@0 | 28 | // recompilation by calling out into the VM. Example use: |
michael@0 | 29 | // |
michael@0 | 30 | // DebugModeOSRVolatileStub<FallbackStubT *> stub(frame, stub_) |
michael@0 | 31 | // |
michael@0 | 32 | // // Call out to the VM |
michael@0 | 33 | // // Other effectful operations like TypeScript::Monitor |
michael@0 | 34 | // |
michael@0 | 35 | // if (stub.invalid()) |
michael@0 | 36 | // return true; |
michael@0 | 37 | // |
michael@0 | 38 | // // First use of stub after VM call. |
michael@0 | 39 | // |
michael@0 | 40 | template <typename T> |
michael@0 | 41 | class DebugModeOSRVolatileStub |
michael@0 | 42 | { |
michael@0 | 43 | T stub_; |
michael@0 | 44 | BaselineFrame *frame_; |
michael@0 | 45 | uint32_t pcOffset_; |
michael@0 | 46 | |
michael@0 | 47 | public: |
michael@0 | 48 | DebugModeOSRVolatileStub(BaselineFrame *frame, ICFallbackStub *stub) |
michael@0 | 49 | : stub_(static_cast<T>(stub)), |
michael@0 | 50 | frame_(frame), |
michael@0 | 51 | pcOffset_(stub->icEntry()->pcOffset()) |
michael@0 | 52 | { } |
michael@0 | 53 | |
michael@0 | 54 | bool invalid() const { |
michael@0 | 55 | ICEntry &entry = frame_->script()->baselineScript()->icEntryFromPCOffset(pcOffset_); |
michael@0 | 56 | return stub_ != entry.fallbackStub(); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | operator const T&() const { MOZ_ASSERT(!invalid()); return stub_; } |
michael@0 | 60 | T operator->() const { MOZ_ASSERT(!invalid()); return stub_; } |
michael@0 | 61 | T *address() { MOZ_ASSERT(!invalid()); return &stub_; } |
michael@0 | 62 | const T *address() const { MOZ_ASSERT(!invalid()); return &stub_; } |
michael@0 | 63 | T &get() { MOZ_ASSERT(!invalid()); return stub_; } |
michael@0 | 64 | const T &get() const { MOZ_ASSERT(!invalid()); return stub_; } |
michael@0 | 65 | |
michael@0 | 66 | bool operator!=(const T &other) const { MOZ_ASSERT(!invalid()); return stub_ != other; } |
michael@0 | 67 | bool operator==(const T &other) const { MOZ_ASSERT(!invalid()); return stub_ == other; } |
michael@0 | 68 | }; |
michael@0 | 69 | |
michael@0 | 70 | // |
michael@0 | 71 | // Auxiliary info to help the DebugModeOSRHandler fix up state. |
michael@0 | 72 | // |
michael@0 | 73 | struct BaselineDebugModeOSRInfo |
michael@0 | 74 | { |
michael@0 | 75 | uint8_t *resumeAddr; |
michael@0 | 76 | jsbytecode *pc; |
michael@0 | 77 | PCMappingSlotInfo slotInfo; |
michael@0 | 78 | ICEntry::Kind frameKind; |
michael@0 | 79 | |
michael@0 | 80 | // Filled in by SyncBaselineDebugModeOSRInfo. |
michael@0 | 81 | uintptr_t stackAdjust; |
michael@0 | 82 | Value valueR0; |
michael@0 | 83 | Value valueR1; |
michael@0 | 84 | |
michael@0 | 85 | BaselineDebugModeOSRInfo(jsbytecode *pc, ICEntry::Kind kind) |
michael@0 | 86 | : resumeAddr(nullptr), |
michael@0 | 87 | pc(pc), |
michael@0 | 88 | slotInfo(0), |
michael@0 | 89 | frameKind(kind), |
michael@0 | 90 | stackAdjust(0), |
michael@0 | 91 | valueR0(UndefinedValue()), |
michael@0 | 92 | valueR1(UndefinedValue()) |
michael@0 | 93 | { } |
michael@0 | 94 | |
michael@0 | 95 | void popValueInto(PCMappingSlotInfo::SlotLocation loc, Value *vp); |
michael@0 | 96 | }; |
michael@0 | 97 | |
michael@0 | 98 | bool |
michael@0 | 99 | RecompileOnStackBaselineScriptsForDebugMode(JSContext *cx, JSCompartment *comp); |
michael@0 | 100 | |
michael@0 | 101 | } // namespace jit |
michael@0 | 102 | } // namespace js |
michael@0 | 103 | |
michael@0 | 104 | #endif // JS_ION |
michael@0 | 105 | |
michael@0 | 106 | #endif // jit_BaselineDebugModeOSR_h |