| OLD | NEW |
| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } else if (is_int8(disp)) { | 248 } else if (is_int8(disp)) { |
| 249 set_modrm(1, rsp); | 249 set_modrm(1, rsp); |
| 250 set_disp8(disp); | 250 set_disp8(disp); |
| 251 } else { | 251 } else { |
| 252 set_modrm(2, rsp); | 252 set_modrm(2, rsp); |
| 253 set_disp32(disp); | 253 set_disp32(disp); |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 | 256 |
| 257 | 257 |
| 258 Operand::Operand(const Operand& base, int32_t displacement_delta) { |
| 259 rex_ = base.rex_; |
| 260 len_ = 1; |
| 261 byte modrm = base.buf_[0]; |
| 262 ASSERT_NE(0xC0, modrm & 0xC0); // Must be a memory operand. |
| 263 if ((modrm & 7) == rsp.code()) { |
| 264 // Has SIB byte |
| 265 buf_[1] = base.buf_[1]; |
| 266 len_ = 2; |
| 267 } |
| 268 int old_displacement; |
| 269 switch (modrm >> 6) { |
| 270 case 0: |
| 271 // No current displacement, unless base is rbp/r13. |
| 272 if ((modrm & 7) != rbp.code()) { |
| 273 old_displacement = 0; |
| 274 break; |
| 275 } |
| 276 // Fallthrough to 32-bit displacement. |
| 277 case 2: |
| 278 // Current 32-bit displacement. |
| 279 old_displacement = |
| 280 Memory::int32_at(const_cast<Address>(base.buf_ + len_)); |
| 281 break; |
| 282 case 1: |
| 283 // Current 8-bit displacement. |
| 284 old_displacement = static_cast<int8_t>(base.buf_[len_]); |
| 285 break; |
| 286 default: |
| 287 UNREACHABLE(); |
| 288 old_displacement = 0; // Seems to be used uninitialized otherwise. |
| 289 } |
| 290 int32_t displacement = old_displacement + displacement_delta; |
| 291 modrm = modrm & 0x3f; |
| 292 if (displacement == 0 && (modrm & 7) != rbp.code()) { |
| 293 // Zero mod part of ModR/M and no displacement. |
| 294 } else if (is_int8(displacement)) { |
| 295 modrm = modrm | 0x40; |
| 296 set_disp8(displacement); |
| 297 } else { |
| 298 modrm = modrm | 0x80u; |
| 299 set_disp32(displacement); |
| 300 } |
| 301 buf_[0] = modrm; |
| 302 } |
| 303 |
| 304 |
| 258 // ----------------------------------------------------------------------------- | 305 // ----------------------------------------------------------------------------- |
| 259 // Implementation of Assembler | 306 // Implementation of Assembler |
| 260 | 307 |
| 261 #ifdef GENERATED_CODE_COVERAGE | 308 #ifdef GENERATED_CODE_COVERAGE |
| 262 static void InitCoverageLog(); | 309 static void InitCoverageLog(); |
| 263 #endif | 310 #endif |
| 264 | 311 |
| 265 byte* Assembler::spare_buffer_ = NULL; | 312 byte* Assembler::spare_buffer_ = NULL; |
| 266 | 313 |
| 267 Assembler::Assembler(void* buffer, int buffer_size) | 314 Assembler::Assembler(void* buffer, int buffer_size) |
| (...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1963 | 2010 |
| 1964 void Assembler::fstp_d(const Operand& adr) { | 2011 void Assembler::fstp_d(const Operand& adr) { |
| 1965 EnsureSpace ensure_space(this); | 2012 EnsureSpace ensure_space(this); |
| 1966 last_pc_ = pc_; | 2013 last_pc_ = pc_; |
| 1967 emit_optional_rex_32(adr); | 2014 emit_optional_rex_32(adr); |
| 1968 emit(0xDD); | 2015 emit(0xDD); |
| 1969 emit_operand(3, adr); | 2016 emit_operand(3, adr); |
| 1970 } | 2017 } |
| 1971 | 2018 |
| 1972 | 2019 |
| 2020 void Assembler::fst_d(const Operand& adr) { |
| 2021 EnsureSpace ensure_space(this); |
| 2022 last_pc_ = pc_; |
| 2023 emit_optional_rex_32(adr); |
| 2024 emit(0xDD); |
| 2025 emit_operand(2, adr); |
| 2026 } |
| 2027 |
| 2028 |
| 2029 void Assembler::fstp(int stack_slot) { |
| 2030 ASSERT(is_uint3(stack_slot)); |
| 2031 EnsureSpace ensure_space(this); |
| 2032 last_pc_ = pc_; |
| 2033 emit(0xDD); |
| 2034 emit(0xD8 + stack_slot); |
| 2035 } |
| 2036 |
| 2037 void Assembler::fst(int stack_slot) { |
| 2038 ASSERT(is_uint3(stack_slot)); |
| 2039 EnsureSpace ensure_space(this); |
| 2040 last_pc_ = pc_; |
| 2041 emit(0xDD); |
| 2042 emit(0xD0 + stack_slot); |
| 2043 } |
| 2044 |
| 1973 void Assembler::fild_s(const Operand& adr) { | 2045 void Assembler::fild_s(const Operand& adr) { |
| 1974 EnsureSpace ensure_space(this); | 2046 EnsureSpace ensure_space(this); |
| 1975 last_pc_ = pc_; | 2047 last_pc_ = pc_; |
| 1976 emit_optional_rex_32(adr); | 2048 emit_optional_rex_32(adr); |
| 1977 emit(0xDB); | 2049 emit(0xDB); |
| 1978 emit_operand(0, adr); | 2050 emit_operand(0, adr); |
| 1979 } | 2051 } |
| 1980 | 2052 |
| 1981 | 2053 |
| 1982 void Assembler::fild_d(const Operand& adr) { | 2054 void Assembler::fild_d(const Operand& adr) { |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2168 | 2240 |
| 2169 | 2241 |
| 2170 void Assembler::ftst() { | 2242 void Assembler::ftst() { |
| 2171 EnsureSpace ensure_space(this); | 2243 EnsureSpace ensure_space(this); |
| 2172 last_pc_ = pc_; | 2244 last_pc_ = pc_; |
| 2173 emit(0xD9); | 2245 emit(0xD9); |
| 2174 emit(0xE4); | 2246 emit(0xE4); |
| 2175 } | 2247 } |
| 2176 | 2248 |
| 2177 | 2249 |
| 2250 void Assembler::fucom(int i) { |
| 2251 EnsureSpace ensure_space(this); |
| 2252 last_pc_ = pc_; |
| 2253 emit_farith(0xDD, 0xE0, i); |
| 2254 } |
| 2255 |
| 2256 |
| 2178 void Assembler::fucomp(int i) { | 2257 void Assembler::fucomp(int i) { |
| 2179 EnsureSpace ensure_space(this); | 2258 EnsureSpace ensure_space(this); |
| 2180 last_pc_ = pc_; | 2259 last_pc_ = pc_; |
| 2181 emit_farith(0xDD, 0xE8, i); | 2260 emit_farith(0xDD, 0xE8, i); |
| 2182 } | 2261 } |
| 2183 | 2262 |
| 2184 | 2263 |
| 2185 void Assembler::fucompp() { | 2264 void Assembler::fucompp() { |
| 2186 EnsureSpace ensure_space(this); | 2265 EnsureSpace ensure_space(this); |
| 2187 last_pc_ = pc_; | 2266 last_pc_ = pc_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2199 | 2278 |
| 2200 | 2279 |
| 2201 void Assembler::fnstsw_ax() { | 2280 void Assembler::fnstsw_ax() { |
| 2202 EnsureSpace ensure_space(this); | 2281 EnsureSpace ensure_space(this); |
| 2203 last_pc_ = pc_; | 2282 last_pc_ = pc_; |
| 2204 emit(0xDF); | 2283 emit(0xDF); |
| 2205 emit(0xE0); | 2284 emit(0xE0); |
| 2206 } | 2285 } |
| 2207 | 2286 |
| 2208 | 2287 |
| 2288 void Assembler::fxam() { |
| 2289 EnsureSpace ensure_space(this); |
| 2290 last_pc_ = pc_; |
| 2291 emit(0xD9); |
| 2292 emit(0xE5); |
| 2293 } |
| 2294 |
| 2209 void Assembler::fwait() { | 2295 void Assembler::fwait() { |
| 2210 EnsureSpace ensure_space(this); | 2296 EnsureSpace ensure_space(this); |
| 2211 last_pc_ = pc_; | 2297 last_pc_ = pc_; |
| 2212 emit(0x9B); | 2298 emit(0x9B); |
| 2213 } | 2299 } |
| 2214 | 2300 |
| 2215 | 2301 |
| 2216 void Assembler::frndint() { | 2302 void Assembler::frndint() { |
| 2217 EnsureSpace ensure_space(this); | 2303 EnsureSpace ensure_space(this); |
| 2218 last_pc_ = pc_; | 2304 last_pc_ = pc_; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2467 written_position_ = current_position_; | 2553 written_position_ = current_position_; |
| 2468 } | 2554 } |
| 2469 } | 2555 } |
| 2470 | 2556 |
| 2471 | 2557 |
| 2472 const int RelocInfo::kApplyMask = RelocInfo::kCodeTargetMask | | 2558 const int RelocInfo::kApplyMask = RelocInfo::kCodeTargetMask | |
| 2473 1 << RelocInfo::INTERNAL_REFERENCE | | 2559 1 << RelocInfo::INTERNAL_REFERENCE | |
| 2474 1 << RelocInfo::JS_RETURN; | 2560 1 << RelocInfo::JS_RETURN; |
| 2475 | 2561 |
| 2476 } } // namespace v8::internal | 2562 } } // namespace v8::internal |
| OLD | NEW |