| 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   349 // ----------------------------------------------------------------------------- |   349 // ----------------------------------------------------------------------------- | 
|   350 // Implementation of Assembler. |   350 // Implementation of Assembler. | 
|   351  |   351  | 
|   352 #ifdef GENERATED_CODE_COVERAGE |   352 #ifdef GENERATED_CODE_COVERAGE | 
|   353 static void InitCoverageLog(); |   353 static void InitCoverageLog(); | 
|   354 #endif |   354 #endif | 
|   355  |   355  | 
|   356 Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size) |   356 Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size) | 
|   357     : AssemblerBase(isolate, buffer, buffer_size), |   357     : AssemblerBase(isolate, buffer, buffer_size), | 
|   358       code_targets_(100), |   358       code_targets_(100), | 
 |   359       runtime_entries_(100), | 
|   359       positions_recorder_(this) { |   360       positions_recorder_(this) { | 
|   360   // Clear the buffer in debug mode unless it was provided by the |   361   // Clear the buffer in debug mode unless it was provided by the | 
|   361   // caller in which case we can't be sure it's okay to overwrite |   362   // caller in which case we can't be sure it's okay to overwrite | 
|   362   // existing code in it. |   363   // existing code in it. | 
|   363 #ifdef DEBUG |   364 #ifdef DEBUG | 
|   364   if (own_buffer_) { |   365   if (own_buffer_) { | 
|   365     memset(buffer_, 0xCC, buffer_size_);  // int3 |   366     memset(buffer_, 0xCC, buffer_size_);  // int3 | 
|   366   } |   367   } | 
|   367 #endif |   368 #endif | 
|   368  |   369  | 
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   833     L->link_to(pc_offset() - sizeof(int32_t)); |   834     L->link_to(pc_offset() - sizeof(int32_t)); | 
|   834   } else { |   835   } else { | 
|   835     ASSERT(L->is_unused()); |   836     ASSERT(L->is_unused()); | 
|   836     int32_t current = pc_offset(); |   837     int32_t current = pc_offset(); | 
|   837     emitl(current); |   838     emitl(current); | 
|   838     L->link_to(current); |   839     L->link_to(current); | 
|   839   } |   840   } | 
|   840 } |   841 } | 
|   841  |   842  | 
|   842  |   843  | 
 |   844 void Assembler::call(Address entry, RelocInfo::Mode rmode) { | 
 |   845   ASSERT(RelocInfo::IsRuntimeEntry(rmode)); | 
 |   846   positions_recorder()->WriteRecordedPositions(); | 
 |   847   EnsureSpace ensure_space(this); | 
 |   848   // 1110 1000 #32-bit disp. | 
 |   849   emit(0xE8); | 
 |   850   emit_runtime_entry(entry, rmode); | 
 |   851 } | 
 |   852  | 
 |   853  | 
|   843 void Assembler::call(Handle<Code> target, |   854 void Assembler::call(Handle<Code> target, | 
|   844                      RelocInfo::Mode rmode, |   855                      RelocInfo::Mode rmode, | 
|   845                      TypeFeedbackId ast_id) { |   856                      TypeFeedbackId ast_id) { | 
|   846   positions_recorder()->WriteRecordedPositions(); |   857   positions_recorder()->WriteRecordedPositions(); | 
|   847   EnsureSpace ensure_space(this); |   858   EnsureSpace ensure_space(this); | 
|   848   // 1110 1000 #32-bit disp. |   859   // 1110 1000 #32-bit disp. | 
|   849   emit(0xE8); |   860   emit(0xE8); | 
|   850   emit_code_target(target, rmode, ast_id); |   861   emit_code_target(target, rmode, ast_id); | 
|   851 } |   862 } | 
|   852  |   863  | 
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1239     ASSERT(L->is_unused()); |  1250     ASSERT(L->is_unused()); | 
|  1240     emit(0x0F); |  1251     emit(0x0F); | 
|  1241     emit(0x80 | cc); |  1252     emit(0x80 | cc); | 
|  1242     int32_t current = pc_offset(); |  1253     int32_t current = pc_offset(); | 
|  1243     emitl(current); |  1254     emitl(current); | 
|  1244     L->link_to(current); |  1255     L->link_to(current); | 
|  1245   } |  1256   } | 
|  1246 } |  1257 } | 
|  1247  |  1258  | 
|  1248  |  1259  | 
 |  1260 void Assembler::j(Condition cc, Address entry, RelocInfo::Mode rmode) { | 
 |  1261   ASSERT(RelocInfo::IsRuntimeEntry(rmode)); | 
 |  1262   EnsureSpace ensure_space(this); | 
 |  1263   ASSERT(is_uint4(cc)); | 
 |  1264   emit(0x0F); | 
 |  1265   emit(0x80 | cc); | 
 |  1266   emit_runtime_entry(entry, rmode); | 
 |  1267 } | 
 |  1268  | 
 |  1269  | 
|  1249 void Assembler::j(Condition cc, |  1270 void Assembler::j(Condition cc, | 
|  1250                   Handle<Code> target, |  1271                   Handle<Code> target, | 
|  1251                   RelocInfo::Mode rmode) { |  1272                   RelocInfo::Mode rmode) { | 
|  1252   EnsureSpace ensure_space(this); |  1273   EnsureSpace ensure_space(this); | 
|  1253   ASSERT(is_uint4(cc)); |  1274   ASSERT(is_uint4(cc)); | 
|  1254   // 0000 1111 1000 tttn #32-bit disp. |  1275   // 0000 1111 1000 tttn #32-bit disp. | 
|  1255   emit(0x0F); |  1276   emit(0x0F); | 
|  1256   emit(0x80 | cc); |  1277   emit(0x80 | cc); | 
|  1257   emit_code_target(target, rmode); |  1278   emit_code_target(target, rmode); | 
|  1258 } |  1279 } | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1301  |  1322  | 
|  1302  |  1323  | 
|  1303 void Assembler::jmp(Handle<Code> target, RelocInfo::Mode rmode) { |  1324 void Assembler::jmp(Handle<Code> target, RelocInfo::Mode rmode) { | 
|  1304   EnsureSpace ensure_space(this); |  1325   EnsureSpace ensure_space(this); | 
|  1305   // 1110 1001 #32-bit disp. |  1326   // 1110 1001 #32-bit disp. | 
|  1306   emit(0xE9); |  1327   emit(0xE9); | 
|  1307   emit_code_target(target, rmode); |  1328   emit_code_target(target, rmode); | 
|  1308 } |  1329 } | 
|  1309  |  1330  | 
|  1310  |  1331  | 
 |  1332 void Assembler::jmp(Address entry, RelocInfo::Mode rmode) { | 
 |  1333   ASSERT(RelocInfo::IsRuntimeEntry(rmode)); | 
 |  1334   EnsureSpace ensure_space(this); | 
 |  1335   ASSERT(RelocInfo::IsRuntimeEntry(rmode)); | 
 |  1336   emit(0xE9); | 
 |  1337   emit_runtime_entry(entry, rmode); | 
 |  1338 } | 
 |  1339  | 
 |  1340  | 
|  1311 void Assembler::jmp(Register target) { |  1341 void Assembler::jmp(Register target) { | 
|  1312   EnsureSpace ensure_space(this); |  1342   EnsureSpace ensure_space(this); | 
|  1313   // Opcode FF/4 r64. |  1343   // Opcode FF/4 r64. | 
|  1314   emit_optional_rex_32(target); |  1344   emit_optional_rex_32(target); | 
|  1315   emit(0xFF); |  1345   emit(0xFF); | 
|  1316   emit_modrm(0x4, target); |  1346   emit_modrm(0x4, target); | 
|  1317 } |  1347 } | 
|  1318  |  1348  | 
|  1319  |  1349  | 
|  1320 void Assembler::jmp(const Operand& src) { |  1350 void Assembler::jmp(const Operand& src) { | 
| (...skipping 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  3042  |  3072  | 
|  3043 void Assembler::RecordComment(const char* msg, bool force) { |  3073 void Assembler::RecordComment(const char* msg, bool force) { | 
|  3044   if (FLAG_code_comments || force) { |  3074   if (FLAG_code_comments || force) { | 
|  3045     EnsureSpace ensure_space(this); |  3075     EnsureSpace ensure_space(this); | 
|  3046     RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); |  3076     RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); | 
|  3047   } |  3077   } | 
|  3048 } |  3078 } | 
|  3049  |  3079  | 
|  3050  |  3080  | 
|  3051 const int RelocInfo::kApplyMask = RelocInfo::kCodeTargetMask | |  3081 const int RelocInfo::kApplyMask = RelocInfo::kCodeTargetMask | | 
 |  3082     1 << RelocInfo::RUNTIME_ENTRY | | 
|  3052     1 << RelocInfo::INTERNAL_REFERENCE | |  3083     1 << RelocInfo::INTERNAL_REFERENCE | | 
|  3053     1 << RelocInfo::CODE_AGE_SEQUENCE; |  3084     1 << RelocInfo::CODE_AGE_SEQUENCE; | 
|  3054  |  3085  | 
|  3055  |  3086  | 
|  3056 bool RelocInfo::IsCodedSpecially() { |  3087 bool RelocInfo::IsCodedSpecially() { | 
|  3057   // The deserializer needs to know whether a pointer is specially coded.  Being |  3088   // The deserializer needs to know whether a pointer is specially coded.  Being | 
|  3058   // specially coded on x64 means that it is a relative 32 bit address, as used |  3089   // specially coded on x64 means that it is a relative 32 bit address, as used | 
|  3059   // by branch instructions. |  3090   // by branch instructions. | 
|  3060   return (1 << rmode_) & kApplyMask; |  3091   return (1 << rmode_) & kApplyMask; | 
|  3061 } |  3092 } | 
|  3062  |  3093  | 
|  3063 } }  // namespace v8::internal |  3094 } }  // namespace v8::internal | 
|  3064  |  3095  | 
|  3065 #endif  // V8_TARGET_ARCH_X64 |  3096 #endif  // V8_TARGET_ARCH_X64 | 
| OLD | NEW |