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

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: Addressed review comments. 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
« no previous file with comments | « src/safepoint-table.cc ('k') | 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 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;
561 static const int kShortCallInstructionLength = 5;
560 562
561 // The debug break slot must be able to contain a call instruction. 563 // The debug break slot must be able to contain a call instruction.
562 static const int kDebugBreakSlotLength = kCallInstructionLength; 564 static const int kDebugBreakSlotLength = kCallInstructionLength;
563 565
564 // One byte opcode for test eax,0xXXXXXXXX. 566 // One byte opcode for test eax,0xXXXXXXXX.
565 static const byte kTestEaxByte = 0xA9; 567 static const byte kTestEaxByte = 0xA9;
566 568
567 // --------------------------------------------------------------------------- 569 // ---------------------------------------------------------------------------
568 // Code generation 570 // Code generation
569 // 571 //
570 // Function names correspond one-to-one to x64 instruction mnemonics. 572 // Function names correspond one-to-one to x64 instruction mnemonics.
571 // Unless specified otherwise, instructions operate on 64-bit operands. 573 // Unless specified otherwise, instructions operate on 64-bit operands.
572 // 574 //
573 // If we need versions of an assembly instruction that operate on different 575 // If we need versions of an assembly instruction that operate on different
574 // width arguments, we add a single-letter suffix specifying the width. 576 // width arguments, we add a single-letter suffix specifying the width.
575 // This is done for the following instructions: mov, cmp, inc, dec, 577 // This is done for the following instructions: mov, cmp, inc, dec,
576 // add, sub, and test. 578 // add, sub, and test.
577 // There are no versions of these instructions without the suffix. 579 // There are no versions of these instructions without the suffix.
578 // - Instructions on 8-bit (byte) operands/registers have a trailing 'b'. 580 // - Instructions on 8-bit (byte) operands/registers have a trailing 'b'.
579 // - Instructions on 16-bit (word) operands/registers have a trailing 'w'. 581 // - Instructions on 16-bit (word) operands/registers have a trailing 'w'.
580 // - Instructions on 32-bit (doubleword) operands/registers use 'l'. 582 // - Instructions on 32-bit (doubleword) operands/registers use 'l'.
581 // - Instructions on 64-bit (quadword) operands/registers use 'q'. 583 // - Instructions on 64-bit (quadword) operands/registers use 'q'.
582 // 584 //
583 // Some mnemonics, such as "and", are the same as C++ keywords. 585 // Some mnemonics, such as "and", are the same as C++ keywords.
584 // Naming conflicts with C++ keywords are resolved by adding a trailing '_'. 586 // Naming conflicts with C++ keywords are resolved by adding a trailing '_'.
585 587
586 // Insert the smallest number of nop instructions 588 // Insert the smallest number of nop instructions
587 // possible to align the pc offset to a multiple 589 // possible to align the pc offset to a multiple
588 // of m. m must be a power of 2. 590 // of m, where m must be a power of 2.
589 void Align(int m); 591 void Align(int m);
590 // Aligns code to something that's optimal for a jump target for the platform. 592 // Aligns code to something that's optimal for a jump target for the platform.
591 void CodeTargetAlign(); 593 void CodeTargetAlign();
592 594
593 // Stack 595 // Stack
594 void pushfq(); 596 void pushfq();
595 void popfq(); 597 void popfq();
596 598
597 void push(Immediate value); 599 void push(Immediate value);
598 // Push a 32 bit integer, and guarantee that it is actually pushed as a 600 // Push a 32 bit integer, and guarantee that it is actually pushed as a
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 // but it may be bound only once. 1106 // but it may be bound only once.
1105 1107
1106 void bind(Label* L); // binds an unbound label L to the current code position 1108 void bind(Label* L); // binds an unbound label L to the current code position
1107 void bind(NearLabel* L); 1109 void bind(NearLabel* L);
1108 1110
1109 // Calls 1111 // Calls
1110 // Call near relative 32-bit displacement, relative to next instruction. 1112 // Call near relative 32-bit displacement, relative to next instruction.
1111 void call(Label* L); 1113 void call(Label* L);
1112 void call(Handle<Code> target, RelocInfo::Mode rmode); 1114 void call(Handle<Code> target, RelocInfo::Mode rmode);
1113 1115
1116 // Calls directly to the given address using a relative offset.
1117 // Should only ever be used in Code objects for calls within the
1118 // same Code object. Should not be used when generating new code (use labels),
1119 // but only when patching existing code.
1120 void call(Address target);
1121
1114 // Call near absolute indirect, address in register 1122 // Call near absolute indirect, address in register
1115 void call(Register adr); 1123 void call(Register adr);
1116 1124
1117 // Call near indirect 1125 // Call near indirect
1118 void call(const Operand& operand); 1126 void call(const Operand& operand);
1119 1127
1120 // Jumps 1128 // Jumps
1121 // Jump short or near relative. 1129 // Jump short or near relative.
1122 // Use a 32-bit signed displacement. 1130 // Use a 32-bit signed displacement.
1123 void jmp(Label* L); // unconditional jump to L 1131 void jmp(Label* L); // unconditional jump to L
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 private: 1543 private:
1536 Assembler* assembler_; 1544 Assembler* assembler_;
1537 #ifdef DEBUG 1545 #ifdef DEBUG
1538 int space_before_; 1546 int space_before_;
1539 #endif 1547 #endif
1540 }; 1548 };
1541 1549
1542 } } // namespace v8::internal 1550 } } // namespace v8::internal
1543 1551
1544 #endif // V8_X64_ASSEMBLER_X64_H_ 1552 #endif // V8_X64_ASSEMBLER_X64_H_
OLDNEW
« no previous file with comments | « src/safepoint-table.cc ('k') | src/x64/assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698