OLD | NEW |
---|---|
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
422 } | 422 } |
423 | 423 |
424 | 424 |
425 | 425 |
426 void CEntryStub::GenerateCore(MacroAssembler* masm, | 426 void CEntryStub::GenerateCore(MacroAssembler* masm, |
427 Label* throw_normal_exception, | 427 Label* throw_normal_exception, |
428 Label* throw_out_of_memory_exception, | 428 Label* throw_out_of_memory_exception, |
429 StackFrame::Type frame_type, | 429 StackFrame::Type frame_type, |
430 bool do_gc, | 430 bool do_gc, |
431 bool always_allocate_scope) { | 431 bool always_allocate_scope) { |
432 // rax: result parameter for PerformGC, if any | 432 // rax: result parameter for PerformGC, if any. |
William Hesse
2009/06/12 12:45:04
What does "result parameter" mean? This is really
Lasse Reichstein
2009/06/12 13:09:13
After the code of GenerateCore, the following code
William Hesse
2009/06/12 14:56:51
I would comment it as:
// rax: result of the previ
| |
433 // rbx: pointer to C function (C callee-saved) | 433 // rbx: pointer to C function (C callee-saved). |
434 // rbp: frame pointer (restored after C call) | 434 // rbp: frame pointer (restored after C call). |
435 // rsp: stack pointer (restored after C call) | 435 // rsp: stack pointer (restored after C call). |
436 // rdi: number of arguments including receiver (C callee-saved) | 436 // rdi: number of arguments including receiver. |
William Hesse
2009/06/12 12:45:04
rdi is also callee-saved. Maybe specify the Unix/
Lasse Reichstein
2009/06/12 13:09:13
The rdi register is only callee-save in the Window
| |
437 // rsi: pointer to the first argument (C callee-saved) | 437 // r15: pointer to the first argument (C callee-saved) |
438 | 438 |
439 if (do_gc) { | 439 if (do_gc) { |
440 __ movq(Operand(rsp, 0), rax); // Result. | 440 __ movq(Operand(rsp, 0), rax); // Result. |
441 __ movq(kScratchRegister, | 441 __ movq(kScratchRegister, |
442 FUNCTION_ADDR(Runtime::PerformGC), | 442 FUNCTION_ADDR(Runtime::PerformGC), |
443 RelocInfo::RUNTIME_ENTRY); | 443 RelocInfo::RUNTIME_ENTRY); |
444 __ call(kScratchRegister); | 444 __ call(kScratchRegister); |
445 } | 445 } |
446 | 446 |
447 ExternalReference scope_depth = | 447 ExternalReference scope_depth = |
448 ExternalReference::heap_always_allocate_scope_depth(); | 448 ExternalReference::heap_always_allocate_scope_depth(); |
449 if (always_allocate_scope) { | 449 if (always_allocate_scope) { |
450 __ movq(kScratchRegister, scope_depth); | 450 __ movq(kScratchRegister, scope_depth); |
William Hesse
2009/06/12 12:45:04
I have also used this code sequence for Statistics
Lasse Reichstein
2009/06/12 13:09:13
If that's the only two places, I'm not too keen on
William Hesse
2009/06/12 14:56:51
Well, they are also the only places incl and decl
| |
451 __ incl(Operand(kScratchRegister, 0)); | 451 __ incl(Operand(kScratchRegister, 0)); |
452 } | 452 } |
453 | 453 |
454 // Call C function. | 454 // Call C function. |
455 #ifdef __MSVC__ | 455 #ifdef __MSVC__ |
456 // MSVC passes arguments in rcx, rdx, r8, r9 | 456 // MSVC passes arguments in rcx, rdx, r8, r9 |
457 __ movq(rcx, rdi); // argc. | 457 __ movq(rcx, rdi); // argc. |
458 __ movq(rdx, rsi); // argv. | 458 __ movq(rdx, r15); // argv. |
459 #else // ! defined(__MSVC__) | 459 #else // ! defined(__MSVC__) |
460 __ movq(rsi, r15); // argv. | |
460 // GCC passes arguments in rdi, rsi, rdx, rcx, r8, r9. | 461 // GCC passes arguments in rdi, rsi, rdx, rcx, r8, r9. |
461 // First two arguments are already in rdi, rsi. | 462 // First arguments is already in rdi. |
William Hesse
2009/06/12 12:45:04
argument
Lasse Reichstein
2009/06/12 13:09:13
fixed.
| |
462 #endif | 463 #endif |
463 __ call(rbx); | 464 __ call(rbx); |
464 // Result is in rax - do not destroy this register! | 465 // Result is in rax - do not destroy this register! |
465 | 466 |
466 if (always_allocate_scope) { | 467 if (always_allocate_scope) { |
467 __ movq(kScratchRegister, scope_depth); | 468 __ movq(kScratchRegister, scope_depth); |
468 __ decl(Operand(kScratchRegister, 0)); | 469 __ decl(Operand(kScratchRegister, 0)); |
469 } | 470 } |
470 | 471 |
471 // Check for failure result. | 472 // Check for failure result. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
581 // this by performing a garbage collection and retrying the | 582 // this by performing a garbage collection and retrying the |
582 // builtin once. | 583 // builtin once. |
583 | 584 |
584 StackFrame::Type frame_type = is_debug_break ? | 585 StackFrame::Type frame_type = is_debug_break ? |
585 StackFrame::EXIT_DEBUG : | 586 StackFrame::EXIT_DEBUG : |
586 StackFrame::EXIT; | 587 StackFrame::EXIT; |
587 | 588 |
588 // Enter the exit frame that transitions from JavaScript to C++. | 589 // Enter the exit frame that transitions from JavaScript to C++. |
589 __ EnterExitFrame(frame_type); | 590 __ EnterExitFrame(frame_type); |
590 | 591 |
591 // rax: result parameter for PerformGC, if any (setup below) | 592 // rax: result parameter for PerformGC, if any (setup below). |
592 // rbx: pointer to builtin function (C callee-saved) | 593 // rbx: pointer to builtin function (C callee-saved). |
593 // rbp: frame pointer (restored after C call) | 594 // rbp: frame pointer (restored after C call). |
594 // rsp: stack pointer (restored after C call) | 595 // rsp: stack pointer (restored after C call). |
595 // rdi: number of arguments including receiver (C callee-saved) | 596 // rdi: number of arguments including receiver. |
William Hesse
2009/06/12 12:45:04
Why isn't this marked as C callee-saved? Or if it
Lasse Reichstein
2009/06/12 13:09:13
It's not callee-saved in the Unix 64-bit ABI, but
| |
596 // rsi: argv pointer (C callee-saved) | 597 // r15: argv pointer (C callee-saved). |
597 | 598 |
598 Label throw_out_of_memory_exception; | 599 Label throw_out_of_memory_exception; |
599 Label throw_normal_exception; | 600 Label throw_normal_exception; |
600 | 601 |
601 // Call into the runtime system. Collect garbage before the call if | 602 // Call into the runtime system. Collect garbage before the call if |
602 // running with --gc-greedy set. | 603 // running with --gc-greedy set. |
603 if (FLAG_gc_greedy) { | 604 if (FLAG_gc_greedy) { |
604 Failure* failure = Failure::RetryAfterGC(0); | 605 Failure* failure = Failure::RetryAfterGC(0); |
605 __ movq(rax, failure, RelocInfo::NONE); | 606 __ movq(rax, failure, RelocInfo::NONE); |
606 } | 607 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
723 | 724 |
724 // Restore frame pointer and return. | 725 // Restore frame pointer and return. |
725 __ pop(rbp); | 726 __ pop(rbp); |
726 __ ret(0); | 727 __ ret(0); |
727 } | 728 } |
728 | 729 |
729 | 730 |
730 #undef __ | 731 #undef __ |
731 | 732 |
732 } } // namespace v8::internal | 733 } } // namespace v8::internal |
OLD | NEW |