Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Split JIT flags into flags and options.

Flags are correspond local state, options describe configuration and
influence the behaviour of the code generator.
  • Loading branch information...
commit 1b111c920b76b917683c5c5f3c72e0686e00b9cb 1 parent c2e5690
@nominolo authored
Showing with 34 additions and 21 deletions.
  1. +3 −2 vm/assembler.cc
  2. +14 −16 vm/jit.cc
  3. +17 −3 vm/jit.hh
View
5 vm/assembler.cc
@@ -797,10 +797,11 @@ void Assembler::prepareTail(IRBuffer *buf, IRRef saveref) {
}
}
- if (jit()->flags_.get(Jit::kDebugTrace)) {
+ if (jit()->getOption(Jit::kOptDebugTrace)) {
// Reserve space for CALL to asmTrace
p -= 5;
}
+
mcp = p;
}
@@ -815,7 +816,7 @@ void Assembler::fixupTail(MCode *target, IRRef saveref) {
uint32_t traceId = ir(saveref)->op2();
p = emitSetTraceId(p, traceId);
}
- if (jit()->flags_.get(Jit::kDebugTrace)) {
+ if (jit()->getOption(Jit::kOptDebugTrace)) {
*(int32_t *)(p - 4) = jmprel(p, (MCode *)(void *)&asmTrace);
p[-5] = XI_CALL;
}
View
30 vm/jit.cc
@@ -54,7 +54,7 @@ Jit::numFragments()
Jit::Jit()
: cap_(NULL),
startPc_(NULL), startBase_(NULL), parent_(NULL),
- flags_(), targets_(),
+ flags_(), options_(), targets_(),
prng_(), mcode_(&prng_), asm_(this) {
Jit::resetFragments();
memset(exitStubGroup_, 0, sizeof(exitStubGroup_));
@@ -65,16 +65,23 @@ Jit::~Jit() {
Jit::resetFragments();
}
-void Jit::beginRecording(Capability *cap, BcIns *startPc, Word *base, bool isReturn) {
+void Jit::beginRecording(Capability *cap, BcIns *startPc, Word *base, bool isReturn)
+{
LC_ASSERT(cap_ == NULL);
LC_ASSERT(targets_.size() == 0);
+ initRecording(cap, base, startPc);
+ flags_.set(kIsReturnTrace, isReturn);
+}
+
+void Jit::initRecording(Capability *cap, Word *base, BcIns *startPc)
+{
+ resetRecorderState();
cap_ = cap;
startPc_ = startPc;
startBase_ = base;
parent_ = NULL;
parentExitNo_ = ~0;
- flags_.clear(kLastInsWasBranch);
- flags_.set(kIsReturnTrace, isReturn);
+ flags_.clear();
buf_.reset(base, cap->currentThread()->top());
callStack_.reset();
btb_.reset(startPc_, &callStack_);
@@ -159,18 +166,13 @@ void Jit::beginSideTrace(Capability *cap, Word *base, Fragment *parent, SnapNo s
LC_ASSERT(cap_ == NULL);
LC_ASSERT(targets_.size() == 0);
LC_ASSERT(cap != NULL);
- resetRecorderState();
+
Snapshot &snap = parent->snap(snapno);
- cap_ = cap;
- startPc_ = snap.pc();
- startBase_ = base;
+ initRecording(cap, base, snap.pc());
+
parent_ = parent;
parentExitNo_ = snapno;
- buf_.reset(base, cap->currentThread()->top());
buf_.parent_ = parent;
- callStack_.reset();
- btb_.reset(startPc_, &callStack_);
- lastResult_ = TRef();
replaySnapshot(parent, snapno, base);
@@ -178,10 +180,6 @@ void Jit::beginSideTrace(Capability *cap, Word *base, Fragment *parent, SnapNo s
buf_.debugPrint(cerr, ~0);
buf_.slots_.debugPrint(cerr);
}
-
-#ifdef LC_TRACE_STATS
- stats_ = NULL;
-#endif
}
static IRType littypeToIRType(uint8_t littype) {
View
20 vm/jit.hh
@@ -172,6 +172,19 @@ public:
return fragments_[traceId];
}
+ typedef enum {
+ kOptDebugTrace,
+ kOptFastHeapCheckFail
+ } JitOption;
+
+ inline void setOption(JitOption option, bool value) {
+ options_.set((int)option, value);
+ }
+
+ inline bool getOption(JitOption option) const {
+ return options_.get((int)option);
+ }
+
inline MachineCode *mcode() { return &mcode_; }
inline IRBuffer *buffer() { return &buf_; }
inline Assembler *assembler() { return &asm_; }
@@ -182,12 +195,13 @@ public:
return fragments_[fragmentMap_[idx]];
}
- inline void setDebugTrace(bool val) { flags_.set(kDebugTrace, val); }
+ inline void setDebugTrace(bool val) { options_.set(kOptDebugTrace, val); }
static inline void registerFragment(BcIns *startPc, Fragment *F);
static void resetFragments();
static uint32_t numFragments();
private:
+ void initRecording(Capability *cap, Word *base, BcIns *startPc);
Word *pushFrame(Word *base, BcIns *returnPc, TRef noderef,
uint32_t framesize);
void finishRecording();
@@ -196,14 +210,14 @@ private:
static const int kLastInsWasBranch = 0;
static const int kIsReturnTrace = 1;
- static const int kDebugTrace = 2;
Capability *cap_;
BcIns *startPc_;
Word *startBase_;
Fragment *parent_;
ExitNo parentExitNo_;
- Flags32 flags_;
+ Flags32 flags_; // reset each time
+ Flags32 options_; // configuration options
TRef lastResult_;
std::vector<BcIns*> targets_;
Prng prng_;
Please sign in to comment.
Something went wrong with that request. Please try again.