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

Side by Side Diff: runtime/vm/debugger_x64.cc

Issue 22825023: Uses an object pool on x64 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/debugger.h" 8 #include "vm/debugger.h"
9 9
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 24 matching lines...) Expand all
35 ASSERT(num_actual_args > 0); 35 ASSERT(num_actual_args > 0);
36 // Stack pointer points to last argument that was pushed on the stack. 36 // Stack pointer points to last argument that was pushed on the stack.
37 uword closure_addr = sp() + ((num_actual_args - 1) * kWordSize); 37 uword closure_addr = sp() + ((num_actual_args - 1) * kWordSize);
38 return reinterpret_cast<RawObject*>( 38 return reinterpret_cast<RawObject*>(
39 *reinterpret_cast<uword*>(closure_addr)); 39 *reinterpret_cast<uword*>(closure_addr));
40 } 40 }
41 41
42 42
43 void CodeBreakpoint::PatchFunctionReturn() { 43 void CodeBreakpoint::PatchFunctionReturn() {
44 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 13); 44 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 13);
45 // movq %rbp,%rsp 45 ASSERT((code[0] == 0x4c) && (code[1] == 0x8b) && (code[2] == 0x7d) &&
46 ASSERT((code[0] == 0x48) && (code[1] == 0x89) && (code[2] == 0xec)); 46 (code[3] == 0xf0)); // movq r15,[rbp-0x10]
47 ASSERT(code[3] == 0x5d); // popq %rbp 47 ASSERT((code[4] == 0x48) && (code[5] == 0x89) &&
48 ASSERT(code[4] == 0xc3); // ret 48 (code[6] == 0xec)); // mov rsp, rbp
49 // Next 8 bytes are nop instructions 49 ASSERT(code[7] == 0x5d); // pop rbp
50 ASSERT((code[5] == 0x90) && (code[6] == 0x90) && 50 ASSERT(code[8] == 0xc3); // ret
51 (code[7] == 0x90) && (code[8] == 0x90) && 51 ASSERT((code[9] == 0x90) && (code[10] == 0x90) && (code[11] == 0x90) &&
52 (code[9] == 0x90) && (code[10] == 0x90) && 52 (code[12] == 0x90)); // nops
53 (code[11] == 0x90) && (code[12] == 0x90)); 53 // Smash code with call instruction and relative target address.
54 // Smash code with call instruction and relative target address.
55 uword stub_addr = StubCode::BreakpointReturnEntryPoint(); 54 uword stub_addr = StubCode::BreakpointReturnEntryPoint();
56 code[0] = 0x49; 55 code[0] = 0x49;
57 code[1] = 0xbb; 56 code[1] = 0xbb;
58 *reinterpret_cast<uword*>(&code[2]) = stub_addr; 57 *reinterpret_cast<uword*>(&code[2]) = stub_addr;
59 code[10] = 0x41; 58 code[10] = 0x41;
60 code[11] = 0xff; 59 code[11] = 0xff;
61 code[12] = 0xd3; 60 code[12] = 0xd3;
62 CPU::FlushICache(pc_ - 13, 13); 61 CPU::FlushICache(pc_ - 13, 13);
63 } 62 }
64 63
65 64
66 void CodeBreakpoint::RestoreFunctionReturn() { 65 void CodeBreakpoint::RestoreFunctionReturn() {
67 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 13); 66 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 13);
68 ASSERT((code[0] == 0x49) && (code[1] == 0xbb)); 67 ASSERT((code[0] == 0x49) && (code[1] == 0xbb));
69 code[0] = 0x48; // movq %rbp,%rsp 68 code[0] = 0x4c; // movq r15,[rbp-0x10]
Florian Schneider 2013/09/04 09:39:47 I know it was this way before, but wouldn't it be
zra 2013/09/04 21:00:41 Yes. Perhaps for another CL.
70 code[1] = 0x89; 69 code[1] = 0x8b;
71 code[2] = 0xec; 70 code[2] = 0x7d;
72 code[3] = 0x5d; // popq %rbp 71 code[3] = 0xf0;
73 code[4] = 0xc3; // ret 72 code[4] = 0x48; // mov rsp, rbp
74 code[5] = 0x90; // nop 73 code[5] = 0x89;
75 code[6] = 0x90; // nop 74 code[6] = 0xec;
76 code[7] = 0x90; // nop 75 code[7] = 0x5d; // pop rbp
77 code[8] = 0x90; // nop 76 code[8] = 0xc3; // ret
78 code[9] = 0x90; // nop 77 code[9] = 0x90;
79 code[10] = 0x90; // nop 78 code[10] = 0x90; // nop
80 code[11] = 0x90; // nop 79 code[11] = 0x90; // nop
81 code[12] = 0x90; // nop 80 code[12] = 0x90; // nop
82 CPU::FlushICache(pc_ - 13, 13); 81 CPU::FlushICache(pc_ - 13, 13);
83 } 82 }
84 83
85 } // namespace dart 84 } // namespace dart
86 85
87 #endif // defined TARGET_ARCH_X64 86 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698