| 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" |
| 11 #include "vm/flow_graph_compiler.h" |
| 11 #include "vm/instructions.h" | 12 #include "vm/instructions.h" |
| 12 #include "vm/object_store.h" | 13 #include "vm/object_store.h" |
| 13 #include "vm/symbols.h" | 14 #include "vm/symbols.h" |
| 14 | 15 |
| 15 namespace dart { | 16 namespace dart { |
| 16 | 17 |
| 17 DECLARE_FLAG(bool, enable_type_checks); | 18 DECLARE_FLAG(bool, enable_type_checks); |
| 18 | 19 |
| 19 // When entering intrinsics code: | 20 // When entering intrinsics code: |
| 20 // RBX: IC Data | 21 // RBX: IC Data |
| (...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 return false; // Compile method for slow case. | 1337 return false; // Compile method for slow case. |
| 1337 } | 1338 } |
| 1338 | 1339 |
| 1339 | 1340 |
| 1340 bool Intrinsifier::Math_cos(Assembler* assembler) { | 1341 bool Intrinsifier::Math_cos(Assembler* assembler) { |
| 1341 EmitTrigonometric(assembler, kCosine); | 1342 EmitTrigonometric(assembler, kCosine); |
| 1342 return false; // Compile method for slow case. | 1343 return false; // Compile method for slow case. |
| 1343 } | 1344 } |
| 1344 | 1345 |
| 1345 | 1346 |
| 1347 // var state = ((_A * (_state[kSTATE_LO])) + _state[kSTATE_HI]) & _MASK_64; |
| 1348 // _state[kSTATE_LO] = state & _MASK_32; |
| 1349 // _state[kSTATE_HI] = state >> 32; |
| 1350 bool Intrinsifier::Random_nextState(Assembler* assembler) { |
| 1351 const Library& math_lib = Library::Handle(Library::MathLibrary()); |
| 1352 ASSERT(!math_lib.IsNull()); |
| 1353 const Class& random_class = |
| 1354 Class::Handle(math_lib.LookupClassAllowPrivate(Symbols::_Random())); |
| 1355 ASSERT(!random_class.IsNull()); |
| 1356 const Field& state_field = Field::ZoneHandle( |
| 1357 random_class.LookupInstanceField(Symbols::_state())); |
| 1358 ASSERT(!state_field.IsNull()); |
| 1359 const Field& random_A_field = Field::ZoneHandle( |
| 1360 random_class.LookupStaticField(Symbols::_A())); |
| 1361 ASSERT(!random_A_field.IsNull()); |
| 1362 ASSERT(random_A_field.is_const()); |
| 1363 const Instance& a_value = Instance::Handle(random_A_field.value()); |
| 1364 const int64_t a_int_value = Integer::Cast(a_value).AsInt64Value(); |
| 1365 __ movq(RAX, Address(RSP, + 1 * kWordSize)); // Receiver. |
| 1366 __ movq(RBX, FieldAddress(RAX, state_field.Offset())); // Field '_state'. |
| 1367 // Addresses of _state[0] and _state[1]. |
| 1368 Address addr_0 = FlowGraphCompiler::ElementAddressForIntIndex( |
| 1369 kTypedDataUint32ArrayCid, |
| 1370 FlowGraphCompiler::ElementSizeFor(kTypedDataUint32ArrayCid), |
| 1371 RBX, |
| 1372 0); |
| 1373 Address addr_1 = FlowGraphCompiler::ElementAddressForIntIndex( |
| 1374 kTypedDataUint32ArrayCid, |
| 1375 FlowGraphCompiler::ElementSizeFor(kTypedDataUint32ArrayCid), |
| 1376 RBX, |
| 1377 1); |
| 1378 |
| 1379 __ movq(RAX, Immediate(a_int_value)); |
| 1380 __ movl(RCX, addr_0); |
| 1381 __ imulq(RCX, RAX); |
| 1382 __ movl(RDX, addr_1); |
| 1383 __ addq(RDX, RCX); |
| 1384 __ movl(addr_0, RDX); |
| 1385 __ shrq(RDX, Immediate(32)); |
| 1386 __ movl(addr_1, RDX); |
| 1387 __ ret(); |
| 1388 return true; |
| 1389 } |
| 1390 |
| 1391 |
| 1392 |
| 1346 // Identity comparison. | 1393 // Identity comparison. |
| 1347 bool Intrinsifier::Object_equal(Assembler* assembler) { | 1394 bool Intrinsifier::Object_equal(Assembler* assembler) { |
| 1348 Label is_true; | 1395 Label is_true; |
| 1349 __ movq(RAX, Address(RSP, + 1 * kWordSize)); | 1396 __ movq(RAX, Address(RSP, + 1 * kWordSize)); |
| 1350 __ cmpq(RAX, Address(RSP, + 2 * kWordSize)); | 1397 __ cmpq(RAX, Address(RSP, + 2 * kWordSize)); |
| 1351 __ j(EQUAL, &is_true, Assembler::kNearJump); | 1398 __ j(EQUAL, &is_true, Assembler::kNearJump); |
| 1352 __ LoadObject(RAX, Bool::False()); | 1399 __ LoadObject(RAX, Bool::False()); |
| 1353 __ ret(); | 1400 __ ret(); |
| 1354 __ Bind(&is_true); | 1401 __ Bind(&is_true); |
| 1355 __ LoadObject(RAX, Bool::True()); | 1402 __ LoadObject(RAX, Bool::True()); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 __ Bind(&fall_through); | 1681 __ Bind(&fall_through); |
| 1635 return false; | 1682 return false; |
| 1636 } | 1683 } |
| 1637 | 1684 |
| 1638 | 1685 |
| 1639 #undef __ | 1686 #undef __ |
| 1640 | 1687 |
| 1641 } // namespace dart | 1688 } // namespace dart |
| 1642 | 1689 |
| 1643 #endif // defined TARGET_ARCH_X64 | 1690 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |