Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Side by Side Diff: runtime/vm/intrinsifier_ia32.cc

Issue 15502004: Intrinsify random nextState, improve perfromance significantly. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intrinsifier_arm.cc ('k') | runtime/vm/intrinsifier_mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. 11 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
12 #if defined(TARGET_ARCH_IA32) 12 #if defined(TARGET_ARCH_IA32)
13 13
14 #include "vm/intrinsifier.h" 14 #include "vm/intrinsifier.h"
15 15
16 #include "vm/assembler.h" 16 #include "vm/assembler.h"
17 #include "vm/flow_graph_compiler.h"
17 #include "vm/object.h" 18 #include "vm/object.h"
18 #include "vm/object_store.h" 19 #include "vm/object_store.h"
19 #include "vm/os.h" 20 #include "vm/os.h"
20 #include "vm/stub_code.h" 21 #include "vm/stub_code.h"
21 #include "vm/symbols.h" 22 #include "vm/symbols.h"
22 23
23 namespace dart { 24 namespace dart {
24 25
25 DECLARE_FLAG(bool, enable_type_checks); 26 DECLARE_FLAG(bool, enable_type_checks);
26 27
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 return false; // Compile method for slow case. 1421 return false; // Compile method for slow case.
1421 } 1422 }
1422 1423
1423 1424
1424 bool Intrinsifier::Math_cos(Assembler* assembler) { 1425 bool Intrinsifier::Math_cos(Assembler* assembler) {
1425 EmitTrigonometric(assembler, kCosine); 1426 EmitTrigonometric(assembler, kCosine);
1426 return false; // Compile method for slow case. 1427 return false; // Compile method for slow case.
1427 } 1428 }
1428 1429
1429 1430
1431 // var state = ((_A * (_state[kSTATE_LO])) + _state[kSTATE_HI]) & _MASK_64;
1432 // _state[kSTATE_LO] = state & _MASK_32;
1433 // _state[kSTATE_HI] = state >> 32;
1434 bool Intrinsifier::Random_nextState(Assembler* assembler) {
1435 const Library& math_lib = Library::Handle(Library::MathLibrary());
1436 ASSERT(!math_lib.IsNull());
1437 const Class& random_class =
1438 Class::Handle(math_lib.LookupClassAllowPrivate(Symbols::_Random()));
1439 ASSERT(!random_class.IsNull());
1440 const Field& state_field = Field::ZoneHandle(
1441 random_class.LookupInstanceField(Symbols::_state()));
1442 ASSERT(!state_field.IsNull());
1443 const Field& random_A_field = Field::ZoneHandle(
1444 random_class.LookupStaticField(Symbols::_A()));
1445 ASSERT(!random_A_field.IsNull());
1446 ASSERT(random_A_field.is_const());
1447 const Instance& a_value = Instance::Handle(random_A_field.value());
1448 const int64_t a_int_value = Integer::Cast(a_value).AsInt64Value();
1449 // 'a_int_value' is a mask.
1450 ASSERT(Utils::IsUint(32, a_int_value));
1451 int32_t a_int32_value = static_cast<int32_t>(a_int_value);
1452 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Receiver.
1453 __ movl(EBX, FieldAddress(EAX, state_field.Offset())); // Field '_state'.
1454 // Addresses of _state[0] and _state[1].
1455 Address addr_0 = FlowGraphCompiler::ElementAddressForIntIndex(
1456 kTypedDataUint32ArrayCid,
1457 FlowGraphCompiler::ElementSizeFor(kTypedDataUint32ArrayCid),
1458 EBX,
1459 0);
1460 Address addr_1 = FlowGraphCompiler::ElementAddressForIntIndex(
1461 kTypedDataUint32ArrayCid,
1462 FlowGraphCompiler::ElementSizeFor(kTypedDataUint32ArrayCid),
1463 EBX,
1464 1);
1465 __ movl(EAX, Immediate(a_int32_value));
1466 // 64-bit multiply EAX * value -> EDX:EAX.
1467 __ mull(addr_0);
1468 __ addl(EAX, addr_1);
1469 __ adcl(EDX, Immediate(0));
1470 __ movl(addr_1, EDX);
1471 __ movl(addr_0, EAX);
1472 __ ret();
1473 return true;
1474 }
1475
1476
1430 // Identity comparison. 1477 // Identity comparison.
1431 bool Intrinsifier::Object_equal(Assembler* assembler) { 1478 bool Intrinsifier::Object_equal(Assembler* assembler) {
1432 Label is_true; 1479 Label is_true;
1433 __ movl(EAX, Address(ESP, + 1 * kWordSize)); 1480 __ movl(EAX, Address(ESP, + 1 * kWordSize));
1434 __ cmpl(EAX, Address(ESP, + 2 * kWordSize)); 1481 __ cmpl(EAX, Address(ESP, + 2 * kWordSize));
1435 __ j(EQUAL, &is_true, Assembler::kNearJump); 1482 __ j(EQUAL, &is_true, Assembler::kNearJump);
1436 __ LoadObject(EAX, Bool::False()); 1483 __ LoadObject(EAX, Bool::False());
1437 __ ret(); 1484 __ ret();
1438 __ Bind(&is_true); 1485 __ Bind(&is_true);
1439 __ LoadObject(EAX, Bool::True()); 1486 __ LoadObject(EAX, Bool::True());
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 __ ret(); 1761 __ ret();
1715 1762
1716 __ Bind(&fall_through); 1763 __ Bind(&fall_through);
1717 return false; 1764 return false;
1718 } 1765 }
1719 1766
1720 #undef __ 1767 #undef __
1721 } // namespace dart 1768 } // namespace dart
1722 1769
1723 #endif // defined TARGET_ARCH_IA32 1770 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier_arm.cc ('k') | runtime/vm/intrinsifier_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698