Lines Matching refs:generator
79 RegisterID* ThrowableExpressionData::emitThrowReferenceError(BytecodeGenerator& generator, const UString& message)
81 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
82 generator.emitThrowReferenceError(message);
83 return generator.newTemporary();
88 RegisterID* NullNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
90 if (dst == generator.ignoredResult())
92 return generator.emitLoad(dst, jsNull());
97 RegisterID* BooleanNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
99 if (dst == generator.ignoredResult())
101 return generator.emitLoad(dst, m_value);
106 RegisterID* NumberNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
108 if (dst == generator.ignoredResult())
110 return generator.emitLoad(dst, m_value);
115 RegisterID* StringNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
117 if (dst == generator.ignoredResult())
119 return generator.emitLoad(dst, m_value);
124 RegisterID* RegExpNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
126 if (dst == generator.ignoredResult())
128 return generator.emitNewRegExp(generator.finalDestination(dst),
129 generator.globalData()->regExpCache()->lookupOrCreate(m_pattern.ustring(), regExpFlags(m_flags.ustring())));
134 RegisterID* ThisNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
136 if (dst == generator.ignoredResult())
138 return generator.moveToDestinationIfNeeded(dst, generator.thisRegister());
143 bool ResolveNode::isPure(BytecodeGenerator& generator) const
145 return generator.isLocal(m_ident);
148 RegisterID* ResolveNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
150 if (RegisterID* local = generator.registerFor(m_ident)) {
151 if (dst == generator.ignoredResult())
153 return generator.moveToDestinationIfNeeded(dst, local);
156 generator.emitExpressionInfo(m_startOffset + m_ident.length(), m_ident.length(), 0);
157 return generator.emitResolve(generator.finalDestination(dst), m_ident);
162 RegisterID* ArrayNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
175 return generator.emitNewArray(generator.finalDestination(dst), m_element);
177 RefPtr<RegisterID> array = generator.emitNewArray(generator.tempDestination(dst), m_element);
180 RegisterID* value = generator.emitNode(n->value());
182 generator.emitPutByIndex(array.get(), length++, value);
186 RegisterID* value = generator.emitLoad(0, jsNumber(m_elision + length));
187 generator.emitPutById(array.get(), generator.propertyNames().length, value);
190 return generator.moveToDestinationIfNeeded(dst, array.get());
222 RegisterID* ObjectLiteralNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
225 if (dst == generator.ignoredResult())
227 return generator.emitNewObject(generator.finalDestination(dst));
229 return generator.emitNode(dst, m_list);
234 RegisterID* PropertyListNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
236 RefPtr<RegisterID> newObj = generator.tempDestination(dst);
238 generator.emitNewObject(newObj.get());
241 RegisterID* value = generator.emitNode(p->m_node->m_assign);
245 generator.emitDirectPutById(newObj.get(), p->m_node->name(), value);
249 generator.emitPutGetter(newObj.get(), p->m_node->name(), value);
253 generator.emitPutSetter(newObj.get(), p->m_node->name(), value);
261 return generator.moveToDestinationIfNeeded(dst, newObj.get());
266 RegisterID* BracketAccessorNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
268 if (m_base->isResolveNode() && generator.willResolveToArguments(static_cast<ResolveNode*>(m_base)->identifier())) {
269 RegisterID* property = generator.emitNode(m_subscript);
270 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
271 return generator.emitGetArgumentByVal(generator.finalDestination(dst), generator.uncheckedRegisterForArguments(), property);
274 RefPtr<RegisterID> base = generator.emitNodeForLeftHandSide(m_base, m_subscriptHasAssignments, m_subscript->isPure(generator));
275 RegisterID* property = generator.emitNode(m_subscript);
276 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
277 return generator.emitGetByVal(generator.finalDestination(dst), base.get(), property);
282 RegisterID* DotAccessorNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
284 if (m_ident == generator.propertyNames().length) {
288 if (!generator.willResolveToArguments(resolveNode->identifier()))
290 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
291 return generator.emitGetArgumentsLength(generator.finalDestination(dst), generator.uncheckedRegisterForArguments());
295 RegisterID* base = generator.emitNode(m_base);
296 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
297 return generator.emitGetById(generator.finalDestination(dst), base, m_ident);
302 RegisterID* ArgumentListNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
305 return generator.emitNode(dst, m_expr);
310 RegisterID* NewExprNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
312 RefPtr<RegisterID> func = generator.emitNode(m_expr);
313 CallArguments callArguments(generator, m_args);
314 return generator.emitConstruct(generator.finalDestinationOrIgnored(dst), func.get(), callArguments, divot(), startOffset(), endOffset());
317 CallArguments::CallArguments(BytecodeGenerator& generator, ArgumentsNode* argumentsNode)
320 if (generator.shouldEmitProfileHooks())
321 m_profileHookRegister = generator.newTemporary();
322 m_argv.append(generator.newTemporary());
325 m_argv.append(generator.newTemporary());
334 RegisterID* EvalFunctionCallNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
336 RefPtr<RegisterID> func = generator.tempDestination(dst);
337 CallArguments callArguments(generator, m_args);
338 generator.emitExpressionInfo(divot() - startOffset() + 4, 4, 0);
339 generator.emitResolveWithBase(callArguments.thisRegister(), func.get(), generator.propertyNames().eval);
340 return generator.emitCallEval(generator.finalDestination(dst, func.get()), func.get(), callArguments, divot(), startOffset(), endOffset());
345 RegisterID* FunctionCallValueNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
347 RefPtr<RegisterID> func = generator.emitNode(m_expr);
348 CallArguments callArguments(generator, m_args);
349 generator.emitLoad(callArguments.thisRegister(), jsUndefined());
350 return generator.emitCall(generator.finalDestinationOrIgnored(dst, func.get()), func.get(), callArguments, divot(), startOffset(), endOffset());
355 RegisterID* FunctionCallResolveNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
357 if (RefPtr<RegisterID> local = generator.registerFor(m_ident)) {
358 CallArguments callArguments(generator, m_args);
359 generator.emitLoad(callArguments.thisRegister(), jsUndefined());
360 return generator.emitCall(generator.finalDestinationOrIgnored(dst, callArguments.thisRegister()), local.get(), callArguments, divot(), startOffset(), endOffset());
367 if (generator.findScopedProperty(m_ident, index, depth, false, requiresDynamicChecks, globalObject) && index != missingSymbolMarker() && !requiresDynamicChecks) {
368 RefPtr<RegisterID> func = generator.emitGetScopedVar(generator.newTemporary(), depth, index, globalObject);
369 CallArguments callArguments(generator, m_args);
370 generator.emitLoad(callArguments.thisRegister(), jsUndefined());
371 return generator.emitCall(generator.finalDestinationOrIgnored(dst, func.get()), func.get(), callArguments, divot(), startOffset(), endOffset());
374 RefPtr<RegisterID> func = generator.newTemporary();
375 CallArguments callArguments(generator, m_args);
377 generator.emitExpressionInfo(identifierStart + m_ident.length(), m_ident.length(), 0);
378 generator.emitResolveWithBase(callArguments.thisRegister(), func.get(), m_ident);
379 return generator.emitCall(generator.finalDestinationOrIgnored(dst, func.get()), func.get(), callArguments, divot(), startOffset(), endOffset());
384 RegisterID* FunctionCallBracketNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
386 RefPtr<RegisterID> base = generator.emitNode(m_base);
387 RegisterID* property = generator.emitNode(m_subscript);
388 generator.emitExpressionInfo(divot() - m_subexpressionDivotOffset, startOffset() - m_subexpressionDivotOffset, m_subexpressionEndOffset);
389 RefPtr<RegisterID> function = generator.emitGetByVal(generator.tempDestination(dst), base.get(), property);
390 CallArguments callArguments(generator, m_args);
391 generator.emitMove(callArguments.thisRegister(), base.get());
392 return generator.emitCall(generator.finalDestinationOrIgnored(dst, function.get()), function.get(), callArguments, divot(), startOffset(), endOffset());
397 RegisterID* FunctionCallDotNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
399 RefPtr<RegisterID> function = generator.tempDestination(dst);
400 CallArguments callArguments(generator, m_args);
401 generator.emitNode(callArguments.thisRegister(), m_base);
402 generator.emitExpressionInfo(divot() - m_subexpressionDivotOffset, startOffset() - m_subexpressionDivotOffset, m_subexpressionEndOffset);
403 generator.emitMethodCheck();
404 generator.emitGetById(function.get(), callArguments.thisRegister(), m_ident);
405 return generator.emitCall(generator.finalDestinationOrIgnored(dst, function.get()), function.get(), callArguments, divot(), startOffset(), endOffset());
408 RegisterID* CallFunctionCallDotNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
410 generator.newLabel();
411 RefPtr<Label> end = generator.newLabel();
412 RefPtr<RegisterID> base = generator.emitNode(m_base);
413 generator.emitExpressionInfo(divot() - m_subexpressionDivotOffset, startOffset() - m_subexpressionDivotOffset, m_subexpressionEndOffset);
414 RefPtr<RegisterID> function = generator.emitGetById(generator.tempDestination(dst), base.get(), m_ident);
415 RefPtr<RegisterID> finalDestinationOrIgnored = generator.finalDestinationOrIgnored(dst, function.get());
416 generator.emitJumpIfNotFunctionCall(function.get(), realCall.get());
422 RefPtr<RegisterID> realFunction = generator.emitMove(generator.tempDestination(dst), base.get());
423 CallArguments callArguments(generator, m_args);
424 generator.emitNode(callArguments.thisRegister(), oldList->m_expr);
425 generator.emitCall(finalDestinationOrIgnored.get(), realFunction.get(), callArguments, divot(), startOffset(), endOffset());
426 generator.emitJump(end.get());
431 RefPtr<RegisterID> realFunction = generator.emitMove(generator.tempDestination(dst), base.get());
432 CallArguments callArguments(generator, m_args);
433 generator.emitLoad(callArguments.thisRegister(), jsUndefined());
434 generator.emitCall(finalDestinationOrIgnored.get(), realFunction.get(), callArguments, divot(), startOffset(), endOffset());
435 generator.emitJump(end.get());
438 generator.emitLabel(realCall.get());
440 CallArguments callArguments(generator, m_args);
441 generator.emitMove(callArguments.thisRegister(), base.get());
442 generator.emitCall(finalDestinationOrIgnored.get(), function.get(), callArguments, divot(), startOffset(), endOffset());
444 generator.emitLabel(end.get());
454 RegisterID* ApplyFunctionCallDotNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
461 RefPtr<Label> realCall = generator.newLabel();
462 RefPtr<Label> end = generator.newLabel();
463 RefPtr<RegisterID> base = generator.emitNode(m_base);
464 generator.emitExpressionInfo(divot() - m_subexpressionDivotOffset, startOffset() - m_subexpressionDivotOffset, m_subexpressionEndOffset);
465 RefPtr<RegisterID> function = generator.emitGetById(generator.tempDestination(dst), base.get(), m_ident);
466 RefPtr<RegisterID> finalDestinationOrIgnored = generator.finalDestinationOrIgnored(dst, function.get());
467 generator.emitJumpIfNotFunctionApply(function.get(), realCall.get());
475 m_args->m_listNode = static_cast<ArrayNode*>(m_args->m_listNode->m_next->m_expr)->toArgumentList(generator.globalData());
476 RefPtr<RegisterID> realFunction = generator.emitMove(generator.tempDestination(dst), base.get());
477 CallArguments callArguments(generator, m_args);
478 generator.emitNode(callArguments.thisRegister(), oldList->m_expr);
479 generator.emitCall(finalDestinationOrIgnored.get(), realFunction.get(), callArguments, divot(), startOffset(), endOffset());
482 RefPtr<RegisterID> realFunction = generator.emitMove(generator.tempDestination(dst), base.get());
483 CallArguments callArguments(generator, m_args);
484 generator.emitNode(callArguments.thisRegister(), oldList->m_expr);
485 generator.emitCall(finalDestinationOrIgnored.get(), realFunction.get(), callArguments, divot(), startOffset(), endOffset());
489 RefPtr<RegisterID> realFunction = generator.emitMove(generator.tempDestination(dst), base.get());
490 CallArguments callArguments(generator, m_args);
491 generator.emitLoad(callArguments.thisRegister(), jsUndefined());
492 generator.emitCall(finalDestinationOrIgnored.get(), realFunction.get(), callArguments, divot(), startOffset(), endOffset());
496 RefPtr<RegisterID> realFunction = generator.emitMove(generator.newTemporary(), base.get());
497 RefPtr<RegisterID> argsCountRegister = generator.newTemporary();
498 RefPtr<RegisterID> thisRegister = generator.newTemporary();
499 RefPtr<RegisterID> argsRegister = generator.newTemporary();
500 generator.emitNode(thisRegister.get(), m_args->m_listNode->m_expr);
505 isArgumentsApply = generator.willResolveToArguments(resolveNode->identifier());
507 generator.emitMove(argsRegister.get(), generator.uncheckedRegisterForArguments());
510 generator.emitNode(argsRegister.get(), args->m_expr);
512 generator.emitNode(args->m_expr);
514 generator.emitLoadVarargs(argsCountRegister.get(), thisRegister.get(), argsRegister.get());
515 generator.emitCallVarargs(finalDestinationOrIgnored.get(), realFunction.get(), thisRegister.get(), argsCountRegister.get(), divot(), startOffset(), endOffset());
517 generator.emitJump(end.get());
519 generator.emitLabel(realCall.get());
521 CallArguments callArguments(generator, m_args);
522 generator.emitMove(callArguments.thisRegister(), base.get());
523 generator.emitCall(finalDestinationOrIgnored.get(), function.get(), callArguments, divot(), startOffset(), endOffset());
525 generator.emitLabel(end.get());
531 static RegisterID* emitPreIncOrDec(BytecodeGenerator& generator, RegisterID* srcDst, Operator oper)
533 return (oper == OpPlusPlus) ? generator.emitPreInc(srcDst) : generator.emitPreDec(srcDst);
536 static RegisterID* emitPostIncOrDec(BytecodeGenerator& generator, RegisterID* dst, RegisterID* srcDst, Operator oper)
539 return generator.emitToJSNumber(dst, srcDst);
540 return (oper == OpPlusPlus) ? generator.emitPostInc(dst, srcDst) : generator.emitPostDec(dst, srcDst);
543 RegisterID* PostfixResolveNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
545 if (RegisterID* local = generator.registerFor(m_ident)) {
546 if (generator.isLocalConstant(m_ident)) {
547 if (dst == generator.ignoredResult())
549 return generator.emitToJSNumber(generator.finalDestination(dst), local);
552 if (dst == generator.ignoredResult())
553 return emitPreIncOrDec(generator, local, m_operator);
554 return emitPostIncOrDec(generator, generator.finalDestination(dst), local, m_operator);
561 if (generator.findScopedProperty(m_ident, index, depth, true, requiresDynamicChecks, globalObject) && index != missingSymbolMarker() && !requiresDynamicChecks) {
562 RefPtr<RegisterID> value = generator.emitGetScopedVar(generator.newTemporary(), depth, index, globalObject);
564 if (dst == generator.ignoredResult()) {
566 emitPreIncOrDec(generator, value.get(), m_operator);
568 oldValue = emitPostIncOrDec(generator, generator.finalDestination(dst), value.get(), m_operator);
570 generator.emitPutScopedVar(depth, index, value.get(), globalObject);
574 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
575 RefPtr<RegisterID> value = generator.newTemporary();
576 RefPtr<RegisterID> base = generator.emitResolveWithBase(generator.newTemporary(), value.get(), m_ident);
578 if (dst == generator.ignoredResult()) {
580 emitPreIncOrDec(generator, value.get(), m_operator);
582 oldValue = emitPostIncOrDec(generator, generator.finalDestination(dst), value.get(), m_operator);
584 generator.emitPutById(base.get(), m_ident, value.get());
590 RegisterID* PostfixBracketNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
592 RefPtr<RegisterID> base = generator.emitNode(m_base);
593 RefPtr<RegisterID> property = generator.emitNode(m_subscript);
595 generator.emitExpressionInfo(divot() - m_subexpressionDivotOffset, startOffset() - m_subexpressionDivotOffset, m_subexpressionEndOffset);
596 RefPtr<RegisterID> value = generator.emitGetByVal(generator.newTemporary(), base.get(), property.get());
598 if (dst == generator.ignoredResult()) {
601 generator.emitPreInc(value.get());
603 generator.emitPreDec(value.get());
605 oldValue = (m_operator == OpPlusPlus) ? generator.emitPostInc(generator.finalDestination(dst), value.get()) : generator.emitPostDec(generator.finalDestination(dst), value.get());
607 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
608 generator.emitPutByVal(base.get(), property.get(), value.get());
614 RegisterID* PostfixDotNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
616 RefPtr<RegisterID> base = generator.emitNode(m_base);
618 generator.emitExpressionInfo(divot() - m_subexpressionDivotOffset, startOffset() - m_subexpressionDivotOffset, m_subexpressionEndOffset);
619 RefPtr<RegisterID> value = generator.emitGetById(generator.newTemporary(), base.get(), m_ident);
621 if (dst == generator.ignoredResult()) {
624 generator.emitPreInc(value.get());
626 generator.emitPreDec(value.get());
628 oldValue = (m_operator == OpPlusPlus) ? generator.emitPostInc(generator.finalDestination(dst), value.get()) : generator.emitPostDec(generator.finalDestination(dst), value.get());
630 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
631 generator.emitPutById(base.get(), m_ident, value.get());
637 RegisterID* PostfixErrorNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
639 return emitThrowReferenceError(generator, m_operator == OpPlusPlus
646 RegisterID* DeleteResolveNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
648 if (generator.registerFor(m_ident))
649 return generator.emitLoad(generator.finalDestination(dst), false);
651 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
652 RegisterID* base = generator.emitResolveBase(generator.tempDestination(dst), m_ident);
653 return generator.emitDeleteById(generator.finalDestination(dst, base), base, m_ident);
658 RegisterID* DeleteBracketNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
660 RefPtr<RegisterID> r0 = generator.emitNode(m_base);
661 RegisterID* r1 = generator.emitNode(m_subscript);
663 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
664 return generator.emitDeleteByVal(generator.finalDestination(dst), r0.get(), r1);
669 RegisterID* DeleteDotNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
671 RegisterID* r0 = generator.emitNode(m_base);
673 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
674 return generator.emitDeleteById(generator.finalDestination(dst), r0, m_ident);
679 RegisterID* DeleteValueNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
681 generator.emitNode(generator.ignoredResult(), m_expr);
684 return generator.emitLoad(generator.finalDestination(dst), true);
689 RegisterID* VoidNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
691 if (dst == generator.ignoredResult()) {
692 generator.emitNode(generator.ignoredResult(), m_expr);
695 RefPtr<RegisterID> r0 = generator.emitNode(m_expr);
696 return generator.emitLoad(dst, jsUndefined());
701 RegisterID* TypeOfResolveNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
703 if (RegisterID* local = generator.registerFor(m_ident)) {
704 if (dst == generator.ignoredResult())
706 return generator.emitTypeOf(generator.finalDestination(dst), local);
709 RefPtr<RegisterID> scratch = generator.emitResolveBase(generator.tempDestination(dst), m_ident);
710 generator.emitGetById(scratch.get(), scratch.get(), m_ident);
711 if (dst == generator.ignoredResult())
713 return generator.emitTypeOf(generator.finalDestination(dst, scratch.get()), scratch.get());
718 RegisterID* TypeOfValueNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
720 if (dst == generator.ignoredResult()) {
721 generator.emitNode(generator.ignoredResult(), m_expr);
724 RefPtr<RegisterID> src = generator.emitNode(m_expr);
725 return generator.emitTypeOf(generator.finalDestination(dst), src.get());
730 RegisterID* PrefixResolveNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
732 if (RegisterID* local = generator.registerFor(m_ident)) {
733 if (generator.isLocalConstant(m_ident)) {
734 if (dst == generator.ignoredResult())
736 RefPtr<RegisterID> r0 = generator.emitLoad(generator.finalDestination(dst), (m_operator == OpPlusPlus) ? 1.0 : -1.0);
737 return generator
740 emitPreIncOrDec(generator, local, m_operator);
741 return generator.moveToDestinationIfNeeded(dst, local);
748 if (generator.findScopedProperty(m_ident, index, depth, false, requiresDynamicChecks, globalObject) && index != missingSymbolMarker() && !requiresDynamicChecks) {
749 RefPtr<RegisterID> propDst = generator.emitGetScopedVar(generator.tempDestination(dst), depth, index, globalObject);
750 emitPreIncOrDec(generator, propDst.get(), m_operator);
751 generator.emitPutScopedVar(depth, index, propDst.get(), globalObject);
752 return generator.moveToDestinationIfNeeded(dst, propDst.get());
755 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
756 RefPtr<RegisterID> propDst = generator.tempDestination(dst);
757 RefPtr<RegisterID> base = generator.emitResolveWithBase(generator.newTemporary(), propDst.get(), m_ident);
758 emitPreIncOrDec(generator, propDst.get(), m_operator);
759 generator.emitPutById(base.get(), m_ident, propDst.get());
760 return generator.moveToDestinationIfNeeded(dst, propDst.get());
765 RegisterID* PrefixBracketNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
767 RefPtr<RegisterID> base = generator.emitNode(m_base);
768 RefPtr<RegisterID> property = generator.emitNode(m_subscript);
769 RefPtr<RegisterID> propDst = generator.tempDestination(dst);
771 generator.emitExpressionInfo(divot() + m_subexpressionDivotOffset, m_subexpressionStartOffset, endOffset() - m_subexpressionDivotOffset);
772 RegisterID* value = generator.emitGetByVal(propDst.get(), base.get(), property.get());
774 generator.emitPreInc(value);
776 generator.emitPreDec(value);
777 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
778 generator.emitPutByVal(base.get(), property.get(), value);
779 return generator.moveToDestinationIfNeeded(dst, propDst.get());
784 RegisterID* PrefixDotNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
786 RefPtr<RegisterID> base = generator.emitNode(m_base);
787 RefPtr<RegisterID> propDst = generator.tempDestination(dst);
789 generator.emitExpressionInfo(divot() + m_subexpressionDivotOffset, m_subexpressionStartOffset, endOffset() - m_subexpressionDivotOffset);
790 RegisterID* value = generator.emitGetById(propDst.get(), base.get(), m_ident);
792 generator.emitPreInc(value);
794 generator.emitPreDec(value);
795 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
796 generator.emitPutById(base.get(), m_ident, value);
797 return generator.moveToDestinationIfNeeded(dst, propDst.get());
802 RegisterID* PrefixErrorNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
804 return emitThrowReferenceError(generator, m_operator == OpPlusPlus
811 RegisterID* UnaryOpNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
813 RegisterID* src = generator.emitNode(m_expr);
814 return generator.emitUnaryOp(opcodeID(), generator.finalDestination(dst), src);
820 void LogicalNotNode::emitBytecodeInConditionContext(BytecodeGenerator& generator, Label* trueTarget, Label* falseTarget, bool fallThroughMeansTrue)
825 generator.emitNodeInConditionContext(expr(), falseTarget, trueTarget, !fallThroughMeansTrue);
859 RegisterID* BinaryOpNode::emitStrcat(BytecodeGenerator& generator, RegisterID* dst, RegisterID* lhs, ReadModifyResolveNode* emitExpressionInfoForMe)
885 temporaryRegisters.append(generator.newTemporary());
888 temporaryRegisters.append(generator.newTemporary());
890 generator.emitNode(leftMostAddChildTempRegister, leftMostAddChild);
921 temporaryRegisters.append(generator.newTemporary());
922 generator.emitNode(temporaryRegisters.last().get(), node);
927 generator.emitToPrimitive(leftMostAddChildTempRegister, leftMostAddChildTempRegister);
932 generator.emitToPrimitive(temporaryRegisters.last().get(), temporaryRegisters.last().get());
939 generator.emitExpressionInfo(emitExpressionInfoForMe->divot(), emitExpressionInfoForMe->startOffset(), emitExpressionInfoForMe->endOffset());
944 generator.emitToPrimitive(temporaryRegisters[0].get(), lhs);
946 return generator.emitStrcat(generator.finalDestination(dst, temporaryRegisters[0].get()), temporaryRegisters[0].get(), temporaryRegisters.size());
949 RegisterID* BinaryOpNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
954 return emitStrcat(generator, dst);
958 RefPtr<RegisterID> src = generator.tempDestination(dst);
959 generator.emitNode(src.get(), m_expr1->isNull() ? m_expr2 : m_expr1);
960 return generator.emitUnaryOp(op_neq_null, generator.finalDestination(dst, src.get()), src.get());
964 RefPtr<RegisterID> src1 = generator.emitNodeForLeftHandSide(m_expr1, m_rightHasAssignments, m_expr2->isPure(generator));
965 RegisterID* src2 = generator.emitNode(m_expr2);
966 return generator.emitBinaryOp(opcodeID, generator.finalDestination(dst, src1.get()), src1.get(), src2, OperandTypes(m_expr1->resultDescriptor(), m_expr2->resultDescriptor()));
969 RegisterID* EqualNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
972 RefPtr<RegisterID> src = generator.tempDestination(dst);
973 generator.emitNode(src.get(), m_expr1->isNull() ? m_expr2 : m_expr1);
974 return generator.emitUnaryOp(op_eq_null, generator.finalDestination(dst, src.get()), src.get());
977 RefPtr<RegisterID> src1 = generator.emitNodeForLeftHandSide(m_expr1, m_rightHasAssignments, m_expr2->isPure(generator));
978 RegisterID* src2 = generator.emitNode(m_expr2);
979 return generator.emitEqualityOp(op_eq, generator.finalDestination(dst, src1.get()), src1.get(), src2);
982 RegisterID* StrictEqualNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
984 RefPtr<RegisterID> src1 = generator.emitNodeForLeftHandSide(m_expr1, m_rightHasAssignments, m_expr2->isPure(generator));
985 RegisterID* src2 = generator.emitNode(m_expr2);
986 return generator.emitEqualityOp(op_stricteq, generator.finalDestination(dst, src1.get()), src1.get(), src2);
989 RegisterID* ReverseBinaryOpNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
991 RefPtr<RegisterID> src1 = generator.emitNodeForLeftHandSide(m_expr1, m_rightHasAssignments, m_expr2->isPure(generator));
992 RegisterID* src2 = generator.emitNode(m_expr2);
993 return generator.emitBinaryOp(opcodeID(), generator.finalDestination(dst, src1.get()), src2, src1.get(), OperandTypes(m_expr2->resultDescriptor(), m_expr1->resultDescriptor()));
996 RegisterID* ThrowableBinaryOpNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
998 RefPtr<RegisterID> src1 = generator.emitNodeForLeftHandSide(m_expr1, m_rightHasAssignments, m_expr2->isPure(generator));
999 RegisterID* src2 = generator.emitNode(m_expr2);
1000 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
1001 return generator.emitBinaryOp(opcodeID(), generator.finalDestination(dst, src1.get()), src1.get(), src2, OperandTypes(m_expr1->resultDescriptor(), m_expr2->resultDescriptor()));
1004 RegisterID* InstanceOfNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1006 RefPtr<RegisterID> src1 = generator.emitNodeForLeftHandSide(m_expr1, m_rightHasAssignments, m_expr2->isPure(generator));
1007 RefPtr<RegisterID> src2 = generator.emitNode(m_expr2);
1009 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
1010 generator.emitCheckHasInstance(src2.get());
1012 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
1013 RegisterID* src2Prototype = generator.emitGetById(generator.newTemporary(), src2.get(), generator.globalData()->propertyNames->prototype);
1015 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
1016 return generator.emitInstanceOf(generator.finalDestination(dst, src1.get()), src1.get(), src2.get(), src2Prototype);
1021 RegisterID* LogicalOpNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1023 RefPtr<RegisterID> temp = generator.tempDestination(dst);
1024 RefPtr<Label> target = generator.newLabel();
1026 generator.emitNode(temp.get(), m_expr1);
1028 generator.emitJumpIfFalse(temp.get(), target.get());
1030 generator.emitJumpIfTrue(temp.get(), target.get());
1031 generator.emitNode(temp.get(), m_expr2);
1032 generator.emitLabel(target.get());
1034 return generator.moveToDestinationIfNeeded(dst, temp.get());
1037 void LogicalOpNode::emitBytecodeInConditionContext(BytecodeGenerator& generator, Label* trueTarget, Label* falseTarget, bool fallThroughMeansTrue)
1040 RefPtr<Label> afterExpr1 = generator.newLabel();
1042 generator.emitNodeInConditionContext(m_expr1, afterExpr1.get(), falseTarget, true);
1044 generator.emitNodeInConditionContext(m_expr1, trueTarget, afterExpr1.get(), false);
1045 generator.emitLabel(afterExpr1.get());
1047 RegisterID* temp = generator.emitNode(m_expr1);
1049 generator.emitJumpIfFalse(temp, falseTarget);
1051 generator.emitJumpIfTrue(temp, trueTarget);
1055 generator.emitNodeInConditionContext(m_expr2, trueTarget, falseTarget, fallThroughMeansTrue);
1057 RegisterID* temp = generator.emitNode(m_expr2);
1059 generator.emitJumpIfFalse(temp, falseTarget);
1061 generator.emitJumpIfTrue(temp, trueTarget);
1067 RegisterID* ConditionalNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1069 RefPtr<RegisterID> newDst = generator.finalDestination(dst);
1070 RefPtr<Label> beforeElse = generator.newLabel();
1071 RefPtr<Label> afterElse = generator.newLabel();
1074 RefPtr<Label> beforeThen = generator
1075 generator.emitNodeInConditionContext(m_logical, beforeThen.get(), beforeElse.get(), true);
1076 generator.emitLabel(beforeThen.get());
1078 RegisterID* cond = generator.emitNode(m_logical);
1079 generator.emitJumpIfFalse(cond, beforeElse.get());
1082 generator.emitNode(newDst.get(), m_expr1);
1083 generator.emitJump(afterElse.get());
1085 generator.emitLabel(beforeElse.get());
1086 generator.emitNode(newDst.get(), m_expr2);
1088 generator.emitLabel(afterElse.get());
1096 static ALWAYS_INLINE RegisterID* emitReadModifyAssignment(BytecodeGenerator& generator, RegisterID* dst, RegisterID* src1, ExpressionNode* m_right, Operator oper, OperandTypes types, ReadModifyResolveNode* emitExpressionInfoForMe = 0)
1108 return static_cast<AddNode*>(m_right)->emitStrcat(generator, dst, src1, emitExpressionInfoForMe);
1140 RegisterID* src2 = generator.emitNode(m_right);
1145 generator.emitExpressionInfo(emitExpressionInfoForMe->divot(), emitExpressionInfoForMe->startOffset(), emitExpressionInfoForMe->endOffset());
1147 return generator.emitBinaryOp(opcodeID, dst, src1, src2, types);
1150 RegisterID* ReadModifyResolveNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1152 if (RegisterID* local = generator.registerFor(m_ident)) {
1153 if (generator.isLocalConstant(m_ident)) {
1154 return emitReadModifyAssignment(generator, generator.finalDestination(dst), local, m_right, m_operator, OperandTypes(ResultType::unknownType(), m_right->resultDescriptor()));
1157 if (generator.leftHandSideNeedsCopy(m_rightHasAssignments, m_right->isPure(generator))) {
1158 RefPtr<RegisterID> result = generator.newTemporary();
1159 generator.emitMove(result.get(), local);
1160 emitReadModifyAssignment(generator, result.get(), result.get(), m_right, m_operator, OperandTypes(ResultType::unknownType(), m_right->resultDescriptor()));
1161 generator.emitMove(local, result.get());
1162 return generator.moveToDestinationIfNeeded(dst, result.get());
1165 RegisterID* result = emitReadModifyAssignment(generator, local, local, m_right, m_operator, OperandTypes(ResultType::unknownType(), m_right->resultDescriptor()));
1166 return generator.moveToDestinationIfNeeded(dst, result);
1173 if (generator.findScopedProperty(m_ident, index, depth, true, requiresDynamicChecks, globalObject) && index != missingSymbolMarker() && !requiresDynamicChecks) {
1174 RefPtr<RegisterID> src1 = generator.emitGetScopedVar(generator.tempDestination(dst), depth, index, globalObject);
1175 RegisterID* result = emitReadModifyAssignment(generator, generator.finalDestination(dst, src1.get()), src1.get(), m_right, m_operator, OperandTypes(ResultType::unknownType(), m_right->resultDescriptor()));
1176 generator.emitPutScopedVar(depth, index, result, globalObject);
1180 RefPtr<RegisterID> src1 = generator.tempDestination(dst);
1181 generator.emitExpressionInfo(divot() - startOffset() + m_ident.length(), m_ident.length(), 0);
1182 RefPtr<RegisterID> base = generator.emitResolveWithBase(generator.newTemporary(), src1.get(), m_ident);
1183 RegisterID* result = emitReadModifyAssignment(generator, generator.finalDestination(dst, src1.get()), src1.get(), m_right, m_operator, OperandTypes(ResultType::unknownType(), m_right->resultDescriptor()), this);
1184 return generator.emitPutById(base.get(), m_ident, result);
1189 RegisterID* AssignResolveNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1191 if (RegisterID* local = generator.registerFor(m_ident)) {
1192 if (generator.isLocalConstant(m_ident))
1193 return generator.emitNode(dst, m_right);
1195 RegisterID* result = generator.emitNode(local, m_right);
1196 return generator.moveToDestinationIfNeeded(dst, result);
1203 if (generator.findScopedProperty(m_ident, index, depth, true, requiresDynamicChecks, globalObject) && index != missingSymbolMarker() && !requiresDynamicChecks) {
1204 if (dst == generator.ignoredResult())
1206 RegisterID* value = generator.emitNode(dst, m_right);
1207 generator.emitPutScopedVar(depth, index, value, globalObject);
1211 RefPtr<RegisterID> base = generator.emitResolveBaseForPut(generator.newTemporary(), m_ident);
1212 if (dst == generator.ignoredResult())
1214 RegisterID* value = generator.emitNode(dst, m_right);
1215 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
1216 return generator.emitPutById(base.get(), m_ident, value);
1221 RegisterID* AssignDotNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1223 RefPtr<RegisterID> base = generator.emitNodeForLeftHandSide(m_base, m_rightHasAssignments, m_right->isPure(generator));
1224 RefPtr<RegisterID> value = generator.destinationForAssignResult(dst);
1225 RegisterID* result = generator.emitNode(value.get(), m_right);
1226 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
1227 generator.emitPutById(base.get(), m_ident, result);
1228 return generator.moveToDestinationIfNeeded(dst, result);
1233 RegisterID* ReadModifyDotNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1235 RefPtr<RegisterID> base = generator.emitNodeForLeftHandSide(m_base, m_rightHasAssignments, m_right->isPure(generator));
1237 generator.emitExpressionInfo(divot() - m_subexpressionDivotOffset, startOffset() - m_subexpressionDivotOffset, m_subexpressionEndOffset);
1238 RefPtr<RegisterID> value = generator.emitGetById(generator.tempDestination(dst), base.get(), m_ident);
1239 RegisterID* updatedValue = emitReadModifyAssignment(generator, generator.finalDestination(dst, value.get()), value.get(), m_right, m_operator, OperandTypes(ResultType::unknownType(), m_right->resultDescriptor()));
1241 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
1242 return generator.emitPutById(base.get(), m_ident, updatedValue);
1247 RegisterID* AssignErrorNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
1249 return emitThrowReferenceError(generator, "Left side of assignment is not a reference.");
1254 RegisterID* AssignBracketNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1256 RefPtr<RegisterID> base = generator.emitNodeForLeftHandSide(m_base, m_subscriptHasAssignments || m_rightHasAssignments, m_subscript->isPure(generator) && m_right->isPure(generator));
1257 RefPtr<RegisterID> property = generator.emitNodeForLeftHandSide(m_subscript, m_rightHasAssignments, m_right->isPure(generator));
1258 RefPtr<RegisterID> value = generator.destinationForAssignResult(dst);
1259 RegisterID* result = generator.emitNode(value.get(), m_right);
1261 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
1262 generator.emitPutByVal(base.get(), property.get(), result);
1263 return generator.moveToDestinationIfNeeded(dst, result);
1268 RegisterID* ReadModifyBracketNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1270 RefPtr<RegisterID> base = generator.emitNodeForLeftHandSide(m_base, m_subscriptHasAssignments || m_rightHasAssignments, m_subscript->isPure(generator) && m_right->isPure(generator));
1271 RefPtr<RegisterID> property = generator.emitNodeForLeftHandSide(m_subscript, m_rightHasAssignments, m_right->isPure(generator));
1273 generator.emitExpressionInfo(divot() - m_subexpressionDivotOffset, startOffset() - m_subexpressionDivotOffset, m_subexpressionEndOffset);
1274 RefPtr<RegisterID> value = generator.emitGetByVal(generator.tempDestination(dst), base.get(), property.get());
1275 RegisterID* updatedValue = emitReadModifyAssignment(generator, generator.finalDestination(dst, value.get()), value.get(), m_right, m_operator, OperandTypes(ResultType::unknownType(), m_right->resultDescriptor()));
1277 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
1278 generator.emitPutByVal(base.get(), property.get(), updatedValue);
1285 RegisterID* CommaNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1289 generator.emitNode(generator.ignoredResult(), m_expressions[i]);
1290 return generator.emitNode(dst, m_expressions.last());
1295 RegisterID* ConstDeclNode::emitCodeSingle(BytecodeGenerator& generator)
1297 if (RegisterID* local = generator.constRegisterFor(m_ident)) {
1301 return generator.emitNode(local, m_init);
1304 if (generator.codeType() != EvalCode) {
1306 return generator.emitNode(m_init);
1308 return generator.emitResolve(generator.newTemporary(), m_ident);
1312 RefPtr<RegisterID> base = generator.emitResolveBase(generator.newTemporary(), m_ident);
1313 RegisterID* value = m_init ? generator.emitNode(m_init) : generator.emitLoad(0, jsUndefined());
1314 return generator.emitPutById(base.get(), m_ident, value);
1317 RegisterID* ConstDeclNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
1321 result = n->emitCodeSingle(generator);
1328 RegisterID* ConstStatementNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
1330 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1331 return generator.emitNode(m_next);
1343 inline void SourceElements::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1347 generator.emitNode(dst, m_statements[i]);
1362 RegisterID* BlockNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1365 m_statements->emitBytecode(generator, dst);
1371 RegisterID* EmptyStatementNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1373 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1379 RegisterID* DebuggerStatementNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1381 generator.emitDebugHook(DidReachBreakpoint, firstLine(), lastLine());
1387 RegisterID* ExprStatementNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1390 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1391 return generator.emitNode(dst, m_expr);
1396 RegisterID* VarStatementNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
1399 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1400 return generator.emitNode(m_expr);
1405 RegisterID* IfNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1407 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1409 RefPtr<Label> afterThen = generator.newLabel();
1412 RefPtr<Label> beforeThen = generator.newLabel();
1413 generator.emitNodeInConditionContext(m_condition, beforeThen.get(), afterThen.get(), true);
1414 generator.emitLabel(beforeThen.get());
1416 RegisterID* cond = generator.emitNode(m_condition);
1417 generator.emitJumpIfFalse(cond, afterThen.get());
1420 generator.emitNode(dst, m_ifBlock);
1421 generator.emitLabel(afterThen.get());
1429 RegisterID* IfElseNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1431 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1433 RefPtr<Label> beforeElse = generator.newLabel();
1434 RefPtr<Label> afterElse = generator.newLabel();
1437 RefPtr<Label> beforeThen = generator.newLabel();
1438 generator.emitNodeInConditionContext(m_condition, beforeThen.get(), beforeElse.get(), true);
1439 generator.emitLabel(beforeThen.get());
1441 RegisterID* cond = generator.emitNode(m_condition);
1442 generator.emitJumpIfFalse(cond, beforeElse.get());
1445 generator.emitNode(dst, m_ifBlock);
1446 generator.emitJump(afterElse.get());
1448 generator.emitLabel(beforeElse.get());
1450 generator.emitNode(dst, m_elseBlock);
1452 generator.emitLabel(afterElse.get());
1460 RegisterID* DoWhileNode::emitBytecode(BytecodeGenerator& generator
1462 RefPtr<LabelScope> scope = generator.newLabelScope(LabelScope::Loop);
1464 RefPtr<Label> topOfLoop = generator.newLabel();
1465 generator.emitLabel(topOfLoop.get());
1467 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1469 RefPtr<RegisterID> result = generator.emitNode(dst, m_statement);
1471 generator.emitLabel(scope->continueTarget());
1472 generator.emitDebugHook(WillExecuteStatement, m_expr->lineNo(), m_expr->lineNo());
1474 generator.emitNodeInConditionContext(m_expr, topOfLoop.get(), scope->breakTarget(), false);
1476 RegisterID* cond = generator.emitNode(m_expr);
1477 generator.emitJumpIfTrue(cond, topOfLoop.get());
1480 generator.emitLabel(scope->breakTarget());
1486 RegisterID* WhileNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1488 RefPtr<LabelScope> scope = generator.newLabelScope(LabelScope::Loop);
1490 generator.emitJump(scope->continueTarget());
1492 RefPtr<Label> topOfLoop = generator.newLabel();
1493 generator.emitLabel(topOfLoop.get());
1495 generator.emitNode(dst, m_statement);
1497 generator.emitLabel(scope->continueTarget());
1498 generator.emitDebugHook(WillExecuteStatement, m_expr->lineNo(), m_expr->lineNo());
1501 generator.emitNodeInConditionContext(m_expr, topOfLoop.get(), scope->breakTarget(), false);
1503 RegisterID* cond = generator.emitNode(m_expr);
1504 generator.emitJumpIfTrue(cond, topOfLoop.get());
1507 generator.emitLabel(scope->breakTarget());
1515 RegisterID* ForNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1517 RefPtr<LabelScope> scope = generator.newLabelScope(LabelScope::Loop);
1519 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1522 generator.emitNode(generator.ignoredResult(), m_expr1);
1524 RefPtr<Label> condition = generator.newLabel();
1525 generator.emitJump(condition.get());
1527 RefPtr<Label> topOfLoop = generator.newLabel();
1528 generator.emitLabel(topOfLoop.get());
1530 RefPtr<RegisterID> result = generator.emitNode(dst, m_statement);
1532 generator.emitLabel(scope->continueTarget());
1533 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1535 generator.emitNode(generator.ignoredResult(), m_expr3);
1537 generator.emitLabel(condition.get());
1540 generator.emitNodeInConditionContext(m_expr2, topOfLoop.get(), scope->breakTarget(), false);
1542 RegisterID* cond = generator.emitNode(m_expr2);
1543 generator.emitJumpIfTrue(cond, topOfLoop.get());
1546 generator.emitJump(topOfLoop.get());
1548 generator.emitLabel(scope->breakTarget());
1554 RegisterID* ForInNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1556 RefPtr<LabelScope> scope = generator.newLabelScope(LabelScope::Loop);
1559 return emitThrowReferenceError(generator, "Left side of for-in statement is not a reference.");
1561 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1564 generator.emitNode(generator.ignoredResult(), m_init);
1566 RefPtr<RegisterID> base = generator.newTemporary();
1567 generator.emitNode(base.get(), m_expr);
1568 RefPtr<RegisterID> i = generator.newTemporary();
1569 RefPtr<RegisterID> size = generator.newTemporary();
1571 RefPtr<RegisterID> iter = generator.emitGetPropertyNames(generator.newTemporary(), base.get(), i.get(), size.get(), scope->breakTarget());
1572 generator.emitJump(scope->continueTarget());
1574 RefPtr<Label> loopStart = generator.newLabel();
1575 generator.emitLabel(loopStart.get());
1581 propertyName = generator.registerFor(ident);
1583 propertyName = generator.newTemporary();
1585 RegisterID* base = generator.emitResolveBaseForPut(generator.newTemporary(), ident);
1587 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
1588 generator.emitPutById(base, ident, propertyName);
1590 expectedSubscript = generator.emitMove(generator.newTemporary(), propertyName);
1591 generator.pushOptimisedForIn(expectedSubscript.get(), iter.get(), i.get(), propertyName);
1597 propertyName = generator.newTemporary();
1599 RegisterID* base = generator.emitNode(assignNode->base());
1601 generator.emitExpressionInfo(assignNode->divot(), assignNode->startOffset(), assignNode->endOffset());
1602 generator.emitPutById(base, ident, propertyName);
1606 propertyName = generator.newTemporary();
1608 RefPtr<RegisterID> base = generator.emitNode(assignNode->base());
1609 RegisterID* subscript = generator.emitNode(assignNode->subscript());
1611 generator.emitExpressionInfo(assignNode->divot(), assignNode->startOffset(), assignNode->endOffset());
1612 generator.emitPutByVal(base.get(), subscript, propertyName);
1615 generator.emitNode(dst, m_statement);
1618 generator.popOptimisedForIn();
1620 generator.emitLabel(scope->continueTarget());
1621 generator.emitNextPropertyName(propertyName, base.get(), i.get(), size.get(), iter.get(), loopStart.get());
1622 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1623 generator.emitLabel(scope->breakTarget());
1630 RegisterID* ContinueNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1632 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1634 LabelScope* scope = generator.continueTarget(m_ident);
1637 generator.emitJumpScopes(scope->continueTarget(), scope->scopeDepth());
1644 RegisterID* BreakNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1646 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1648 LabelScope* scope = generator.breakTarget(m_ident);
1651 generator.emitJumpScopes(scope->breakTarget(), scope->scopeDepth());
1657 RegisterID* ReturnNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1659 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1660 ASSERT(generator.codeType() == FunctionCode);
1662 if (dst == generator.ignoredResult())
1664 RegisterID* r0 = m_value ? generator.emitNode(dst, m_value) : generator.emitLoad(dst, jsUndefined());
1666 if (generator.scopeDepth()) {
1667 RefPtr<Label> l0 = generator.newLabel();
1668 if (generator.hasFinaliser() && !r0->isTemporary()) {
1669 returnRegister = generator.emitMove(generator.newTemporary(), r0);
1672 generator.emitJumpScopes(l0.get(), 0);
1673 generator.emitLabel(l0.get());
1675 generator.emitDebugHook(WillLeaveCallFrame, firstLine(), lastLine());
1676 return generator.emitReturn(r0);
1681 RegisterID* WithNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1683 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1685 RefPtr<RegisterID> scope = generator.newTemporary();
1686 generator.emitNode(scope.get(), m_expr); // scope must be protected until popped
1687 generator.emitExpressionInfo(m_divot, m_expressionLength, 0);
1688 generator.emitPushScope(scope.get());
1689 RegisterID* result = generator.emitNode(dst, m_statement);
1690 generator.emitPopScope();
1696 inline void CaseClauseNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1699 m_statements->emitBytecode(generator, dst);
1780 RegisterID* CaseBlockNode::emitBytecodeForBlock(BytecodeGenerator& generator, RegisterID* switchExpression, RegisterID* dst)
1792 labelVector.append(generator.newLabel());
1793 defaultLabel = generator.newLabel();
1794 generator.beginSwitch(switchExpression, switchType);
1798 RefPtr<RegisterID> clauseVal = generator.newTemporary();
1799 generator.emitNode(clauseVal.get(), list->getClause()->expr());
1800 generator.emitBinaryOp(op_stricteq, clauseVal.get(), clauseVal.get(), switchExpression, OperandTypes());
1801 labelVector.append(generator.newLabel());
1802 generator.emitJumpIfTrue(clauseVal.get(), labelVector[labelVector.size() - 1].get());
1806 RefPtr<RegisterID> clauseVal = generator.newTemporary();
1807 generator.emitNode(clauseVal.get(), list->getClause()->expr());
1808 generator.emitBinaryOp(op_stricteq, clauseVal.get(), clauseVal.get(), switchExpression, OperandTypes());
1809 labelVector.append(generator.newLabel());
1810 generator.emitJumpIfTrue(clauseVal.get(), labelVector[labelVector.size() - 1].get());
1812 defaultLabel = generator.newLabel();
1813 generator.emitJump(defaultLabel.get());
1820 generator.emitLabel(labelVector[i++].get());
1821 list->getClause()->emitBytecode(generator, dst);
1825 generator.emitLabel(defaultLabel.get());
1826 m_defaultClause->emitBytecode(generator, dst);
1830 generator.emitLabel(labelVector[i++].get());
1831 list->getClause()->emitBytecode(generator, dst);
1834 generator.emitLabel(defaultLabel.get());
1839 generator.endSwitch(labelVector.size(), labelVector.data(), literalVector.data(), defaultLabel.get(), min_num, max_num);
1846 RegisterID* SwitchNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1848 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1850 RefPtr<LabelScope> scope = generator.newLabelScope(LabelScope::Switch);
1852 RefPtr<RegisterID> r0 = generator.emitNode(m_expr);
1853 RegisterID* r1 = m_block->emitBytecodeForBlock(generator, r0.get(), dst);
1855 generator.emitLabel(scope->breakTarget());
1861 RegisterID* LabelNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1863 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1865 ASSERT(!generator.breakTarget(m_name));
1867 RefPtr<LabelScope> scope = generator.newLabelScope(LabelScope::NamedLabel, &m_name);
1868 RegisterID* r0 = generator.emitNode(dst, m_statement);
1870 generator.emitLabel(scope->breakTarget());
1876 RegisterID* ThrowNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1878 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1880 if (dst == generator.ignoredResult())
1882 RefPtr<RegisterID> expr = generator.emitNode(m_expr);
1883 generator.emitExpressionInfo(divot(), startOffset(), endOffset());
1884 generator.emitThrow(expr.get());
1890 RegisterID* TryNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
1895 generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
1897 RefPtr<Label> tryStartLabel = generator.newLabel();
1901 finallyStart = generator.newLabel();
1902 finallyReturnAddr = generator.newTemporary();
1903 generator.pushFinallyContext(finallyStart.get(), finallyReturnAddr.get());
1906 generator.emitLabel(tryStartLabel.get());
1907 generator.emitNode(dst, m_tryBlock);
1910 RefPtr<Label> catchEndLabel = generator.newLabel();
1913 generator.emitJump(catchEndLabel.get());
1916 RefPtr<Label> here = generator.emitLabel(generator.newLabel().get());
1917 RefPtr<RegisterID> exceptionRegister = generator.emitCatch(generator.newTemporary(), tryStartLabel.get(), here.get());
1919 RefPtr<RegisterID> dynamicScopeObject = generator.emitNewObject(generator.newTemporary());
1920 generator.emitPutById(dynamicScopeObject.get(), m_exceptionIdent, exceptionRegister.get());
1921 generator.emitMove(exceptionRegister.get(), dynamicScopeObject.get());
1922 generator.emitPushScope(exceptionRegister.get());
1924 generator.emitPushNewScope(exceptionRegister.get(), m_exceptionIdent, exceptionRegister.get());
1925 generator.emitNode(dst, m_catchBlock);
1926 generator.emitPopScope();
1927 generator.emitLabel(catchEndLabel.get());
1931 generator.popFinallyContext();
1936 RefPtr<RegisterID> highestUsedRegister = generator.highestUsedRegister();
1937 RefPtr<Label> finallyEndLabel = generator.newLabel();
1940 generator.emitJumpSubroutine(finallyReturnAddr.get(), finallyStart.get());
1941 generator.emitJump(finallyEndLabel.get());
1944 RefPtr<Label> here = generator.emitLabel(generator.newLabel().get());
1945 RefPtr<RegisterID> tempExceptionRegister = generator.emitCatch(generator.newTemporary(), tryStartLabel.get(), here.get());
1946 generator.emitJumpSubroutine(finallyReturnAddr.get(), finallyStart.get());
1947 generator.emitThrow(tempExceptionRegister.get());
1950 generator.emitLabel(finallyStart.get());
1951 generator.emitNode(dst, m_finallyBlock);
1952 generator.emitSubroutineReturn(finallyReturnAddr.get());
1954 generator.emitLabel(finallyEndLabel.get());
1962 inline void ScopeNode::emitStatementsBytecode(BytecodeGenerator& generator, RegisterID* dst)
1965 m_data->m_statements->emitBytecode(generator, dst);
1970 RegisterID* ProgramNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
1972 generator.emitDebugHook(WillExecuteProgram, firstLine(), lastLine());
1974 RefPtr<RegisterID> dstRegister = generator.newTemporary();
1975 generator.emitLoad(dstRegister.get(), jsUndefined());
1976 emitStatementsBytecode(generator, dstRegister.get());
1978 generator.emitDebugHook(DidExecuteProgram, firstLine(), lastLine());
1979 generator.emitEnd(dstRegister.get());
1985 RegisterID* EvalNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
1987 generator.emitDebugHook(WillExecuteProgram, firstLine(), lastLine());
1989 RefPtr<RegisterID> dstRegister = generator.newTemporary();
1990 generator.emitLoad(dstRegister.get(), jsUndefined());
1991 emitStatementsBytecode(generator, dstRegister.get());
1993 generator.emitDebugHook(DidExecuteProgram, firstLine(), lastLine());
1994 generator.emitEnd(dstRegister.get());
2000 RegisterID* FunctionBodyNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
2002 generator.emitDebugHook(DidEnterCallFrame, firstLine(), lastLine());
2003 emitStatementsBytecode(generator, generator.ignoredResult());
2017 RegisterID* r0 = generator.isConstructor() ? generator.thisRegister() : generator.emitLoad(0, jsUndefined());
2018 generator.emitDebugHook(WillLeaveCallFrame, firstLine(), lastLine());
2019 generator.emitReturn(r0);
2030 generator.setIsNumericCompareFunction(generator.argumentNumberFor(static_cast<ResolveNode*>(lhsExpression)->identifier()) == 1
2031 && generator.argumentNumberFor(static_cast<ResolveNode*>(rhsExpression)->identifier()) == 2);
2041 RegisterID* FuncDeclNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
2043 if (dst == generator.ignoredResult())
2050 RegisterID* FuncExprNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
2052 return generator.emitNewFunctionExpression(generator.finalDestination(dst), this);