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 // The intrinsic code below is executed before a method has built its frame. | 5 // The intrinsic code below is executed before a method has built its frame. |
6 // The return address is on the stack and the arguments below it. | 6 // The return address is on the stack and the arguments below it. |
7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. | 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. |
8 // Each intrinsification method returns true if the corresponding | 8 // Each intrinsification method returns true if the corresponding |
9 // Dart method was intrinsified. | 9 // Dart method was intrinsified. |
10 | 10 |
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 __ movsd(FieldAddress(EAX, Double::value_offset()), XMM0); | 1319 __ movsd(FieldAddress(EAX, Double::value_offset()), XMM0); |
1320 __ ret(); | 1320 __ ret(); |
1321 __ Bind(&is_smi); | 1321 __ Bind(&is_smi); |
1322 __ SmiUntag(EAX); | 1322 __ SmiUntag(EAX); |
1323 __ cvtsi2sd(XMM1, EAX); | 1323 __ cvtsi2sd(XMM1, EAX); |
1324 __ jmp(&double_op); | 1324 __ jmp(&double_op); |
1325 __ Bind(&fall_through); | 1325 __ Bind(&fall_through); |
1326 } | 1326 } |
1327 | 1327 |
1328 | 1328 |
1329 enum TrigonometricFunctions { | |
1330 kSine, | |
1331 kCosine, | |
1332 }; | |
1333 | |
1334 | |
1335 static void EmitTrigonometric(Assembler* assembler, | |
1336 TrigonometricFunctions kind) { | |
1337 Label fall_through, is_smi, double_op; | |
1338 TestLastArgumentIsDouble(assembler, &is_smi, &fall_through); | |
1339 // Argument is double and is in EAX. | |
1340 __ fldl(FieldAddress(EAX, Double::value_offset())); | |
1341 __ Bind(&double_op); | |
1342 switch (kind) { | |
1343 case kSine: __ fsin(); break; | |
1344 case kCosine: __ fcos(); break; | |
1345 default: | |
1346 UNREACHABLE(); | |
1347 } | |
1348 const Class& double_class = Class::Handle( | |
1349 Isolate::Current()->object_store()->double_class()); | |
1350 Label alloc_failed; | |
1351 __ TryAllocate(double_class, | |
1352 &alloc_failed, | |
1353 Assembler::kNearJump, | |
1354 EAX); // Result register. | |
1355 __ fstpl(FieldAddress(EAX, Double::value_offset())); | |
1356 __ ret(); | |
1357 | |
1358 __ Bind(&is_smi); // smi -> double. | |
1359 __ SmiUntag(EAX); | |
1360 __ pushl(EAX); | |
1361 __ filds(Address(ESP, 0)); | |
1362 __ popl(EAX); | |
1363 __ jmp(&double_op); | |
1364 | |
1365 __ Bind(&alloc_failed); | |
1366 __ ffree(0); | |
1367 __ fincstp(); | |
1368 | |
1369 __ Bind(&fall_through); | |
1370 } | |
1371 | |
1372 | |
1373 void Intrinsifier::Math_sin(Assembler* assembler) { | |
1374 EmitTrigonometric(assembler, kSine); | |
1375 } | |
1376 | |
1377 | |
1378 void Intrinsifier::Math_cos(Assembler* assembler) { | |
1379 EmitTrigonometric(assembler, kCosine); | |
1380 } | |
1381 | |
1382 | |
1383 // var state = ((_A * (_state[kSTATE_LO])) + _state[kSTATE_HI]) & _MASK_64; | 1329 // var state = ((_A * (_state[kSTATE_LO])) + _state[kSTATE_HI]) & _MASK_64; |
1384 // _state[kSTATE_LO] = state & _MASK_32; | 1330 // _state[kSTATE_LO] = state & _MASK_32; |
1385 // _state[kSTATE_HI] = state >> 32; | 1331 // _state[kSTATE_HI] = state >> 32; |
1386 void Intrinsifier::Random_nextState(Assembler* assembler) { | 1332 void Intrinsifier::Random_nextState(Assembler* assembler) { |
1387 const Library& math_lib = Library::Handle(Library::MathLibrary()); | 1333 const Library& math_lib = Library::Handle(Library::MathLibrary()); |
1388 ASSERT(!math_lib.IsNull()); | 1334 ASSERT(!math_lib.IsNull()); |
1389 const Class& random_class = Class::Handle( | 1335 const Class& random_class = Class::Handle( |
1390 math_lib.LookupClassAllowPrivate(Symbols::_Random())); | 1336 math_lib.LookupClassAllowPrivate(Symbols::_Random())); |
1391 ASSERT(!random_class.IsNull()); | 1337 ASSERT(!random_class.IsNull()); |
1392 const Field& state_field = Field::ZoneHandle( | 1338 const Field& state_field = Field::ZoneHandle( |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1783 | 1729 |
1784 | 1730 |
1785 void Intrinsifier::TwoByteString_equality(Assembler* assembler) { | 1731 void Intrinsifier::TwoByteString_equality(Assembler* assembler) { |
1786 StringEquality(assembler, kTwoByteStringCid); | 1732 StringEquality(assembler, kTwoByteStringCid); |
1787 } | 1733 } |
1788 | 1734 |
1789 #undef __ | 1735 #undef __ |
1790 } // namespace dart | 1736 } // namespace dart |
1791 | 1737 |
1792 #endif // defined TARGET_ARCH_IA32 | 1738 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |