OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/intrinsifier.h" | 8 #include "vm/intrinsifier.h" |
9 | 9 |
10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 | 1230 |
1231 | 1231 |
1232 // Check if the last argument is a double, jump to label 'is_smi' if smi | 1232 // Check if the last argument is a double, jump to label 'is_smi' if smi |
1233 // (easy to convert to double), otherwise jump to label 'not_double_smi', | 1233 // (easy to convert to double), otherwise jump to label 'not_double_smi', |
1234 // Returns the last argument in RAX. | 1234 // Returns the last argument in RAX. |
1235 static void TestLastArgumentIsDouble(Assembler* assembler, | 1235 static void TestLastArgumentIsDouble(Assembler* assembler, |
1236 Label* is_smi, | 1236 Label* is_smi, |
1237 Label* not_double_smi) { | 1237 Label* not_double_smi) { |
1238 __ movq(RAX, Address(RSP, + 1 * kWordSize)); | 1238 __ movq(RAX, Address(RSP, + 1 * kWordSize)); |
1239 __ testq(RAX, Immediate(kSmiTagMask)); | 1239 __ testq(RAX, Immediate(kSmiTagMask)); |
1240 __ j(ZERO, is_smi, Assembler::kFarJump); // Jump if Smi. | 1240 __ j(ZERO, is_smi); // Jump if Smi. |
1241 __ CompareClassId(RAX, kDoubleCid); | 1241 __ CompareClassId(RAX, kDoubleCid); |
1242 __ j(NOT_EQUAL, not_double_smi, Assembler::kFarJump); | 1242 __ j(NOT_EQUAL, not_double_smi); |
1243 // Fall through if double. | 1243 // Fall through if double. |
1244 } | 1244 } |
1245 | 1245 |
1246 | 1246 |
1247 // Both arguments on stack, left argument is a double, right argument is of | 1247 // Both arguments on stack, left argument is a double, right argument is of |
1248 // unknown type. Return true or false object in RAX. Any NaN argument | 1248 // unknown type. Return true or false object in RAX. Any NaN argument |
1249 // returns false. Any non-double argument causes control flow to fall through | 1249 // returns false. Any non-double argument causes control flow to fall through |
1250 // to the slow case (compiled method body). | 1250 // to the slow case (compiled method body). |
1251 static void CompareDoubles(Assembler* assembler, Condition true_condition) { | 1251 static void CompareDoubles(Assembler* assembler, Condition true_condition) { |
1252 Label fall_through, is_false, is_true, is_smi, double_op; | 1252 Label fall_through, is_false, is_true, is_smi, double_op; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 void Intrinsifier::Double_div(Assembler* assembler) { | 1346 void Intrinsifier::Double_div(Assembler* assembler) { |
1347 DoubleArithmeticOperations(assembler, Token::kDIV); | 1347 DoubleArithmeticOperations(assembler, Token::kDIV); |
1348 } | 1348 } |
1349 | 1349 |
1350 | 1350 |
1351 void Intrinsifier::Double_mulFromInteger(Assembler* assembler) { | 1351 void Intrinsifier::Double_mulFromInteger(Assembler* assembler) { |
1352 Label fall_through; | 1352 Label fall_through; |
1353 // Only smis allowed. | 1353 // Only smis allowed. |
1354 __ movq(RAX, Address(RSP, + 1 * kWordSize)); | 1354 __ movq(RAX, Address(RSP, + 1 * kWordSize)); |
1355 __ testq(RAX, Immediate(kSmiTagMask)); | 1355 __ testq(RAX, Immediate(kSmiTagMask)); |
1356 __ j(NOT_ZERO, &fall_through, Assembler::kFarJump); | 1356 __ j(NOT_ZERO, &fall_through); |
1357 // Is Smi. | 1357 // Is Smi. |
1358 __ SmiUntag(RAX); | 1358 __ SmiUntag(RAX); |
1359 __ cvtsi2sdq(XMM1, RAX); | 1359 __ cvtsi2sdq(XMM1, RAX); |
1360 __ movq(RAX, Address(RSP, + 2 * kWordSize)); | 1360 __ movq(RAX, Address(RSP, + 2 * kWordSize)); |
1361 __ movsd(XMM0, FieldAddress(RAX, Double::value_offset())); | 1361 __ movsd(XMM0, FieldAddress(RAX, Double::value_offset())); |
1362 __ mulsd(XMM0, XMM1); | 1362 __ mulsd(XMM0, XMM1); |
1363 const Class& double_class = Class::Handle( | 1363 const Class& double_class = Class::Handle( |
1364 Isolate::Current()->object_store()->double_class()); | 1364 Isolate::Current()->object_store()->double_class()); |
1365 __ TryAllocate(double_class, | 1365 __ TryAllocate(double_class, |
1366 &fall_through, | 1366 &fall_through, |
1367 Assembler::kFarJump, | 1367 Assembler::kFarJump, |
1368 RAX, // Result register. | 1368 RAX, // Result register. |
1369 kNoRegister); // Pool pointer might not be loaded. | 1369 kNoRegister); // Pool pointer might not be loaded. |
1370 __ movsd(FieldAddress(RAX, Double::value_offset()), XMM0); | 1370 __ movsd(FieldAddress(RAX, Double::value_offset()), XMM0); |
1371 __ ret(); | 1371 __ ret(); |
1372 __ Bind(&fall_through); | 1372 __ Bind(&fall_through); |
1373 } | 1373 } |
1374 | 1374 |
1375 | 1375 |
1376 // Left is double right is integer (Bigint, Mint or Smi) | 1376 // Left is double right is integer (Bigint, Mint or Smi) |
1377 void Intrinsifier::DoubleFromInteger(Assembler* assembler) { | 1377 void Intrinsifier::DoubleFromInteger(Assembler* assembler) { |
1378 Label fall_through; | 1378 Label fall_through; |
1379 __ movq(RAX, Address(RSP, +1 * kWordSize)); | 1379 __ movq(RAX, Address(RSP, +1 * kWordSize)); |
1380 __ testq(RAX, Immediate(kSmiTagMask)); | 1380 __ testq(RAX, Immediate(kSmiTagMask)); |
1381 __ j(NOT_ZERO, &fall_through, Assembler::kFarJump); | 1381 __ j(NOT_ZERO, &fall_through); |
1382 // Is Smi. | 1382 // Is Smi. |
1383 __ SmiUntag(RAX); | 1383 __ SmiUntag(RAX); |
1384 __ cvtsi2sdq(XMM0, RAX); | 1384 __ cvtsi2sdq(XMM0, RAX); |
1385 const Class& double_class = Class::Handle( | 1385 const Class& double_class = Class::Handle( |
1386 Isolate::Current()->object_store()->double_class()); | 1386 Isolate::Current()->object_store()->double_class()); |
1387 __ TryAllocate(double_class, | 1387 __ TryAllocate(double_class, |
1388 &fall_through, | 1388 &fall_through, |
1389 Assembler::kFarJump, | 1389 Assembler::kFarJump, |
1390 RAX, // Result register. | 1390 RAX, // Result register. |
1391 kNoRegister); // Pool pointer might not be loaded. | 1391 kNoRegister); // Pool pointer might not be loaded. |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 // Set return value to Isolate::current_tag_. | 2015 // Set return value to Isolate::current_tag_. |
2016 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); | 2016 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); |
2017 __ ret(); | 2017 __ ret(); |
2018 } | 2018 } |
2019 | 2019 |
2020 #undef __ | 2020 #undef __ |
2021 | 2021 |
2022 } // namespace dart | 2022 } // namespace dart |
2023 | 2023 |
2024 #endif // defined TARGET_ARCH_X64 | 2024 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |