| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
| 9 #include "src/compiler/gap-resolver.h" | 9 #include "src/compiler/gap-resolver.h" |
| 10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 public: | 184 public: |
| 185 OutOfLineLoadInteger(CodeGenerator* gen, Register result) | 185 OutOfLineLoadInteger(CodeGenerator* gen, Register result) |
| 186 : OutOfLineCode(gen), result_(result) {} | 186 : OutOfLineCode(gen), result_(result) {} |
| 187 | 187 |
| 188 void Generate() final { __ xor_(result_, result_); } | 188 void Generate() final { __ xor_(result_, result_); } |
| 189 | 189 |
| 190 private: | 190 private: |
| 191 Register const result_; | 191 Register const result_; |
| 192 }; | 192 }; |
| 193 | 193 |
| 194 class OutOfLineLoadNaN final : public OutOfLineCode { | 194 class OutOfLineLoadFloat32NaN final : public OutOfLineCode { |
| 195 public: | 195 public: |
| 196 OutOfLineLoadNaN(CodeGenerator* gen, X87Register result) | 196 OutOfLineLoadFloat32NaN(CodeGenerator* gen, X87Register result) |
| 197 : OutOfLineCode(gen), result_(result) {} | 197 : OutOfLineCode(gen), result_(result) {} |
| 198 | 198 |
| 199 void Generate() final { | 199 void Generate() final { |
| 200 DCHECK(result_.code() == 0); | 200 DCHECK(result_.code() == 0); |
| 201 USE(result_); | 201 USE(result_); |
| 202 __ fstp(0); | 202 __ fstp(0); |
| 203 __ push(Immediate(0xffffffff)); | 203 __ push(Immediate(0xffc00000)); |
| 204 __ push(Immediate(0x7fffffff)); | 204 __ fld_s(MemOperand(esp, 0)); |
| 205 __ lea(esp, Operand(esp, kFloatSize)); |
| 206 } |
| 207 |
| 208 private: |
| 209 X87Register const result_; |
| 210 }; |
| 211 |
| 212 class OutOfLineLoadFloat64NaN final : public OutOfLineCode { |
| 213 public: |
| 214 OutOfLineLoadFloat64NaN(CodeGenerator* gen, X87Register result) |
| 215 : OutOfLineCode(gen), result_(result) {} |
| 216 |
| 217 void Generate() final { |
| 218 DCHECK(result_.code() == 0); |
| 219 USE(result_); |
| 220 __ fstp(0); |
| 221 __ push(Immediate(0xfff80000)); |
| 222 __ push(Immediate(0x00000000)); |
| 205 __ fld_d(MemOperand(esp, 0)); | 223 __ fld_d(MemOperand(esp, 0)); |
| 206 __ lea(esp, Operand(esp, kDoubleSize)); | 224 __ lea(esp, Operand(esp, kDoubleSize)); |
| 207 } | 225 } |
| 208 | 226 |
| 209 private: | 227 private: |
| 210 X87Register const result_; | 228 X87Register const result_; |
| 211 }; | 229 }; |
| 212 | 230 |
| 213 | |
| 214 class OutOfLineTruncateDoubleToI final : public OutOfLineCode { | 231 class OutOfLineTruncateDoubleToI final : public OutOfLineCode { |
| 215 public: | 232 public: |
| 216 OutOfLineTruncateDoubleToI(CodeGenerator* gen, Register result, | 233 OutOfLineTruncateDoubleToI(CodeGenerator* gen, Register result, |
| 217 X87Register input) | 234 X87Register input) |
| 218 : OutOfLineCode(gen), result_(result), input_(input) {} | 235 : OutOfLineCode(gen), result_(result), input_(input) {} |
| 219 | 236 |
| 220 void Generate() final { | 237 void Generate() final { |
| 221 UNIMPLEMENTED(); | 238 UNIMPLEMENTED(); |
| 222 USE(result_); | 239 USE(result_); |
| 223 USE(input_); | 240 USE(input_); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 Register const object_; | 281 Register const object_; |
| 265 Operand const operand_; | 282 Operand const operand_; |
| 266 Register const value_; | 283 Register const value_; |
| 267 Register const scratch0_; | 284 Register const scratch0_; |
| 268 Register const scratch1_; | 285 Register const scratch1_; |
| 269 RecordWriteMode const mode_; | 286 RecordWriteMode const mode_; |
| 270 }; | 287 }; |
| 271 | 288 |
| 272 } // namespace | 289 } // namespace |
| 273 | 290 |
| 274 #define ASSEMBLE_CHECKED_LOAD_FLOAT(asm_instr) \ | 291 #define ASSEMBLE_CHECKED_LOAD_FLOAT(asm_instr, OutOfLineLoadNaN) \ |
| 275 do { \ | 292 do { \ |
| 276 auto result = i.OutputDoubleRegister(); \ | 293 auto result = i.OutputDoubleRegister(); \ |
| 277 auto offset = i.InputRegister(0); \ | 294 auto offset = i.InputRegister(0); \ |
| 278 DCHECK(result.code() == 0); \ | 295 DCHECK(result.code() == 0); \ |
| 279 if (instr->InputAt(1)->IsRegister()) { \ | 296 if (instr->InputAt(1)->IsRegister()) { \ |
| 280 __ cmp(offset, i.InputRegister(1)); \ | 297 __ cmp(offset, i.InputRegister(1)); \ |
| 281 } else { \ | 298 } else { \ |
| 282 __ cmp(offset, i.InputImmediate(1)); \ | 299 __ cmp(offset, i.InputImmediate(1)); \ |
| 283 } \ | 300 } \ |
| 284 OutOfLineCode* ool = new (zone()) OutOfLineLoadNaN(this, result); \ | 301 OutOfLineCode* ool = new (zone()) OutOfLineLoadNaN(this, result); \ |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1288 if (FLAG_debug_code && FLAG_enable_slow_asserts) { | 1305 if (FLAG_debug_code && FLAG_enable_slow_asserts) { |
| 1289 __ VerifyX87StackDepth(1); | 1306 __ VerifyX87StackDepth(1); |
| 1290 } | 1307 } |
| 1291 __ fstp(0); | 1308 __ fstp(0); |
| 1292 __ fld_d(MemOperand(esp, kDoubleSize)); | 1309 __ fld_d(MemOperand(esp, kDoubleSize)); |
| 1293 __ fld_d(MemOperand(esp, 0)); | 1310 __ fld_d(MemOperand(esp, 0)); |
| 1294 __ fld(1); | 1311 __ fld(1); |
| 1295 __ fld(1); | 1312 __ fld(1); |
| 1296 __ FCmp(); | 1313 __ FCmp(); |
| 1297 | 1314 |
| 1298 auto ool = new (zone()) OutOfLineLoadNaN(this, i.OutputDoubleRegister()); | 1315 auto ool = |
| 1316 new (zone()) OutOfLineLoadFloat64NaN(this, i.OutputDoubleRegister()); |
| 1299 __ j(parity_even, ool->entry()); | 1317 __ j(parity_even, ool->entry()); |
| 1300 __ j(below, &done_compare, Label::kNear); | 1318 __ j(below, &done_compare, Label::kNear); |
| 1301 __ j(above, &compare_swap, Label::kNear); | 1319 __ j(above, &compare_swap, Label::kNear); |
| 1302 __ push(eax); | 1320 __ push(eax); |
| 1303 __ lea(esp, Operand(esp, -kDoubleSize)); | 1321 __ lea(esp, Operand(esp, -kDoubleSize)); |
| 1304 __ fld(1); | 1322 __ fld(1); |
| 1305 __ fstp_d(Operand(esp, 0)); | 1323 __ fstp_d(Operand(esp, 0)); |
| 1306 __ mov(eax, MemOperand(esp, 4)); | 1324 __ mov(eax, MemOperand(esp, 4)); |
| 1307 __ and_(eax, Immediate(0x80000000)); | 1325 __ and_(eax, Immediate(0x80000000)); |
| 1308 __ lea(esp, Operand(esp, kDoubleSize)); | 1326 __ lea(esp, Operand(esp, kDoubleSize)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1323 if (FLAG_debug_code && FLAG_enable_slow_asserts) { | 1341 if (FLAG_debug_code && FLAG_enable_slow_asserts) { |
| 1324 __ VerifyX87StackDepth(1); | 1342 __ VerifyX87StackDepth(1); |
| 1325 } | 1343 } |
| 1326 __ fstp(0); | 1344 __ fstp(0); |
| 1327 __ fld_d(MemOperand(esp, kDoubleSize)); | 1345 __ fld_d(MemOperand(esp, kDoubleSize)); |
| 1328 __ fld_d(MemOperand(esp, 0)); | 1346 __ fld_d(MemOperand(esp, 0)); |
| 1329 __ fld(1); | 1347 __ fld(1); |
| 1330 __ fld(1); | 1348 __ fld(1); |
| 1331 __ FCmp(); | 1349 __ FCmp(); |
| 1332 | 1350 |
| 1333 auto ool = new (zone()) OutOfLineLoadNaN(this, i.OutputDoubleRegister()); | 1351 auto ool = |
| 1352 new (zone()) OutOfLineLoadFloat64NaN(this, i.OutputDoubleRegister()); |
| 1334 __ j(parity_even, ool->entry()); | 1353 __ j(parity_even, ool->entry()); |
| 1335 __ j(above, &done_compare, Label::kNear); | 1354 __ j(above, &done_compare, Label::kNear); |
| 1336 __ j(below, &compare_swap, Label::kNear); | 1355 __ j(below, &compare_swap, Label::kNear); |
| 1337 __ push(eax); | 1356 __ push(eax); |
| 1338 __ lea(esp, Operand(esp, -kDoubleSize)); | 1357 __ lea(esp, Operand(esp, -kDoubleSize)); |
| 1339 __ fld(0); | 1358 __ fld(0); |
| 1340 __ fstp_d(Operand(esp, 0)); | 1359 __ fstp_d(Operand(esp, 0)); |
| 1341 __ mov(eax, MemOperand(esp, 4)); | 1360 __ mov(eax, MemOperand(esp, 4)); |
| 1342 __ and_(eax, Immediate(0x80000000)); | 1361 __ and_(eax, Immediate(0x80000000)); |
| 1343 __ lea(esp, Operand(esp, kDoubleSize)); | 1362 __ lea(esp, Operand(esp, kDoubleSize)); |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1891 case kCheckedLoadInt16: | 1910 case kCheckedLoadInt16: |
| 1892 ASSEMBLE_CHECKED_LOAD_INTEGER(movsx_w); | 1911 ASSEMBLE_CHECKED_LOAD_INTEGER(movsx_w); |
| 1893 break; | 1912 break; |
| 1894 case kCheckedLoadUint16: | 1913 case kCheckedLoadUint16: |
| 1895 ASSEMBLE_CHECKED_LOAD_INTEGER(movzx_w); | 1914 ASSEMBLE_CHECKED_LOAD_INTEGER(movzx_w); |
| 1896 break; | 1915 break; |
| 1897 case kCheckedLoadWord32: | 1916 case kCheckedLoadWord32: |
| 1898 ASSEMBLE_CHECKED_LOAD_INTEGER(mov); | 1917 ASSEMBLE_CHECKED_LOAD_INTEGER(mov); |
| 1899 break; | 1918 break; |
| 1900 case kCheckedLoadFloat32: | 1919 case kCheckedLoadFloat32: |
| 1901 ASSEMBLE_CHECKED_LOAD_FLOAT(fld_s); | 1920 ASSEMBLE_CHECKED_LOAD_FLOAT(fld_s, OutOfLineLoadFloat32NaN); |
| 1902 break; | 1921 break; |
| 1903 case kCheckedLoadFloat64: | 1922 case kCheckedLoadFloat64: |
| 1904 ASSEMBLE_CHECKED_LOAD_FLOAT(fld_d); | 1923 ASSEMBLE_CHECKED_LOAD_FLOAT(fld_d, OutOfLineLoadFloat64NaN); |
| 1905 break; | 1924 break; |
| 1906 case kCheckedStoreWord8: | 1925 case kCheckedStoreWord8: |
| 1907 ASSEMBLE_CHECKED_STORE_INTEGER(mov_b); | 1926 ASSEMBLE_CHECKED_STORE_INTEGER(mov_b); |
| 1908 break; | 1927 break; |
| 1909 case kCheckedStoreWord16: | 1928 case kCheckedStoreWord16: |
| 1910 ASSEMBLE_CHECKED_STORE_INTEGER(mov_w); | 1929 ASSEMBLE_CHECKED_STORE_INTEGER(mov_w); |
| 1911 break; | 1930 break; |
| 1912 case kCheckedStoreWord32: | 1931 case kCheckedStoreWord32: |
| 1913 ASSEMBLE_CHECKED_STORE_INTEGER(mov); | 1932 ASSEMBLE_CHECKED_STORE_INTEGER(mov); |
| 1914 break; | 1933 break; |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2636 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2655 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
| 2637 __ Nop(padding_size); | 2656 __ Nop(padding_size); |
| 2638 } | 2657 } |
| 2639 } | 2658 } |
| 2640 | 2659 |
| 2641 #undef __ | 2660 #undef __ |
| 2642 | 2661 |
| 2643 } // namespace compiler | 2662 } // namespace compiler |
| 2644 } // namespace internal | 2663 } // namespace internal |
| 2645 } // namespace v8 | 2664 } // namespace v8 |
| OLD | NEW |