mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Bug 1618198 part 2 - Implement various trivial bytecode ops. r=iain
Depends on D64368 Differential Revision: https://phabricator.services.mozilla.com/D64369 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
d80563daa8
commit
2bb1e352b2
@ -105,20 +105,20 @@ bool WarpBuilder::buildPrologue() {
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the environment chain.
|
||||
MInstruction* env = MConstant::New(alloc(), UndefinedValue());
|
||||
current->add(env);
|
||||
current->initSlot(info().environmentChainSlot(), env);
|
||||
MConstant* undef = constant(UndefinedValue());
|
||||
|
||||
// Initialize the return value.
|
||||
MInstruction* returnValue = MConstant::New(alloc(), UndefinedValue());
|
||||
current->add(returnValue);
|
||||
current->initSlot(info().returnValueSlot(), returnValue);
|
||||
// Initialize local slots.
|
||||
for (uint32_t i = 0; i < info().nlocals(); i++) {
|
||||
current->initSlot(info().localSlot(i), undef);
|
||||
}
|
||||
|
||||
// Initialize the environment chain and return value slots.
|
||||
current->initSlot(info().environmentChainSlot(), undef);
|
||||
current->initSlot(info().returnValueSlot(), undef);
|
||||
|
||||
current->add(MStart::New(alloc()));
|
||||
|
||||
// TODO: environment chain initialization
|
||||
// TODO: initialize local slots
|
||||
|
||||
// Guard against over-recursion.
|
||||
MCheckOverRecursed* check = MCheckOverRecursed::New(alloc());
|
||||
@ -165,11 +165,90 @@ bool WarpBuilder::buildEpilogue() { return true; }
|
||||
|
||||
bool WarpBuilder::build_Nop(BytecodeLocation) { return true; }
|
||||
|
||||
bool WarpBuilder::build_NopDestructuring(BytecodeLocation) { return true; }
|
||||
|
||||
bool WarpBuilder::build_TryDestructuring(BytecodeLocation) { return true; }
|
||||
|
||||
bool WarpBuilder::build_Lineno(BytecodeLocation) { return true; }
|
||||
|
||||
bool WarpBuilder::build_Undefined(BytecodeLocation) {
|
||||
// If this ever changes, change what JSOp::GImplicitThis does too.
|
||||
pushConstant(UndefinedValue());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_Void(BytecodeLocation) {
|
||||
current->pop();
|
||||
pushConstant(UndefinedValue());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_Null(BytecodeLocation) {
|
||||
pushConstant(NullValue());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_Hole(BytecodeLocation) {
|
||||
pushConstant(MagicValue(JS_ELEMENTS_HOLE));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_Uninitialized(BytecodeLocation) {
|
||||
pushConstant(MagicValue(JS_UNINITIALIZED_LEXICAL));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_False(BytecodeLocation) {
|
||||
pushConstant(BooleanValue(false));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_True(BytecodeLocation) {
|
||||
pushConstant(BooleanValue(true));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_Pop(BytecodeLocation) {
|
||||
current->pop();
|
||||
// TODO: IonBuilder inserts a resume point in loops, re-evaluate this.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_PopN(BytecodeLocation loc) {
|
||||
for (uint32_t i = 0, n = loc.getPopCount(); i < n; i++) {
|
||||
current->pop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_Dup(BytecodeLocation) {
|
||||
current->pushSlot(current->stackDepth() - 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_Dup2(BytecodeLocation) {
|
||||
uint32_t lhsSlot = current->stackDepth() - 2;
|
||||
uint32_t rhsSlot = current->stackDepth() - 1;
|
||||
current->pushSlot(lhsSlot);
|
||||
current->pushSlot(rhsSlot);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_Swap(BytecodeLocation) {
|
||||
current->swapAt(-1);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_Zero(BytecodeLocation) {
|
||||
pushConstant(Int32Value(0));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_One(BytecodeLocation) {
|
||||
pushConstant(Int32Value(1));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_Return(BytecodeLocation) {
|
||||
MDefinition* def = current->pop();
|
||||
|
||||
@ -194,3 +273,18 @@ bool WarpBuilder::build_RetRval(BytecodeLocation) {
|
||||
setTerminatedBlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_GetLocal(BytecodeLocation loc) {
|
||||
current->pushLocal(loc.local());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_SetLocal(BytecodeLocation loc) {
|
||||
current->setLocal(loc.local());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::build_InitLexical(BytecodeLocation loc) {
|
||||
current->setLocal(loc.local());
|
||||
return true;
|
||||
}
|
@ -18,7 +18,26 @@ namespace jit {
|
||||
// this should be replaced with the FOR_EACH_OPCODE macro.
|
||||
#define WARP_OPCODE_LIST(_) \
|
||||
_(Nop) \
|
||||
_(NopDestructuring) \
|
||||
_(TryDestructuring) \
|
||||
_(Lineno) \
|
||||
_(Undefined) \
|
||||
_(Void) \
|
||||
_(Null) \
|
||||
_(Hole) \
|
||||
_(Uninitialized) \
|
||||
_(False) \
|
||||
_(True) \
|
||||
_(Zero) \
|
||||
_(One) \
|
||||
_(Pop) \
|
||||
_(PopN) \
|
||||
_(Dup) \
|
||||
_(Dup2) \
|
||||
_(Swap) \
|
||||
_(GetLocal) \
|
||||
_(SetLocal) \
|
||||
_(InitLexical) \
|
||||
_(Return) \
|
||||
_(RetRval)
|
||||
|
||||
|
@ -192,6 +192,11 @@ class BytecodeLocation {
|
||||
return GET_JUMP_OFFSET(rawBytecode_ + (2 * JUMP_OFFSET_LEN));
|
||||
}
|
||||
|
||||
uint32_t getPopCount() const {
|
||||
MOZ_ASSERT(is(JSOp::PopN));
|
||||
return GET_UINT16(rawBytecode_);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
// To ease writing assertions
|
||||
bool isValid() const { return isValid(debugOnlyScript_); }
|
||||
|
Loading…
Reference in New Issue
Block a user