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

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

Issue 6928060: Merge Label and NearLabel (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: address comments Created 9 years, 7 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/assembler-x64.h ('k') | src/x64/builtins-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 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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 // Relative address, relative to point after address. 451 // Relative address, relative to point after address.
452 int imm32 = pos - (current + sizeof(int32_t)); 452 int imm32 = pos - (current + sizeof(int32_t));
453 long_at_put(current, imm32); 453 long_at_put(current, imm32);
454 current = next; 454 current = next;
455 next = long_at(next); 455 next = long_at(next);
456 } 456 }
457 // Fix up last fixup on linked list. 457 // Fix up last fixup on linked list.
458 int last_imm32 = pos - (current + sizeof(int32_t)); 458 int last_imm32 = pos - (current + sizeof(int32_t));
459 long_at_put(current, last_imm32); 459 long_at_put(current, last_imm32);
460 } 460 }
461 while (L->is_near_linked()) {
462 int fixup_pos = L->near_link_pos();
463 int offset_to_next =
464 static_cast<int>(*reinterpret_cast<int8_t*>(addr_at(fixup_pos)));
465 ASSERT(offset_to_next <= 0);
466 int disp = pos - (fixup_pos + sizeof(int8_t));
467 ASSERT(is_int8(disp));
468 set_byte_at(fixup_pos, disp);
469 if (offset_to_next < 0) {
470 L->link_to(fixup_pos + offset_to_next, Label::kNear);
471 } else {
472 L->UnuseNear();
473 }
474 }
461 L->bind_to(pos); 475 L->bind_to(pos);
462 } 476 }
463 477
464 478
465 void Assembler::bind(Label* L) { 479 void Assembler::bind(Label* L) {
466 bind_to(L, pc_offset()); 480 bind_to(L, pc_offset());
467 } 481 }
468 482
469 483
470 void Assembler::bind(NearLabel* L) { 484 void Assembler::bind(NearLabel* L) {
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 emit_modrm(0, dst); 1221 emit_modrm(0, dst);
1208 } 1222 }
1209 1223
1210 1224
1211 void Assembler::int3() { 1225 void Assembler::int3() {
1212 EnsureSpace ensure_space(this); 1226 EnsureSpace ensure_space(this);
1213 emit(0xCC); 1227 emit(0xCC);
1214 } 1228 }
1215 1229
1216 1230
1217 void Assembler::j(Condition cc, Label* L) { 1231 void Assembler::j(Condition cc, Label* L, Hint hint, Label::Distance distance) {
1218 if (cc == always) { 1232 if (cc == always) {
1219 jmp(L); 1233 jmp(L);
1220 return; 1234 return;
1221 } else if (cc == never) { 1235 } else if (cc == never) {
1222 return; 1236 return;
1223 } 1237 }
1224 EnsureSpace ensure_space(this); 1238 EnsureSpace ensure_space(this);
1225 ASSERT(is_uint4(cc)); 1239 ASSERT(is_uint4(cc));
1240 if (FLAG_emit_branch_hints && hint != no_hint) emit(hint);
1226 if (L->is_bound()) { 1241 if (L->is_bound()) {
1227 const int short_size = 2; 1242 const int short_size = 2;
1228 const int long_size = 6; 1243 const int long_size = 6;
1229 int offs = L->pos() - pc_offset(); 1244 int offs = L->pos() - pc_offset();
1230 ASSERT(offs <= 0); 1245 ASSERT(offs <= 0);
1231 if (is_int8(offs - short_size)) { 1246 if (is_int8(offs - short_size)) {
1232 // 0111 tttn #8-bit disp. 1247 // 0111 tttn #8-bit disp.
1233 emit(0x70 | cc); 1248 emit(0x70 | cc);
1234 emit((offs - short_size) & 0xFF); 1249 emit((offs - short_size) & 0xFF);
1235 } else { 1250 } else {
1236 // 0000 1111 1000 tttn #32-bit disp. 1251 // 0000 1111 1000 tttn #32-bit disp.
1237 emit(0x0F); 1252 emit(0x0F);
1238 emit(0x80 | cc); 1253 emit(0x80 | cc);
1239 emitl(offs - long_size); 1254 emitl(offs - long_size);
1240 } 1255 }
1256 } else if (distance == Label::kNear) {
1257 // 0111 tttn #8-bit disp
1258 emit(0x70 | cc);
1259 byte disp = 0x00;
1260 if (L->is_near_linked()) {
1261 int offset = L->near_link_pos() - pc_offset();
1262 ASSERT(is_int8(offset));
1263 disp = static_cast<byte>(offset & 0xFF);
1264 }
1265 L->link_to(pc_offset(), Label::kNear);
1266 emit(disp);
1241 } else if (L->is_linked()) { 1267 } else if (L->is_linked()) {
1242 // 0000 1111 1000 tttn #32-bit disp. 1268 // 0000 1111 1000 tttn #32-bit disp.
1243 emit(0x0F); 1269 emit(0x0F);
1244 emit(0x80 | cc); 1270 emit(0x80 | cc);
1245 emitl(L->pos()); 1271 emitl(L->pos());
1246 L->link_to(pc_offset() - sizeof(int32_t)); 1272 L->link_to(pc_offset() - sizeof(int32_t));
1247 } else { 1273 } else {
1248 ASSERT(L->is_unused()); 1274 ASSERT(L->is_unused());
1249 emit(0x0F); 1275 emit(0x0F);
1250 emit(0x80 | cc); 1276 emit(0x80 | cc);
(...skipping 29 matching lines...) Expand all
1280 emit(0x70 | cc); 1306 emit(0x70 | cc);
1281 emit((offs - short_size) & 0xFF); 1307 emit((offs - short_size) & 0xFF);
1282 } else { 1308 } else {
1283 emit(0x70 | cc); 1309 emit(0x70 | cc);
1284 emit(0x00); // The displacement will be resolved later. 1310 emit(0x00); // The displacement will be resolved later.
1285 L->link_to(pc_offset()); 1311 L->link_to(pc_offset());
1286 } 1312 }
1287 } 1313 }
1288 1314
1289 1315
1290 void Assembler::jmp(Label* L) { 1316 void Assembler::jmp(Label* L, Label::Distance distance) {
1291 EnsureSpace ensure_space(this); 1317 EnsureSpace ensure_space(this);
1292 const int short_size = sizeof(int8_t); 1318 const int short_size = sizeof(int8_t);
1293 const int long_size = sizeof(int32_t); 1319 const int long_size = sizeof(int32_t);
1294 if (L->is_bound()) { 1320 if (L->is_bound()) {
1295 int offs = L->pos() - pc_offset() - 1; 1321 int offs = L->pos() - pc_offset() - 1;
1296 ASSERT(offs <= 0); 1322 ASSERT(offs <= 0);
1297 if (is_int8(offs - short_size)) { 1323 if (is_int8(offs - short_size)) {
1298 // 1110 1011 #8-bit disp. 1324 // 1110 1011 #8-bit disp.
1299 emit(0xEB); 1325 emit(0xEB);
1300 emit((offs - short_size) & 0xFF); 1326 emit((offs - short_size) & 0xFF);
1301 } else { 1327 } else {
1302 // 1110 1001 #32-bit disp. 1328 // 1110 1001 #32-bit disp.
1303 emit(0xE9); 1329 emit(0xE9);
1304 emitl(offs - long_size); 1330 emitl(offs - long_size);
1305 } 1331 }
1306 } else if (L->is_linked()) { 1332 } else if (distance == Label::kNear) {
1333 emit(0xEB);
1334 byte disp = 0x00;
1335 if (L->is_near_linked()) {
1336 int offset = L->near_link_pos() - pc_offset();
1337 ASSERT(is_int8(offset));
1338 disp = static_cast<byte>(offset & 0xFF);
1339 }
1340 L->link_to(pc_offset(), Label::kNear);
1341 emit(disp);
1342 } else if (L->is_linked()) {
1307 // 1110 1001 #32-bit disp. 1343 // 1110 1001 #32-bit disp.
1308 emit(0xE9); 1344 emit(0xE9);
1309 emitl(L->pos()); 1345 emitl(L->pos());
1310 L->link_to(pc_offset() - long_size); 1346 L->link_to(pc_offset() - long_size);
1311 } else { 1347 } else {
1312 // 1110 1001 #32-bit disp. 1348 // 1110 1001 #32-bit disp.
1313 ASSERT(L->is_unused()); 1349 ASSERT(L->is_unused());
1314 emit(0xE9); 1350 emit(0xE9);
1315 int32_t current = pc_offset(); 1351 int32_t current = pc_offset();
1316 emitl(current); 1352 emitl(current);
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after
3034 // specially coded on x64 means that it is a relative 32 bit address, as used 3070 // specially coded on x64 means that it is a relative 32 bit address, as used
3035 // by branch instructions. 3071 // by branch instructions.
3036 return (1 << rmode_) & kApplyMask; 3072 return (1 << rmode_) & kApplyMask;
3037 } 3073 }
3038 3074
3039 3075
3040 3076
3041 } } // namespace v8::internal 3077 } } // namespace v8::internal
3042 3078
3043 #endif // V8_TARGET_ARCH_X64 3079 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.h ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698