| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 EnterWithContextStatement* stmt) { | 94 EnterWithContextStatement* stmt) { |
| 95 Visit(stmt->expression()); | 95 Visit(stmt->expression()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 | 98 |
| 99 void BreakableStatementChecker::VisitExitContextStatement( | 99 void BreakableStatementChecker::VisitExitContextStatement( |
| 100 ExitContextStatement* stmt) { | 100 ExitContextStatement* stmt) { |
| 101 } | 101 } |
| 102 | 102 |
| 103 | 103 |
| 104 void BreakableStatementChecker::VisitExitScopedBlockStatement( |
| 105 ExitScopedBlockStatement* stmt) { |
| 106 } |
| 107 |
| 108 |
| 104 void BreakableStatementChecker::VisitSwitchStatement(SwitchStatement* stmt) { | 109 void BreakableStatementChecker::VisitSwitchStatement(SwitchStatement* stmt) { |
| 105 // Switch statements breakable if the tag expression is. | 110 // Switch statements breakable if the tag expression is. |
| 106 Visit(stmt->tag()); | 111 Visit(stmt->tag()); |
| 107 } | 112 } |
| 108 | 113 |
| 109 | 114 |
| 110 void BreakableStatementChecker::VisitDoWhileStatement(DoWhileStatement* stmt) { | 115 void BreakableStatementChecker::VisitDoWhileStatement(DoWhileStatement* stmt) { |
| 111 // Mark do while as breakable to avoid adding a break slot in front of it. | 116 // Mark do while as breakable to avoid adding a break slot in front of it. |
| 112 is_breakable_ = true; | 117 is_breakable_ = true; |
| 113 } | 118 } |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 Comment cmnt(masm_, "[ ExitContextStatement"); | 973 Comment cmnt(masm_, "[ ExitContextStatement"); |
| 969 SetStatementPosition(stmt); | 974 SetStatementPosition(stmt); |
| 970 | 975 |
| 971 // Pop context. | 976 // Pop context. |
| 972 LoadContextField(context_register(), Context::PREVIOUS_INDEX); | 977 LoadContextField(context_register(), Context::PREVIOUS_INDEX); |
| 973 // Update local stack frame context field. | 978 // Update local stack frame context field. |
| 974 StoreToFrameField(StandardFrameConstants::kContextOffset, context_register()); | 979 StoreToFrameField(StandardFrameConstants::kContextOffset, context_register()); |
| 975 } | 980 } |
| 976 | 981 |
| 977 | 982 |
| 983 void FullCodeGenerator::VisitExitScopedBlockStatement( |
| 984 ExitScopedBlockStatement* stmt) { |
| 985 Comment cmnt(masm_, "[ ExitScopedBlockStatement"); |
| 986 SetStatementPosition(stmt); |
| 987 |
| 988 if (scope()->num_heap_slots() > 0) { |
| 989 // Pop context. |
| 990 LoadContextField(context_register(), Context::PREVIOUS_INDEX); |
| 991 // Update local stack frame context field. |
| 992 StoreToFrameField(StandardFrameConstants::kContextOffset, |
| 993 context_register()); |
| 994 } |
| 995 } |
| 996 |
| 997 |
| 978 void FullCodeGenerator::VisitDoWhileStatement(DoWhileStatement* stmt) { | 998 void FullCodeGenerator::VisitDoWhileStatement(DoWhileStatement* stmt) { |
| 979 Comment cmnt(masm_, "[ DoWhileStatement"); | 999 Comment cmnt(masm_, "[ DoWhileStatement"); |
| 980 SetStatementPosition(stmt); | 1000 SetStatementPosition(stmt); |
| 981 Label body, stack_check; | 1001 Label body, stack_check; |
| 982 | 1002 |
| 983 Iteration loop_statement(this, stmt); | 1003 Iteration loop_statement(this, stmt); |
| 984 increment_loop_depth(); | 1004 increment_loop_depth(); |
| 985 | 1005 |
| 986 __ bind(&body); | 1006 __ bind(&body); |
| 987 Visit(stmt->body()); | 1007 Visit(stmt->body()); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 // At this point, the exception is in a register, and store it in | 1119 // At this point, the exception is in a register, and store it in |
| 1100 // the temporary local variable (prints as ".catch-var") before | 1120 // the temporary local variable (prints as ".catch-var") before |
| 1101 // executing the catch block. The catch block has been rewritten | 1121 // executing the catch block. The catch block has been rewritten |
| 1102 // to introduce a new scope to bind the catch variable and to remove | 1122 // to introduce a new scope to bind the catch variable and to remove |
| 1103 // that scope again afterwards. | 1123 // that scope again afterwards. |
| 1104 | 1124 |
| 1105 Label try_handler_setup, catch_entry, done; | 1125 Label try_handler_setup, catch_entry, done; |
| 1106 __ Call(&try_handler_setup); | 1126 __ Call(&try_handler_setup); |
| 1107 // Try handler code, exception in result register. | 1127 // Try handler code, exception in result register. |
| 1108 | 1128 |
| 1109 // Extend the context before executing the catch block. | 1129 if (stmt->scope()->num_heap_slots() > 0) { |
| 1110 { Comment cmnt(masm_, "[ Extend catch context"); | 1130 // Extend the context before executing the catch block. |
| 1131 Comment cmnt(masm_, "[ Extend catch context"); |
| 1111 __ Push(stmt->variable()->name()); | 1132 __ Push(stmt->variable()->name()); |
| 1112 __ push(result_register()); | 1133 __ push(result_register()); |
| 1113 PushFunctionArgumentForContextAllocation(); | 1134 PushFunctionArgumentForContextAllocation(); |
| 1114 __ CallRuntime(Runtime::kPushCatchContext, 3); | 1135 __ CallRuntime(Runtime::kPushCatchContext, 3); |
| 1115 StoreToFrameField(StandardFrameConstants::kContextOffset, | 1136 StoreToFrameField(StandardFrameConstants::kContextOffset, |
| 1116 context_register()); | 1137 context_register()); |
| 1138 } else { |
| 1139 // Assign exception value to the stack allocated catch variable. |
| 1140 EmitVariableAssignment(stmt->variable(), Token::ASSIGN); |
| 1117 } | 1141 } |
| 1118 | 1142 |
| 1119 Scope* saved_scope = scope(); | 1143 Scope* saved_scope = scope(); |
| 1120 scope_ = stmt->scope(); | 1144 scope_ = stmt->scope(); |
| 1121 ASSERT(scope_->declarations()->is_empty()); | 1145 ASSERT(scope_->declarations()->is_empty()); |
| 1122 Visit(stmt->catch_block()); | 1146 Visit(stmt->catch_block()); |
| 1123 scope_ = saved_scope; | 1147 scope_ = saved_scope; |
| 1124 __ jmp(&done); | 1148 __ jmp(&done); |
| 1125 | 1149 |
| 1126 // Try block code. Sets up the exception handler chain. | 1150 // Try block code. Sets up the exception handler chain. |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 } | 1339 } |
| 1316 | 1340 |
| 1317 return false; | 1341 return false; |
| 1318 } | 1342 } |
| 1319 | 1343 |
| 1320 | 1344 |
| 1321 #undef __ | 1345 #undef __ |
| 1322 | 1346 |
| 1323 | 1347 |
| 1324 } } // namespace v8::internal | 1348 } } // namespace v8::internal |
| OLD | NEW |