| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 180 |
| 181 | 181 |
| 182 void BreakableStatementChecker::VisitObjectLiteral(ObjectLiteral* expr) { | 182 void BreakableStatementChecker::VisitObjectLiteral(ObjectLiteral* expr) { |
| 183 } | 183 } |
| 184 | 184 |
| 185 | 185 |
| 186 void BreakableStatementChecker::VisitArrayLiteral(ArrayLiteral* expr) { | 186 void BreakableStatementChecker::VisitArrayLiteral(ArrayLiteral* expr) { |
| 187 } | 187 } |
| 188 | 188 |
| 189 | 189 |
| 190 void BreakableStatementChecker::VisitCatchExtensionObject( | |
| 191 CatchExtensionObject* expr) { | |
| 192 } | |
| 193 | |
| 194 | |
| 195 void BreakableStatementChecker::VisitAssignment(Assignment* expr) { | 190 void BreakableStatementChecker::VisitAssignment(Assignment* expr) { |
| 196 // If assigning to a property (including a global property) the assignment is | 191 // If assigning to a property (including a global property) the assignment is |
| 197 // breakable. | 192 // breakable. |
| 198 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); | 193 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); |
| 199 Property* prop = expr->target()->AsProperty(); | 194 Property* prop = expr->target()->AsProperty(); |
| 200 if (prop != NULL || (var != NULL && var->is_global())) { | 195 if (prop != NULL || (var != NULL && var->is_global())) { |
| 201 is_breakable_ = true; | 196 is_breakable_ = true; |
| 202 return; | 197 return; |
| 203 } | 198 } |
| 204 | 199 |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 | 950 |
| 956 EmitReturnSequence(); | 951 EmitReturnSequence(); |
| 957 } | 952 } |
| 958 | 953 |
| 959 | 954 |
| 960 void FullCodeGenerator::VisitWithEnterStatement(WithEnterStatement* stmt) { | 955 void FullCodeGenerator::VisitWithEnterStatement(WithEnterStatement* stmt) { |
| 961 Comment cmnt(masm_, "[ WithEnterStatement"); | 956 Comment cmnt(masm_, "[ WithEnterStatement"); |
| 962 SetStatementPosition(stmt); | 957 SetStatementPosition(stmt); |
| 963 | 958 |
| 964 VisitForStackValue(stmt->expression()); | 959 VisitForStackValue(stmt->expression()); |
| 965 if (stmt->is_catch_block()) { | 960 __ CallRuntime(Runtime::kPushContext, 1); |
| 966 __ CallRuntime(Runtime::kPushCatchContext, 1); | |
| 967 } else { | |
| 968 __ CallRuntime(Runtime::kPushContext, 1); | |
| 969 } | |
| 970 // Both runtime calls return the new context in both the context and the | |
| 971 // result registers. | |
| 972 | |
| 973 // Update local stack frame context field. | |
| 974 StoreToFrameField(StandardFrameConstants::kContextOffset, context_register()); | 961 StoreToFrameField(StandardFrameConstants::kContextOffset, context_register()); |
| 975 } | 962 } |
| 976 | 963 |
| 977 | 964 |
| 978 void FullCodeGenerator::VisitWithExitStatement(WithExitStatement* stmt) { | 965 void FullCodeGenerator::VisitWithExitStatement(WithExitStatement* stmt) { |
| 979 Comment cmnt(masm_, "[ WithExitStatement"); | 966 Comment cmnt(masm_, "[ WithExitStatement"); |
| 980 SetStatementPosition(stmt); | 967 SetStatementPosition(stmt); |
| 981 | 968 |
| 982 // Pop context. | 969 // Pop context. |
| 983 LoadContextField(context_register(), Context::PREVIOUS_INDEX); | 970 LoadContextField(context_register(), Context::PREVIOUS_INDEX); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 // At this point, the exception is in a register, and store it in | 1097 // At this point, the exception is in a register, and store it in |
| 1111 // the temporary local variable (prints as ".catch-var") before | 1098 // the temporary local variable (prints as ".catch-var") before |
| 1112 // executing the catch block. The catch block has been rewritten | 1099 // executing the catch block. The catch block has been rewritten |
| 1113 // to introduce a new scope to bind the catch variable and to remove | 1100 // to introduce a new scope to bind the catch variable and to remove |
| 1114 // that scope again afterwards. | 1101 // that scope again afterwards. |
| 1115 | 1102 |
| 1116 Label try_handler_setup, catch_entry, done; | 1103 Label try_handler_setup, catch_entry, done; |
| 1117 __ Call(&try_handler_setup); | 1104 __ Call(&try_handler_setup); |
| 1118 // Try handler code, exception in result register. | 1105 // Try handler code, exception in result register. |
| 1119 | 1106 |
| 1120 // Store exception in local .catch variable before executing catch block. | 1107 // Extend the context before executing the catch block. |
| 1121 { | 1108 { Comment cmnt(masm_, "[ Extend catch context"); |
| 1122 // The catch variable is *always* a variable proxy for a local variable. | 1109 __ push(stmt->name()); |
| 1123 Variable* catch_var = stmt->catch_var()->AsVariableProxy()->AsVariable(); | 1110 __ push(result_register()); |
| 1124 ASSERT_NOT_NULL(catch_var); | 1111 __ CallRuntime(Runtime::kCreateCatchExtensionObject, 2); |
| 1125 Slot* variable_slot = catch_var->AsSlot(); | 1112 __ push(result_register()); |
| 1126 ASSERT_NOT_NULL(variable_slot); | 1113 __ CallRuntime(Runtime::kPushCatchContext, 1); |
| 1127 ASSERT_EQ(Slot::LOCAL, variable_slot->type()); | 1114 StoreToFrameField(StandardFrameConstants::kContextOffset, |
| 1128 StoreToFrameField(SlotOffset(variable_slot), result_register()); | 1115 context_register()); |
| 1129 } | 1116 } |
| 1130 | 1117 |
| 1131 Visit(stmt->catch_block()); | 1118 Visit(stmt->catch_block()); |
| 1132 __ jmp(&done); | 1119 __ jmp(&done); |
| 1133 | 1120 |
| 1134 // Try block code. Sets up the exception handler chain. | 1121 // Try block code. Sets up the exception handler chain. |
| 1135 __ bind(&try_handler_setup); | 1122 __ bind(&try_handler_setup); |
| 1136 { | 1123 { |
| 1137 TryCatch try_block(this, &catch_entry); | 1124 TryCatch try_block(this, &catch_entry); |
| 1138 __ PushTryHandler(IN_JAVASCRIPT, TRY_CATCH_HANDLER); | 1125 __ PushTryHandler(IN_JAVASCRIPT, TRY_CATCH_HANDLER); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 } | 1261 } |
| 1275 | 1262 |
| 1276 | 1263 |
| 1277 void FullCodeGenerator::VisitSharedFunctionInfoLiteral( | 1264 void FullCodeGenerator::VisitSharedFunctionInfoLiteral( |
| 1278 SharedFunctionInfoLiteral* expr) { | 1265 SharedFunctionInfoLiteral* expr) { |
| 1279 Comment cmnt(masm_, "[ SharedFunctionInfoLiteral"); | 1266 Comment cmnt(masm_, "[ SharedFunctionInfoLiteral"); |
| 1280 EmitNewClosure(expr->shared_function_info(), false); | 1267 EmitNewClosure(expr->shared_function_info(), false); |
| 1281 } | 1268 } |
| 1282 | 1269 |
| 1283 | 1270 |
| 1284 void FullCodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* expr) { | |
| 1285 // Call runtime routine to allocate the catch extension object and | |
| 1286 // assign the exception value to the catch variable. | |
| 1287 Comment cmnt(masm_, "[ CatchExtensionObject"); | |
| 1288 VisitForStackValue(expr->key()); | |
| 1289 VisitForStackValue(expr->value()); | |
| 1290 // Create catch extension object. | |
| 1291 __ CallRuntime(Runtime::kCreateCatchExtensionObject, 2); | |
| 1292 context()->Plug(result_register()); | |
| 1293 } | |
| 1294 | |
| 1295 | |
| 1296 void FullCodeGenerator::VisitThrow(Throw* expr) { | 1271 void FullCodeGenerator::VisitThrow(Throw* expr) { |
| 1297 Comment cmnt(masm_, "[ Throw"); | 1272 Comment cmnt(masm_, "[ Throw"); |
| 1298 VisitForStackValue(expr->exception()); | 1273 VisitForStackValue(expr->exception()); |
| 1299 __ CallRuntime(Runtime::kThrow, 1); | 1274 __ CallRuntime(Runtime::kThrow, 1); |
| 1300 // Never returns here. | 1275 // Never returns here. |
| 1301 } | 1276 } |
| 1302 | 1277 |
| 1303 | 1278 |
| 1304 int FullCodeGenerator::TryFinally::Exit(int stack_depth) { | 1279 int FullCodeGenerator::TryFinally::Exit(int stack_depth) { |
| 1305 // The macros used here must preserve the result register. | 1280 // The macros used here must preserve the result register. |
| 1306 __ Drop(stack_depth); | 1281 __ Drop(stack_depth); |
| 1307 __ PopTryHandler(); | 1282 __ PopTryHandler(); |
| 1308 __ Call(finally_entry_); | 1283 __ Call(finally_entry_); |
| 1309 return 0; | 1284 return 0; |
| 1310 } | 1285 } |
| 1311 | 1286 |
| 1312 | 1287 |
| 1313 int FullCodeGenerator::TryCatch::Exit(int stack_depth) { | 1288 int FullCodeGenerator::TryCatch::Exit(int stack_depth) { |
| 1314 // The macros used here must preserve the result register. | 1289 // The macros used here must preserve the result register. |
| 1315 __ Drop(stack_depth); | 1290 __ Drop(stack_depth); |
| 1316 __ PopTryHandler(); | 1291 __ PopTryHandler(); |
| 1317 return 0; | 1292 return 0; |
| 1318 } | 1293 } |
| 1319 | 1294 |
| 1320 | 1295 |
| 1321 #undef __ | 1296 #undef __ |
| 1322 | 1297 |
| 1323 | 1298 |
| 1324 } } // namespace v8::internal | 1299 } } // namespace v8::internal |
| OLD | NEW |