OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 2213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2224 node->break_target()->Bind(); | 2224 node->break_target()->Bind(); |
2225 } | 2225 } |
2226 } | 2226 } |
2227 break; | 2227 break; |
2228 } | 2228 } |
2229 | 2229 |
2230 case LoopStatement::WHILE_LOOP: { | 2230 case LoopStatement::WHILE_LOOP: { |
2231 // Do not duplicate conditions with function literal | 2231 // Do not duplicate conditions with function literal |
2232 // subexpressions. This can cause us to compile the function | 2232 // subexpressions. This can cause us to compile the function |
2233 // literal twice. | 2233 // literal twice. |
2234 bool test_at_bottom = !node->has_function_literal(); | 2234 bool test_at_bottom = |
| 2235 !scope_->is_global_scope() && !node->has_function_literal(); |
2235 | 2236 |
2236 IncrementLoopNesting(); | 2237 IncrementLoopNesting(); |
2237 | 2238 |
2238 // If the condition is always false and has no side effects, we | 2239 // If the condition is always false and has no side effects, we |
2239 // do not need to compile anything. | 2240 // do not need to compile anything. |
2240 if (info == ALWAYS_FALSE) break; | 2241 if (info == ALWAYS_FALSE) break; |
2241 | 2242 |
2242 JumpTarget body; | 2243 JumpTarget body; |
2243 if (test_at_bottom) { | 2244 if (test_at_bottom) { |
2244 body.Initialize(this, JumpTarget::BIDIRECTIONAL); | 2245 body.Initialize(this, JumpTarget::BIDIRECTIONAL); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2322 if (node->break_target()->is_linked()) { | 2323 if (node->break_target()->is_linked()) { |
2323 node->break_target()->Bind(); | 2324 node->break_target()->Bind(); |
2324 } | 2325 } |
2325 break; | 2326 break; |
2326 } | 2327 } |
2327 | 2328 |
2328 case LoopStatement::FOR_LOOP: { | 2329 case LoopStatement::FOR_LOOP: { |
2329 // Do not duplicate conditions with function literal | 2330 // Do not duplicate conditions with function literal |
2330 // subexpressions. This can cause us to compile the function | 2331 // subexpressions. This can cause us to compile the function |
2331 // literal twice. | 2332 // literal twice. |
2332 bool test_at_bottom = !node->has_function_literal(); | 2333 bool test_at_bottom = |
| 2334 !scope_->is_global_scope() && !node->has_function_literal(); |
2333 | 2335 |
2334 // Compile the init expression if present. | 2336 // Compile the init expression if present. |
2335 if (node->init() != NULL) { | 2337 if (node->init() != NULL) { |
2336 Visit(node->init()); | 2338 Visit(node->init()); |
2337 } | 2339 } |
2338 | 2340 |
2339 IncrementLoopNesting(); | 2341 IncrementLoopNesting(); |
2340 | 2342 |
2341 // If the condition is always false and has no side effects, we | 2343 // If the condition is always false and has no side effects, we |
2342 // do not need to compile anything else. | 2344 // do not need to compile anything else. |
(...skipping 4607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6950 | 6952 |
6951 // Slow-case: Go through the JavaScript implementation. | 6953 // Slow-case: Go through the JavaScript implementation. |
6952 __ bind(&slow); | 6954 __ bind(&slow); |
6953 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); | 6955 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); |
6954 } | 6956 } |
6955 | 6957 |
6956 | 6958 |
6957 #undef __ | 6959 #undef __ |
6958 | 6960 |
6959 } } // namespace v8::internal | 6961 } } // namespace v8::internal |
OLD | NEW |