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

Side by Side Diff: src/x64/disasm-x64.cc

Issue 7491052: Static state cleanup: add more consts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 4 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/x64/deoptimizer-x64.cc ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 //------------------------------------------------------------------ 51 //------------------------------------------------------------------
52 // Tables 52 // Tables
53 //------------------------------------------------------------------ 53 //------------------------------------------------------------------
54 struct ByteMnemonic { 54 struct ByteMnemonic {
55 int b; // -1 terminates, otherwise must be in range (0..255) 55 int b; // -1 terminates, otherwise must be in range (0..255)
56 OperandType op_order_; 56 OperandType op_order_;
57 const char* mnem; 57 const char* mnem;
58 }; 58 };
59 59
60 60
61 static ByteMnemonic two_operands_instr[] = { 61 static const ByteMnemonic two_operands_instr[] = {
62 { 0x00, BYTE_OPER_REG_OP_ORDER, "add" }, 62 { 0x00, BYTE_OPER_REG_OP_ORDER, "add" },
63 { 0x01, OPER_REG_OP_ORDER, "add" }, 63 { 0x01, OPER_REG_OP_ORDER, "add" },
64 { 0x02, BYTE_REG_OPER_OP_ORDER, "add" }, 64 { 0x02, BYTE_REG_OPER_OP_ORDER, "add" },
65 { 0x03, REG_OPER_OP_ORDER, "add" }, 65 { 0x03, REG_OPER_OP_ORDER, "add" },
66 { 0x08, BYTE_OPER_REG_OP_ORDER, "or" }, 66 { 0x08, BYTE_OPER_REG_OP_ORDER, "or" },
67 { 0x09, OPER_REG_OP_ORDER, "or" }, 67 { 0x09, OPER_REG_OP_ORDER, "or" },
68 { 0x0A, BYTE_REG_OPER_OP_ORDER, "or" }, 68 { 0x0A, BYTE_REG_OPER_OP_ORDER, "or" },
69 { 0x0B, REG_OPER_OP_ORDER, "or" }, 69 { 0x0B, REG_OPER_OP_ORDER, "or" },
70 { 0x10, BYTE_OPER_REG_OP_ORDER, "adc" }, 70 { 0x10, BYTE_OPER_REG_OP_ORDER, "adc" },
71 { 0x11, OPER_REG_OP_ORDER, "adc" }, 71 { 0x11, OPER_REG_OP_ORDER, "adc" },
(...skipping 26 matching lines...) Expand all
98 { 0x87, REG_OPER_OP_ORDER, "xchg" }, 98 { 0x87, REG_OPER_OP_ORDER, "xchg" },
99 { 0x88, BYTE_OPER_REG_OP_ORDER, "mov" }, 99 { 0x88, BYTE_OPER_REG_OP_ORDER, "mov" },
100 { 0x89, OPER_REG_OP_ORDER, "mov" }, 100 { 0x89, OPER_REG_OP_ORDER, "mov" },
101 { 0x8A, BYTE_REG_OPER_OP_ORDER, "mov" }, 101 { 0x8A, BYTE_REG_OPER_OP_ORDER, "mov" },
102 { 0x8B, REG_OPER_OP_ORDER, "mov" }, 102 { 0x8B, REG_OPER_OP_ORDER, "mov" },
103 { 0x8D, REG_OPER_OP_ORDER, "lea" }, 103 { 0x8D, REG_OPER_OP_ORDER, "lea" },
104 { -1, UNSET_OP_ORDER, "" } 104 { -1, UNSET_OP_ORDER, "" }
105 }; 105 };
106 106
107 107
108 static ByteMnemonic zero_operands_instr[] = { 108 static const ByteMnemonic zero_operands_instr[] = {
109 { 0xC3, UNSET_OP_ORDER, "ret" }, 109 { 0xC3, UNSET_OP_ORDER, "ret" },
110 { 0xC9, UNSET_OP_ORDER, "leave" }, 110 { 0xC9, UNSET_OP_ORDER, "leave" },
111 { 0xF4, UNSET_OP_ORDER, "hlt" }, 111 { 0xF4, UNSET_OP_ORDER, "hlt" },
112 { 0xCC, UNSET_OP_ORDER, "int3" }, 112 { 0xCC, UNSET_OP_ORDER, "int3" },
113 { 0x60, UNSET_OP_ORDER, "pushad" }, 113 { 0x60, UNSET_OP_ORDER, "pushad" },
114 { 0x61, UNSET_OP_ORDER, "popad" }, 114 { 0x61, UNSET_OP_ORDER, "popad" },
115 { 0x9C, UNSET_OP_ORDER, "pushfd" }, 115 { 0x9C, UNSET_OP_ORDER, "pushfd" },
116 { 0x9D, UNSET_OP_ORDER, "popfd" }, 116 { 0x9D, UNSET_OP_ORDER, "popfd" },
117 { 0x9E, UNSET_OP_ORDER, "sahf" }, 117 { 0x9E, UNSET_OP_ORDER, "sahf" },
118 { 0x99, UNSET_OP_ORDER, "cdq" }, 118 { 0x99, UNSET_OP_ORDER, "cdq" },
119 { 0x9B, UNSET_OP_ORDER, "fwait" }, 119 { 0x9B, UNSET_OP_ORDER, "fwait" },
120 { 0xA4, UNSET_OP_ORDER, "movs" }, 120 { 0xA4, UNSET_OP_ORDER, "movs" },
121 { 0xA5, UNSET_OP_ORDER, "movs" }, 121 { 0xA5, UNSET_OP_ORDER, "movs" },
122 { 0xA6, UNSET_OP_ORDER, "cmps" }, 122 { 0xA6, UNSET_OP_ORDER, "cmps" },
123 { 0xA7, UNSET_OP_ORDER, "cmps" }, 123 { 0xA7, UNSET_OP_ORDER, "cmps" },
124 { -1, UNSET_OP_ORDER, "" } 124 { -1, UNSET_OP_ORDER, "" }
125 }; 125 };
126 126
127 127
128 static ByteMnemonic call_jump_instr[] = { 128 static const ByteMnemonic call_jump_instr[] = {
129 { 0xE8, UNSET_OP_ORDER, "call" }, 129 { 0xE8, UNSET_OP_ORDER, "call" },
130 { 0xE9, UNSET_OP_ORDER, "jmp" }, 130 { 0xE9, UNSET_OP_ORDER, "jmp" },
131 { -1, UNSET_OP_ORDER, "" } 131 { -1, UNSET_OP_ORDER, "" }
132 }; 132 };
133 133
134 134
135 static ByteMnemonic short_immediate_instr[] = { 135 static const ByteMnemonic short_immediate_instr[] = {
136 { 0x05, UNSET_OP_ORDER, "add" }, 136 { 0x05, UNSET_OP_ORDER, "add" },
137 { 0x0D, UNSET_OP_ORDER, "or" }, 137 { 0x0D, UNSET_OP_ORDER, "or" },
138 { 0x15, UNSET_OP_ORDER, "adc" }, 138 { 0x15, UNSET_OP_ORDER, "adc" },
139 { 0x1D, UNSET_OP_ORDER, "sbb" }, 139 { 0x1D, UNSET_OP_ORDER, "sbb" },
140 { 0x25, UNSET_OP_ORDER, "and" }, 140 { 0x25, UNSET_OP_ORDER, "and" },
141 { 0x2D, UNSET_OP_ORDER, "sub" }, 141 { 0x2D, UNSET_OP_ORDER, "sub" },
142 { 0x35, UNSET_OP_ORDER, "xor" }, 142 { 0x35, UNSET_OP_ORDER, "xor" },
143 { 0x3D, UNSET_OP_ORDER, "cmp" }, 143 { 0x3D, UNSET_OP_ORDER, "cmp" },
144 { -1, UNSET_OP_ORDER, "" } 144 { -1, UNSET_OP_ORDER, "" }
145 }; 145 };
146 146
147 147
148 static const char* conditional_code_suffix[] = { 148 static const char* const conditional_code_suffix[] = {
149 "o", "no", "c", "nc", "z", "nz", "na", "a", 149 "o", "no", "c", "nc", "z", "nz", "na", "a",
150 "s", "ns", "pe", "po", "l", "ge", "le", "g" 150 "s", "ns", "pe", "po", "l", "ge", "le", "g"
151 }; 151 };
152 152
153 153
154 enum InstructionType { 154 enum InstructionType {
155 NO_INSTR, 155 NO_INSTR,
156 ZERO_OPERANDS_INSTR, 156 ZERO_OPERANDS_INSTR,
157 TWO_OPERANDS_INSTR, 157 TWO_OPERANDS_INSTR,
158 JUMP_CONDITIONAL_SHORT_INSTR, 158 JUMP_CONDITIONAL_SHORT_INSTR,
(...skipping 27 matching lines...) Expand all
186 public: 186 public:
187 InstructionTable(); 187 InstructionTable();
188 const InstructionDesc& Get(byte x) const { 188 const InstructionDesc& Get(byte x) const {
189 return instructions_[x]; 189 return instructions_[x];
190 } 190 }
191 191
192 private: 192 private:
193 InstructionDesc instructions_[256]; 193 InstructionDesc instructions_[256];
194 void Clear(); 194 void Clear();
195 void Init(); 195 void Init();
196 void CopyTable(ByteMnemonic bm[], InstructionType type); 196 void CopyTable(const ByteMnemonic bm[], InstructionType type);
197 void SetTableRange(InstructionType type, byte start, byte end, bool byte_size, 197 void SetTableRange(InstructionType type, byte start, byte end, bool byte_size,
198 const char* mnem); 198 const char* mnem);
199 void AddJumpConditionalShort(); 199 void AddJumpConditionalShort();
200 }; 200 };
201 201
202 202
203 InstructionTable::InstructionTable() { 203 InstructionTable::InstructionTable() {
204 Clear(); 204 Clear();
205 Init(); 205 Init();
206 } 206 }
(...skipping 14 matching lines...) Expand all
221 CopyTable(zero_operands_instr, ZERO_OPERANDS_INSTR); 221 CopyTable(zero_operands_instr, ZERO_OPERANDS_INSTR);
222 CopyTable(call_jump_instr, CALL_JUMP_INSTR); 222 CopyTable(call_jump_instr, CALL_JUMP_INSTR);
223 CopyTable(short_immediate_instr, SHORT_IMMEDIATE_INSTR); 223 CopyTable(short_immediate_instr, SHORT_IMMEDIATE_INSTR);
224 AddJumpConditionalShort(); 224 AddJumpConditionalShort();
225 SetTableRange(PUSHPOP_INSTR, 0x50, 0x57, false, "push"); 225 SetTableRange(PUSHPOP_INSTR, 0x50, 0x57, false, "push");
226 SetTableRange(PUSHPOP_INSTR, 0x58, 0x5F, false, "pop"); 226 SetTableRange(PUSHPOP_INSTR, 0x58, 0x5F, false, "pop");
227 SetTableRange(MOVE_REG_INSTR, 0xB8, 0xBF, false, "mov"); 227 SetTableRange(MOVE_REG_INSTR, 0xB8, 0xBF, false, "mov");
228 } 228 }
229 229
230 230
231 void InstructionTable::CopyTable(ByteMnemonic bm[], InstructionType type) { 231 void InstructionTable::CopyTable(const ByteMnemonic bm[],
232 InstructionType type) {
232 for (int i = 0; bm[i].b >= 0; i++) { 233 for (int i = 0; bm[i].b >= 0; i++) {
233 InstructionDesc* id = &instructions_[bm[i].b]; 234 InstructionDesc* id = &instructions_[bm[i].b];
234 id->mnem = bm[i].mnem; 235 id->mnem = bm[i].mnem;
235 OperandType op_order = bm[i].op_order_; 236 OperandType op_order = bm[i].op_order_;
236 id->op_order_ = 237 id->op_order_ =
237 static_cast<OperandType>(op_order & ~BYTE_SIZE_OPERAND_FLAG); 238 static_cast<OperandType>(op_order & ~BYTE_SIZE_OPERAND_FLAG);
238 ASSERT_EQ(NO_INSTR, id->type); // Information not already entered 239 ASSERT_EQ(NO_INSTR, id->type); // Information not already entered
239 id->type = type; 240 id->type = type;
240 id->byte_size_operation = ((op_order & BYTE_SIZE_OPERAND_FLAG) != 0); 241 id->byte_size_operation = ((op_order & BYTE_SIZE_OPERAND_FLAG) != 0);
241 } 242 }
(...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 for (int i = 6 - static_cast<int>(pc - prev_pc); i >= 0; i--) { 1825 for (int i = 6 - static_cast<int>(pc - prev_pc); i >= 0; i--) {
1825 fprintf(f, " "); 1826 fprintf(f, " ");
1826 } 1827 }
1827 fprintf(f, " %s\n", buffer.start()); 1828 fprintf(f, " %s\n", buffer.start());
1828 } 1829 }
1829 } 1830 }
1830 1831
1831 } // namespace disasm 1832 } // namespace disasm
1832 1833
1833 #endif // V8_TARGET_ARCH_X64 1834 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/deoptimizer-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698