Skip to content

Commit

Permalink
Don't need to guard MBase
Browse files Browse the repository at this point in the history
Summary: After D8337098, we no longer need to guard on `MBase`.

Reviewed By: ricklavoie

Differential Revision: D50544898

fbshipit-source-id: 11ee112b513f0ea35eb4894dfb81d34710def845
  • Loading branch information
voorka authored and facebook-github-bot committed Oct 23, 2023
1 parent 2d8589f commit 15bb34a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
20 changes: 8 additions & 12 deletions hphp/runtime/vm/jit/region-tracelet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,17 @@ SBInvOffset curSpOffset(const Env& env) {
}

/*
* Check if the current predicted type for the location in ii is specific
* enough for what the current opcode wants. If not, return false.
* Check if the input has a known datatype or whether we need
* to insert a guard.
*/
bool consumeInput(Env& env, const InputInfo& input) {
if (input.dontGuard) return true;
bool needGuardForInput(Env& env, const InputInfo& input) {
if (input.dontGuard) return false;
auto const type = irgen::provenType(env.irgs, input.loc);

if (!type.isKnownDataType()) {
// Trying to consume a value without a precise enough type.
FTRACE(1, "selectTracelet: {} tried to consume {}, type {}\n",
env.inst.toString(), show(input.loc), type.toString());
return false;
}
if (type.isKnownDataType()) return false;

FTRACE(1, "selectTracelet: {} input {}, needs a guard due to unknown type {}\n",
env.inst.toString(), show(input.loc), type.toString());
return true;
}

Expand Down Expand Up @@ -242,9 +239,8 @@ bool prepareInstruction(Env& env) {
addGuardIfUntracked(Location::Stack{sbInvOff});
}

// Check all the inputs for unknown values.
for (auto const& input : inputInfos) {
if (!consumeInput(env, input)) {
if (needGuardForInput(env, input)) {
FTRACE(2, "Stopping tracelet consuming {} input {}\n",
opcodeToName(env.inst.op()), show(input.loc));
return false;
Expand Down
11 changes: 3 additions & 8 deletions hphp/runtime/vm/jit/translator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,7 @@ const InstrInfo& getInstrInfo(Op op) {
namespace {
int64_t countOperands(uint64_t mask) {
const uint64_t ignore = Local | Iter | DontGuardStack1 |
DontGuardAny | This | MBase | StackI | StackI2 | MKey | LocalRange |
DontGuardBase;
DontGuardAny | This | MBase | StackI | StackI2 | MKey | LocalRange;
mask &= ~ignore;

static const uint64_t counts[][2] = {
Expand Down Expand Up @@ -837,12 +836,8 @@ InputInfoVec getInputs(const NormalizedInstruction& ni, SBInvOffset bcSPOff) {
break;
}
}
if (flags & MBase) {
inputs.emplace_back(Location::MBase{});
if (flags & DontGuardBase) {
inputs.back().dontGuard = true;
}
}

if (flags & MBase) inputs.emplace_back(Location::MBase{});

SKTRACE(1, sk, "stack args: virtual sfo now %d\n", stackOff.offset);
TRACE(1, "%s\n", Trace::prettyNode("Inputs", inputs).c_str());
Expand Down

0 comments on commit 15bb34a

Please sign in to comment.