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

Unified Diff: runtime/vm/intrinsifier_x64.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intrinsifier_mips.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intrinsifier_x64.cc
===================================================================
--- runtime/vm/intrinsifier_x64.cc (revision 22881)
+++ runtime/vm/intrinsifier_x64.cc (working copy)
@@ -8,6 +8,7 @@
#include "vm/intrinsifier.h"
#include "vm/assembler.h"
+#include "vm/flow_graph_compiler.h"
#include "vm/instructions.h"
#include "vm/object_store.h"
#include "vm/symbols.h"
@@ -1343,6 +1344,52 @@
}
+// var state = ((_A * (_state[kSTATE_LO])) + _state[kSTATE_HI]) & _MASK_64;
+// _state[kSTATE_LO] = state & _MASK_32;
+// _state[kSTATE_HI] = state >> 32;
+bool Intrinsifier::Random_nextState(Assembler* assembler) {
+ const Library& math_lib = Library::Handle(Library::MathLibrary());
+ ASSERT(!math_lib.IsNull());
+ const Class& random_class =
+ Class::Handle(math_lib.LookupClassAllowPrivate(Symbols::_Random()));
+ ASSERT(!random_class.IsNull());
+ const Field& state_field = Field::ZoneHandle(
+ random_class.LookupInstanceField(Symbols::_state()));
+ ASSERT(!state_field.IsNull());
+ const Field& random_A_field = Field::ZoneHandle(
+ random_class.LookupStaticField(Symbols::_A()));
+ ASSERT(!random_A_field.IsNull());
+ ASSERT(random_A_field.is_const());
+ const Instance& a_value = Instance::Handle(random_A_field.value());
+ const int64_t a_int_value = Integer::Cast(a_value).AsInt64Value();
+ __ movq(RAX, Address(RSP, + 1 * kWordSize)); // Receiver.
+ __ movq(RBX, FieldAddress(RAX, state_field.Offset())); // Field '_state'.
+ // Addresses of _state[0] and _state[1].
+ Address addr_0 = FlowGraphCompiler::ElementAddressForIntIndex(
+ kTypedDataUint32ArrayCid,
+ FlowGraphCompiler::ElementSizeFor(kTypedDataUint32ArrayCid),
+ RBX,
+ 0);
+ Address addr_1 = FlowGraphCompiler::ElementAddressForIntIndex(
+ kTypedDataUint32ArrayCid,
+ FlowGraphCompiler::ElementSizeFor(kTypedDataUint32ArrayCid),
+ RBX,
+ 1);
+
+ __ movq(RAX, Immediate(a_int_value));
+ __ movl(RCX, addr_0);
+ __ imulq(RCX, RAX);
+ __ movl(RDX, addr_1);
+ __ addq(RDX, RCX);
+ __ movl(addr_0, RDX);
+ __ shrq(RDX, Immediate(32));
+ __ movl(addr_1, RDX);
+ __ ret();
+ return true;
+}
+
+
+
// Identity comparison.
bool Intrinsifier::Object_equal(Assembler* assembler) {
Label is_true;
« no previous file with comments | « runtime/vm/intrinsifier_mips.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698