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

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

Issue 203016: Implement code patcher for x64 (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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 | « no previous file | src/x64/assembler-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 (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions 5 // modification, are permitted provided that the following conditions
6 // are met: 6 // are met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 const int RelocInfo::kApplyMask = 150 const int RelocInfo::kApplyMask =
151 RelocInfo::kCodeTargetMask | 1 << RelocInfo::RUNTIME_ENTRY | 151 RelocInfo::kCodeTargetMask | 1 << RelocInfo::RUNTIME_ENTRY |
152 1 << RelocInfo::JS_RETURN | 1 << RelocInfo::INTERNAL_REFERENCE; 152 1 << RelocInfo::JS_RETURN | 1 << RelocInfo::INTERNAL_REFERENCE;
153 153
154 154
155 void RelocInfo::PatchCode(byte* instructions, int instruction_count) { 155 void RelocInfo::PatchCode(byte* instructions, int instruction_count) {
156 // Patch the code at the current address with the supplied instructions. 156 // Patch the code at the current address with the supplied instructions.
157 for (int i = 0; i < instruction_count; i++) { 157 for (int i = 0; i < instruction_count; i++) {
158 *(pc_ + i) = *(instructions + i); 158 *(pc_ + i) = *(instructions + i);
159 } 159 }
160
161 // Indicate that code has changed.
162 CPU::FlushICache(pc_, instruction_count);
160 } 163 }
161 164
162 165
163 // Patch the code at the current PC with a call to the target address. 166 // Patch the code at the current PC with a call to the target address.
164 // Additional guard int3 instructions can be added if required. 167 // Additional guard int3 instructions can be added if required.
165 void RelocInfo::PatchCodeWithCall(Address target, int guard_bytes) { 168 void RelocInfo::PatchCodeWithCall(Address target, int guard_bytes) {
166 // Call instruction takes up 5 bytes and int3 takes up one byte. 169 // Call instruction takes up 5 bytes and int3 takes up one byte.
167 int code_size = 5 + guard_bytes; 170 static const int kCallCodeSize = 5;
171 int code_size = kCallCodeSize + guard_bytes;
172
173 // Create a code patcher.
174 CodePatcher patcher(pc_, code_size);
175
176 // Add a label for checking the size of the code used for returning.
177 #ifdef DEBUG
178 Label check_codesize;
179 patcher.masm()->bind(&check_codesize);
180 #endif
168 181
169 // Patch the code. 182 // Patch the code.
170 CodePatcher patcher(pc_, code_size);
171 patcher.masm()->call(target, RelocInfo::NONE); 183 patcher.masm()->call(target, RelocInfo::NONE);
172 184
185 // Check that the size of the code generated is as expected.
186 ASSERT_EQ(kCallCodeSize, patcher.masm()->SizeOfCodeGeneratedSince(&check_codes ize));
187
173 // Add the requested number of int3 instructions after the call. 188 // Add the requested number of int3 instructions after the call.
174 for (int i = 0; i < guard_bytes; i++) { 189 for (int i = 0; i < guard_bytes; i++) {
175 patcher.masm()->int3(); 190 patcher.masm()->int3();
176 } 191 }
177 } 192 }
178 193
179 194
180 // ----------------------------------------------------------------------------- 195 // -----------------------------------------------------------------------------
181 // Implementation of Operand 196 // Implementation of Operand
182 197
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 push_insn[1] = 13; // Skip over coverage insns. 2244 push_insn[1] = 13; // Skip over coverage insns.
2230 if (coverage_log != NULL) { 2245 if (coverage_log != NULL) {
2231 fprintf(coverage_log, "%s\n", file_line); 2246 fprintf(coverage_log, "%s\n", file_line);
2232 fflush(coverage_log); 2247 fflush(coverage_log);
2233 } 2248 }
2234 } 2249 }
2235 2250
2236 #endif 2251 #endif
2237 2252
2238 } } // namespace v8::internal 2253 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/x64/assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698