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

Side by Side Diff: src/x64/assembler-x64.cc

Issue 155286: X64: Let debugger patch JSReturn with a debug break. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 5 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/debug.h ('k') | src/x64/codegen-x64.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 XMMRegister xmm8 = { 8 }; 66 XMMRegister xmm8 = { 8 };
67 XMMRegister xmm9 = { 9 }; 67 XMMRegister xmm9 = { 9 };
68 XMMRegister xmm10 = { 10 }; 68 XMMRegister xmm10 = { 10 };
69 XMMRegister xmm11 = { 11 }; 69 XMMRegister xmm11 = { 11 };
70 XMMRegister xmm12 = { 12 }; 70 XMMRegister xmm12 = { 12 };
71 XMMRegister xmm13 = { 13 }; 71 XMMRegister xmm13 = { 13 };
72 XMMRegister xmm14 = { 14 }; 72 XMMRegister xmm14 = { 14 };
73 XMMRegister xmm15 = { 15 }; 73 XMMRegister xmm15 = { 15 };
74 74
75 75
76 Operand::Operand(Register base, int32_t disp): rex_(0) { 76 // -----------------------------------------------------------------------------
77 len_ = 1; 77 // Implementation of CpuFeatures
78 if (base.is(rsp) || base.is(r12)) {
79 // SIB byte is needed to encode (rsp + offset) or (r12 + offset).
80 set_sib(times_1, rsp, base);
81 }
82
83 if (disp == 0 && !base.is(rbp) && !base.is(r13)) {
84 set_modrm(0, base);
85 } else if (is_int8(disp)) {
86 set_modrm(1, base);
87 set_disp8(disp);
88 } else {
89 set_modrm(2, base);
90 set_disp32(disp);
91 }
92 }
93
94
95 Operand::Operand(Register base,
96 Register index,
97 ScaleFactor scale,
98 int32_t disp): rex_(0) {
99 ASSERT(!index.is(rsp));
100 len_ = 1;
101 set_sib(scale, index, base);
102 if (disp == 0 && !base.is(rbp) && !base.is(r13)) {
103 // This call to set_modrm doesn't overwrite the REX.B (or REX.X) bits
104 // possibly set by set_sib.
105 set_modrm(0, rsp);
106 } else if (is_int8(disp)) {
107 set_modrm(1, rsp);
108 set_disp8(disp);
109 } else {
110 set_modrm(2, rsp);
111 set_disp32(disp);
112 }
113 }
114
115 78
116 // The required user mode extensions in X64 are (from AMD64 ABI Table A.1): 79 // The required user mode extensions in X64 are (from AMD64 ABI Table A.1):
117 // fpu, tsc, cx8, cmov, mmx, sse, sse2, fxsr, syscall 80 // fpu, tsc, cx8, cmov, mmx, sse, sse2, fxsr, syscall
118 uint64_t CpuFeatures::supported_ = kDefaultCpuFeatures; 81 uint64_t CpuFeatures::supported_ = kDefaultCpuFeatures;
119 uint64_t CpuFeatures::enabled_ = 0; 82 uint64_t CpuFeatures::enabled_ = 0;
120 83
121 void CpuFeatures::Probe() { 84 void CpuFeatures::Probe() {
122 ASSERT(Heap::HasBeenSetup()); 85 ASSERT(Heap::HasBeenSetup());
123 ASSERT(supported_ == kDefaultCpuFeatures); 86 ASSERT(supported_ == kDefaultCpuFeatures);
124 if (Serializer::enabled()) return; // No features if we might serialize. 87 if (Serializer::enabled()) return; // No features if we might serialize.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 Code::cast(code), "CpuFeatures::Probe")); 149 Code::cast(code), "CpuFeatures::Probe"));
187 typedef uint64_t (*F0)(); 150 typedef uint64_t (*F0)();
188 F0 probe = FUNCTION_CAST<F0>(Code::cast(code)->entry()); 151 F0 probe = FUNCTION_CAST<F0>(Code::cast(code)->entry());
189 supported_ = probe(); 152 supported_ = probe();
190 // SSE2 and CMOV must be available on an X64 CPU. 153 // SSE2 and CMOV must be available on an X64 CPU.
191 ASSERT(IsSupported(CPUID)); 154 ASSERT(IsSupported(CPUID));
192 ASSERT(IsSupported(SSE2)); 155 ASSERT(IsSupported(SSE2));
193 ASSERT(IsSupported(CMOV)); 156 ASSERT(IsSupported(CMOV));
194 } 157 }
195 158
159
160 // -----------------------------------------------------------------------------
161 // Implementation of RelocInfo
162
163 // Patch the code at the current PC with a call to the target address.
164 // Additional guard int3 instructions can be added if required.
165 void RelocInfo::PatchCodeWithCall(Address target, int guard_bytes) {
166 // Call instruction takes up 13 bytes and int3 takes up one byte.
167 Address patch_site = pc_;
168 Memory::uint16_at(patch_site) = 0xBA49u; // movq r10, imm64
169 // Write "0x00, call r10" starting at last byte of address. We overwrite
170 // the 0x00 later, and this lets us write a uint32.
171 Memory::uint32_at(patch_site + 9) = 0xD2FF4900u; // 0x00, call r10
172 Memory::Address_at(patch_site + 2) = target;
173
174 // Add the requested number of int3 instructions after the call.
175 for (int i = 0; i < guard_bytes; i++) {
176 *(patch_site + 13 + i) = 0xCC; // int3
177 }
178 }
179
180
181 // -----------------------------------------------------------------------------
182 // Implementation of Operand
183
184 Operand::Operand(Register base, int32_t disp): rex_(0) {
185 len_ = 1;
186 if (base.is(rsp) || base.is(r12)) {
187 // SIB byte is needed to encode (rsp + offset) or (r12 + offset).
188 set_sib(times_1, rsp, base);
189 }
190
191 if (disp == 0 && !base.is(rbp) && !base.is(r13)) {
192 set_modrm(0, base);
193 } else if (is_int8(disp)) {
194 set_modrm(1, base);
195 set_disp8(disp);
196 } else {
197 set_modrm(2, base);
198 set_disp32(disp);
199 }
200 }
201
202
203 Operand::Operand(Register base,
204 Register index,
205 ScaleFactor scale,
206 int32_t disp): rex_(0) {
207 ASSERT(!index.is(rsp));
208 len_ = 1;
209 set_sib(scale, index, base);
210 if (disp == 0 && !base.is(rbp) && !base.is(r13)) {
211 // This call to set_modrm doesn't overwrite the REX.B (or REX.X) bits
212 // possibly set by set_sib.
213 set_modrm(0, rsp);
214 } else if (is_int8(disp)) {
215 set_modrm(1, rsp);
216 set_disp8(disp);
217 } else {
218 set_modrm(2, rsp);
219 set_disp32(disp);
220 }
221 }
222
223
196 // ----------------------------------------------------------------------------- 224 // -----------------------------------------------------------------------------
197 // Implementation of Assembler 225 // Implementation of Assembler
198 226
199 #ifdef GENERATED_CODE_COVERAGE 227 #ifdef GENERATED_CODE_COVERAGE
200 static void InitCoverageLog(); 228 static void InitCoverageLog();
201 #endif 229 #endif
202 230
203 byte* Assembler::spare_buffer_ = NULL; 231 byte* Assembler::spare_buffer_ = NULL;
204 232
205 Assembler::Assembler(void* buffer, int buffer_size) { 233 Assembler::Assembler(void* buffer, int buffer_size) {
(...skipping 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after
2193 bool BreakLocationIterator::IsDebugBreakAtReturn() { 2221 bool BreakLocationIterator::IsDebugBreakAtReturn() {
2194 UNIMPLEMENTED(); 2222 UNIMPLEMENTED();
2195 return false; 2223 return false;
2196 } 2224 }
2197 2225
2198 void BreakLocationIterator::SetDebugBreakAtReturn() { 2226 void BreakLocationIterator::SetDebugBreakAtReturn() {
2199 UNIMPLEMENTED(); 2227 UNIMPLEMENTED();
2200 } 2228 }
2201 2229
2202 } } // namespace v8::internal 2230 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/debug.h ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698