| OLD | NEW |
| 1 // Copyright 2010 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 183 } |
| 184 | 184 |
| 185 // Indicate that code has changed. | 185 // Indicate that code has changed. |
| 186 CPU::FlushICache(pc_, instruction_count); | 186 CPU::FlushICache(pc_, instruction_count); |
| 187 } | 187 } |
| 188 | 188 |
| 189 | 189 |
| 190 // ----------------------------------------------------------------------------- | 190 // ----------------------------------------------------------------------------- |
| 191 // Register constants. | 191 // Register constants. |
| 192 | 192 |
| 193 const int Register::registerCodeByAllocationIndex[kNumAllocatableRegisters] = { | 193 const int Register::kRegisterCodeByAllocationIndex[kNumAllocatableRegisters] = { |
| 194 // rax, rbx, rdx, rcx, rdi, r8, r9, r11, r14, r12 | 194 // rax, rbx, rdx, rcx, rdi, r8, r9, r11, r14, r15 |
| 195 0, 3, 2, 1, 7, 8, 9, 11, 14, 12 | 195 0, 3, 2, 1, 7, 8, 9, 11, 14, 15 |
| 196 }; | 196 }; |
| 197 | 197 |
| 198 const int Register::allocationIndexByRegisterCode[kNumRegisters] = { | 198 const int Register::kAllocationIndexByRegisterCode[kNumRegisters] = { |
| 199 0, 3, 2, 1, -1, -1, -1, 4, 5, 6, -1, 7, 9, -1, 8, -1 | 199 0, 3, 2, 1, -1, -1, -1, 4, 5, 6, -1, 7, -1, -1, 8, 9 |
| 200 }; | 200 }; |
| 201 | 201 |
| 202 | 202 |
| 203 // ----------------------------------------------------------------------------- | 203 // ----------------------------------------------------------------------------- |
| 204 // Implementation of Operand | 204 // Implementation of Operand |
| 205 | 205 |
| 206 Operand::Operand(Register base, int32_t disp) : rex_(0) { | 206 Operand::Operand(Register base, int32_t disp) : rex_(0) { |
| 207 len_ = 1; | 207 len_ = 1; |
| 208 if (base.is(rsp) || base.is(r12)) { | 208 if (base.is(rsp) || base.is(r12)) { |
| 209 // SIB byte is needed to encode (rsp + offset) or (r12 + offset). | 209 // SIB byte is needed to encode (rsp + offset) or (r12 + offset). |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 // ----------------------------------------------------------------------------- | 331 // ----------------------------------------------------------------------------- |
| 332 // Implementation of Assembler. | 332 // Implementation of Assembler. |
| 333 | 333 |
| 334 #ifdef GENERATED_CODE_COVERAGE | 334 #ifdef GENERATED_CODE_COVERAGE |
| 335 static void InitCoverageLog(); | 335 static void InitCoverageLog(); |
| 336 #endif | 336 #endif |
| 337 | 337 |
| 338 byte* Assembler::spare_buffer_ = NULL; | 338 byte* Assembler::spare_buffer_ = NULL; |
| 339 | 339 |
| 340 Assembler::Assembler(void* buffer, int buffer_size) | 340 Assembler::Assembler(void* buffer, int buffer_size) |
| 341 : code_targets_(100), positions_recorder_(this) { | 341 : code_targets_(100), |
| 342 positions_recorder_(this), |
| 343 emit_debug_code_(FLAG_debug_code) { |
| 342 if (buffer == NULL) { | 344 if (buffer == NULL) { |
| 343 // Do our own buffer management. | 345 // Do our own buffer management. |
| 344 if (buffer_size <= kMinimalBufferSize) { | 346 if (buffer_size <= kMinimalBufferSize) { |
| 345 buffer_size = kMinimalBufferSize; | 347 buffer_size = kMinimalBufferSize; |
| 346 | 348 |
| 347 if (spare_buffer_ != NULL) { | 349 if (spare_buffer_ != NULL) { |
| 348 buffer = spare_buffer_; | 350 buffer = spare_buffer_; |
| 349 spare_buffer_ = NULL; | 351 spare_buffer_ = NULL; |
| 350 } | 352 } |
| 351 } | 353 } |
| (...skipping 2636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2988 EnsureSpace ensure_space(this); | 2990 EnsureSpace ensure_space(this); |
| 2989 last_pc_ = pc_; | 2991 last_pc_ = pc_; |
| 2990 emit(0xF2); | 2992 emit(0xF2); |
| 2991 emit_optional_rex_32(dst, src); | 2993 emit_optional_rex_32(dst, src); |
| 2992 emit(0x0F); | 2994 emit(0x0F); |
| 2993 emit(0x5E); | 2995 emit(0x5E); |
| 2994 emit_sse_operand(dst, src); | 2996 emit_sse_operand(dst, src); |
| 2995 } | 2997 } |
| 2996 | 2998 |
| 2997 | 2999 |
| 3000 void Assembler::andpd(XMMRegister dst, XMMRegister src) { |
| 3001 EnsureSpace ensure_space(this); |
| 3002 last_pc_ = pc_; |
| 3003 emit(0x66); |
| 3004 emit_optional_rex_32(dst, src); |
| 3005 emit(0x0F); |
| 3006 emit(0x54); |
| 3007 emit_sse_operand(dst, src); |
| 3008 } |
| 3009 |
| 3010 |
| 3011 void Assembler::orpd(XMMRegister dst, XMMRegister src) { |
| 3012 EnsureSpace ensure_space(this); |
| 3013 last_pc_ = pc_; |
| 3014 emit(0x66); |
| 3015 emit_optional_rex_32(dst, src); |
| 3016 emit(0x0F); |
| 3017 emit(0x56); |
| 3018 emit_sse_operand(dst, src); |
| 3019 } |
| 3020 |
| 3021 |
| 2998 void Assembler::xorpd(XMMRegister dst, XMMRegister src) { | 3022 void Assembler::xorpd(XMMRegister dst, XMMRegister src) { |
| 2999 EnsureSpace ensure_space(this); | 3023 EnsureSpace ensure_space(this); |
| 3000 last_pc_ = pc_; | 3024 last_pc_ = pc_; |
| 3001 emit(0x66); | 3025 emit(0x66); |
| 3002 emit_optional_rex_32(dst, src); | 3026 emit_optional_rex_32(dst, src); |
| 3003 emit(0x0F); | 3027 emit(0x0F); |
| 3004 emit(0x57); | 3028 emit(0x57); |
| 3005 emit_sse_operand(dst, src); | 3029 emit_sse_operand(dst, src); |
| 3006 } | 3030 } |
| 3007 | 3031 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3085 | 3109 |
| 3086 void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { | 3110 void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { |
| 3087 ASSERT(rmode != RelocInfo::NONE); | 3111 ASSERT(rmode != RelocInfo::NONE); |
| 3088 // Don't record external references unless the heap will be serialized. | 3112 // Don't record external references unless the heap will be serialized. |
| 3089 if (rmode == RelocInfo::EXTERNAL_REFERENCE) { | 3113 if (rmode == RelocInfo::EXTERNAL_REFERENCE) { |
| 3090 #ifdef DEBUG | 3114 #ifdef DEBUG |
| 3091 if (!Serializer::enabled()) { | 3115 if (!Serializer::enabled()) { |
| 3092 Serializer::TooLateToEnableNow(); | 3116 Serializer::TooLateToEnableNow(); |
| 3093 } | 3117 } |
| 3094 #endif | 3118 #endif |
| 3095 if (!Serializer::enabled() && !FLAG_debug_code) { | 3119 if (!Serializer::enabled() && !emit_debug_code()) { |
| 3096 return; | 3120 return; |
| 3097 } | 3121 } |
| 3098 } | 3122 } |
| 3099 RelocInfo rinfo(pc_, rmode, data); | 3123 RelocInfo rinfo(pc_, rmode, data); |
| 3100 reloc_info_writer.Write(&rinfo); | 3124 reloc_info_writer.Write(&rinfo); |
| 3101 } | 3125 } |
| 3102 | 3126 |
| 3103 void Assembler::RecordJSReturn() { | 3127 void Assembler::RecordJSReturn() { |
| 3104 positions_recorder()->WriteRecordedPositions(); | 3128 positions_recorder()->WriteRecordedPositions(); |
| 3105 EnsureSpace ensure_space(this); | 3129 EnsureSpace ensure_space(this); |
| 3106 RecordRelocInfo(RelocInfo::JS_RETURN); | 3130 RecordRelocInfo(RelocInfo::JS_RETURN); |
| 3107 } | 3131 } |
| 3108 | 3132 |
| 3109 | 3133 |
| 3110 void Assembler::RecordDebugBreakSlot() { | 3134 void Assembler::RecordDebugBreakSlot() { |
| 3111 positions_recorder()->WriteRecordedPositions(); | 3135 positions_recorder()->WriteRecordedPositions(); |
| 3112 EnsureSpace ensure_space(this); | 3136 EnsureSpace ensure_space(this); |
| 3113 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT); | 3137 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT); |
| 3114 } | 3138 } |
| 3115 | 3139 |
| 3116 | 3140 |
| 3117 void Assembler::RecordComment(const char* msg) { | 3141 void Assembler::RecordComment(const char* msg, bool force) { |
| 3118 if (FLAG_code_comments) { | 3142 if (FLAG_code_comments || force) { |
| 3119 EnsureSpace ensure_space(this); | 3143 EnsureSpace ensure_space(this); |
| 3120 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); | 3144 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); |
| 3121 } | 3145 } |
| 3122 } | 3146 } |
| 3123 | 3147 |
| 3124 | 3148 |
| 3125 const int RelocInfo::kApplyMask = RelocInfo::kCodeTargetMask | | 3149 const int RelocInfo::kApplyMask = RelocInfo::kCodeTargetMask | |
| 3126 1 << RelocInfo::INTERNAL_REFERENCE; | 3150 1 << RelocInfo::INTERNAL_REFERENCE; |
| 3127 | 3151 |
| 3128 | 3152 |
| 3129 bool RelocInfo::IsCodedSpecially() { | 3153 bool RelocInfo::IsCodedSpecially() { |
| 3130 // The deserializer needs to know whether a pointer is specially coded. Being | 3154 // The deserializer needs to know whether a pointer is specially coded. Being |
| 3131 // specially coded on x64 means that it is a relative 32 bit address, as used | 3155 // specially coded on x64 means that it is a relative 32 bit address, as used |
| 3132 // by branch instructions. | 3156 // by branch instructions. |
| 3133 return (1 << rmode_) & kApplyMask; | 3157 return (1 << rmode_) & kApplyMask; |
| 3134 } | 3158 } |
| 3135 | 3159 |
| 3136 | 3160 |
| 3137 | 3161 |
| 3138 } } // namespace v8::internal | 3162 } } // namespace v8::internal |
| 3139 | 3163 |
| 3140 #endif // V8_TARGET_ARCH_X64 | 3164 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |