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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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* arg_isolate, void* buffer, int buffer_size) | 349 Assembler::Assembler(Isolate* arg_isolate, void* buffer, int buffer_size) |
350 : AssemblerBase(arg_isolate), | 350 : AssemblerBase(arg_isolate), |
351 code_targets_(100), | 351 code_targets_(100), |
352 positions_recorder_(this), | 352 positions_recorder_(this), |
353 emit_debug_code_(FLAG_debug_code) { | 353 emit_debug_code_(FLAG_debug_code), |
354 predictable_code_size_(false) { | |
354 if (buffer == NULL) { | 355 if (buffer == NULL) { |
355 // Do our own buffer management. | 356 // Do our own buffer management. |
356 if (buffer_size <= kMinimalBufferSize) { | 357 if (buffer_size <= kMinimalBufferSize) { |
357 buffer_size = kMinimalBufferSize; | 358 buffer_size = kMinimalBufferSize; |
358 | 359 |
359 if (isolate() != NULL && isolate()->assembler_spare_buffer() != NULL) { | 360 if (isolate() != NULL && isolate()->assembler_spare_buffer() != NULL) { |
360 buffer = isolate()->assembler_spare_buffer(); | 361 buffer = isolate()->assembler_spare_buffer(); |
361 isolate()->set_assembler_spare_buffer(NULL); | 362 isolate()->set_assembler_spare_buffer(NULL); |
362 } | 363 } |
363 } | 364 } |
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1227 } else if (cc == never) { | 1228 } else if (cc == never) { |
1228 return; | 1229 return; |
1229 } | 1230 } |
1230 EnsureSpace ensure_space(this); | 1231 EnsureSpace ensure_space(this); |
1231 ASSERT(is_uint4(cc)); | 1232 ASSERT(is_uint4(cc)); |
1232 if (L->is_bound()) { | 1233 if (L->is_bound()) { |
1233 const int short_size = 2; | 1234 const int short_size = 2; |
1234 const int long_size = 6; | 1235 const int long_size = 6; |
1235 int offs = L->pos() - pc_offset(); | 1236 int offs = L->pos() - pc_offset(); |
1236 ASSERT(offs <= 0); | 1237 ASSERT(offs <= 0); |
1237 if (is_int8(offs - short_size)) { | 1238 if (is_int8(offs - short_size) && !predictable_code_size_) { |
Jakob Kummerow
2012/07/31 14:44:58
A comment would be nice about why we have to disab
| |
1238 // 0111 tttn #8-bit disp. | 1239 // 0111 tttn #8-bit disp. |
1239 emit(0x70 | cc); | 1240 emit(0x70 | cc); |
1240 emit((offs - short_size) & 0xFF); | 1241 emit((offs - short_size) & 0xFF); |
1241 } else { | 1242 } else { |
1242 // 0000 1111 1000 tttn #32-bit disp. | 1243 // 0000 1111 1000 tttn #32-bit disp. |
1243 emit(0x0F); | 1244 emit(0x0F); |
1244 emit(0x80 | cc); | 1245 emit(0x80 | cc); |
1245 emitl(offs - long_size); | 1246 emitl(offs - long_size); |
1246 } | 1247 } |
1247 } else if (distance == Label::kNear) { | 1248 } else if (distance == Label::kNear) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1284 } | 1285 } |
1285 | 1286 |
1286 | 1287 |
1287 void Assembler::jmp(Label* L, Label::Distance distance) { | 1288 void Assembler::jmp(Label* L, Label::Distance distance) { |
1288 EnsureSpace ensure_space(this); | 1289 EnsureSpace ensure_space(this); |
1289 const int short_size = sizeof(int8_t); | 1290 const int short_size = sizeof(int8_t); |
1290 const int long_size = sizeof(int32_t); | 1291 const int long_size = sizeof(int32_t); |
1291 if (L->is_bound()) { | 1292 if (L->is_bound()) { |
1292 int offs = L->pos() - pc_offset() - 1; | 1293 int offs = L->pos() - pc_offset() - 1; |
1293 ASSERT(offs <= 0); | 1294 ASSERT(offs <= 0); |
1294 if (is_int8(offs - short_size)) { | 1295 if (is_int8(offs - short_size) && !predictable_code_size_) { |
1295 // 1110 1011 #8-bit disp. | 1296 // 1110 1011 #8-bit disp. |
1296 emit(0xEB); | 1297 emit(0xEB); |
1297 emit((offs - short_size) & 0xFF); | 1298 emit((offs - short_size) & 0xFF); |
1298 } else { | 1299 } else { |
1299 // 1110 1001 #32-bit disp. | 1300 // 1110 1001 #32-bit disp. |
1300 emit(0xE9); | 1301 emit(0xE9); |
1301 emitl(offs - long_size); | 1302 emitl(offs - long_size); |
1302 } | 1303 } |
1303 } else if (distance == Label::kNear) { | 1304 } else if (distance == Label::kNear) { |
1304 emit(0xEB); | 1305 emit(0xEB); |
(...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3043 bool RelocInfo::IsCodedSpecially() { | 3044 bool RelocInfo::IsCodedSpecially() { |
3044 // The deserializer needs to know whether a pointer is specially coded. Being | 3045 // The deserializer needs to know whether a pointer is specially coded. Being |
3045 // specially coded on x64 means that it is a relative 32 bit address, as used | 3046 // specially coded on x64 means that it is a relative 32 bit address, as used |
3046 // by branch instructions. | 3047 // by branch instructions. |
3047 return (1 << rmode_) & kApplyMask; | 3048 return (1 << rmode_) & kApplyMask; |
3048 } | 3049 } |
3049 | 3050 |
3050 } } // namespace v8::internal | 3051 } } // namespace v8::internal |
3051 | 3052 |
3052 #endif // V8_TARGET_ARCH_X64 | 3053 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |