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 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 UNREACHABLE(); | 1029 UNREACHABLE(); |
1030 } | 1030 } |
1031 | 1031 |
1032 | 1032 |
1033 void FullCodeGenerator::VisitLiteral(Literal* expr) { | 1033 void FullCodeGenerator::VisitLiteral(Literal* expr) { |
1034 Comment cmnt(masm_, "[ Literal"); | 1034 Comment cmnt(masm_, "[ Literal"); |
1035 Apply(context_, expr); | 1035 Apply(context_, expr); |
1036 } | 1036 } |
1037 | 1037 |
1038 | 1038 |
1039 void FullCodeGenerator::VisitAssignment(Assignment* expr) { | |
1040 Comment cmnt(masm_, "[ Assignment"); | |
1041 ASSERT(expr->op() != Token::INIT_CONST); | |
1042 // Left-hand side can only be a property, a global or a (parameter or local) | |
1043 // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY. | |
1044 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; | |
1045 LhsKind assign_type = VARIABLE; | |
1046 Property* prop = expr->target()->AsProperty(); | |
1047 if (prop != NULL) { | |
1048 assign_type = | |
1049 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; | |
1050 } | |
1051 | |
1052 // Evaluate LHS expression. | |
1053 switch (assign_type) { | |
1054 case VARIABLE: | |
1055 // Nothing to do here. | |
1056 break; | |
1057 case NAMED_PROPERTY: | |
1058 if (expr->is_compound()) { | |
1059 // We need the receiver both on the stack and in the accumulator. | |
1060 VisitForValue(prop->obj(), kAccumulator); | |
1061 __ push(result_register()); | |
1062 } else { | |
1063 VisitForValue(prop->obj(), kStack); | |
1064 } | |
1065 break; | |
1066 case KEYED_PROPERTY: | |
1067 VisitForValue(prop->obj(), kStack); | |
1068 VisitForValue(prop->key(), kStack); | |
1069 break; | |
1070 } | |
1071 | |
1072 // If we have a compound assignment: Get value of LHS expression and | |
1073 // store in on top of the stack. | |
1074 if (expr->is_compound()) { | |
1075 Location saved_location = location_; | |
1076 location_ = kStack; | |
1077 switch (assign_type) { | |
1078 case VARIABLE: | |
1079 EmitVariableLoad(expr->target()->AsVariableProxy()->var(), | |
1080 Expression::kValue); | |
1081 break; | |
1082 case NAMED_PROPERTY: | |
1083 EmitNamedPropertyLoad(prop); | |
1084 __ push(result_register()); | |
1085 break; | |
1086 case KEYED_PROPERTY: | |
1087 EmitKeyedPropertyLoad(prop); | |
1088 __ push(result_register()); | |
1089 break; | |
1090 } | |
1091 location_ = saved_location; | |
1092 } | |
1093 | |
1094 // Evaluate RHS expression. | |
1095 Expression* rhs = expr->value(); | |
1096 VisitForValue(rhs, kAccumulator); | |
1097 | |
1098 // If we have a compound assignment: Apply operator. | |
1099 if (expr->is_compound()) { | |
1100 Location saved_location = location_; | |
1101 location_ = kAccumulator; | |
1102 EmitBinaryOp(expr->binary_op(), Expression::kValue); | |
1103 location_ = saved_location; | |
1104 } | |
1105 | |
1106 // Record source position before possible IC call. | |
1107 SetSourcePosition(expr->position()); | |
1108 | |
1109 // Store the value. | |
1110 switch (assign_type) { | |
1111 case VARIABLE: | |
1112 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), | |
1113 context_); | |
1114 break; | |
1115 case NAMED_PROPERTY: | |
1116 EmitNamedPropertyAssignment(expr); | |
1117 break; | |
1118 case KEYED_PROPERTY: | |
1119 EmitKeyedPropertyAssignment(expr); | |
1120 break; | |
1121 } | |
1122 } | |
1123 | |
1124 | |
1125 void FullCodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* expr) { | 1039 void FullCodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* expr) { |
1126 // Call runtime routine to allocate the catch extension object and | 1040 // Call runtime routine to allocate the catch extension object and |
1127 // assign the exception value to the catch variable. | 1041 // assign the exception value to the catch variable. |
1128 Comment cmnt(masm_, "[ CatchExtensionObject"); | 1042 Comment cmnt(masm_, "[ CatchExtensionObject"); |
1129 VisitForValue(expr->key(), kStack); | 1043 VisitForValue(expr->key(), kStack); |
1130 VisitForValue(expr->value(), kStack); | 1044 VisitForValue(expr->value(), kStack); |
1131 // Create catch extension object. | 1045 // Create catch extension object. |
1132 __ CallRuntime(Runtime::kCreateCatchExtensionObject, 2); | 1046 __ CallRuntime(Runtime::kCreateCatchExtensionObject, 2); |
1133 Apply(context_, result_register()); | 1047 Apply(context_, result_register()); |
1134 } | 1048 } |
(...skipping 20 matching lines...) Expand all Loading... |
1155 // The macros used here must preserve the result register. | 1069 // The macros used here must preserve the result register. |
1156 __ Drop(stack_depth); | 1070 __ Drop(stack_depth); |
1157 __ PopTryHandler(); | 1071 __ PopTryHandler(); |
1158 return 0; | 1072 return 0; |
1159 } | 1073 } |
1160 | 1074 |
1161 #undef __ | 1075 #undef __ |
1162 | 1076 |
1163 | 1077 |
1164 } } // namespace v8::internal | 1078 } } // namespace v8::internal |
OLD | NEW |