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

Unified Diff: runtime/vm/assembler_ia32.cc

Issue 8888020: Teach the assembler how to generate multi-byte nops. Teach the (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/assembler_ia32.h ('k') | runtime/vm/assembler_ia32_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/assembler_ia32.cc
===================================================================
--- runtime/vm/assembler_ia32.cc (revision 2148)
+++ runtime/vm/assembler_ia32.cc (working copy)
@@ -1096,10 +1096,66 @@
}
-
-void Assembler::nop() {
+void Assembler::nop(int size) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
- EmitUint8(0x90);
+ // There are nops up to size 15, but for now just provide up to size 8.
+ ASSERT(0 < size && size <= MAX_NOP_SIZE);
+ switch (size) {
+ case 1:
+ EmitUint8(0x90);
+ break;
+ case 2:
+ EmitUint8(0x66);
+ EmitUint8(0x90);
+ break;
+ case 3:
+ EmitUint8(0x0F);
+ EmitUint8(0x1F);
+ EmitUint8(0x00);
+ break;
+ case 4:
+ EmitUint8(0x0F);
+ EmitUint8(0x1F);
+ EmitUint8(0x40);
+ EmitUint8(0x00);
+ break;
+ case 5:
+ EmitUint8(0x0F);
+ EmitUint8(0x1F);
+ EmitUint8(0x44);
+ EmitUint8(0x00);
+ EmitUint8(0x00);
+ break;
+ case 6:
+ EmitUint8(0x66);
+ EmitUint8(0x0F);
+ EmitUint8(0x1F);
+ EmitUint8(0x44);
+ EmitUint8(0x00);
+ EmitUint8(0x00);
+ break;
+ case 7:
+ EmitUint8(0x0F);
+ EmitUint8(0x1F);
+ EmitUint8(0x80);
+ EmitUint8(0x00);
+ EmitUint8(0x00);
+ EmitUint8(0x00);
+ EmitUint8(0x00);
+ break;
+ case 8:
+ EmitUint8(0x0F);
+ EmitUint8(0x1F);
+ EmitUint8(0x84);
+ EmitUint8(0x00);
+ EmitUint8(0x00);
+ EmitUint8(0x00);
+ EmitUint8(0x00);
+ EmitUint8(0x00);
+ break;
+ default:
+ UNIMPLEMENTED();
+ }
}
@@ -1333,10 +1389,20 @@
void Assembler::Align(int alignment, int offset) {
ASSERT(Utils::IsPowerOfTwo(alignment));
- // Emit nop instruction until the real position is aligned.
- while (((offset + buffer_.GetPosition()) & (alignment-1)) != 0) {
- nop();
+ int pos = offset + buffer_.GetPosition();
+ int mod = pos & (alignment - 1);
+ if (mod == 0) {
+ return;
}
+ int bytes_needed = alignment - mod;
+ while (bytes_needed > MAX_NOP_SIZE) {
+ nop(MAX_NOP_SIZE);
+ bytes_needed -= MAX_NOP_SIZE;
+ }
+ if (bytes_needed) {
+ nop(bytes_needed);
+ }
+ ASSERT(((offset + buffer_.GetPosition()) & (alignment-1)) == 0);
}
« no previous file with comments | « runtime/vm/assembler_ia32.h ('k') | runtime/vm/assembler_ia32_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698