js/src/jit/BaselineDebugModeOSR.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit/BaselineDebugModeOSR.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,106 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99:
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef jit_BaselineDebugModeOSR_h
    1.11 +#define jit_BaselineDebugModeOSR_h
    1.12 +
    1.13 +#ifdef JS_ION
    1.14 +
    1.15 +#include "jit/BaselineFrame.h"
    1.16 +#include "jit/BaselineIC.h"
    1.17 +#include "jit/BaselineJIT.h"
    1.18 +
    1.19 +namespace js {
    1.20 +namespace jit {
    1.21 +
    1.22 +// Note that this file and the corresponding .cpp implement debug mode
    1.23 +// on-stack recompilation. This is to be distinguished from ordinary
    1.24 +// Baseline->Ion OSR, which is used to jump into compiled loops.
    1.25 +
    1.26 +//
    1.27 +// A volatile location due to recompilation of an on-stack baseline script
    1.28 +// (e.g., for debug mode toggling).
    1.29 +//
    1.30 +// It is usually used in fallback stubs which may trigger on-stack
    1.31 +// recompilation by calling out into the VM. Example use:
    1.32 +//
    1.33 +//     DebugModeOSRVolatileStub<FallbackStubT *> stub(frame, stub_)
    1.34 +//
    1.35 +//     // Call out to the VM
    1.36 +//     // Other effectful operations like TypeScript::Monitor
    1.37 +//
    1.38 +//     if (stub.invalid())
    1.39 +//         return true;
    1.40 +//
    1.41 +//     // First use of stub after VM call.
    1.42 +//
    1.43 +template <typename T>
    1.44 +class DebugModeOSRVolatileStub
    1.45 +{
    1.46 +    T stub_;
    1.47 +    BaselineFrame *frame_;
    1.48 +    uint32_t pcOffset_;
    1.49 +
    1.50 +  public:
    1.51 +    DebugModeOSRVolatileStub(BaselineFrame *frame, ICFallbackStub *stub)
    1.52 +      : stub_(static_cast<T>(stub)),
    1.53 +        frame_(frame),
    1.54 +        pcOffset_(stub->icEntry()->pcOffset())
    1.55 +    { }
    1.56 +
    1.57 +    bool invalid() const {
    1.58 +        ICEntry &entry = frame_->script()->baselineScript()->icEntryFromPCOffset(pcOffset_);
    1.59 +        return stub_ != entry.fallbackStub();
    1.60 +    }
    1.61 +
    1.62 +    operator const T&() const { MOZ_ASSERT(!invalid()); return stub_; }
    1.63 +    T operator->() const { MOZ_ASSERT(!invalid()); return stub_; }
    1.64 +    T *address() { MOZ_ASSERT(!invalid()); return &stub_; }
    1.65 +    const T *address() const { MOZ_ASSERT(!invalid()); return &stub_; }
    1.66 +    T &get() { MOZ_ASSERT(!invalid()); return stub_; }
    1.67 +    const T &get() const { MOZ_ASSERT(!invalid()); return stub_; }
    1.68 +
    1.69 +    bool operator!=(const T &other) const { MOZ_ASSERT(!invalid()); return stub_ != other; }
    1.70 +    bool operator==(const T &other) const { MOZ_ASSERT(!invalid()); return stub_ == other; }
    1.71 +};
    1.72 +
    1.73 +//
    1.74 +// Auxiliary info to help the DebugModeOSRHandler fix up state.
    1.75 +//
    1.76 +struct BaselineDebugModeOSRInfo
    1.77 +{
    1.78 +    uint8_t *resumeAddr;
    1.79 +    jsbytecode *pc;
    1.80 +    PCMappingSlotInfo slotInfo;
    1.81 +    ICEntry::Kind frameKind;
    1.82 +
    1.83 +    // Filled in by SyncBaselineDebugModeOSRInfo.
    1.84 +    uintptr_t stackAdjust;
    1.85 +    Value valueR0;
    1.86 +    Value valueR1;
    1.87 +
    1.88 +    BaselineDebugModeOSRInfo(jsbytecode *pc, ICEntry::Kind kind)
    1.89 +      : resumeAddr(nullptr),
    1.90 +        pc(pc),
    1.91 +        slotInfo(0),
    1.92 +        frameKind(kind),
    1.93 +        stackAdjust(0),
    1.94 +        valueR0(UndefinedValue()),
    1.95 +        valueR1(UndefinedValue())
    1.96 +    { }
    1.97 +
    1.98 +    void popValueInto(PCMappingSlotInfo::SlotLocation loc, Value *vp);
    1.99 +};
   1.100 +
   1.101 +bool
   1.102 +RecompileOnStackBaselineScriptsForDebugMode(JSContext *cx, JSCompartment *comp);
   1.103 +
   1.104 +} // namespace jit
   1.105 +} // namespace js
   1.106 +
   1.107 +#endif // JS_ION
   1.108 +
   1.109 +#endif // jit_BaselineDebugModeOSR_h

mercurial