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

Side by Side Diff: src/liveedit.cc

Issue 10263002: Fix issue 825 (LiveEdit vs. function with no locals) in core and for ia32. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 8 years, 7 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/ia32/debug-ia32.cc ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2012 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
11 // with the distribution. 11 // with the distribution.
(...skipping 11 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 28
29 #include "v8.h" 29 #include "v8.h"
30 30
31 #include "liveedit.h" 31 #include "liveedit.h"
32 32
33 #include "code-stubs.h"
33 #include "compilation-cache.h" 34 #include "compilation-cache.h"
34 #include "compiler.h" 35 #include "compiler.h"
35 #include "debug.h" 36 #include "debug.h"
36 #include "deoptimizer.h" 37 #include "deoptimizer.h"
37 #include "global-handles.h" 38 #include "global-handles.h"
38 #include "parser.h" 39 #include "parser.h"
39 #include "scopeinfo.h" 40 #include "scopeinfo.h"
40 #include "scopes.h" 41 #include "scopes.h"
41 #include "v8memory.h" 42 #include "v8memory.h"
42 43
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 1469
1469 StackFrame* pre_top_frame = frames[top_frame_index - 1]; 1470 StackFrame* pre_top_frame = frames[top_frame_index - 1];
1470 StackFrame* top_frame = frames[top_frame_index]; 1471 StackFrame* top_frame = frames[top_frame_index];
1471 StackFrame* bottom_js_frame = frames[bottom_js_frame_index]; 1472 StackFrame* bottom_js_frame = frames[bottom_js_frame_index];
1472 1473
1473 ASSERT(bottom_js_frame->is_java_script()); 1474 ASSERT(bottom_js_frame->is_java_script());
1474 1475
1475 // Check the nature of the top frame. 1476 // Check the nature of the top frame.
1476 Isolate* isolate = Isolate::Current(); 1477 Isolate* isolate = Isolate::Current();
1477 Code* pre_top_frame_code = pre_top_frame->LookupCode(); 1478 Code* pre_top_frame_code = pre_top_frame->LookupCode();
1479 bool frame_has_padding;
1478 if (pre_top_frame_code->is_inline_cache_stub() && 1480 if (pre_top_frame_code->is_inline_cache_stub() &&
1479 pre_top_frame_code->ic_state() == DEBUG_BREAK) { 1481 pre_top_frame_code->ic_state() == DEBUG_BREAK) {
1480 // OK, we can drop inline cache calls. 1482 // OK, we can drop inline cache calls.
1481 *mode = Debug::FRAME_DROPPED_IN_IC_CALL; 1483 *mode = Debug::FRAME_DROPPED_IN_IC_CALL;
1484 frame_has_padding = Debug::FramePaddingLayout::kIsSupported;
1482 } else if (pre_top_frame_code == 1485 } else if (pre_top_frame_code ==
1483 isolate->debug()->debug_break_slot()) { 1486 isolate->debug()->debug_break_slot()) {
1484 // OK, we can drop debug break slot. 1487 // OK, we can drop debug break slot.
1485 *mode = Debug::FRAME_DROPPED_IN_DEBUG_SLOT_CALL; 1488 *mode = Debug::FRAME_DROPPED_IN_DEBUG_SLOT_CALL;
1489 frame_has_padding = Debug::FramePaddingLayout::kIsSupported;
1486 } else if (pre_top_frame_code == 1490 } else if (pre_top_frame_code ==
1487 isolate->builtins()->builtin( 1491 isolate->builtins()->builtin(
1488 Builtins::kFrameDropper_LiveEdit)) { 1492 Builtins::kFrameDropper_LiveEdit)) {
1489 // OK, we can drop our own code. 1493 // OK, we can drop our own code.
1490 *mode = Debug::FRAME_DROPPED_IN_DIRECT_CALL; 1494 *mode = Debug::FRAME_DROPPED_IN_DIRECT_CALL;
1495 frame_has_padding = false;
1491 } else if (pre_top_frame_code == 1496 } else if (pre_top_frame_code ==
1492 isolate->builtins()->builtin(Builtins::kReturn_DebugBreak)) { 1497 isolate->builtins()->builtin(Builtins::kReturn_DebugBreak)) {
1493 *mode = Debug::FRAME_DROPPED_IN_RETURN_CALL; 1498 *mode = Debug::FRAME_DROPPED_IN_RETURN_CALL;
1499 frame_has_padding = Debug::FramePaddingLayout::kIsSupported;
1494 } else if (pre_top_frame_code->kind() == Code::STUB && 1500 } else if (pre_top_frame_code->kind() == Code::STUB &&
1495 pre_top_frame_code->major_key()) { 1501 pre_top_frame_code->major_key() == CodeStub::CEntry) {
1496 // Entry from our unit tests, it's fine, we support this case. 1502 // Entry from our unit tests on 'debugger' statement.
1503 // It's fine, we support this case.
1497 *mode = Debug::FRAME_DROPPED_IN_DIRECT_CALL; 1504 *mode = Debug::FRAME_DROPPED_IN_DIRECT_CALL;
1505 // We don't have a padding from 'debugger' statement call.
1506 // Here the stub is CEntry, it's not debug-only and can't be padded.
1507 // If anyone would complain, a proxy padded stub could be added.
1508 frame_has_padding = false;
1498 } else { 1509 } else {
1499 return "Unknown structure of stack above changing function"; 1510 return "Unknown structure of stack above changing function";
1500 } 1511 }
1501 1512
1502 Address unused_stack_top = top_frame->sp(); 1513 Address unused_stack_top = top_frame->sp();
1503 Address unused_stack_bottom = bottom_js_frame->fp() 1514 Address unused_stack_bottom = bottom_js_frame->fp()
1504 - Debug::kFrameDropperFrameSize * kPointerSize // Size of the new frame. 1515 - Debug::kFrameDropperFrameSize * kPointerSize // Size of the new frame.
1505 + kPointerSize; // Bigger address end is exclusive. 1516 + kPointerSize; // Bigger address end is exclusive.
1506 1517
1518 Address* top_frame_pc_address = top_frame->pc_address();
1519
1520 // top_frame may be damaged below this point. Do not used it.
1521 ASSERT(!(top_frame = NULL));
1522
1507 if (unused_stack_top > unused_stack_bottom) { 1523 if (unused_stack_top > unused_stack_bottom) {
1508 return "Not enough space for frame dropper frame"; 1524 if (frame_has_padding) {
1525 int shortage_bytes = unused_stack_top - unused_stack_bottom;
1526
1527 Address padding_start = pre_top_frame->fp() -
1528 Debug::FramePaddingLayout::kFrameBaseSize * kPointerSize;
1529
1530 Address padding_pointer = padding_start;
1531 Smi* padding_object =
1532 Smi::FromInt(Debug::FramePaddingLayout::kPaddingValue);
1533 while (Memory::Object_at(padding_pointer) == padding_object) {
1534 padding_pointer -= kPointerSize;
1535 }
1536 int padding_counter =
1537 Smi::cast(Memory::Object_at(padding_pointer))->value();
1538 if (padding_counter * kPointerSize < shortage_bytes) {
1539 return "Not enough space for frame dropper frame "
1540 "(even with padding frame)";
1541 }
1542 Memory::Object_at(padding_pointer) =
1543 Smi::FromInt(padding_counter - shortage_bytes / kPointerSize);
1544
1545 StackFrame* pre_pre_frame = frames[top_frame_index - 2];
1546
1547 memmove(padding_start + kPointerSize - shortage_bytes,
1548 padding_start + kPointerSize,
1549 Debug::FramePaddingLayout::kFrameBaseSize * kPointerSize);
1550
1551 pre_top_frame->UpdateFp(pre_top_frame->fp() - shortage_bytes);
1552 pre_pre_frame->SetCallerFp(pre_top_frame->fp());
1553 unused_stack_top -= shortage_bytes;
1554
1555 STATIC_ASSERT(sizeof(Address) == kPointerSize);
1556 top_frame_pc_address -= shortage_bytes / kPointerSize;
1557 } else {
1558 return "Not enough space for frame dropper frame";
1559 }
1509 } 1560 }
1510 1561
1511 // Committing now. After this point we should return only NULL value. 1562 // Committing now. After this point we should return only NULL value.
1512 1563
1513 FixTryCatchHandler(pre_top_frame, bottom_js_frame); 1564 FixTryCatchHandler(pre_top_frame, bottom_js_frame);
1514 // Make sure FixTryCatchHandler is idempotent. 1565 // Make sure FixTryCatchHandler is idempotent.
1515 ASSERT(!FixTryCatchHandler(pre_top_frame, bottom_js_frame)); 1566 ASSERT(!FixTryCatchHandler(pre_top_frame, bottom_js_frame));
1516 1567
1517 Handle<Code> code = Isolate::Current()->builtins()->FrameDropper_LiveEdit(); 1568 Handle<Code> code = Isolate::Current()->builtins()->FrameDropper_LiveEdit();
1518 top_frame->set_pc(code->entry()); 1569 *top_frame_pc_address = code->entry();
1519 pre_top_frame->SetCallerFp(bottom_js_frame->fp()); 1570 pre_top_frame->SetCallerFp(bottom_js_frame->fp());
1520 1571
1521 *restarter_frame_function_pointer = 1572 *restarter_frame_function_pointer =
1522 Debug::SetUpFrameDropperFrame(bottom_js_frame, code); 1573 Debug::SetUpFrameDropperFrame(bottom_js_frame, code);
1523 1574
1524 ASSERT((**restarter_frame_function_pointer)->IsJSFunction()); 1575 ASSERT((**restarter_frame_function_pointer)->IsJSFunction());
1525 1576
1526 for (Address a = unused_stack_top; 1577 for (Address a = unused_stack_top;
1527 a < unused_stack_bottom; 1578 a < unused_stack_bottom;
1528 a += kPointerSize) { 1579 a += kPointerSize) {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 1816
1766 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { 1817 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) {
1767 return false; 1818 return false;
1768 } 1819 }
1769 1820
1770 #endif // ENABLE_DEBUGGER_SUPPORT 1821 #endif // ENABLE_DEBUGGER_SUPPORT
1771 1822
1772 1823
1773 1824
1774 } } // namespace v8::internal 1825 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/debug-ia32.cc ('k') | src/mips/debug-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698