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

Unified Diff: runtime/vm/intrinsifier_ia32.cc

Issue 8440051: Intrinsify String.charCodeAt, String.length and String.hashCode. Improves frog performance by 2x. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 | « no previous file | runtime/vm/object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intrinsifier_ia32.cc
===================================================================
--- runtime/vm/intrinsifier_ia32.cc (revision 1097)
+++ runtime/vm/intrinsifier_ia32.cc (working copy)
@@ -75,6 +75,9 @@
V(Object, ==, Object_equal) \
V(FixedSizeArrayIterator, next, FixedSizeArrayIterator_next) \
V(FixedSizeArrayIterator, hasNext, FixedSizeArrayIterator_hasNext) \
+ V(StringBase, get:length, String_getLength) \
+ V(StringBase, charCodeAt, String_charCodeAt) \
+ V(StringBase, hashCode, String_hashCode) \
#define __ assembler->
@@ -897,6 +900,50 @@
}
+static bool String_getLength(Assembler* assembler) {
+ __ movl(EAX, Address(ESP, + 1 * kWordSize));
siva 2011/11/02 20:22:06 // String object.
srdjan 2011/11/02 20:31:42 Done.
+ __ movl(EAX, FieldAddress(EAX, String::length_offset()));
+ __ ret();
+ return true;
+}
+
+
+// TODO(srdjan): Implement for two and four byte strings as well.
+static bool String_charCodeAt(Assembler* assembler) {
+ ObjectStore* object_store = Isolate::Current()->object_store();
+ Label fall_through;
+ __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Index.
+ __ movl(EAX, Address(ESP, + 2 * kWordSize)); // Array.
siva 2011/11/02 20:22:06 // String object. (not Array)
srdjan 2011/11/02 20:31:42 Done.
+ __ testl(EBX, Immediate(kSmiTagMask));
+ __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index.
+ // Range check.
+ __ cmpl(EBX, FieldAddress(EAX, String::length_offset()));
+ // Runtime throws exception.
+ __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump);
+ __ movl(EDI, FieldAddress(EAX, Instance::class_offset()));
+ __ CompareObject(EDI,
+ Class::ZoneHandle(object_store->one_byte_string_class()));
+ __ j(NOT_EQUAL, &fall_through);
+ __ SmiUntag(EBX);
+ __ movzxb(EAX, FieldAddress(EAX, EBX, TIMES_1, OneByteString::data_offset()));
+ __ SmiTag(EAX);
+ __ ret();
+ __ Bind(&fall_through);
+ return false;
+}
+
+
+static bool String_hashCode(Assembler* assembler) {
+ Label fall_through;
+ __ movl(EAX, Address(ESP, + 1 * kWordSize));
siva 2011/11/02 20:22:06 // String object.
srdjan 2011/11/02 20:31:42 Done.
+ __ movl(EAX, FieldAddress(EAX, String::hash_offset()));
+ __ cmpl(EAX, Immediate(0));
+ __ j(EQUAL, &fall_through, Assembler::kNearJump);
siva 2011/11/02 20:22:06 // Hash not computed yet.
srdjan 2011/11/02 20:31:42 Done.
+ __ ret();
+ __ Bind(&fall_through);
+ return false;
+}
+
#undef __
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698