| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 if (has_valid_frame()) { | 310 if (has_valid_frame()) { |
| 311 // If there is a valid frame, control flow can fall off the end of | 311 // If there is a valid frame, control flow can fall off the end of |
| 312 // the body. In that case there is an implicit return statement. | 312 // the body. In that case there is an implicit return statement. |
| 313 ASSERT(!function_return_is_shadowed_); | 313 ASSERT(!function_return_is_shadowed_); |
| 314 CodeForReturnPosition(fun); | 314 CodeForReturnPosition(fun); |
| 315 frame_->PrepareForReturn(); | 315 frame_->PrepareForReturn(); |
| 316 Result undefined(Factory::undefined_value()); | 316 Result undefined(Factory::undefined_value()); |
| 317 if (function_return_.is_bound()) { | 317 if (function_return_.is_bound()) { |
| 318 function_return_.Jump(&undefined); | 318 function_return_.Jump(&undefined); |
| 319 } else { | 319 } else { |
| 320 // Though this is a (possibly) backward block, the frames | 320 function_return_.Bind(&undefined); |
| 321 // can only differ on their top element. | |
| 322 function_return_.Bind(&undefined, 1); | |
| 323 GenerateReturnSequence(&undefined); | 321 GenerateReturnSequence(&undefined); |
| 324 } | 322 } |
| 325 } else if (function_return_.is_linked()) { | 323 } else if (function_return_.is_linked()) { |
| 326 // If the return target has dangling jumps to it, then we have not | 324 // If the return target has dangling jumps to it, then we have not |
| 327 // yet generated the return sequence. This can happen when (a) | 325 // yet generated the return sequence. This can happen when (a) |
| 328 // control does not flow off the end of the body so we did not | 326 // control does not flow off the end of the body so we did not |
| 329 // compile an artificial return statement just above, and (b) there | 327 // compile an artificial return statement just above, and (b) there |
| 330 // are return statements in the body but (c) they are all shadowed. | 328 // are return statements in the body but (c) they are all shadowed. |
| 331 Result return_value; | 329 Result return_value; |
| 332 // Though this is a (possibly) backward block, the frames can | 330 function_return_.Bind(&return_value); |
| 333 // only differ on their top element. | |
| 334 function_return_.Bind(&return_value, 1); | |
| 335 GenerateReturnSequence(&return_value); | 331 GenerateReturnSequence(&return_value); |
| 336 } | 332 } |
| 337 } | 333 } |
| 338 } | 334 } |
| 339 | 335 |
| 340 // Adjust for function-level loop nesting. | 336 // Adjust for function-level loop nesting. |
| 341 loop_nesting_ -= fun->loop_nesting(); | 337 loop_nesting_ -= fun->loop_nesting(); |
| 342 | 338 |
| 343 // Code generation state must be reset. | 339 // Code generation state must be reset. |
| 344 ASSERT(state_ == NULL); | 340 ASSERT(state_ == NULL); |
| (...skipping 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2321 Result return_value = frame_->Pop(); | 2317 Result return_value = frame_->Pop(); |
| 2322 if (function_return_is_shadowed_) { | 2318 if (function_return_is_shadowed_) { |
| 2323 function_return_.Jump(&return_value); | 2319 function_return_.Jump(&return_value); |
| 2324 } else { | 2320 } else { |
| 2325 frame_->PrepareForReturn(); | 2321 frame_->PrepareForReturn(); |
| 2326 if (function_return_.is_bound()) { | 2322 if (function_return_.is_bound()) { |
| 2327 // If the function return label is already bound we reuse the | 2323 // If the function return label is already bound we reuse the |
| 2328 // code by jumping to the return site. | 2324 // code by jumping to the return site. |
| 2329 function_return_.Jump(&return_value); | 2325 function_return_.Jump(&return_value); |
| 2330 } else { | 2326 } else { |
| 2331 // Though this is a (possibly) backward block, the frames can | 2327 function_return_.Bind(&return_value); |
| 2332 // only differ on their top element. | |
| 2333 function_return_.Bind(&return_value, 1); | |
| 2334 GenerateReturnSequence(&return_value); | 2328 GenerateReturnSequence(&return_value); |
| 2335 } | 2329 } |
| 2336 } | 2330 } |
| 2337 } | 2331 } |
| 2338 | 2332 |
| 2339 | 2333 |
| 2340 void CodeGenerator::GenerateReturnSequence(Result* return_value) { | 2334 void CodeGenerator::GenerateReturnSequence(Result* return_value) { |
| 2341 // The return value is a live (but not currently reference counted) | 2335 // The return value is a live (but not currently reference counted) |
| 2342 // reference to eax. This is safe because the current frame does not | 2336 // reference to eax. This is safe because the current frame does not |
| 2343 // contain a reference to eax (it is prepared for the return by spilling | 2337 // contain a reference to eax (it is prepared for the return by spilling |
| (...skipping 5110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7454 | 7448 |
| 7455 // Slow-case: Go through the JavaScript implementation. | 7449 // Slow-case: Go through the JavaScript implementation. |
| 7456 __ bind(&slow); | 7450 __ bind(&slow); |
| 7457 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); | 7451 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); |
| 7458 } | 7452 } |
| 7459 | 7453 |
| 7460 | 7454 |
| 7461 #undef __ | 7455 #undef __ |
| 7462 | 7456 |
| 7463 } } // namespace v8::internal | 7457 } } // namespace v8::internal |
| OLD | NEW |