|
|
|
Lines 4142-4157
BytecodeEmitter::emitIteratorNext(ParseN
|
Link Here
|
|---|
|
| 4142 |
if (!emit1(JSOP_DUP)) // ... ITER ITER |
4142 |
if (!emit1(JSOP_DUP)) // ... ITER ITER |
| 4143 |
return false; |
4143 |
return false; |
| 4144 |
if (!emitAtomOp(cx->names().next, JSOP_CALLPROP)) // ... ITER NEXT |
4144 |
if (!emitAtomOp(cx->names().next, JSOP_CALLPROP)) // ... ITER NEXT |
| 4145 |
return false; |
4145 |
return false; |
| 4146 |
if (!emit1(JSOP_SWAP)) // ... NEXT ITER |
4146 |
if (!emit1(JSOP_SWAP)) // ... NEXT ITER |
| 4147 |
return false; |
4147 |
return false; |
| 4148 |
if (!emitCall(JSOP_CALL, 0, pn)) // ... RESULT |
4148 |
if (!emitCall(JSOP_CALL, 0, pn)) // ... RESULT |
| 4149 |
return false; |
4149 |
return false; |
|
|
4150 |
if (!emitRequireIsObjectIteratorNext()) // ... RESULT |
| 4151 |
return false; |
| 4150 |
checkTypeSet(JSOP_CALL); |
4152 |
checkTypeSet(JSOP_CALL); |
| 4151 |
return true; |
4153 |
return true; |
| 4152 |
} |
4154 |
} |
| 4153 |
|
4155 |
|
| 4154 |
bool |
4156 |
bool |
| 4155 |
BytecodeEmitter::emitDefault(ParseNode* defaultExpr) |
4157 |
BytecodeEmitter::emitDefault(ParseNode* defaultExpr) |
| 4156 |
{ |
4158 |
{ |
| 4157 |
if (!emit1(JSOP_DUP)) // VALUE VALUE |
4159 |
if (!emit1(JSOP_DUP)) // VALUE VALUE |
|
Lines 5662-5713
BytecodeEmitter::emitWith(ParseNode* pn)
|
Link Here
|
|---|
|
| 5662 |
if (!emitTree(pn->pn_right)) |
5664 |
if (!emitTree(pn->pn_right)) |
| 5663 |
return false; |
5665 |
return false; |
| 5664 |
if (!leaveNestedScope(&stmtInfo)) |
5666 |
if (!leaveNestedScope(&stmtInfo)) |
| 5665 |
return false; |
5667 |
return false; |
| 5666 |
return true; |
5668 |
return true; |
| 5667 |
} |
5669 |
} |
| 5668 |
|
5670 |
|
| 5669 |
bool |
5671 |
bool |
| 5670 |
BytecodeEmitter::emitRequireObjectCoercible() |
5672 |
BytecodeEmitter::emitCallSelfHosted1AfterDup(JSAtom* func) |
| 5671 |
{ |
5673 |
{ |
| 5672 |
// For simplicity, handle this in self-hosted code, at cost of 13 bytes of |
|
|
| 5673 |
// bytecode versus 1 byte for a dedicated opcode. As more places need this |
| 5674 |
// behavior, we may want to reconsider this tradeoff. |
| 5675 |
|
| 5676 |
#ifdef DEBUG |
5674 |
#ifdef DEBUG |
| 5677 |
auto depth = this->stackDepth; |
5675 |
auto depth = this->stackDepth; |
| 5678 |
#endif |
5676 |
#endif |
| 5679 |
MOZ_ASSERT(depth > 0); // VAL |
5677 |
MOZ_ASSERT(depth > 0); // VAL |
| 5680 |
if (!emit1(JSOP_DUP)) // VAL VAL |
5678 |
if (!emit1(JSOP_DUP)) // VAL VAL |
| 5681 |
return false; |
5679 |
return false; |
| 5682 |
|
5680 |
|
| 5683 |
// Note that "intrinsic" is a misnomer: we're calling a *self-hosted* |
5681 |
// Note that "intrinsic" is a misnomer: we're calling a *self-hosted* |
| 5684 |
// function that's not an intrinsic! But it nonetheless works as desired. |
5682 |
// function that's not an intrinsic! But it nonetheless works as desired. |
| 5685 |
if (!emitAtomOp(cx->names().RequireObjectCoercible, |
5683 |
if (!emitAtomOp(func, JSOP_GETINTRINSIC)) // VAL VAL FUNC |
| 5686 |
JSOP_GETINTRINSIC)) // VAL VAL REQUIREOBJECTCOERCIBLE |
5684 |
return false; |
| 5687 |
{ |
5685 |
if (!emit1(JSOP_UNDEFINED)) // VAL VAL FUNC UNDEFINED |
| 5688 |
return false; |
5686 |
return false; |
| 5689 |
} |
5687 |
if (!emit2(JSOP_PICK, 2)) // VAL FUNC UNDEFINED VAL |
| 5690 |
if (!emit1(JSOP_UNDEFINED)) // VAL VAL REQUIREOBJECTCOERCIBLE UNDEFINED |
|
|
| 5691 |
return false; |
| 5692 |
if (!emit2(JSOP_PICK, 2)) // VAL REQUIREOBJECTCOERCIBLE UNDEFINED VAL |
| 5693 |
return false; |
5688 |
return false; |
| 5694 |
if (!emitCall(JSOP_CALL, 1)) // VAL IGNORED |
5689 |
if (!emitCall(JSOP_CALL, 1)) // VAL IGNORED |
| 5695 |
return false; |
5690 |
return false; |
| 5696 |
checkTypeSet(JSOP_CALL); |
5691 |
checkTypeSet(JSOP_CALL); |
| 5697 |
|
5692 |
|
| 5698 |
if (!emit1(JSOP_POP)) // VAL |
5693 |
if (!emit1(JSOP_POP)) // VAL |
| 5699 |
return false; |
5694 |
return false; |
| 5700 |
|
5695 |
|
| 5701 |
MOZ_ASSERT(depth == this->stackDepth); |
5696 |
MOZ_ASSERT(depth == this->stackDepth); |
| 5702 |
return true; |
5697 |
return true; |
| 5703 |
} |
5698 |
} |
| 5704 |
|
5699 |
|
| 5705 |
bool |
5700 |
bool |
|
|
5701 |
BytecodeEmitter::emitRequireObjectCoercible() |
| 5702 |
{ |
| 5703 |
// For simplicity, handle this in self-hosted code, at cost of 13 bytes of |
| 5704 |
// bytecode versus 1 byte for a dedicated opcode. As more places need this |
| 5705 |
// behavior, we may want to reconsider this tradeoff. |
| 5706 |
|
| 5707 |
return emitCallSelfHosted1AfterDup(cx->names().RequireObjectCoercible); |
| 5708 |
} |
| 5709 |
|
| 5710 |
bool |
| 5711 |
BytecodeEmitter::emitRequireIsObjectIteratorNext() |
| 5712 |
{ |
| 5713 |
return emitCallSelfHosted1AfterDup(cx->names().RequireIsObjectIteratorNext); |
| 5714 |
} |
| 5715 |
|
| 5716 |
bool |
| 5706 |
BytecodeEmitter::emitIterator() |
5717 |
BytecodeEmitter::emitIterator() |
| 5707 |
{ |
5718 |
{ |
| 5708 |
// Convert iterable to iterator. |
5719 |
// Convert iterable to iterator. |
| 5709 |
if (!emit1(JSOP_DUP)) // OBJ OBJ |
5720 |
if (!emit1(JSOP_DUP)) // OBJ OBJ |
| 5710 |
return false; |
5721 |
return false; |
| 5711 |
if (!emit2(JSOP_SYMBOL, uint8_t(JS::SymbolCode::iterator))) // OBJ OBJ @@ITERATOR |
5722 |
if (!emit2(JSOP_SYMBOL, uint8_t(JS::SymbolCode::iterator))) // OBJ OBJ @@ITERATOR |
| 5712 |
return false; |
5723 |
return false; |
| 5713 |
if (!emitElemOpBase(JSOP_CALLELEM)) // OBJ ITERFN |
5724 |
if (!emitElemOpBase(JSOP_CALLELEM)) // OBJ ITERFN |
|
Lines 7228-7243
BytecodeEmitter::emitYieldStar(ParseNode
|
Link Here
|
|---|
|
| 7228 |
if (!emitAtomOp(cx->names().next, JSOP_CALLPROP)) // RECEIVED ITER ITER NEXT |
7239 |
if (!emitAtomOp(cx->names().next, JSOP_CALLPROP)) // RECEIVED ITER ITER NEXT |
| 7229 |
return false; |
7240 |
return false; |
| 7230 |
if (!emit1(JSOP_SWAP)) // RECEIVED ITER NEXT ITER |
7241 |
if (!emit1(JSOP_SWAP)) // RECEIVED ITER NEXT ITER |
| 7231 |
return false; |
7242 |
return false; |
| 7232 |
if (!emit2(JSOP_PICK, 3)) // ITER NEXT ITER RECEIVED |
7243 |
if (!emit2(JSOP_PICK, 3)) // ITER NEXT ITER RECEIVED |
| 7233 |
return false; |
7244 |
return false; |
| 7234 |
if (!emitCall(JSOP_CALL, 1, iter)) // ITER RESULT |
7245 |
if (!emitCall(JSOP_CALL, 1, iter)) // ITER RESULT |
| 7235 |
return false; |
7246 |
return false; |
|
|
7247 |
if (!emitRequireIsObjectIteratorNext()) // ITER RESULT |
| 7248 |
return false; |
| 7236 |
checkTypeSet(JSOP_CALL); |
7249 |
checkTypeSet(JSOP_CALL); |
| 7237 |
MOZ_ASSERT(this->stackDepth == depth); |
7250 |
MOZ_ASSERT(this->stackDepth == depth); |
| 7238 |
|
7251 |
|
| 7239 |
if (!emitJumpTargetAndPatch(checkResult)) // checkResult: |
7252 |
if (!emitJumpTargetAndPatch(checkResult)) // checkResult: |
| 7240 |
return false; |
7253 |
return false; |
| 7241 |
|
7254 |
|
| 7242 |
// if (!result.done) goto tryStart; // ITER RESULT |
7255 |
// if (!result.done) goto tryStart; // ITER RESULT |
| 7243 |
if (!emit1(JSOP_DUP)) // ITER RESULT RESULT |
7256 |
if (!emit1(JSOP_DUP)) // ITER RESULT RESULT |