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

Side by Side Diff: src/x64/assembler-x64-inl.h

Issue 6271008: Make V8 more Valgrind-friendly. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 11 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/assembler-ia32-inl.h ('k') | no next file » | 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 193
194 // ----------------------------------------------------------------------------- 194 // -----------------------------------------------------------------------------
195 // Implementation of RelocInfo 195 // Implementation of RelocInfo
196 196
197 // The modes possibly affected by apply must be in kApplyMask. 197 // The modes possibly affected by apply must be in kApplyMask.
198 void RelocInfo::apply(intptr_t delta) { 198 void RelocInfo::apply(intptr_t delta) {
199 if (IsInternalReference(rmode_)) { 199 if (IsInternalReference(rmode_)) {
200 // absolute code pointer inside code object moves with the code object. 200 // absolute code pointer inside code object moves with the code object.
201 Memory::Address_at(pc_) += static_cast<int32_t>(delta); 201 Memory::Address_at(pc_) += static_cast<int32_t>(delta);
202 CPU::FlushICache(pc_, sizeof(Address));
202 } else if (IsCodeTarget(rmode_)) { 203 } else if (IsCodeTarget(rmode_)) {
203 Memory::int32_at(pc_) -= static_cast<int32_t>(delta); 204 Memory::int32_at(pc_) -= static_cast<int32_t>(delta);
205 CPU::FlushICache(pc_, sizeof(int32_t));
204 } 206 }
205 } 207 }
206 208
207 209
208 Address RelocInfo::target_address() { 210 Address RelocInfo::target_address() {
209 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); 211 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
210 if (IsCodeTarget(rmode_)) { 212 if (IsCodeTarget(rmode_)) {
211 return Assembler::target_address_at(pc_); 213 return Assembler::target_address_at(pc_);
212 } else { 214 } else {
213 return Memory::Address_at(pc_); 215 return Memory::Address_at(pc_);
(...skipping 15 matching lines...) Expand all
229 } 231 }
230 } 232 }
231 233
232 234
233 void RelocInfo::set_target_address(Address target) { 235 void RelocInfo::set_target_address(Address target) {
234 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); 236 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
235 if (IsCodeTarget(rmode_)) { 237 if (IsCodeTarget(rmode_)) {
236 Assembler::set_target_address_at(pc_, target); 238 Assembler::set_target_address_at(pc_, target);
237 } else { 239 } else {
238 Memory::Address_at(pc_) = target; 240 Memory::Address_at(pc_) = target;
241 CPU::FlushICache(pc_, sizeof(Address));
239 } 242 }
240 } 243 }
241 244
242 245
243 Object* RelocInfo::target_object() { 246 Object* RelocInfo::target_object() {
244 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); 247 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
245 return Memory::Object_at(pc_); 248 return Memory::Object_at(pc_);
246 } 249 }
247 250
248 251
(...skipping 15 matching lines...) Expand all
264 267
265 Address* RelocInfo::target_reference_address() { 268 Address* RelocInfo::target_reference_address() {
266 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); 269 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE);
267 return reinterpret_cast<Address*>(pc_); 270 return reinterpret_cast<Address*>(pc_);
268 } 271 }
269 272
270 273
271 void RelocInfo::set_target_object(Object* target) { 274 void RelocInfo::set_target_object(Object* target) {
272 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); 275 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
273 *reinterpret_cast<Object**>(pc_) = target; 276 *reinterpret_cast<Object**>(pc_) = target;
277 CPU::FlushICache(pc_, sizeof(Address));
274 } 278 }
275 279
276 280
277 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { 281 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() {
278 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); 282 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL);
279 Address address = Memory::Address_at(pc_); 283 Address address = Memory::Address_at(pc_);
280 return Handle<JSGlobalPropertyCell>( 284 return Handle<JSGlobalPropertyCell>(
281 reinterpret_cast<JSGlobalPropertyCell**>(address)); 285 reinterpret_cast<JSGlobalPropertyCell**>(address));
282 } 286 }
283 287
284 288
285 JSGlobalPropertyCell* RelocInfo::target_cell() { 289 JSGlobalPropertyCell* RelocInfo::target_cell() {
286 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); 290 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL);
287 Address address = Memory::Address_at(pc_); 291 Address address = Memory::Address_at(pc_);
288 Object* object = HeapObject::FromAddress( 292 Object* object = HeapObject::FromAddress(
289 address - JSGlobalPropertyCell::kValueOffset); 293 address - JSGlobalPropertyCell::kValueOffset);
290 return reinterpret_cast<JSGlobalPropertyCell*>(object); 294 return reinterpret_cast<JSGlobalPropertyCell*>(object);
291 } 295 }
292 296
293 297
294 void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell) { 298 void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell) {
295 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); 299 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL);
296 Address address = cell->address() + JSGlobalPropertyCell::kValueOffset; 300 Address address = cell->address() + JSGlobalPropertyCell::kValueOffset;
297 Memory::Address_at(pc_) = address; 301 Memory::Address_at(pc_) = address;
302 CPU::FlushICache(pc_, sizeof(Address));
298 } 303 }
299 304
300 305
301 bool RelocInfo::IsPatchedReturnSequence() { 306 bool RelocInfo::IsPatchedReturnSequence() {
302 // The recognized call sequence is: 307 // The recognized call sequence is:
303 // movq(kScratchRegister, immediate64); call(kScratchRegister); 308 // movq(kScratchRegister, immediate64); call(kScratchRegister);
304 // It only needs to be distinguished from a return sequence 309 // It only needs to be distinguished from a return sequence
305 // movq(rsp, rbp); pop(rbp); ret(n); int3 *6 310 // movq(rsp, rbp); pop(rbp); ret(n); int3 *6
306 // The 11th byte is int3 (0xCC) in the return sequence and 311 // The 11th byte is int3 (0xCC) in the return sequence and
307 // REX.WB (0x48+register bit) for the call sequence. 312 // REX.WB (0x48+register bit) for the call sequence.
(...skipping 16 matching lines...) Expand all
324 return Memory::Address_at( 329 return Memory::Address_at(
325 pc_ + Assembler::kRealPatchReturnSequenceAddressOffset); 330 pc_ + Assembler::kRealPatchReturnSequenceAddressOffset);
326 } 331 }
327 332
328 333
329 void RelocInfo::set_call_address(Address target) { 334 void RelocInfo::set_call_address(Address target) {
330 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || 335 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) ||
331 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); 336 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()));
332 Memory::Address_at(pc_ + Assembler::kRealPatchReturnSequenceAddressOffset) = 337 Memory::Address_at(pc_ + Assembler::kRealPatchReturnSequenceAddressOffset) =
333 target; 338 target;
339 CPU::FlushICache(pc_ + Assembler::kRealPatchReturnSequenceAddressOffset,
340 sizeof(Address));
334 } 341 }
335 342
336 343
337 Object* RelocInfo::call_object() { 344 Object* RelocInfo::call_object() {
338 return *call_object_address(); 345 return *call_object_address();
339 } 346 }
340 347
341 348
342 void RelocInfo::set_call_object(Object* target) { 349 void RelocInfo::set_call_object(Object* target) {
343 *call_object_address() = target; 350 *call_object_address() = target;
344 } 351 }
345 352
346 353
347 Object** RelocInfo::call_object_address() { 354 Object** RelocInfo::call_object_address() {
348 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || 355 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) ||
349 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); 356 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()));
350 return reinterpret_cast<Object**>( 357 return reinterpret_cast<Object**>(
351 pc_ + Assembler::kPatchReturnSequenceAddressOffset); 358 pc_ + Assembler::kPatchReturnSequenceAddressOffset);
352 } 359 }
353 360
354 361
355 void RelocInfo::Visit(ObjectVisitor* visitor) { 362 void RelocInfo::Visit(ObjectVisitor* visitor) {
356 RelocInfo::Mode mode = rmode(); 363 RelocInfo::Mode mode = rmode();
357 if (mode == RelocInfo::EMBEDDED_OBJECT) { 364 if (mode == RelocInfo::EMBEDDED_OBJECT) {
358 visitor->VisitPointer(target_object_address()); 365 visitor->VisitPointer(target_object_address());
366 CPU::FlushICache(pc_, sizeof(Address));
359 } else if (RelocInfo::IsCodeTarget(mode)) { 367 } else if (RelocInfo::IsCodeTarget(mode)) {
360 visitor->VisitCodeTarget(this); 368 visitor->VisitCodeTarget(this);
361 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { 369 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
362 visitor->VisitExternalReference(target_reference_address()); 370 visitor->VisitExternalReference(target_reference_address());
371 CPU::FlushICache(pc_, sizeof(Address));
363 #ifdef ENABLE_DEBUGGER_SUPPORT 372 #ifdef ENABLE_DEBUGGER_SUPPORT
364 } else if (Debug::has_break_points() && 373 } else if (Debug::has_break_points() &&
365 ((RelocInfo::IsJSReturn(mode) && 374 ((RelocInfo::IsJSReturn(mode) &&
366 IsPatchedReturnSequence()) || 375 IsPatchedReturnSequence()) ||
367 (RelocInfo::IsDebugBreakSlot(mode) && 376 (RelocInfo::IsDebugBreakSlot(mode) &&
368 IsPatchedDebugBreakSlotSequence()))) { 377 IsPatchedDebugBreakSlotSequence()))) {
369 visitor->VisitDebugTarget(this); 378 visitor->VisitDebugTarget(this);
370 #endif 379 #endif
371 } else if (mode == RelocInfo::RUNTIME_ENTRY) { 380 } else if (mode == RelocInfo::RUNTIME_ENTRY) {
372 visitor->VisitRuntimeEntry(this); 381 visitor->VisitRuntimeEntry(this);
373 } 382 }
374 } 383 }
375 384
376 385
377 template<typename StaticVisitor> 386 template<typename StaticVisitor>
378 void RelocInfo::Visit() { 387 void RelocInfo::Visit() {
379 RelocInfo::Mode mode = rmode(); 388 RelocInfo::Mode mode = rmode();
380 if (mode == RelocInfo::EMBEDDED_OBJECT) { 389 if (mode == RelocInfo::EMBEDDED_OBJECT) {
381 StaticVisitor::VisitPointer(target_object_address()); 390 StaticVisitor::VisitPointer(target_object_address());
391 CPU::FlushICache(pc_, sizeof(Address));
382 } else if (RelocInfo::IsCodeTarget(mode)) { 392 } else if (RelocInfo::IsCodeTarget(mode)) {
383 StaticVisitor::VisitCodeTarget(this); 393 StaticVisitor::VisitCodeTarget(this);
384 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { 394 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
385 StaticVisitor::VisitExternalReference(target_reference_address()); 395 StaticVisitor::VisitExternalReference(target_reference_address());
396 CPU::FlushICache(pc_, sizeof(Address));
386 #ifdef ENABLE_DEBUGGER_SUPPORT 397 #ifdef ENABLE_DEBUGGER_SUPPORT
387 } else if (Debug::has_break_points() && 398 } else if (Debug::has_break_points() &&
388 ((RelocInfo::IsJSReturn(mode) && 399 ((RelocInfo::IsJSReturn(mode) &&
389 IsPatchedReturnSequence()) || 400 IsPatchedReturnSequence()) ||
390 (RelocInfo::IsDebugBreakSlot(mode) && 401 (RelocInfo::IsDebugBreakSlot(mode) &&
391 IsPatchedDebugBreakSlotSequence()))) { 402 IsPatchedDebugBreakSlotSequence()))) {
392 StaticVisitor::VisitDebugTarget(this); 403 StaticVisitor::VisitDebugTarget(this);
393 #endif 404 #endif
394 } else if (mode == RelocInfo::RUNTIME_ENTRY) { 405 } else if (mode == RelocInfo::RUNTIME_ENTRY) {
395 StaticVisitor::VisitRuntimeEntry(this); 406 StaticVisitor::VisitRuntimeEntry(this);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 ASSERT(len_ == 1 || len_ == 2); 442 ASSERT(len_ == 1 || len_ == 2);
432 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); 443 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]);
433 *p = disp; 444 *p = disp;
434 len_ += sizeof(int32_t); 445 len_ += sizeof(int32_t);
435 } 446 }
436 447
437 448
438 } } // namespace v8::internal 449 } } // namespace v8::internal
439 450
440 #endif // V8_X64_ASSEMBLER_X64_INL_H_ 451 #endif // V8_X64_ASSEMBLER_X64_INL_H_
OLDNEW
« no previous file with comments | « src/ia32/assembler-ia32-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698