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 __ fldz(); |
ahaas
2016/08/11 06:39:00
I think you could also just push the default NaN i
| |
204 __ push(Immediate(0x7fffffff)); | 204 __ fldz(); |
205 __ fld_d(MemOperand(esp, 0)); | 205 __ fdiv(1); |
206 __ lea(esp, Operand(esp, kDoubleSize)); | 206 __ fstp(0); |
207 __ lea(esp, Operand(esp, -kFloatSize)); | |
208 __ fstp_s(MemOperand(esp, 0)); | |
209 __ fld_s(MemOperand(esp, 0)); | |
210 __ lea(esp, Operand(esp, kFloatSize)); | |
207 } | 211 } |
208 | 212 |
209 private: | 213 private: |
210 X87Register const result_; | 214 X87Register const result_; |
211 }; | 215 }; |
212 | 216 |
217 class OutOfLineLoadFloat64NaN final : public OutOfLineCode { | |
218 public: | |
219 OutOfLineLoadFloat64NaN(CodeGenerator* gen, X87Register result) | |
220 : OutOfLineCode(gen), result_(result) {} | |
221 | |
222 void Generate() final { | |
223 DCHECK(result_.code() == 0); | |
224 USE(result_); | |
225 __ fstp(0); | |
226 __ fldz(); | |
227 __ fldz(); | |
228 __ fdiv(1); | |
229 __ fstp(0); | |
230 } | |
231 | |
232 private: | |
233 X87Register const result_; | |
234 }; | |
213 | 235 |
214 class OutOfLineTruncateDoubleToI final : public OutOfLineCode { | 236 class OutOfLineTruncateDoubleToI final : public OutOfLineCode { |
215 public: | 237 public: |
216 OutOfLineTruncateDoubleToI(CodeGenerator* gen, Register result, | 238 OutOfLineTruncateDoubleToI(CodeGenerator* gen, Register result, |
217 X87Register input) | 239 X87Register input) |
218 : OutOfLineCode(gen), result_(result), input_(input) {} | 240 : OutOfLineCode(gen), result_(result), input_(input) {} |
219 | 241 |
220 void Generate() final { | 242 void Generate() final { |
221 UNIMPLEMENTED(); | 243 UNIMPLEMENTED(); |
222 USE(result_); | 244 USE(result_); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 Register const object_; | 286 Register const object_; |
265 Operand const operand_; | 287 Operand const operand_; |
266 Register const value_; | 288 Register const value_; |
267 Register const scratch0_; | 289 Register const scratch0_; |
268 Register const scratch1_; | 290 Register const scratch1_; |
269 RecordWriteMode const mode_; | 291 RecordWriteMode const mode_; |
270 }; | 292 }; |
271 | 293 |
272 } // namespace | 294 } // namespace |
273 | 295 |
274 #define ASSEMBLE_CHECKED_LOAD_FLOAT(asm_instr) \ | 296 #define ASSEMBLE_CHECKED_LOAD_FLOAT(asm_instr, OutOfLineLoadNaN) \ |
275 do { \ | 297 do { \ |
276 auto result = i.OutputDoubleRegister(); \ | 298 auto result = i.OutputDoubleRegister(); \ |
277 auto offset = i.InputRegister(0); \ | 299 auto offset = i.InputRegister(0); \ |
278 DCHECK(result.code() == 0); \ | 300 DCHECK(result.code() == 0); \ |
279 if (instr->InputAt(1)->IsRegister()) { \ | 301 if (instr->InputAt(1)->IsRegister()) { \ |
280 __ cmp(offset, i.InputRegister(1)); \ | 302 __ cmp(offset, i.InputRegister(1)); \ |
281 } else { \ | 303 } else { \ |
282 __ cmp(offset, i.InputImmediate(1)); \ | 304 __ cmp(offset, i.InputImmediate(1)); \ |
283 } \ | 305 } \ |
284 OutOfLineCode* ool = new (zone()) OutOfLineLoadNaN(this, result); \ | 306 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) { | 1310 if (FLAG_debug_code && FLAG_enable_slow_asserts) { |
1289 __ VerifyX87StackDepth(1); | 1311 __ VerifyX87StackDepth(1); |
1290 } | 1312 } |
1291 __ fstp(0); | 1313 __ fstp(0); |
1292 __ fld_d(MemOperand(esp, kDoubleSize)); | 1314 __ fld_d(MemOperand(esp, kDoubleSize)); |
1293 __ fld_d(MemOperand(esp, 0)); | 1315 __ fld_d(MemOperand(esp, 0)); |
1294 __ fld(1); | 1316 __ fld(1); |
1295 __ fld(1); | 1317 __ fld(1); |
1296 __ FCmp(); | 1318 __ FCmp(); |
1297 | 1319 |
1298 auto ool = new (zone()) OutOfLineLoadNaN(this, i.OutputDoubleRegister()); | 1320 auto ool = |
1321 new (zone()) OutOfLineLoadFloat64NaN(this, i.OutputDoubleRegister()); | |
1299 __ j(parity_even, ool->entry()); | 1322 __ j(parity_even, ool->entry()); |
1300 __ j(below, &done_compare, Label::kNear); | 1323 __ j(below, &done_compare, Label::kNear); |
1301 __ j(above, &compare_swap, Label::kNear); | 1324 __ j(above, &compare_swap, Label::kNear); |
1302 __ push(eax); | 1325 __ push(eax); |
1303 __ lea(esp, Operand(esp, -kDoubleSize)); | 1326 __ lea(esp, Operand(esp, -kDoubleSize)); |
1304 __ fld(1); | 1327 __ fld(1); |
1305 __ fstp_d(Operand(esp, 0)); | 1328 __ fstp_d(Operand(esp, 0)); |
1306 __ mov(eax, MemOperand(esp, 4)); | 1329 __ mov(eax, MemOperand(esp, 4)); |
1307 __ and_(eax, Immediate(0x80000000)); | 1330 __ and_(eax, Immediate(0x80000000)); |
1308 __ lea(esp, Operand(esp, kDoubleSize)); | 1331 __ lea(esp, Operand(esp, kDoubleSize)); |
(...skipping 14 matching lines...) Expand all Loading... | |
1323 if (FLAG_debug_code && FLAG_enable_slow_asserts) { | 1346 if (FLAG_debug_code && FLAG_enable_slow_asserts) { |
1324 __ VerifyX87StackDepth(1); | 1347 __ VerifyX87StackDepth(1); |
1325 } | 1348 } |
1326 __ fstp(0); | 1349 __ fstp(0); |
1327 __ fld_d(MemOperand(esp, kDoubleSize)); | 1350 __ fld_d(MemOperand(esp, kDoubleSize)); |
1328 __ fld_d(MemOperand(esp, 0)); | 1351 __ fld_d(MemOperand(esp, 0)); |
1329 __ fld(1); | 1352 __ fld(1); |
1330 __ fld(1); | 1353 __ fld(1); |
1331 __ FCmp(); | 1354 __ FCmp(); |
1332 | 1355 |
1333 auto ool = new (zone()) OutOfLineLoadNaN(this, i.OutputDoubleRegister()); | 1356 auto ool = |
1357 new (zone()) OutOfLineLoadFloat64NaN(this, i.OutputDoubleRegister()); | |
1334 __ j(parity_even, ool->entry()); | 1358 __ j(parity_even, ool->entry()); |
1335 __ j(above, &done_compare, Label::kNear); | 1359 __ j(above, &done_compare, Label::kNear); |
1336 __ j(below, &compare_swap, Label::kNear); | 1360 __ j(below, &compare_swap, Label::kNear); |
1337 __ push(eax); | 1361 __ push(eax); |
1338 __ lea(esp, Operand(esp, -kDoubleSize)); | 1362 __ lea(esp, Operand(esp, -kDoubleSize)); |
1339 __ fld(0); | 1363 __ fld(0); |
1340 __ fstp_d(Operand(esp, 0)); | 1364 __ fstp_d(Operand(esp, 0)); |
1341 __ mov(eax, MemOperand(esp, 4)); | 1365 __ mov(eax, MemOperand(esp, 4)); |
1342 __ and_(eax, Immediate(0x80000000)); | 1366 __ and_(eax, Immediate(0x80000000)); |
1343 __ lea(esp, Operand(esp, kDoubleSize)); | 1367 __ lea(esp, Operand(esp, kDoubleSize)); |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1891 case kCheckedLoadInt16: | 1915 case kCheckedLoadInt16: |
1892 ASSEMBLE_CHECKED_LOAD_INTEGER(movsx_w); | 1916 ASSEMBLE_CHECKED_LOAD_INTEGER(movsx_w); |
1893 break; | 1917 break; |
1894 case kCheckedLoadUint16: | 1918 case kCheckedLoadUint16: |
1895 ASSEMBLE_CHECKED_LOAD_INTEGER(movzx_w); | 1919 ASSEMBLE_CHECKED_LOAD_INTEGER(movzx_w); |
1896 break; | 1920 break; |
1897 case kCheckedLoadWord32: | 1921 case kCheckedLoadWord32: |
1898 ASSEMBLE_CHECKED_LOAD_INTEGER(mov); | 1922 ASSEMBLE_CHECKED_LOAD_INTEGER(mov); |
1899 break; | 1923 break; |
1900 case kCheckedLoadFloat32: | 1924 case kCheckedLoadFloat32: |
1901 ASSEMBLE_CHECKED_LOAD_FLOAT(fld_s); | 1925 ASSEMBLE_CHECKED_LOAD_FLOAT(fld_s, OutOfLineLoadFloat32NaN); |
1902 break; | 1926 break; |
1903 case kCheckedLoadFloat64: | 1927 case kCheckedLoadFloat64: |
1904 ASSEMBLE_CHECKED_LOAD_FLOAT(fld_d); | 1928 ASSEMBLE_CHECKED_LOAD_FLOAT(fld_d, OutOfLineLoadFloat64NaN); |
1905 break; | 1929 break; |
1906 case kCheckedStoreWord8: | 1930 case kCheckedStoreWord8: |
1907 ASSEMBLE_CHECKED_STORE_INTEGER(mov_b); | 1931 ASSEMBLE_CHECKED_STORE_INTEGER(mov_b); |
1908 break; | 1932 break; |
1909 case kCheckedStoreWord16: | 1933 case kCheckedStoreWord16: |
1910 ASSEMBLE_CHECKED_STORE_INTEGER(mov_w); | 1934 ASSEMBLE_CHECKED_STORE_INTEGER(mov_w); |
1911 break; | 1935 break; |
1912 case kCheckedStoreWord32: | 1936 case kCheckedStoreWord32: |
1913 ASSEMBLE_CHECKED_STORE_INTEGER(mov); | 1937 ASSEMBLE_CHECKED_STORE_INTEGER(mov); |
1914 break; | 1938 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; | 2660 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
2637 __ Nop(padding_size); | 2661 __ Nop(padding_size); |
2638 } | 2662 } |
2639 } | 2663 } |
2640 | 2664 |
2641 #undef __ | 2665 #undef __ |
2642 | 2666 |
2643 } // namespace compiler | 2667 } // namespace compiler |
2644 } // namespace internal | 2668 } // namespace internal |
2645 } // namespace v8 | 2669 } // namespace v8 |
OLD | NEW |