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

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
« no previous file with comments | « runtime/vm/constants_x64.h ('k') | runtime/vm/find_code_object_test.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 (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/assembler.h"
10 #include "vm/cpu.h" 11 #include "vm/cpu.h"
11 #include "vm/stub_code.h" 12 #include "vm/stub_code.h"
12 13
13 namespace dart { 14 namespace dart {
14 15
15 // TODO(hausner): Handle captured variables. 16 // TODO(hausner): Handle captured variables.
16 RawInstance* ActivationFrame::GetLocalVarValue(intptr_t slot_index) { 17 RawInstance* ActivationFrame::GetLocalVarValue(intptr_t slot_index) {
17 uword var_address = fp() + slot_index * kWordSize; 18 uword var_address = fp() + slot_index * kWordSize;
18 return reinterpret_cast<RawInstance*>( 19 return reinterpret_cast<RawInstance*>(
19 *reinterpret_cast<uword*>(var_address)); 20 *reinterpret_cast<uword*>(var_address));
(...skipping 15 matching lines...) Expand all
35 ASSERT(num_actual_args > 0); 36 ASSERT(num_actual_args > 0);
36 // Stack pointer points to last argument that was pushed on the stack. 37 // Stack pointer points to last argument that was pushed on the stack.
37 uword closure_addr = sp() + ((num_actual_args - 1) * kWordSize); 38 uword closure_addr = sp() + ((num_actual_args - 1) * kWordSize);
38 return reinterpret_cast<RawObject*>( 39 return reinterpret_cast<RawObject*>(
39 *reinterpret_cast<uword*>(closure_addr)); 40 *reinterpret_cast<uword*>(closure_addr));
40 } 41 }
41 42
42 43
43 void CodeBreakpoint::PatchFunctionReturn() { 44 void CodeBreakpoint::PatchFunctionReturn() {
44 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 13); 45 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 13);
45 // movq %rbp,%rsp 46 ASSERT((code[0] == 0x4c) && (code[1] == 0x8b) && (code[2] == 0x7d) &&
46 ASSERT((code[0] == 0x48) && (code[1] == 0x89) && (code[2] == 0xec)); 47 (code[3] == 0xf0)); // movq r15,[rbp-0x10]
47 ASSERT(code[3] == 0x5d); // popq %rbp 48 ASSERT((code[4] == 0x48) && (code[5] == 0x89) &&
48 ASSERT(code[4] == 0xc3); // ret 49 (code[6] == 0xec)); // mov rsp, rbp
49 // Next 8 bytes are nop instructions 50 ASSERT(code[7] == 0x5d); // pop rbp
50 ASSERT((code[5] == 0x90) && (code[6] == 0x90) && 51 ASSERT(code[8] == 0xc3); // ret
51 (code[7] == 0x90) && (code[8] == 0x90) && 52 ASSERT((code[9] == 0x0F) && (code[10] == 0x1F) && (code[11] == 0x40) &&
52 (code[9] == 0x90) && (code[10] == 0x90) && 53 (code[12] == 0x00)); // nops
53 (code[11] == 0x90) && (code[12] == 0x90)); 54 // 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(); 55 uword stub_addr = StubCode::BreakpointReturnEntryPoint();
56 code[0] = 0x49; 56 code[0] = 0x49;
57 code[1] = 0xbb; 57 code[1] = 0xbb;
58 *reinterpret_cast<uword*>(&code[2]) = stub_addr; 58 *reinterpret_cast<uword*>(&code[2]) = stub_addr;
59 code[10] = 0x41; 59 code[10] = 0x41;
60 code[11] = 0xff; 60 code[11] = 0xff;
61 code[12] = 0xd3; 61 code[12] = 0xd3;
62 CPU::FlushICache(pc_ - 13, 13); 62 CPU::FlushICache(pc_ - 13, 13);
63 } 63 }
64 64
65 65
66 void CodeBreakpoint::RestoreFunctionReturn() { 66 void CodeBreakpoint::RestoreFunctionReturn() {
67 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 13); 67 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 13);
68 ASSERT((code[0] == 0x49) && (code[1] == 0xbb)); 68 ASSERT((code[0] == 0x49) && (code[1] == 0xbb));
69 code[0] = 0x48; // movq %rbp,%rsp 69
70 code[1] = 0x89; 70 MemoryRegion code_region(reinterpret_cast<void*>(pc_ - 13), 13);
71 code[2] = 0xec; 71 Assembler assembler;
72 code[3] = 0x5d; // popq %rbp 72
73 code[4] = 0xc3; // ret 73 assembler.ReturnPatchable();
74 code[5] = 0x90; // nop 74 assembler.FinalizeInstructions(code_region);
75 code[6] = 0x90; // nop 75
76 code[7] = 0x90; // nop
77 code[8] = 0x90; // nop
78 code[9] = 0x90; // nop
79 code[10] = 0x90; // nop
80 code[11] = 0x90; // nop
81 code[12] = 0x90; // nop
82 CPU::FlushICache(pc_ - 13, 13); 76 CPU::FlushICache(pc_ - 13, 13);
83 } 77 }
84 78
85 } // namespace dart 79 } // namespace dart
86 80
87 #endif // defined TARGET_ARCH_X64 81 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/constants_x64.h ('k') | runtime/vm/find_code_object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698