| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 | 632 |
| 633 void FastCodeGenerator::VisitLiteral(Literal* expr) { | 633 void FastCodeGenerator::VisitLiteral(Literal* expr) { |
| 634 Comment cmnt(masm_, "[ Literal"); | 634 Comment cmnt(masm_, "[ Literal"); |
| 635 Apply(expr->context(), expr); | 635 Apply(expr->context(), expr); |
| 636 } | 636 } |
| 637 | 637 |
| 638 | 638 |
| 639 void FastCodeGenerator::VisitAssignment(Assignment* expr) { | 639 void FastCodeGenerator::VisitAssignment(Assignment* expr) { |
| 640 Comment cmnt(masm_, "[ Assignment"); | 640 Comment cmnt(masm_, "[ Assignment"); |
| 641 | 641 |
| 642 // Record source code position of the (possible) IC call. | |
| 643 SetSourcePosition(expr->position()); | |
| 644 | |
| 645 // Left-hand side can only be a property, a global or a (parameter or local) | 642 // Left-hand side can only be a property, a global or a (parameter or local) |
| 646 // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY. | 643 // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY. |
| 647 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; | 644 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; |
| 648 LhsKind assign_type = VARIABLE; | 645 LhsKind assign_type = VARIABLE; |
| 649 Property* prop = expr->target()->AsProperty(); | 646 Property* prop = expr->target()->AsProperty(); |
| 650 // In case of a property we use the uninitialized expression context | 647 // In case of a property we use the uninitialized expression context |
| 651 // of the key to detect a named property. | 648 // of the key to detect a named property. |
| 652 if (prop != NULL) { | 649 if (prop != NULL) { |
| 653 assign_type = (prop->key()->context() == Expression::kUninitialized) | 650 assign_type = (prop->key()->context() == Expression::kUninitialized) |
| 654 ? NAMED_PROPERTY | 651 ? NAMED_PROPERTY |
| (...skipping 20 matching lines...) Expand all Loading... |
| 675 // If we have a compound assignment: Get value of LHS expression and | 672 // If we have a compound assignment: Get value of LHS expression and |
| 676 // store in on top of the stack. | 673 // store in on top of the stack. |
| 677 // Note: Relies on kValue context being 'stack'. | 674 // Note: Relies on kValue context being 'stack'. |
| 678 if (expr->is_compound()) { | 675 if (expr->is_compound()) { |
| 679 switch (assign_type) { | 676 switch (assign_type) { |
| 680 case VARIABLE: | 677 case VARIABLE: |
| 681 EmitVariableLoad(expr->target()->AsVariableProxy()->var(), | 678 EmitVariableLoad(expr->target()->AsVariableProxy()->var(), |
| 682 Expression::kValue); | 679 Expression::kValue); |
| 683 break; | 680 break; |
| 684 case NAMED_PROPERTY: | 681 case NAMED_PROPERTY: |
| 685 EmitNamedPropertyLoad(prop, Expression::kValue); | 682 EmitNamedPropertyLoad(prop); |
| 683 __ push(result_register()); |
| 686 break; | 684 break; |
| 687 case KEYED_PROPERTY: | 685 case KEYED_PROPERTY: |
| 688 EmitKeyedPropertyLoad(prop, Expression::kValue); | 686 EmitKeyedPropertyLoad(prop); |
| 687 __ push(result_register()); |
| 689 break; | 688 break; |
| 690 } | 689 } |
| 691 } | 690 } |
| 692 | 691 |
| 693 // Evaluate RHS expression. | 692 // Evaluate RHS expression. |
| 694 Expression* rhs = expr->value(); | 693 Expression* rhs = expr->value(); |
| 695 ASSERT_EQ(Expression::kValue, rhs->context()); | 694 ASSERT_EQ(Expression::kValue, rhs->context()); |
| 696 Visit(rhs); | 695 Visit(rhs); |
| 697 | 696 |
| 698 // If we have a compount assignment: Apply operator. | 697 // If we have a compount assignment: Apply operator. |
| 699 if (expr->is_compound()) { | 698 if (expr->is_compound()) { |
| 700 EmitCompoundAssignmentOp(expr->binary_op(), Expression::kValue); | 699 EmitCompoundAssignmentOp(expr->binary_op(), Expression::kValue); |
| 701 } | 700 } |
| 702 | 701 |
| 702 // Record source position before possible IC call. |
| 703 SetSourcePosition(expr->position()); |
| 704 |
| 703 // Store the value. | 705 // Store the value. |
| 704 switch (assign_type) { | 706 switch (assign_type) { |
| 705 case VARIABLE: | 707 case VARIABLE: |
| 706 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), | 708 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), |
| 707 expr->context()); | 709 expr->context()); |
| 708 break; | 710 break; |
| 709 case NAMED_PROPERTY: | 711 case NAMED_PROPERTY: |
| 710 EmitNamedPropertyAssignment(expr); | 712 EmitNamedPropertyAssignment(expr); |
| 711 break; | 713 break; |
| 712 case KEYED_PROPERTY: | 714 case KEYED_PROPERTY: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 __ Drop(stack_depth); | 759 __ Drop(stack_depth); |
| 758 __ PopTryHandler(); | 760 __ PopTryHandler(); |
| 759 return 0; | 761 return 0; |
| 760 } | 762 } |
| 761 | 763 |
| 762 | 764 |
| 763 #undef __ | 765 #undef __ |
| 764 | 766 |
| 765 | 767 |
| 766 } } // namespace v8::internal | 768 } } // namespace v8::internal |
| OLD | NEW |