Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Side by Side Diff: src/liveedit.cc

Issue 300793002: Move LiveEdit-related code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix x64 Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/liveedit.h ('k') | src/mips/debug-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 #include "v8.h" 6 #include "v8.h"
7 7
8 #include "liveedit.h" 8 #include "liveedit.h"
9 9
10 #include "code-stubs.h" 10 #include "code-stubs.h"
(...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 Address* above_frame_address = pointer_address; 1526 Address* above_frame_address = pointer_address;
1527 while (*pointer_address < bottom_frame->fp()) { 1527 while (*pointer_address < bottom_frame->fp()) {
1528 pointer_address = &Memory::Address_at(*pointer_address); 1528 pointer_address = &Memory::Address_at(*pointer_address);
1529 } 1529 }
1530 bool change = *above_frame_address != *pointer_address; 1530 bool change = *above_frame_address != *pointer_address;
1531 *above_frame_address = *pointer_address; 1531 *above_frame_address = *pointer_address;
1532 return change; 1532 return change;
1533 } 1533 }
1534 1534
1535 1535
1536 // Initializes an artificial stack frame. The data it contains is used for:
1537 // a. successful work of frame dropper code which eventually gets control,
1538 // b. being compatible with regular stack structure for various stack
1539 // iterators.
1540 // Returns address of stack allocated pointer to restarted function,
1541 // the value that is called 'restarter_frame_function_pointer'. The value
1542 // at this address (possibly updated by GC) may be used later when preparing
1543 // 'step in' operation.
1544 // Frame structure (conforms InternalFrame structure):
1545 // -- code
1546 // -- SMI maker
1547 // -- function (slot is called "context")
1548 // -- frame base
1549 static Object** SetUpFrameDropperFrame(StackFrame* bottom_js_frame,
1550 Handle<Code> code) {
1551 ASSERT(bottom_js_frame->is_java_script());
1552
1553 Address fp = bottom_js_frame->fp();
1554
1555 // Move function pointer into "context" slot.
1556 Memory::Object_at(fp + StandardFrameConstants::kContextOffset) =
1557 Memory::Object_at(fp + JavaScriptFrameConstants::kFunctionOffset);
1558
1559 Memory::Object_at(fp + InternalFrameConstants::kCodeOffset) = *code;
1560 Memory::Object_at(fp + StandardFrameConstants::kMarkerOffset) =
1561 Smi::FromInt(StackFrame::INTERNAL);
1562
1563 return reinterpret_cast<Object**>(&Memory::Object_at(
1564 fp + StandardFrameConstants::kContextOffset));
1565 }
1566
1567
1536 // Removes specified range of frames from stack. There may be 1 or more 1568 // Removes specified range of frames from stack. There may be 1 or more
1537 // frames in range. Anyway the bottom frame is restarted rather than dropped, 1569 // frames in range. Anyway the bottom frame is restarted rather than dropped,
1538 // and therefore has to be a JavaScript frame. 1570 // and therefore has to be a JavaScript frame.
1539 // Returns error message or NULL. 1571 // Returns error message or NULL.
1540 static const char* DropFrames(Vector<StackFrame*> frames, 1572 static const char* DropFrames(Vector<StackFrame*> frames,
1541 int top_frame_index, 1573 int top_frame_index,
1542 int bottom_js_frame_index, 1574 int bottom_js_frame_index,
1543 Debug::FrameDropMode* mode, 1575 LiveEdit::FrameDropMode* mode,
1544 Object*** restarter_frame_function_pointer) { 1576 Object*** restarter_frame_function_pointer) {
1545 if (!Debug::kFrameDropperSupported) { 1577 if (!LiveEdit::kFrameDropperSupported) {
1546 return "Stack manipulations are not supported in this architecture."; 1578 return "Stack manipulations are not supported in this architecture.";
1547 } 1579 }
1548 1580
1549 StackFrame* pre_top_frame = frames[top_frame_index - 1]; 1581 StackFrame* pre_top_frame = frames[top_frame_index - 1];
1550 StackFrame* top_frame = frames[top_frame_index]; 1582 StackFrame* top_frame = frames[top_frame_index];
1551 StackFrame* bottom_js_frame = frames[bottom_js_frame_index]; 1583 StackFrame* bottom_js_frame = frames[bottom_js_frame_index];
1552 1584
1553 ASSERT(bottom_js_frame->is_java_script()); 1585 ASSERT(bottom_js_frame->is_java_script());
1554 1586
1555 // Check the nature of the top frame. 1587 // Check the nature of the top frame.
1556 Isolate* isolate = bottom_js_frame->isolate(); 1588 Isolate* isolate = bottom_js_frame->isolate();
1557 Code* pre_top_frame_code = pre_top_frame->LookupCode(); 1589 Code* pre_top_frame_code = pre_top_frame->LookupCode();
1558 bool frame_has_padding; 1590 bool frame_has_padding = true;
1559 if (pre_top_frame_code->is_inline_cache_stub() && 1591 if (pre_top_frame_code->is_inline_cache_stub() &&
1560 pre_top_frame_code->is_debug_stub()) { 1592 pre_top_frame_code->is_debug_stub()) {
1561 // OK, we can drop inline cache calls. 1593 // OK, we can drop inline cache calls.
1562 *mode = Debug::FRAME_DROPPED_IN_IC_CALL; 1594 *mode = LiveEdit::FRAME_DROPPED_IN_IC_CALL;
1563 frame_has_padding = Debug::FramePaddingLayout::kIsSupported;
1564 } else if (pre_top_frame_code == 1595 } else if (pre_top_frame_code ==
1565 isolate->builtins()->builtin(Builtins::kSlot_DebugBreak)) { 1596 isolate->builtins()->builtin(Builtins::kSlot_DebugBreak)) {
1566 // OK, we can drop debug break slot. 1597 // OK, we can drop debug break slot.
1567 *mode = Debug::FRAME_DROPPED_IN_DEBUG_SLOT_CALL; 1598 *mode = LiveEdit::FRAME_DROPPED_IN_DEBUG_SLOT_CALL;
1568 frame_has_padding = Debug::FramePaddingLayout::kIsSupported;
1569 } else if (pre_top_frame_code == 1599 } else if (pre_top_frame_code ==
1570 isolate->builtins()->builtin( 1600 isolate->builtins()->builtin(Builtins::kFrameDropper_LiveEdit)) {
1571 Builtins::kFrameDropper_LiveEdit)) {
1572 // OK, we can drop our own code. 1601 // OK, we can drop our own code.
1573 pre_top_frame = frames[top_frame_index - 2]; 1602 pre_top_frame = frames[top_frame_index - 2];
1574 top_frame = frames[top_frame_index - 1]; 1603 top_frame = frames[top_frame_index - 1];
1575 *mode = Debug::CURRENTLY_SET_MODE; 1604 *mode = LiveEdit::CURRENTLY_SET_MODE;
1576 frame_has_padding = false; 1605 frame_has_padding = false;
1577 } else if (pre_top_frame_code == 1606 } else if (pre_top_frame_code ==
1578 isolate->builtins()->builtin(Builtins::kReturn_DebugBreak)) { 1607 isolate->builtins()->builtin(Builtins::kReturn_DebugBreak)) {
1579 *mode = Debug::FRAME_DROPPED_IN_RETURN_CALL; 1608 *mode = LiveEdit::FRAME_DROPPED_IN_RETURN_CALL;
1580 frame_has_padding = Debug::FramePaddingLayout::kIsSupported;
1581 } else if (pre_top_frame_code->kind() == Code::STUB && 1609 } else if (pre_top_frame_code->kind() == Code::STUB &&
1582 pre_top_frame_code->major_key() == CodeStub::CEntry) { 1610 pre_top_frame_code->major_key() == CodeStub::CEntry) {
1583 // Entry from our unit tests on 'debugger' statement. 1611 // Entry from our unit tests on 'debugger' statement.
1584 // It's fine, we support this case. 1612 // It's fine, we support this case.
1585 *mode = Debug::FRAME_DROPPED_IN_DIRECT_CALL; 1613 *mode = LiveEdit::FRAME_DROPPED_IN_DIRECT_CALL;
1586 // We don't have a padding from 'debugger' statement call. 1614 // We don't have a padding from 'debugger' statement call.
1587 // Here the stub is CEntry, it's not debug-only and can't be padded. 1615 // Here the stub is CEntry, it's not debug-only and can't be padded.
1588 // If anyone would complain, a proxy padded stub could be added. 1616 // If anyone would complain, a proxy padded stub could be added.
1589 frame_has_padding = false; 1617 frame_has_padding = false;
1590 } else if (pre_top_frame->type() == StackFrame::ARGUMENTS_ADAPTOR) { 1618 } else if (pre_top_frame->type() == StackFrame::ARGUMENTS_ADAPTOR) {
1591 // This must be adaptor that remain from the frame dropping that 1619 // This must be adaptor that remain from the frame dropping that
1592 // is still on stack. A frame dropper frame must be above it. 1620 // is still on stack. A frame dropper frame must be above it.
1593 ASSERT(frames[top_frame_index - 2]->LookupCode() == 1621 ASSERT(frames[top_frame_index - 2]->LookupCode() ==
1594 isolate->builtins()->builtin(Builtins::kFrameDropper_LiveEdit)); 1622 isolate->builtins()->builtin(Builtins::kFrameDropper_LiveEdit));
1595 pre_top_frame = frames[top_frame_index - 3]; 1623 pre_top_frame = frames[top_frame_index - 3];
1596 top_frame = frames[top_frame_index - 2]; 1624 top_frame = frames[top_frame_index - 2];
1597 *mode = Debug::CURRENTLY_SET_MODE; 1625 *mode = LiveEdit::CURRENTLY_SET_MODE;
1598 frame_has_padding = false; 1626 frame_has_padding = false;
1599 } else { 1627 } else {
1600 return "Unknown structure of stack above changing function"; 1628 return "Unknown structure of stack above changing function";
1601 } 1629 }
1602 1630
1603 Address unused_stack_top = top_frame->sp(); 1631 Address unused_stack_top = top_frame->sp();
1632 int new_frame_size = LiveEdit::kFrameDropperFrameSize * kPointerSize;
1604 Address unused_stack_bottom = bottom_js_frame->fp() 1633 Address unused_stack_bottom = bottom_js_frame->fp()
1605 - Debug::kFrameDropperFrameSize * kPointerSize // Size of the new frame. 1634 - new_frame_size + kPointerSize; // Bigger address end is exclusive.
1606 + kPointerSize; // Bigger address end is exclusive.
1607 1635
1608 Address* top_frame_pc_address = top_frame->pc_address(); 1636 Address* top_frame_pc_address = top_frame->pc_address();
1609 1637
1610 // top_frame may be damaged below this point. Do not used it. 1638 // top_frame may be damaged below this point. Do not used it.
1611 ASSERT(!(top_frame = NULL)); 1639 ASSERT(!(top_frame = NULL));
1612 1640
1613 if (unused_stack_top > unused_stack_bottom) { 1641 if (unused_stack_top > unused_stack_bottom) {
1614 if (frame_has_padding) { 1642 if (frame_has_padding) {
1615 int shortage_bytes = 1643 int shortage_bytes =
1616 static_cast<int>(unused_stack_top - unused_stack_bottom); 1644 static_cast<int>(unused_stack_top - unused_stack_bottom);
1617 1645
1618 Address padding_start = pre_top_frame->fp() - 1646 Address padding_start = pre_top_frame->fp() -
1619 Debug::FramePaddingLayout::kFrameBaseSize * kPointerSize; 1647 LiveEdit::kFrameDropperFrameSize * kPointerSize;
1620 1648
1621 Address padding_pointer = padding_start; 1649 Address padding_pointer = padding_start;
1622 Smi* padding_object = 1650 Smi* padding_object = Smi::FromInt(LiveEdit::kFramePaddingValue);
1623 Smi::FromInt(Debug::FramePaddingLayout::kPaddingValue);
1624 while (Memory::Object_at(padding_pointer) == padding_object) { 1651 while (Memory::Object_at(padding_pointer) == padding_object) {
1625 padding_pointer -= kPointerSize; 1652 padding_pointer -= kPointerSize;
1626 } 1653 }
1627 int padding_counter = 1654 int padding_counter =
1628 Smi::cast(Memory::Object_at(padding_pointer))->value(); 1655 Smi::cast(Memory::Object_at(padding_pointer))->value();
1629 if (padding_counter * kPointerSize < shortage_bytes) { 1656 if (padding_counter * kPointerSize < shortage_bytes) {
1630 return "Not enough space for frame dropper frame " 1657 return "Not enough space for frame dropper frame "
1631 "(even with padding frame)"; 1658 "(even with padding frame)";
1632 } 1659 }
1633 Memory::Object_at(padding_pointer) = 1660 Memory::Object_at(padding_pointer) =
1634 Smi::FromInt(padding_counter - shortage_bytes / kPointerSize); 1661 Smi::FromInt(padding_counter - shortage_bytes / kPointerSize);
1635 1662
1636 StackFrame* pre_pre_frame = frames[top_frame_index - 2]; 1663 StackFrame* pre_pre_frame = frames[top_frame_index - 2];
1637 1664
1638 MemMove(padding_start + kPointerSize - shortage_bytes, 1665 MemMove(padding_start + kPointerSize - shortage_bytes,
1639 padding_start + kPointerSize, 1666 padding_start + kPointerSize,
1640 Debug::FramePaddingLayout::kFrameBaseSize * kPointerSize); 1667 LiveEdit::kFrameDropperFrameSize * kPointerSize);
1641 1668
1642 pre_top_frame->UpdateFp(pre_top_frame->fp() - shortage_bytes); 1669 pre_top_frame->UpdateFp(pre_top_frame->fp() - shortage_bytes);
1643 pre_pre_frame->SetCallerFp(pre_top_frame->fp()); 1670 pre_pre_frame->SetCallerFp(pre_top_frame->fp());
1644 unused_stack_top -= shortage_bytes; 1671 unused_stack_top -= shortage_bytes;
1645 1672
1646 STATIC_ASSERT(sizeof(Address) == kPointerSize); 1673 STATIC_ASSERT(sizeof(Address) == kPointerSize);
1647 top_frame_pc_address -= shortage_bytes / kPointerSize; 1674 top_frame_pc_address -= shortage_bytes / kPointerSize;
1648 } else { 1675 } else {
1649 return "Not enough space for frame dropper frame"; 1676 return "Not enough space for frame dropper frame";
1650 } 1677 }
1651 } 1678 }
1652 1679
1653 // Committing now. After this point we should return only NULL value. 1680 // Committing now. After this point we should return only NULL value.
1654 1681
1655 FixTryCatchHandler(pre_top_frame, bottom_js_frame); 1682 FixTryCatchHandler(pre_top_frame, bottom_js_frame);
1656 // Make sure FixTryCatchHandler is idempotent. 1683 // Make sure FixTryCatchHandler is idempotent.
1657 ASSERT(!FixTryCatchHandler(pre_top_frame, bottom_js_frame)); 1684 ASSERT(!FixTryCatchHandler(pre_top_frame, bottom_js_frame));
1658 1685
1659 Handle<Code> code = isolate->builtins()->FrameDropper_LiveEdit(); 1686 Handle<Code> code = isolate->builtins()->FrameDropper_LiveEdit();
1660 *top_frame_pc_address = code->entry(); 1687 *top_frame_pc_address = code->entry();
1661 pre_top_frame->SetCallerFp(bottom_js_frame->fp()); 1688 pre_top_frame->SetCallerFp(bottom_js_frame->fp());
1662 1689
1663 *restarter_frame_function_pointer = 1690 *restarter_frame_function_pointer =
1664 Debug::SetUpFrameDropperFrame(bottom_js_frame, code); 1691 SetUpFrameDropperFrame(bottom_js_frame, code);
1665 1692
1666 ASSERT((**restarter_frame_function_pointer)->IsJSFunction()); 1693 ASSERT((**restarter_frame_function_pointer)->IsJSFunction());
1667 1694
1668 for (Address a = unused_stack_top; 1695 for (Address a = unused_stack_top;
1669 a < unused_stack_bottom; 1696 a < unused_stack_bottom;
1670 a += kPointerSize) { 1697 a += kPointerSize) {
1671 Memory::Object_at(a) = Smi::FromInt(0); 1698 Memory::Object_at(a) = Smi::FromInt(0);
1672 } 1699 }
1673 1700
1674 return NULL; 1701 return NULL;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 if (!do_drop) { 1796 if (!do_drop) {
1770 // We are in check-only mode. 1797 // We are in check-only mode.
1771 return NULL; 1798 return NULL;
1772 } 1799 }
1773 1800
1774 if (!target_frame_found) { 1801 if (!target_frame_found) {
1775 // Nothing to drop. 1802 // Nothing to drop.
1776 return target.GetNotFoundMessage(); 1803 return target.GetNotFoundMessage();
1777 } 1804 }
1778 1805
1779 Debug::FrameDropMode drop_mode = Debug::FRAMES_UNTOUCHED; 1806 LiveEdit::FrameDropMode drop_mode = LiveEdit::FRAMES_UNTOUCHED;
1780 Object** restarter_frame_function_pointer = NULL; 1807 Object** restarter_frame_function_pointer = NULL;
1781 const char* error_message = DropFrames(frames, top_frame_index, 1808 const char* error_message = DropFrames(frames, top_frame_index,
1782 bottom_js_frame_index, &drop_mode, 1809 bottom_js_frame_index, &drop_mode,
1783 &restarter_frame_function_pointer); 1810 &restarter_frame_function_pointer);
1784 1811
1785 if (error_message != NULL) { 1812 if (error_message != NULL) {
1786 return error_message; 1813 return error_message;
1787 } 1814 }
1788 1815
1789 // Adjust break_frame after some frames has been dropped. 1816 // Adjust break_frame after some frames has been dropped.
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 void LiveEditFunctionTracker::RecordRootFunctionInfo(Handle<Code> code) { 2045 void LiveEditFunctionTracker::RecordRootFunctionInfo(Handle<Code> code) {
2019 isolate_->active_function_info_listener()->FunctionCode(code); 2046 isolate_->active_function_info_listener()->FunctionCode(code);
2020 } 2047 }
2021 2048
2022 2049
2023 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { 2050 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) {
2024 return isolate->active_function_info_listener() != NULL; 2051 return isolate->active_function_info_listener() != NULL;
2025 } 2052 }
2026 2053
2027 } } // namespace v8::internal 2054 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/liveedit.h ('k') | src/mips/debug-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698