Bug 1530745 - Part 6: Change JSOP_RESUME immediate back to UINT8. r=arai

And add more assertions to document implicit requirements about opcode lengths.

Depends on D22670

Differential Revision: https://phabricator.services.mozilla.com/D22671

--HG--
extra : moz-landing-system : lando
This commit is contained in:
André Bargull 2019-03-08 12:38:47 +00:00
Родитель fdc89b3f4a
Коммит 2f06ea1477
5 изменённых файлов: 26 добавлений и 4 удалений

Просмотреть файл

@ -7128,11 +7128,11 @@ bool BytecodeEmitter::emitSelfHostedResumeGenerator(BinaryNode* callNode) {
ParseNode* kindNode = valNode->pn_next;
MOZ_ASSERT(kindNode->isKind(ParseNodeKind::StringExpr));
uint16_t operand = AbstractGeneratorObject::getResumeKind(
uint8_t operand = AbstractGeneratorObject::getResumeKind(
cx, kindNode->as<NameNode>().atom());
MOZ_ASSERT(!kindNode->pn_next);
if (!emitCall(JSOP_RESUME, operand)) {
if (!emit2(JSOP_RESUME, operand)) {
return false;
}

Просмотреть файл

@ -319,6 +319,11 @@ bool AbstractGeneratorObject::isAfterYieldOrAwait(JSOp op) {
return false;
}
static_assert(JSOP_YIELD_LENGTH == JSOP_INITIALYIELD_LENGTH,
"JSOP_YIELD and JSOP_INITIALYIELD must have the same length");
static_assert(JSOP_YIELD_LENGTH == JSOP_AWAIT_LENGTH,
"JSOP_YIELD and JSOP_AWAIT must have the same length");
uint32_t offset = nextOffset - JSOP_YIELD_LENGTH;
MOZ_ASSERT(code[offset] == JSOP_INITIALYIELD || code[offset] == JSOP_YIELD ||
code[offset] == JSOP_AWAIT);

Просмотреть файл

@ -41,7 +41,7 @@ class AbstractGeneratorObject : public NativeObject {
public:
static inline ResumeKind getResumeKind(jsbytecode* pc) {
MOZ_ASSERT(*pc == JSOP_RESUME);
unsigned arg = GET_UINT16(pc);
unsigned arg = GET_UINT8(pc);
MOZ_ASSERT(arg <= RETURN);
return static_cast<ResumeKind>(arg);
}

Просмотреть файл

@ -2111,6 +2111,10 @@ static MOZ_NEVER_INLINE JS_HAZ_JSNATIVE_CALLER bool Interpret(JSContext* cx,
if (MOZ_LIKELY(interpReturnOK)) {
TypeScript::Monitor(cx, script, REGS.pc, REGS.sp[-1]);
if (JSOp(*REGS.pc) == JSOP_RESUME) {
ADVANCE_AND_DISPATCH(JSOP_RESUME_LENGTH);
}
MOZ_ASSERT(CodeSpec[*REGS.pc].length == JSOP_CALL_LENGTH);
ADVANCE_AND_DISPATCH(JSOP_CALL_LENGTH);
}
@ -3024,6 +3028,19 @@ static MOZ_NEVER_INLINE JS_HAZ_JSNATIVE_CALLER bool Interpret(JSContext* cx,
CASE(JSOP_CALLITER)
CASE(JSOP_SUPERCALL)
CASE(JSOP_FUNCALL) {
static_assert(JSOP_CALL_LENGTH == JSOP_NEW_LENGTH,
"call and new must be the same size");
static_assert(JSOP_CALL_LENGTH == JSOP_CALL_IGNORES_RV_LENGTH,
"call and call-ignores-rv must be the same size");
static_assert(JSOP_CALL_LENGTH == JSOP_CALLITER_LENGTH,
"call and calliter must be the same size");
static_assert(JSOP_CALL_LENGTH == JSOP_SUPERCALL_LENGTH,
"call and supercall must be the same size");
static_assert(JSOP_CALL_LENGTH == JSOP_FUNCALL_LENGTH,
"call and funcall must be the same size");
static_assert(JSOP_CALL_LENGTH == JSOP_FUNAPPLY_LENGTH,
"call and funapply must be the same size");
if (REGS.fp()->hasPushedGeckoProfilerFrame()) {
cx->geckoProfiler().updatePC(cx, script, REGS.pc);
}

Просмотреть файл

@ -2220,7 +2220,7 @@
* Operands: resume kind (AbstractGeneratorObject::ResumeKind)
* Stack: gen, val => rval
*/ \
MACRO(JSOP_RESUME, 205, "resume", NULL, 3, 2, 1, JOF_UINT16|JOF_INVOKE) \
MACRO(JSOP_RESUME, 205, "resume", NULL, 2, 2, 1, JOF_UINT8|JOF_INVOKE) \
/*
* Load the callee stored in a CallObject on the environment chain. The
* numHops operand is the number of environment objects to skip on the