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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | 346 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
347 | 347 |
348 function_return_.Bind(); | 348 function_return_.Bind(); |
349 if (FLAG_trace) { | 349 if (FLAG_trace) { |
350 // Push the return value on the stack as the parameter. | 350 // Push the return value on the stack as the parameter. |
351 // Runtime::TraceExit returns the parameter as it is. | 351 // Runtime::TraceExit returns the parameter as it is. |
352 frame_->EmitPush(r0); | 352 frame_->EmitPush(r0); |
353 frame_->CallRuntime(Runtime::kTraceExit, 1); | 353 frame_->CallRuntime(Runtime::kTraceExit, 1); |
354 } | 354 } |
355 | 355 |
| 356 #ifdef DEBUG |
356 // Add a label for checking the size of the code used for returning. | 357 // Add a label for checking the size of the code used for returning. |
357 Label check_exit_codesize; | 358 Label check_exit_codesize; |
358 masm_->bind(&check_exit_codesize); | 359 masm_->bind(&check_exit_codesize); |
| 360 #endif |
359 | 361 |
360 // Calculate the exact length of the return sequence and make sure that | 362 { |
361 // the constant pool is not emitted inside of the return sequence. | 363 // Make sure that the constant pool is not emitted inside of the return |
362 int32_t sp_delta = (scope()->num_parameters() + 1) * kPointerSize; | 364 // sequence. |
363 int return_sequence_length = Assembler::kJSReturnSequenceLength; | 365 Assembler::BlockConstPoolScope block_const_pool(masm_); |
364 if (!masm_->ImmediateFitsAddrMode1Instruction(sp_delta)) { | 366 |
365 // Additional mov instruction generated. | 367 // Tear down the frame which will restore the caller's frame pointer and |
366 return_sequence_length++; | 368 // the link register. |
| 369 frame_->Exit(); |
| 370 |
| 371 // Here we use masm_-> instead of the __ macro to avoid the code coverage |
| 372 // tool from instrumenting as we rely on the code size here. |
| 373 int32_t sp_delta = (scope()->num_parameters() + 1) * kPointerSize; |
| 374 masm_->add(sp, sp, Operand(sp_delta)); |
| 375 masm_->Jump(lr); |
367 } | 376 } |
368 masm_->BlockConstPoolFor(return_sequence_length); | |
369 | 377 |
370 // Tear down the frame which will restore the caller's frame pointer and | 378 #ifdef DEBUG |
371 // the link register. | |
372 frame_->Exit(); | |
373 | |
374 // Here we use masm_-> instead of the __ macro to avoid the code coverage | |
375 // tool from instrumenting as we rely on the code size here. | |
376 masm_->add(sp, sp, Operand(sp_delta)); | |
377 masm_->Jump(lr); | |
378 | |
379 // Check that the size of the code used for returning matches what is | 379 // Check that the size of the code used for returning matches what is |
380 // expected by the debugger. The add instruction above is an addressing | 380 // expected by the debugger. If the sp_delts above cannot be encoded in the |
381 // mode 1 instruction where there are restrictions on which immediate values | 381 // add instruction the add will generate two instructions. |
382 // can be encoded in the instruction and which immediate values requires | 382 int return_sequence_length = |
383 // use of an additional instruction for moving the immediate to a temporary | 383 masm_->InstructionsGeneratedSince(&check_exit_codesize); |
384 // register. | 384 CHECK(return_sequence_length == Assembler::kJSReturnSequenceLength || |
385 ASSERT_EQ(return_sequence_length, | 385 return_sequence_length == Assembler::kJSReturnSequenceLength + 1); |
386 masm_->InstructionsGeneratedSince(&check_exit_codesize)); | 386 #endif |
387 } | 387 } |
388 | 388 |
389 // Adjust for function-level loop nesting. | 389 // Adjust for function-level loop nesting. |
390 ASSERT(loop_nesting_ == info->loop_nesting()); | 390 ASSERT(loop_nesting_ == info->loop_nesting()); |
391 loop_nesting_ = 0; | 391 loop_nesting_ = 0; |
392 | 392 |
393 // Code generation state must be reset. | 393 // Code generation state must be reset. |
394 ASSERT(!has_cc()); | 394 ASSERT(!has_cc()); |
395 ASSERT(state_ == NULL); | 395 ASSERT(state_ == NULL); |
396 ASSERT(!function_return_is_shadowed_); | 396 ASSERT(!function_return_is_shadowed_); |
(...skipping 8558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8955 | 8955 |
8956 // Just jump to runtime to add the two strings. | 8956 // Just jump to runtime to add the two strings. |
8957 __ bind(&string_add_runtime); | 8957 __ bind(&string_add_runtime); |
8958 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); | 8958 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); |
8959 } | 8959 } |
8960 | 8960 |
8961 | 8961 |
8962 #undef __ | 8962 #undef __ |
8963 | 8963 |
8964 } } // namespace v8::internal | 8964 } } // namespace v8::internal |
OLD | NEW |