OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
754 UNREACHABLE(); | 754 UNREACHABLE(); |
755 } | 755 } |
756 } | 756 } |
757 | 757 |
758 | 758 |
759 void FullCodeGenerator::EmitLogicalOperation(BinaryOperation* expr) { | 759 void FullCodeGenerator::EmitLogicalOperation(BinaryOperation* expr) { |
760 Label eval_right, done; | 760 Label eval_right, done; |
761 | 761 |
762 context()->EmitLogicalLeft(expr, &eval_right, &done); | 762 context()->EmitLogicalLeft(expr, &eval_right, &done); |
763 | 763 |
764 PrepareForBailoutForId(expr->RightId(), NO_REGISTERS); | |
Kasper Lund
2010/12/16 08:32:38
I wonder if it would make sense to somehow split t
| |
764 __ bind(&eval_right); | 765 __ bind(&eval_right); |
765 if (context()->IsTest()) ForwardBailoutToChild(expr); | 766 if (context()->IsTest()) ForwardBailoutToChild(expr); |
766 context()->HandleExpression(expr->right()); | 767 context()->HandleExpression(expr->right()); |
767 | 768 |
768 __ bind(&done); | 769 __ bind(&done); |
769 } | 770 } |
770 | 771 |
771 | 772 |
772 void FullCodeGenerator::EffectContext::EmitLogicalLeft(BinaryOperation* expr, | 773 void FullCodeGenerator::EffectContext::EmitLogicalLeft(BinaryOperation* expr, |
773 Label* eval_right, | 774 Label* eval_right, |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
918 } | 919 } |
919 | 920 |
920 | 921 |
921 void FullCodeGenerator::VisitIfStatement(IfStatement* stmt) { | 922 void FullCodeGenerator::VisitIfStatement(IfStatement* stmt) { |
922 Comment cmnt(masm_, "[ IfStatement"); | 923 Comment cmnt(masm_, "[ IfStatement"); |
923 SetStatementPosition(stmt); | 924 SetStatementPosition(stmt); |
924 Label then_part, else_part, done; | 925 Label then_part, else_part, done; |
925 | 926 |
926 if (stmt->HasElseStatement()) { | 927 if (stmt->HasElseStatement()) { |
927 VisitForControl(stmt->condition(), &then_part, &else_part, &then_part); | 928 VisitForControl(stmt->condition(), &then_part, &else_part, &then_part); |
929 PrepareForBailoutForId(stmt->ThenId(), NO_REGISTERS); | |
928 __ bind(&then_part); | 930 __ bind(&then_part); |
929 Visit(stmt->then_statement()); | 931 Visit(stmt->then_statement()); |
930 __ jmp(&done); | 932 __ jmp(&done); |
931 | 933 |
934 PrepareForBailoutForId(stmt->ElseId(), NO_REGISTERS); | |
932 __ bind(&else_part); | 935 __ bind(&else_part); |
933 Visit(stmt->else_statement()); | 936 Visit(stmt->else_statement()); |
934 } else { | 937 } else { |
935 VisitForControl(stmt->condition(), &then_part, &done, &then_part); | 938 VisitForControl(stmt->condition(), &then_part, &done, &then_part); |
939 PrepareForBailoutForId(stmt->ThenId(), NO_REGISTERS); | |
936 __ bind(&then_part); | 940 __ bind(&then_part); |
937 Visit(stmt->then_statement()); | 941 Visit(stmt->then_statement()); |
942 | |
943 PrepareForBailoutForId(stmt->ElseId(), NO_REGISTERS); | |
938 } | 944 } |
939 __ bind(&done); | 945 __ bind(&done); |
940 PrepareForBailoutForId(stmt->id(), NO_REGISTERS); | 946 PrepareForBailoutForId(stmt->id(), NO_REGISTERS); |
941 } | 947 } |
942 | 948 |
943 | 949 |
944 void FullCodeGenerator::VisitContinueStatement(ContinueStatement* stmt) { | 950 void FullCodeGenerator::VisitContinueStatement(ContinueStatement* stmt) { |
945 Comment cmnt(masm_, "[ ContinueStatement"); | 951 Comment cmnt(masm_, "[ ContinueStatement"); |
946 SetStatementPosition(stmt); | 952 SetStatementPosition(stmt); |
947 NestedStatement* current = nesting_stack_; | 953 NestedStatement* current = nesting_stack_; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1046 // possible to break on the condition. | 1052 // possible to break on the condition. |
1047 __ bind(loop_statement.continue_target()); | 1053 __ bind(loop_statement.continue_target()); |
1048 PrepareForBailoutForId(stmt->ContinueId(), NO_REGISTERS); | 1054 PrepareForBailoutForId(stmt->ContinueId(), NO_REGISTERS); |
1049 SetExpressionPosition(stmt->cond(), stmt->condition_position()); | 1055 SetExpressionPosition(stmt->cond(), stmt->condition_position()); |
1050 VisitForControl(stmt->cond(), | 1056 VisitForControl(stmt->cond(), |
1051 &stack_check, | 1057 &stack_check, |
1052 loop_statement.break_target(), | 1058 loop_statement.break_target(), |
1053 &stack_check); | 1059 &stack_check); |
1054 | 1060 |
1055 // Check stack before looping. | 1061 // Check stack before looping. |
1062 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS); | |
1056 __ bind(&stack_check); | 1063 __ bind(&stack_check); |
1057 EmitStackCheck(stmt); | 1064 EmitStackCheck(stmt); |
1058 __ jmp(&body); | 1065 __ jmp(&body); |
1059 | 1066 |
1067 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | |
1060 __ bind(loop_statement.break_target()); | 1068 __ bind(loop_statement.break_target()); |
1061 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | |
1062 decrement_loop_depth(); | 1069 decrement_loop_depth(); |
1063 } | 1070 } |
1064 | 1071 |
1065 | 1072 |
1066 void FullCodeGenerator::VisitWhileStatement(WhileStatement* stmt) { | 1073 void FullCodeGenerator::VisitWhileStatement(WhileStatement* stmt) { |
1067 Comment cmnt(masm_, "[ WhileStatement"); | 1074 Comment cmnt(masm_, "[ WhileStatement"); |
1068 Label test, body; | 1075 Label test, body; |
1069 | 1076 |
1070 Iteration loop_statement(this, stmt); | 1077 Iteration loop_statement(this, stmt); |
1071 increment_loop_depth(); | 1078 increment_loop_depth(); |
1072 | 1079 |
1073 // Emit the test at the bottom of the loop. | 1080 // Emit the test at the bottom of the loop. |
1074 __ jmp(&test); | 1081 __ jmp(&test); |
1075 | 1082 |
1083 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); | |
1076 __ bind(&body); | 1084 __ bind(&body); |
1077 Visit(stmt->body()); | 1085 Visit(stmt->body()); |
1078 | 1086 |
1079 // Emit the statement position here as this is where the while | 1087 // Emit the statement position here as this is where the while |
1080 // statement code starts. | 1088 // statement code starts. |
1081 __ bind(loop_statement.continue_target()); | 1089 __ bind(loop_statement.continue_target()); |
1082 SetStatementPosition(stmt); | 1090 SetStatementPosition(stmt); |
1083 | 1091 |
1084 // Check stack before looping. | 1092 // Check stack before looping. |
1085 EmitStackCheck(stmt); | 1093 EmitStackCheck(stmt); |
1086 | 1094 |
1087 __ bind(&test); | 1095 __ bind(&test); |
1088 VisitForControl(stmt->cond(), | 1096 VisitForControl(stmt->cond(), |
1089 &body, | 1097 &body, |
1090 loop_statement.break_target(), | 1098 loop_statement.break_target(), |
1091 loop_statement.break_target()); | 1099 loop_statement.break_target()); |
1092 | 1100 |
1101 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | |
1093 __ bind(loop_statement.break_target()); | 1102 __ bind(loop_statement.break_target()); |
1094 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | |
1095 decrement_loop_depth(); | 1103 decrement_loop_depth(); |
1096 } | 1104 } |
1097 | 1105 |
1098 | 1106 |
1099 void FullCodeGenerator::VisitForStatement(ForStatement* stmt) { | 1107 void FullCodeGenerator::VisitForStatement(ForStatement* stmt) { |
1100 Comment cmnt(masm_, "[ ForStatement"); | 1108 Comment cmnt(masm_, "[ ForStatement"); |
1101 Label test, body; | 1109 Label test, body; |
1102 | 1110 |
1103 Iteration loop_statement(this, stmt); | 1111 Iteration loop_statement(this, stmt); |
1104 if (stmt->init() != NULL) { | 1112 if (stmt->init() != NULL) { |
1105 Visit(stmt->init()); | 1113 Visit(stmt->init()); |
1106 } | 1114 } |
1107 | 1115 |
1108 increment_loop_depth(); | 1116 increment_loop_depth(); |
1109 // Emit the test at the bottom of the loop (even if empty). | 1117 // Emit the test at the bottom of the loop (even if empty). |
1110 __ jmp(&test); | 1118 __ jmp(&test); |
1111 | 1119 |
1120 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); | |
1112 __ bind(&body); | 1121 __ bind(&body); |
1113 Visit(stmt->body()); | 1122 Visit(stmt->body()); |
1114 | 1123 |
1124 PrepareForBailoutForId(stmt->ContinueId(), NO_REGISTERS); | |
1115 __ bind(loop_statement.continue_target()); | 1125 __ bind(loop_statement.continue_target()); |
1116 PrepareForBailoutForId(stmt->ContinueId(), NO_REGISTERS); | |
1117 | |
1118 SetStatementPosition(stmt); | 1126 SetStatementPosition(stmt); |
1119 if (stmt->next() != NULL) { | 1127 if (stmt->next() != NULL) { |
1120 Visit(stmt->next()); | 1128 Visit(stmt->next()); |
1121 } | 1129 } |
1122 | 1130 |
1123 // Emit the statement position here as this is where the for | 1131 // Emit the statement position here as this is where the for |
1124 // statement code starts. | 1132 // statement code starts. |
1125 SetStatementPosition(stmt); | 1133 SetStatementPosition(stmt); |
1126 | 1134 |
1127 // Check stack before looping. | 1135 // Check stack before looping. |
1128 EmitStackCheck(stmt); | 1136 EmitStackCheck(stmt); |
1129 | 1137 |
1130 __ bind(&test); | 1138 __ bind(&test); |
1131 if (stmt->cond() != NULL) { | 1139 if (stmt->cond() != NULL) { |
1132 VisitForControl(stmt->cond(), | 1140 VisitForControl(stmt->cond(), |
1133 &body, | 1141 &body, |
1134 loop_statement.break_target(), | 1142 loop_statement.break_target(), |
1135 loop_statement.break_target()); | 1143 loop_statement.break_target()); |
1136 } else { | 1144 } else { |
1137 __ jmp(&body); | 1145 __ jmp(&body); |
1138 } | 1146 } |
1139 | 1147 |
1148 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | |
1140 __ bind(loop_statement.break_target()); | 1149 __ bind(loop_statement.break_target()); |
1141 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | |
1142 decrement_loop_depth(); | 1150 decrement_loop_depth(); |
1143 } | 1151 } |
1144 | 1152 |
1145 | 1153 |
1146 void FullCodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { | 1154 void FullCodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { |
1147 Comment cmnt(masm_, "[ TryCatchStatement"); | 1155 Comment cmnt(masm_, "[ TryCatchStatement"); |
1148 SetStatementPosition(stmt); | 1156 SetStatementPosition(stmt); |
1149 // The try block adds a handler to the exception handler chain | 1157 // The try block adds a handler to the exception handler chain |
1150 // before entering, and removes it again when exiting normally. | 1158 // before entering, and removes it again when exiting normally. |
1151 // If an exception is thrown during execution of the try block, | 1159 // If an exception is thrown during execution of the try block, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1262 // Ignore the return value. | 1270 // Ignore the return value. |
1263 #endif | 1271 #endif |
1264 } | 1272 } |
1265 | 1273 |
1266 | 1274 |
1267 void FullCodeGenerator::VisitConditional(Conditional* expr) { | 1275 void FullCodeGenerator::VisitConditional(Conditional* expr) { |
1268 Comment cmnt(masm_, "[ Conditional"); | 1276 Comment cmnt(masm_, "[ Conditional"); |
1269 Label true_case, false_case, done; | 1277 Label true_case, false_case, done; |
1270 VisitForControl(expr->condition(), &true_case, &false_case, &true_case); | 1278 VisitForControl(expr->condition(), &true_case, &false_case, &true_case); |
1271 | 1279 |
1280 PrepareForBailoutForId(expr->ThenId(), NO_REGISTERS); | |
1272 __ bind(&true_case); | 1281 __ bind(&true_case); |
1273 SetExpressionPosition(expr->then_expression(), | 1282 SetExpressionPosition(expr->then_expression(), |
1274 expr->then_expression_position()); | 1283 expr->then_expression_position()); |
1275 if (context()->IsTest()) { | 1284 if (context()->IsTest()) { |
1276 const TestContext* for_test = TestContext::cast(context()); | 1285 const TestContext* for_test = TestContext::cast(context()); |
1277 VisitForControl(expr->then_expression(), | 1286 VisitForControl(expr->then_expression(), |
1278 for_test->true_label(), | 1287 for_test->true_label(), |
1279 for_test->false_label(), | 1288 for_test->false_label(), |
1280 NULL); | 1289 NULL); |
1281 } else { | 1290 } else { |
1282 context()->HandleExpression(expr->then_expression()); | 1291 context()->HandleExpression(expr->then_expression()); |
1283 __ jmp(&done); | 1292 __ jmp(&done); |
1284 } | 1293 } |
1285 | 1294 |
1295 PrepareForBailoutForId(expr->ElseId(), NO_REGISTERS); | |
1286 __ bind(&false_case); | 1296 __ bind(&false_case); |
1287 if (context()->IsTest()) ForwardBailoutToChild(expr); | 1297 if (context()->IsTest()) ForwardBailoutToChild(expr); |
1288 SetExpressionPosition(expr->else_expression(), | 1298 SetExpressionPosition(expr->else_expression(), |
1289 expr->else_expression_position()); | 1299 expr->else_expression_position()); |
1290 context()->HandleExpression(expr->else_expression()); | 1300 context()->HandleExpression(expr->else_expression()); |
1291 // If control flow falls through Visit, merge it with true case here. | 1301 // If control flow falls through Visit, merge it with true case here. |
1292 if (!context()->IsTest()) { | 1302 if (!context()->IsTest()) { |
1293 __ bind(&done); | 1303 __ bind(&done); |
1294 } | 1304 } |
1295 } | 1305 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1361 __ Drop(stack_depth); | 1371 __ Drop(stack_depth); |
1362 __ PopTryHandler(); | 1372 __ PopTryHandler(); |
1363 return 0; | 1373 return 0; |
1364 } | 1374 } |
1365 | 1375 |
1366 | 1376 |
1367 #undef __ | 1377 #undef __ |
1368 | 1378 |
1369 | 1379 |
1370 } } // namespace v8::internal | 1380 } } // namespace v8::internal |
OLD | NEW |