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

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

Issue 6347067: Fix potential overwriting of debug jumps of following code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge/build-x64
Patch Set: Created 9 years, 10 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) 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 are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // 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 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 // Should equal Debug::kX64JSReturnSequenceLength - kCallTargetAddressOffset; 546 // Should equal Debug::kX64JSReturnSequenceLength - kCallTargetAddressOffset;
547 static const int kPatchReturnSequenceAddressOffset = 13 - 4; 547 static const int kPatchReturnSequenceAddressOffset = 13 - 4;
548 // Distance between start of patched debug break slot and where the 548 // Distance between start of patched debug break slot and where the
549 // 32-bit displacement of a near call would be, relative to the pushed 549 // 32-bit displacement of a near call would be, relative to the pushed
550 // return address. TODO: Use return sequence length instead. 550 // return address. TODO: Use return sequence length instead.
551 // Should equal Debug::kX64JSReturnSequenceLength - kCallTargetAddressOffset; 551 // Should equal Debug::kX64JSReturnSequenceLength - kCallTargetAddressOffset;
552 static const int kPatchDebugBreakSlotAddressOffset = 13 - 4; 552 static const int kPatchDebugBreakSlotAddressOffset = 13 - 4;
553 // TODO(X64): Rename this, removing the "Real", after changing the above. 553 // TODO(X64): Rename this, removing the "Real", after changing the above.
554 static const int kRealPatchReturnSequenceAddressOffset = 2; 554 static const int kRealPatchReturnSequenceAddressOffset = 2;
555 555
556 // The x64 JS return sequence is padded with int3 to make it large 556 // Some x64 JS code is padded with int3 to make it large
557 // enough to hold a call instruction when the debugger patches it. 557 // enough to hold an instruction when the debugger patches it.
558 static const int kJumpInstructionLength = 13;
558 static const int kCallInstructionLength = 13; 559 static const int kCallInstructionLength = 13;
559 static const int kJSReturnSequenceLength = 13; 560 static const int kJSReturnSequenceLength = 13;
560 561
561 // The debug break slot must be able to contain a call instruction. 562 // The debug break slot must be able to contain a call instruction.
562 static const int kDebugBreakSlotLength = kCallInstructionLength; 563 static const int kDebugBreakSlotLength = kCallInstructionLength;
563 564
564 // One byte opcode for test eax,0xXXXXXXXX. 565 // One byte opcode for test eax,0xXXXXXXXX.
565 static const byte kTestEaxByte = 0xA9; 566 static const byte kTestEaxByte = 0xA9;
566 567
567 // --------------------------------------------------------------------------- 568 // ---------------------------------------------------------------------------
568 // Code generation 569 // Code generation
569 // 570 //
570 // Function names correspond one-to-one to x64 instruction mnemonics. 571 // Function names correspond one-to-one to x64 instruction mnemonics.
571 // Unless specified otherwise, instructions operate on 64-bit operands. 572 // Unless specified otherwise, instructions operate on 64-bit operands.
572 // 573 //
573 // If we need versions of an assembly instruction that operate on different 574 // If we need versions of an assembly instruction that operate on different
574 // width arguments, we add a single-letter suffix specifying the width. 575 // width arguments, we add a single-letter suffix specifying the width.
575 // This is done for the following instructions: mov, cmp, inc, dec, 576 // This is done for the following instructions: mov, cmp, inc, dec,
576 // add, sub, and test. 577 // add, sub, and test.
577 // There are no versions of these instructions without the suffix. 578 // There are no versions of these instructions without the suffix.
578 // - Instructions on 8-bit (byte) operands/registers have a trailing 'b'. 579 // - Instructions on 8-bit (byte) operands/registers have a trailing 'b'.
579 // - Instructions on 16-bit (word) operands/registers have a trailing 'w'. 580 // - Instructions on 16-bit (word) operands/registers have a trailing 'w'.
580 // - Instructions on 32-bit (doubleword) operands/registers use 'l'. 581 // - Instructions on 32-bit (doubleword) operands/registers use 'l'.
581 // - Instructions on 64-bit (quadword) operands/registers use 'q'. 582 // - Instructions on 64-bit (quadword) operands/registers use 'q'.
582 // 583 //
583 // Some mnemonics, such as "and", are the same as C++ keywords. 584 // Some mnemonics, such as "and", are the same as C++ keywords.
584 // Naming conflicts with C++ keywords are resolved by adding a trailing '_'. 585 // Naming conflicts with C++ keywords are resolved by adding a trailing '_'.
585 586
587 // Inserts nop instructions taking up n bytes.
588 void Pad(int n);
586 // Insert the smallest number of nop instructions 589 // Insert the smallest number of nop instructions
587 // possible to align the pc offset to a multiple 590 // possible to align the pc offset to a multiple
588 // of m. m must be a power of 2. 591 // of m. m must be a power of 2.
589 void Align(int m); 592 void Align(int m);
590 // Aligns code to something that's optimal for a jump target for the platform. 593 // Aligns code to something that's optimal for a jump target for the platform.
591 void CodeTargetAlign(); 594 void CodeTargetAlign();
592 595
593 // Stack 596 // Stack
594 void pushfq(); 597 void pushfq();
595 void popfq(); 598 void popfq();
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 // but it may be bound only once. 1107 // but it may be bound only once.
1105 1108
1106 void bind(Label* L); // binds an unbound label L to the current code position 1109 void bind(Label* L); // binds an unbound label L to the current code position
1107 void bind(NearLabel* L); 1110 void bind(NearLabel* L);
1108 1111
1109 // Calls 1112 // Calls
1110 // Call near relative 32-bit displacement, relative to next instruction. 1113 // Call near relative 32-bit displacement, relative to next instruction.
1111 void call(Label* L); 1114 void call(Label* L);
1112 void call(Handle<Code> target, RelocInfo::Mode rmode); 1115 void call(Handle<Code> target, RelocInfo::Mode rmode);
1113 1116
1117 // Calls directly to the given address using a relative offset.
1118 // Should only ever be used in Code objects for calls within the
1119 // same Code object. Should not be used when generating new code (use labels),
1120 // but only when patching existing code.
1121 void call(Address target);
1122
1114 // Call near absolute indirect, address in register 1123 // Call near absolute indirect, address in register
1115 void call(Register adr); 1124 void call(Register adr);
1116 1125
1117 // Call near indirect 1126 // Call near indirect
1118 void call(const Operand& operand); 1127 void call(const Operand& operand);
1119 1128
1120 // Jumps 1129 // Jumps
1121 // Jump short or near relative. 1130 // Jump short or near relative.
1122 // Use a 32-bit signed displacement. 1131 // Use a 32-bit signed displacement.
1123 void jmp(Label* L); // unconditional jump to L 1132 void jmp(Label* L); // unconditional jump to L
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 private: 1544 private:
1536 Assembler* assembler_; 1545 Assembler* assembler_;
1537 #ifdef DEBUG 1546 #ifdef DEBUG
1538 int space_before_; 1547 int space_before_;
1539 #endif 1548 #endif
1540 }; 1549 };
1541 1550
1542 } } // namespace v8::internal 1551 } } // namespace v8::internal
1543 1552
1544 #endif // V8_X64_ASSEMBLER_X64_H_ 1553 #endif // V8_X64_ASSEMBLER_X64_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698