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

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

Issue 200095: Add near calls (32-bit displacement) to Code objects on X64 platform. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 2 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/assembler-x64-inl.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 257
258 // ----------------------------------------------------------------------------- 258 // -----------------------------------------------------------------------------
259 // Implementation of Assembler 259 // Implementation of Assembler
260 260
261 #ifdef GENERATED_CODE_COVERAGE 261 #ifdef GENERATED_CODE_COVERAGE
262 static void InitCoverageLog(); 262 static void InitCoverageLog();
263 #endif 263 #endif
264 264
265 byte* Assembler::spare_buffer_ = NULL; 265 byte* Assembler::spare_buffer_ = NULL;
266 266
267 Assembler::Assembler(void* buffer, int buffer_size) { 267 Assembler::Assembler(void* buffer, int buffer_size)
268 : code_targets_(100) {
268 if (buffer == NULL) { 269 if (buffer == NULL) {
269 // do our own buffer management 270 // do our own buffer management
270 if (buffer_size <= kMinimalBufferSize) { 271 if (buffer_size <= kMinimalBufferSize) {
271 buffer_size = kMinimalBufferSize; 272 buffer_size = kMinimalBufferSize;
272 273
273 if (spare_buffer_ != NULL) { 274 if (spare_buffer_ != NULL) {
274 buffer = spare_buffer_; 275 buffer = spare_buffer_;
275 spare_buffer_ = NULL; 276 spare_buffer_ = NULL;
276 } 277 }
277 } 278 }
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 L->link_to(pc_offset() - sizeof(int32_t)); 756 L->link_to(pc_offset() - sizeof(int32_t));
756 } else { 757 } else {
757 ASSERT(L->is_unused()); 758 ASSERT(L->is_unused());
758 int32_t current = pc_offset(); 759 int32_t current = pc_offset();
759 emitl(current); 760 emitl(current);
760 L->link_to(current); 761 L->link_to(current);
761 } 762 }
762 } 763 }
763 764
764 765
766 void Assembler::call(Handle<Code> target, RelocInfo::Mode rmode) {
767 EnsureSpace ensure_space(this);
768 last_pc_ = pc_;
769 // 1110 1000 #32-bit disp
770 emit(0xE8);
771 emit_code_target(target, rmode);
772 }
773
774
765 void Assembler::call(Register adr) { 775 void Assembler::call(Register adr) {
766 EnsureSpace ensure_space(this); 776 EnsureSpace ensure_space(this);
767 last_pc_ = pc_; 777 last_pc_ = pc_;
768 // Opcode: FF /2 r64 778 // Opcode: FF /2 r64
769 if (adr.high_bit()) { 779 if (adr.high_bit()) {
770 emit_rex_64(adr); 780 emit_rex_64(adr);
771 } 781 }
772 emit(0xFF); 782 emit(0xFF);
773 emit_modrm(0x2, adr); 783 emit_modrm(0x2, adr);
774 } 784 }
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 ASSERT(L->is_unused()); 1065 ASSERT(L->is_unused());
1056 emit(0x0F); 1066 emit(0x0F);
1057 emit(0x80 | cc); 1067 emit(0x80 | cc);
1058 int32_t current = pc_offset(); 1068 int32_t current = pc_offset();
1059 emitl(current); 1069 emitl(current);
1060 L->link_to(current); 1070 L->link_to(current);
1061 } 1071 }
1062 } 1072 }
1063 1073
1064 1074
1075 void Assembler::j(Condition cc,
1076 Handle<Code> target,
1077 RelocInfo::Mode rmode) {
1078 EnsureSpace ensure_space(this);
1079 last_pc_ = pc_;
1080 ASSERT(is_uint4(cc));
1081 // 0000 1111 1000 tttn #32-bit disp
1082 emit(0x0F);
1083 emit(0x80 | cc);
1084 emit_code_target(target, rmode);
1085 }
1086
1087
1065 void Assembler::jmp(Label* L) { 1088 void Assembler::jmp(Label* L) {
1066 EnsureSpace ensure_space(this); 1089 EnsureSpace ensure_space(this);
1067 last_pc_ = pc_; 1090 last_pc_ = pc_;
1068 if (L->is_bound()) { 1091 if (L->is_bound()) {
1069 int offs = L->pos() - pc_offset() - 1; 1092 int offs = L->pos() - pc_offset() - 1;
1070 ASSERT(offs <= 0); 1093 ASSERT(offs <= 0);
1071 if (is_int8(offs - sizeof(int8_t))) { 1094 if (is_int8(offs - sizeof(int8_t))) {
1072 // 1110 1011 #8-bit disp 1095 // 1110 1011 #8-bit disp
1073 emit(0xEB); 1096 emit(0xEB);
1074 emit((offs - sizeof(int8_t)) & 0xFF); 1097 emit((offs - sizeof(int8_t)) & 0xFF);
(...skipping 11 matching lines...) Expand all
1086 // 1110 1001 #32-bit disp 1109 // 1110 1001 #32-bit disp
1087 ASSERT(L->is_unused()); 1110 ASSERT(L->is_unused());
1088 emit(0xE9); 1111 emit(0xE9);
1089 int32_t current = pc_offset(); 1112 int32_t current = pc_offset();
1090 emitl(current); 1113 emitl(current);
1091 L->link_to(current); 1114 L->link_to(current);
1092 } 1115 }
1093 } 1116 }
1094 1117
1095 1118
1119 void Assembler::jmp(Handle<Code> target, RelocInfo::Mode rmode) {
1120 EnsureSpace ensure_space(this);
1121 last_pc_ = pc_;
1122 // 1110 1001 #32-bit disp
1123 emit(0xE9);
1124 emit_code_target(target, rmode);
1125 }
1126
1127
1096 void Assembler::jmp(Register target) { 1128 void Assembler::jmp(Register target) {
1097 EnsureSpace ensure_space(this); 1129 EnsureSpace ensure_space(this);
1098 last_pc_ = pc_; 1130 last_pc_ = pc_;
1099 // Opcode FF/4 r64 1131 // Opcode FF/4 r64
1100 if (target.high_bit()) { 1132 if (target.high_bit()) {
1101 emit_rex_64(target); 1133 emit_rex_64(target);
1102 } 1134 }
1103 emit(0xFF); 1135 emit(0xFF);
1104 emit_modrm(0x4, target); 1136 emit_modrm(0x4, target);
1105 } 1137 }
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
2380 // also different from the written statement position. 2412 // also different from the written statement position.
2381 if (current_position_ != written_position_ && 2413 if (current_position_ != written_position_ &&
2382 current_position_ != written_statement_position_) { 2414 current_position_ != written_statement_position_) {
2383 EnsureSpace ensure_space(this); 2415 EnsureSpace ensure_space(this);
2384 RecordRelocInfo(RelocInfo::POSITION, current_position_); 2416 RecordRelocInfo(RelocInfo::POSITION, current_position_);
2385 written_position_ = current_position_; 2417 written_position_ = current_position_;
2386 } 2418 }
2387 } 2419 }
2388 2420
2389 2421
2390 const int RelocInfo::kApplyMask = 1 << RelocInfo::INTERNAL_REFERENCE; 2422 const int RelocInfo::kApplyMask = RelocInfo::kCodeTargetMask |
2391 2423 1 << RelocInfo::INTERNAL_REFERENCE |
2424 1 << RelocInfo::JS_RETURN;
2392 2425
2393 } } // namespace v8::internal 2426 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.h ('k') | src/x64/assembler-x64-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698