| 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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 ASSERT(ExitFrameConstants::kCallerFPOffset == 0 * kPointerSize); | 430 ASSERT(ExitFrameConstants::kCallerFPOffset == 0 * kPointerSize); |
| 431 push(ebp); | 431 push(ebp); |
| 432 mov(ebp, Operand(esp)); | 432 mov(ebp, Operand(esp)); |
| 433 | 433 |
| 434 // Reserve room for entry stack pointer and push the code object. | 434 // Reserve room for entry stack pointer and push the code object. |
| 435 ASSERT(ExitFrameConstants::kSPOffset == -1 * kPointerSize); | 435 ASSERT(ExitFrameConstants::kSPOffset == -1 * kPointerSize); |
| 436 push(Immediate(0)); // Saved entry sp, patched before call. | 436 push(Immediate(0)); // Saved entry sp, patched before call. |
| 437 push(Immediate(CodeObject())); // Accessed from ExitFrame::code_slot. | 437 push(Immediate(CodeObject())); // Accessed from ExitFrame::code_slot. |
| 438 | 438 |
| 439 // Save the frame pointer and the context in top. | 439 // Save the frame pointer and the context in top. |
| 440 ExternalReference c_entry_fp_address(Isolate::k_c_entry_fp_address, | 440 ExternalReference c_entry_fp_address(Isolate::kCEntryFPAddress, |
| 441 isolate()); | 441 isolate()); |
| 442 ExternalReference context_address(Isolate::k_context_address, | 442 ExternalReference context_address(Isolate::kContextAddress, |
| 443 isolate()); | 443 isolate()); |
| 444 mov(Operand::StaticVariable(c_entry_fp_address), ebp); | 444 mov(Operand::StaticVariable(c_entry_fp_address), ebp); |
| 445 mov(Operand::StaticVariable(context_address), esi); | 445 mov(Operand::StaticVariable(context_address), esi); |
| 446 } | 446 } |
| 447 | 447 |
| 448 | 448 |
| 449 void MacroAssembler::EnterExitFrameEpilogue(int argc, bool save_doubles) { | 449 void MacroAssembler::EnterExitFrameEpilogue(int argc, bool save_doubles) { |
| 450 // Optionally save all XMM registers. | 450 // Optionally save all XMM registers. |
| 451 if (save_doubles) { | 451 if (save_doubles) { |
| 452 CpuFeatures::Scope scope(SSE2); | 452 CpuFeatures::Scope scope(SSE2); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 lea(esp, Operand(esi, 1 * kPointerSize)); | 511 lea(esp, Operand(esi, 1 * kPointerSize)); |
| 512 | 512 |
| 513 // Push the return address to get ready to return. | 513 // Push the return address to get ready to return. |
| 514 push(ecx); | 514 push(ecx); |
| 515 | 515 |
| 516 LeaveExitFrameEpilogue(); | 516 LeaveExitFrameEpilogue(); |
| 517 } | 517 } |
| 518 | 518 |
| 519 void MacroAssembler::LeaveExitFrameEpilogue() { | 519 void MacroAssembler::LeaveExitFrameEpilogue() { |
| 520 // Restore current context from top and clear it in debug mode. | 520 // Restore current context from top and clear it in debug mode. |
| 521 ExternalReference context_address(Isolate::k_context_address, isolate()); | 521 ExternalReference context_address(Isolate::kContextAddress, isolate()); |
| 522 mov(esi, Operand::StaticVariable(context_address)); | 522 mov(esi, Operand::StaticVariable(context_address)); |
| 523 #ifdef DEBUG | 523 #ifdef DEBUG |
| 524 mov(Operand::StaticVariable(context_address), Immediate(0)); | 524 mov(Operand::StaticVariable(context_address), Immediate(0)); |
| 525 #endif | 525 #endif |
| 526 | 526 |
| 527 // Clear the top frame. | 527 // Clear the top frame. |
| 528 ExternalReference c_entry_fp_address(Isolate::k_c_entry_fp_address, | 528 ExternalReference c_entry_fp_address(Isolate::kCEntryFPAddress, |
| 529 isolate()); | 529 isolate()); |
| 530 mov(Operand::StaticVariable(c_entry_fp_address), Immediate(0)); | 530 mov(Operand::StaticVariable(c_entry_fp_address), Immediate(0)); |
| 531 } | 531 } |
| 532 | 532 |
| 533 | 533 |
| 534 void MacroAssembler::LeaveApiExitFrame() { | 534 void MacroAssembler::LeaveApiExitFrame() { |
| 535 mov(esp, Operand(ebp)); | 535 mov(esp, Operand(ebp)); |
| 536 pop(ebp); | 536 pop(ebp); |
| 537 | 537 |
| 538 LeaveExitFrameEpilogue(); | 538 LeaveExitFrameEpilogue(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 560 } else { | 560 } else { |
| 561 ASSERT(try_location == IN_JS_ENTRY); | 561 ASSERT(try_location == IN_JS_ENTRY); |
| 562 // The frame pointer does not point to a JS frame so we save NULL | 562 // The frame pointer does not point to a JS frame so we save NULL |
| 563 // for ebp. We expect the code throwing an exception to check ebp | 563 // for ebp. We expect the code throwing an exception to check ebp |
| 564 // before dereferencing it to restore the context. | 564 // before dereferencing it to restore the context. |
| 565 push(Immediate(StackHandler::ENTRY)); | 565 push(Immediate(StackHandler::ENTRY)); |
| 566 push(Immediate(0)); // NULL frame pointer. | 566 push(Immediate(0)); // NULL frame pointer. |
| 567 push(Immediate(Smi::FromInt(0))); // No context. | 567 push(Immediate(Smi::FromInt(0))); // No context. |
| 568 } | 568 } |
| 569 // Save the current handler as the next handler. | 569 // Save the current handler as the next handler. |
| 570 push(Operand::StaticVariable(ExternalReference(Isolate::k_handler_address, | 570 push(Operand::StaticVariable(ExternalReference(Isolate::kHandlerAddress, |
| 571 isolate()))); | 571 isolate()))); |
| 572 // Link this handler as the new current one. | 572 // Link this handler as the new current one. |
| 573 mov(Operand::StaticVariable(ExternalReference(Isolate::k_handler_address, | 573 mov(Operand::StaticVariable(ExternalReference(Isolate::kHandlerAddress, |
| 574 isolate())), | 574 isolate())), |
| 575 esp); | 575 esp); |
| 576 } | 576 } |
| 577 | 577 |
| 578 | 578 |
| 579 void MacroAssembler::PopTryHandler() { | 579 void MacroAssembler::PopTryHandler() { |
| 580 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); | 580 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); |
| 581 pop(Operand::StaticVariable(ExternalReference(Isolate::k_handler_address, | 581 pop(Operand::StaticVariable(ExternalReference(Isolate::kHandlerAddress, |
| 582 isolate()))); | 582 isolate()))); |
| 583 add(Operand(esp), Immediate(StackHandlerConstants::kSize - kPointerSize)); | 583 add(Operand(esp), Immediate(StackHandlerConstants::kSize - kPointerSize)); |
| 584 } | 584 } |
| 585 | 585 |
| 586 | 586 |
| 587 void MacroAssembler::Throw(Register value) { | 587 void MacroAssembler::Throw(Register value) { |
| 588 // Adjust this code if not the case. | 588 // Adjust this code if not the case. |
| 589 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); | 589 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); |
| 590 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); | 590 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); |
| 591 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 1 * kPointerSize); | 591 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 1 * kPointerSize); |
| 592 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 2 * kPointerSize); | 592 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 2 * kPointerSize); |
| 593 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 3 * kPointerSize); | 593 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 3 * kPointerSize); |
| 594 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize); | 594 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize); |
| 595 // eax must hold the exception. | 595 // eax must hold the exception. |
| 596 if (!value.is(eax)) { | 596 if (!value.is(eax)) { |
| 597 mov(eax, value); | 597 mov(eax, value); |
| 598 } | 598 } |
| 599 | 599 |
| 600 // Drop the sp to the top of the handler. | 600 // Drop the sp to the top of the handler. |
| 601 ExternalReference handler_address(Isolate::k_handler_address, | 601 ExternalReference handler_address(Isolate::kHandlerAddress, |
| 602 isolate()); | 602 isolate()); |
| 603 mov(esp, Operand::StaticVariable(handler_address)); | 603 mov(esp, Operand::StaticVariable(handler_address)); |
| 604 | 604 |
| 605 // Restore next handler, context, and frame pointer; discard handler state. | 605 // Restore next handler, context, and frame pointer; discard handler state. |
| 606 pop(Operand::StaticVariable(handler_address)); | 606 pop(Operand::StaticVariable(handler_address)); |
| 607 pop(esi); // Context. | 607 pop(esi); // Context. |
| 608 pop(ebp); // Frame pointer. | 608 pop(ebp); // Frame pointer. |
| 609 pop(edx); // State. | 609 pop(edx); // State. |
| 610 | 610 |
| 611 // If the handler is a JS frame, restore the context to the frame. | 611 // If the handler is a JS frame, restore the context to the frame. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 630 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 2 * kPointerSize); | 630 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 2 * kPointerSize); |
| 631 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 3 * kPointerSize); | 631 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 3 * kPointerSize); |
| 632 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize); | 632 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize); |
| 633 | 633 |
| 634 // eax must hold the exception. | 634 // eax must hold the exception. |
| 635 if (!value.is(eax)) { | 635 if (!value.is(eax)) { |
| 636 mov(eax, value); | 636 mov(eax, value); |
| 637 } | 637 } |
| 638 | 638 |
| 639 // Drop sp to the top stack handler. | 639 // Drop sp to the top stack handler. |
| 640 ExternalReference handler_address(Isolate::k_handler_address, | 640 ExternalReference handler_address(Isolate::kHandlerAddress, |
| 641 isolate()); | 641 isolate()); |
| 642 mov(esp, Operand::StaticVariable(handler_address)); | 642 mov(esp, Operand::StaticVariable(handler_address)); |
| 643 | 643 |
| 644 // Unwind the handlers until the ENTRY handler is found. | 644 // Unwind the handlers until the ENTRY handler is found. |
| 645 Label loop, done; | 645 Label loop, done; |
| 646 bind(&loop); | 646 bind(&loop); |
| 647 // Load the type of the current stack handler. | 647 // Load the type of the current stack handler. |
| 648 const int kStateOffset = StackHandlerConstants::kStateOffset; | 648 const int kStateOffset = StackHandlerConstants::kStateOffset; |
| 649 cmp(Operand(esp, kStateOffset), Immediate(StackHandler::ENTRY)); | 649 cmp(Operand(esp, kStateOffset), Immediate(StackHandler::ENTRY)); |
| 650 j(equal, &done, Label::kNear); | 650 j(equal, &done, Label::kNear); |
| 651 // Fetch the next handler in the list. | 651 // Fetch the next handler in the list. |
| 652 const int kNextOffset = StackHandlerConstants::kNextOffset; | 652 const int kNextOffset = StackHandlerConstants::kNextOffset; |
| 653 mov(esp, Operand(esp, kNextOffset)); | 653 mov(esp, Operand(esp, kNextOffset)); |
| 654 jmp(&loop); | 654 jmp(&loop); |
| 655 bind(&done); | 655 bind(&done); |
| 656 | 656 |
| 657 // Set the top handler address to next handler past the current ENTRY handler. | 657 // Set the top handler address to next handler past the current ENTRY handler. |
| 658 pop(Operand::StaticVariable(handler_address)); | 658 pop(Operand::StaticVariable(handler_address)); |
| 659 | 659 |
| 660 if (type == OUT_OF_MEMORY) { | 660 if (type == OUT_OF_MEMORY) { |
| 661 // Set external caught exception to false. | 661 // Set external caught exception to false. |
| 662 ExternalReference external_caught( | 662 ExternalReference external_caught( |
| 663 Isolate::k_external_caught_exception_address, | 663 Isolate::kExternalCaughtExceptionAddress, |
| 664 isolate()); | 664 isolate()); |
| 665 mov(eax, false); | 665 mov(eax, false); |
| 666 mov(Operand::StaticVariable(external_caught), eax); | 666 mov(Operand::StaticVariable(external_caught), eax); |
| 667 | 667 |
| 668 // Set pending exception and eax to out of memory exception. | 668 // Set pending exception and eax to out of memory exception. |
| 669 ExternalReference pending_exception(Isolate::k_pending_exception_address, | 669 ExternalReference pending_exception(Isolate::kPendingExceptionAddress, |
| 670 isolate()); | 670 isolate()); |
| 671 mov(eax, reinterpret_cast<int32_t>(Failure::OutOfMemoryException())); | 671 mov(eax, reinterpret_cast<int32_t>(Failure::OutOfMemoryException())); |
| 672 mov(Operand::StaticVariable(pending_exception), eax); | 672 mov(Operand::StaticVariable(pending_exception), eax); |
| 673 } | 673 } |
| 674 | 674 |
| 675 // Discard the context saved in the handler and clear the context pointer. | 675 // Discard the context saved in the handler and clear the context pointer. |
| 676 pop(edx); | 676 pop(edx); |
| 677 Set(esi, Immediate(0)); | 677 Set(esi, Immediate(0)); |
| 678 | 678 |
| 679 // Restore fp from handler and discard handler state. | 679 // Restore fp from handler and discard handler state. |
| (...skipping 1604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2284 | 2284 |
| 2285 // Check that the code was patched as expected. | 2285 // Check that the code was patched as expected. |
| 2286 ASSERT(masm_.pc_ == address_ + size_); | 2286 ASSERT(masm_.pc_ == address_ + size_); |
| 2287 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2287 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 2288 } | 2288 } |
| 2289 | 2289 |
| 2290 | 2290 |
| 2291 } } // namespace v8::internal | 2291 } } // namespace v8::internal |
| 2292 | 2292 |
| 2293 #endif // V8_TARGET_ARCH_IA32 | 2293 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |