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

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

Issue 6991010: Remove NearLabel, replacing remaining occurrences with Label (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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/code-stubs-x64.h » ('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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 } 474 }
475 L->bind_to(pos); 475 L->bind_to(pos);
476 } 476 }
477 477
478 478
479 void Assembler::bind(Label* L) { 479 void Assembler::bind(Label* L) {
480 bind_to(L, pc_offset()); 480 bind_to(L, pc_offset());
481 } 481 }
482 482
483 483
484 void Assembler::bind(NearLabel* L) {
485 ASSERT(!L->is_bound());
486 while (L->unresolved_branches_ > 0) {
487 int branch_pos = L->unresolved_positions_[L->unresolved_branches_ - 1];
488 int disp = pc_offset() - branch_pos;
489 ASSERT(is_int8(disp));
490 set_byte_at(branch_pos - sizeof(int8_t), disp);
491 L->unresolved_branches_--;
492 }
493 L->bind_to(pc_offset());
494 }
495
496
497 void Assembler::GrowBuffer() { 484 void Assembler::GrowBuffer() {
498 ASSERT(buffer_overflow()); 485 ASSERT(buffer_overflow());
499 if (!own_buffer_) FATAL("external code buffer is too small"); 486 if (!own_buffer_) FATAL("external code buffer is too small");
500 487
501 // Compute new buffer size. 488 // Compute new buffer size.
502 CodeDesc desc; // the new buffer 489 CodeDesc desc; // the new buffer
503 if (buffer_size_ < 4*KB) { 490 if (buffer_size_ < 4*KB) {
504 desc.buffer_size = 4*KB; 491 desc.buffer_size = 4*KB;
505 } else { 492 } else {
506 desc.buffer_size = 2*buffer_size_; 493 desc.buffer_size = 2*buffer_size_;
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 RelocInfo::Mode rmode) { 1273 RelocInfo::Mode rmode) {
1287 EnsureSpace ensure_space(this); 1274 EnsureSpace ensure_space(this);
1288 ASSERT(is_uint4(cc)); 1275 ASSERT(is_uint4(cc));
1289 // 0000 1111 1000 tttn #32-bit disp. 1276 // 0000 1111 1000 tttn #32-bit disp.
1290 emit(0x0F); 1277 emit(0x0F);
1291 emit(0x80 | cc); 1278 emit(0x80 | cc);
1292 emit_code_target(target, rmode); 1279 emit_code_target(target, rmode);
1293 } 1280 }
1294 1281
1295 1282
1296 void Assembler::j(Condition cc, NearLabel* L, Hint hint) {
1297 EnsureSpace ensure_space(this);
1298 ASSERT(0 <= cc && cc < 16);
1299 if (FLAG_emit_branch_hints && hint != no_hint) emit(hint);
1300 if (L->is_bound()) {
1301 const int short_size = 2;
1302 int offs = L->pos() - pc_offset();
1303 ASSERT(offs <= 0);
1304 ASSERT(is_int8(offs - short_size));
1305 // 0111 tttn #8-bit disp
1306 emit(0x70 | cc);
1307 emit((offs - short_size) & 0xFF);
1308 } else {
1309 emit(0x70 | cc);
1310 emit(0x00); // The displacement will be resolved later.
1311 L->link_to(pc_offset());
1312 }
1313 }
1314
1315
1316 void Assembler::jmp(Label* L, Label::Distance distance) { 1283 void Assembler::jmp(Label* L, Label::Distance distance) {
1317 EnsureSpace ensure_space(this); 1284 EnsureSpace ensure_space(this);
1318 const int short_size = sizeof(int8_t); 1285 const int short_size = sizeof(int8_t);
1319 const int long_size = sizeof(int32_t); 1286 const int long_size = sizeof(int32_t);
1320 if (L->is_bound()) { 1287 if (L->is_bound()) {
1321 int offs = L->pos() - pc_offset() - 1; 1288 int offs = L->pos() - pc_offset() - 1;
1322 ASSERT(offs <= 0); 1289 ASSERT(offs <= 0);
1323 if (is_int8(offs - short_size)) { 1290 if (is_int8(offs - short_size)) {
1324 // 1110 1011 #8-bit disp. 1291 // 1110 1011 #8-bit disp.
1325 emit(0xEB); 1292 emit(0xEB);
(...skipping 30 matching lines...) Expand all
1356 1323
1357 1324
1358 void Assembler::jmp(Handle<Code> target, RelocInfo::Mode rmode) { 1325 void Assembler::jmp(Handle<Code> target, RelocInfo::Mode rmode) {
1359 EnsureSpace ensure_space(this); 1326 EnsureSpace ensure_space(this);
1360 // 1110 1001 #32-bit disp. 1327 // 1110 1001 #32-bit disp.
1361 emit(0xE9); 1328 emit(0xE9);
1362 emit_code_target(target, rmode); 1329 emit_code_target(target, rmode);
1363 } 1330 }
1364 1331
1365 1332
1366 void Assembler::jmp(NearLabel* L) {
1367 EnsureSpace ensure_space(this);
1368 if (L->is_bound()) {
1369 const int short_size = sizeof(int8_t);
1370 int offs = L->pos() - pc_offset();
1371 ASSERT(offs <= 0);
1372 ASSERT(is_int8(offs - short_size));
1373 // 1110 1011 #8-bit disp.
1374 emit(0xEB);
1375 emit((offs - short_size) & 0xFF);
1376 } else {
1377 emit(0xEB);
1378 emit(0x00); // The displacement will be resolved later.
1379 L->link_to(pc_offset());
1380 }
1381 }
1382
1383
1384 void Assembler::jmp(Register target) { 1333 void Assembler::jmp(Register target) {
1385 EnsureSpace ensure_space(this); 1334 EnsureSpace ensure_space(this);
1386 // Opcode FF/4 r64. 1335 // Opcode FF/4 r64.
1387 emit_optional_rex_32(target); 1336 emit_optional_rex_32(target);
1388 emit(0xFF); 1337 emit(0xFF);
1389 emit_modrm(0x4, target); 1338 emit_modrm(0x4, target);
1390 } 1339 }
1391 1340
1392 1341
1393 void Assembler::jmp(const Operand& src) { 1342 void Assembler::jmp(const Operand& src) {
(...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after
3070 // specially coded on x64 means that it is a relative 32 bit address, as used 3019 // specially coded on x64 means that it is a relative 32 bit address, as used
3071 // by branch instructions. 3020 // by branch instructions.
3072 return (1 << rmode_) & kApplyMask; 3021 return (1 << rmode_) & kApplyMask;
3073 } 3022 }
3074 3023
3075 3024
3076 3025
3077 } } // namespace v8::internal 3026 } } // namespace v8::internal
3078 3027
3079 #endif // V8_TARGET_ARCH_X64 3028 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.h ('k') | src/x64/code-stubs-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698