| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 // ----------------------------------------------------------------------------- | 342 // ----------------------------------------------------------------------------- |
| 343 // Implementation of Assembler. | 343 // Implementation of Assembler. |
| 344 | 344 |
| 345 #ifdef GENERATED_CODE_COVERAGE | 345 #ifdef GENERATED_CODE_COVERAGE |
| 346 static void InitCoverageLog(); | 346 static void InitCoverageLog(); |
| 347 #endif | 347 #endif |
| 348 | 348 |
| 349 Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size) | 349 Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size) |
| 350 : AssemblerBase(isolate, buffer, buffer_size), | 350 : AssemblerBase(isolate, buffer, buffer_size), |
| 351 code_targets_(100), | 351 code_targets_(100), |
| 352 deopt_entries_(100), |
| 352 positions_recorder_(this) { | 353 positions_recorder_(this) { |
| 353 // Clear the buffer in debug mode unless it was provided by the | 354 // Clear the buffer in debug mode unless it was provided by the |
| 354 // caller in which case we can't be sure it's okay to overwrite | 355 // caller in which case we can't be sure it's okay to overwrite |
| 355 // existing code in it. | 356 // existing code in it. |
| 356 #ifdef DEBUG | 357 #ifdef DEBUG |
| 357 if (own_buffer_) { | 358 if (own_buffer_) { |
| 358 memset(buffer_, 0xCC, buffer_size_); // int3 | 359 memset(buffer_, 0xCC, buffer_size_); // int3 |
| 359 } | 360 } |
| 360 #endif | 361 #endif |
| 361 | 362 |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 L->link_to(pc_offset() - sizeof(int32_t)); | 827 L->link_to(pc_offset() - sizeof(int32_t)); |
| 827 } else { | 828 } else { |
| 828 ASSERT(L->is_unused()); | 829 ASSERT(L->is_unused()); |
| 829 int32_t current = pc_offset(); | 830 int32_t current = pc_offset(); |
| 830 emitl(current); | 831 emitl(current); |
| 831 L->link_to(current); | 832 L->link_to(current); |
| 832 } | 833 } |
| 833 } | 834 } |
| 834 | 835 |
| 835 | 836 |
| 837 void Assembler::call(Address entry, RelocInfo::Mode rmode) { |
| 838 positions_recorder()->WriteRecordedPositions(); |
| 839 EnsureSpace ensure_space(this); |
| 840 ASSERT(RelocInfo::IsDeoptEntry(rmode)); |
| 841 // 1110 1000 #32-bit disp. |
| 842 emit(0xE8); |
| 843 emit_deopt_entry(entry, rmode); |
| 844 } |
| 845 |
| 846 |
| 836 void Assembler::call(Handle<Code> target, | 847 void Assembler::call(Handle<Code> target, |
| 837 RelocInfo::Mode rmode, | 848 RelocInfo::Mode rmode, |
| 838 TypeFeedbackId ast_id) { | 849 TypeFeedbackId ast_id) { |
| 839 positions_recorder()->WriteRecordedPositions(); | 850 positions_recorder()->WriteRecordedPositions(); |
| 840 EnsureSpace ensure_space(this); | 851 EnsureSpace ensure_space(this); |
| 841 // 1110 1000 #32-bit disp. | 852 // 1110 1000 #32-bit disp. |
| 842 emit(0xE8); | 853 emit(0xE8); |
| 843 emit_code_target(target, rmode, ast_id); | 854 emit_code_target(target, rmode, ast_id); |
| 844 } | 855 } |
| 845 | 856 |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1232 ASSERT(L->is_unused()); | 1243 ASSERT(L->is_unused()); |
| 1233 emit(0x0F); | 1244 emit(0x0F); |
| 1234 emit(0x80 | cc); | 1245 emit(0x80 | cc); |
| 1235 int32_t current = pc_offset(); | 1246 int32_t current = pc_offset(); |
| 1236 emitl(current); | 1247 emitl(current); |
| 1237 L->link_to(current); | 1248 L->link_to(current); |
| 1238 } | 1249 } |
| 1239 } | 1250 } |
| 1240 | 1251 |
| 1241 | 1252 |
| 1253 void Assembler::j(Condition cc, byte* entry, RelocInfo::Mode rmode) { |
| 1254 EnsureSpace ensure_space(this); |
| 1255 ASSERT(RelocInfo::IsDeoptEntry(rmode)); |
| 1256 ASSERT(is_uint4(cc)); |
| 1257 emit(0x0F); |
| 1258 emit(0x80 | cc); |
| 1259 emit_deopt_entry(entry, rmode); |
| 1260 } |
| 1261 |
| 1262 |
| 1242 void Assembler::j(Condition cc, | 1263 void Assembler::j(Condition cc, |
| 1243 Handle<Code> target, | 1264 Handle<Code> target, |
| 1244 RelocInfo::Mode rmode) { | 1265 RelocInfo::Mode rmode) { |
| 1245 EnsureSpace ensure_space(this); | 1266 EnsureSpace ensure_space(this); |
| 1246 ASSERT(is_uint4(cc)); | 1267 ASSERT(is_uint4(cc)); |
| 1247 // 0000 1111 1000 tttn #32-bit disp. | 1268 // 0000 1111 1000 tttn #32-bit disp. |
| 1248 emit(0x0F); | 1269 emit(0x0F); |
| 1249 emit(0x80 | cc); | 1270 emit(0x80 | cc); |
| 1250 emit_code_target(target, rmode); | 1271 emit_code_target(target, rmode); |
| 1251 } | 1272 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 // 1110 1001 #32-bit disp. | 1307 // 1110 1001 #32-bit disp. |
| 1287 ASSERT(L->is_unused()); | 1308 ASSERT(L->is_unused()); |
| 1288 emit(0xE9); | 1309 emit(0xE9); |
| 1289 int32_t current = pc_offset(); | 1310 int32_t current = pc_offset(); |
| 1290 emitl(current); | 1311 emitl(current); |
| 1291 L->link_to(current); | 1312 L->link_to(current); |
| 1292 } | 1313 } |
| 1293 } | 1314 } |
| 1294 | 1315 |
| 1295 | 1316 |
| 1317 void Assembler::jmp(byte* entry, RelocInfo::Mode rmode) { |
| 1318 EnsureSpace ensure_space(this); |
| 1319 ASSERT(RelocInfo::IsDeoptEntry(rmode)); |
| 1320 emit(0xE9); |
| 1321 emit_deopt_entry(entry, rmode); |
| 1322 } |
| 1323 |
| 1324 |
| 1296 void Assembler::jmp(Handle<Code> target, RelocInfo::Mode rmode) { | 1325 void Assembler::jmp(Handle<Code> target, RelocInfo::Mode rmode) { |
| 1297 EnsureSpace ensure_space(this); | 1326 EnsureSpace ensure_space(this); |
| 1298 // 1110 1001 #32-bit disp. | 1327 // 1110 1001 #32-bit disp. |
| 1299 emit(0xE9); | 1328 emit(0xE9); |
| 1300 emit_code_target(target, rmode); | 1329 emit_code_target(target, rmode); |
| 1301 } | 1330 } |
| 1302 | 1331 |
| 1303 | 1332 |
| 1304 void Assembler::jmp(Register target) { | 1333 void Assembler::jmp(Register target) { |
| 1305 EnsureSpace ensure_space(this); | 1334 EnsureSpace ensure_space(this); |
| (...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3017 | 3046 |
| 3018 void Assembler::RecordComment(const char* msg, bool force) { | 3047 void Assembler::RecordComment(const char* msg, bool force) { |
| 3019 if (FLAG_code_comments || force) { | 3048 if (FLAG_code_comments || force) { |
| 3020 EnsureSpace ensure_space(this); | 3049 EnsureSpace ensure_space(this); |
| 3021 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); | 3050 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); |
| 3022 } | 3051 } |
| 3023 } | 3052 } |
| 3024 | 3053 |
| 3025 | 3054 |
| 3026 const int RelocInfo::kApplyMask = RelocInfo::kCodeTargetMask | | 3055 const int RelocInfo::kApplyMask = RelocInfo::kCodeTargetMask | |
| 3056 1 << RelocInfo::DEOPT_ENTRY | |
| 3027 1 << RelocInfo::INTERNAL_REFERENCE | | 3057 1 << RelocInfo::INTERNAL_REFERENCE | |
| 3028 1 << RelocInfo::CODE_AGE_SEQUENCE; | 3058 1 << RelocInfo::CODE_AGE_SEQUENCE; |
| 3029 | 3059 |
| 3030 | 3060 |
| 3031 bool RelocInfo::IsCodedSpecially() { | 3061 bool RelocInfo::IsCodedSpecially() { |
| 3032 // The deserializer needs to know whether a pointer is specially coded. Being | 3062 // The deserializer needs to know whether a pointer is specially coded. Being |
| 3033 // specially coded on x64 means that it is a relative 32 bit address, as used | 3063 // specially coded on x64 means that it is a relative 32 bit address, as used |
| 3034 // by branch instructions. | 3064 // by branch instructions. |
| 3035 return (1 << rmode_) & kApplyMask; | 3065 return (1 << rmode_) & kApplyMask; |
| 3036 } | 3066 } |
| 3037 | 3067 |
| 3038 } } // namespace v8::internal | 3068 } } // namespace v8::internal |
| 3039 | 3069 |
| 3040 #endif // V8_TARGET_ARCH_X64 | 3070 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |