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

Unified Diff: src/ia32/lithium-codegen-ia32.cc

Issue 7477045: Tentative implementation of string slices (hidden under the flag --string-slices). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Support for RegExp. Removed methods related to truncate. Created 9 years, 4 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
Index: src/ia32/lithium-codegen-ia32.cc
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc
index e2a18eb2fc96d8d0ec43548a0f3b6547cd4e4777..c4ff689062ffde3a4c762aa726657a0ccfc2db49 100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -3139,6 +3139,7 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
Register string = ToRegister(instr->string());
Vitaly Repeshko 2011/08/12 19:01:00 Simplified version using three (writable) register
Register index = no_reg;
+ Register offset = ToRegister(instr->TempAt(0));
int const_index = -1;
if (instr->index()->IsConstantOperand()) {
const_index = ToInteger32(LConstantOperand::cast(instr->index()));
@@ -3161,7 +3162,7 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
DeferredStringCharCodeAt* deferred =
new DeferredStringCharCodeAt(this, instr);
- Label flat_string, ascii_string, done;
+ Label flat_string, ascii_string, cons_string, two_byte_string, done;
// Fetch the instance type of the receiver into result register.
__ mov(result, FieldOperand(string, HeapObject::kMapOffset));
@@ -3173,14 +3174,33 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
__ j(zero, &flat_string, Label::kNear);
// Handle non-flat strings.
- __ test(result, Immediate(kIsConsStringMask));
- __ j(zero, deferred->entry());
+ __ and_(result, kStringRepresentationMask);
+ __ cmp(result, kConsStringTag);
+ __ j(equal, &cons_string, Label::kNear);
+ __ cmp(result, kExternalStringTag);
+ __ j(equal, deferred->entry());
+
+ // SlicedString.
+ // Unpack slice, add offset and retrieve the result char.
+ __ mov(offset, FieldOperand(string, SlicedString::kOffsetOffset));
+ __ SmiUntag(offset);
+ __ mov(string, FieldOperand(string, SlicedString::kParentOffset));
+ __ mov(result, FieldOperand(string, HeapObject::kMapOffset));
+ __ movzx_b(result, FieldOperand(result, Map::kInstanceTypeOffset));
+ __ add(string, Operand(offset));
+ // Check for ASCII or two-byte string.
+ STATIC_ASSERT(kAsciiStringTag != 0);
+ __ test(result, Immediate(kStringEncodingMask));
+ __ j(not_zero, &ascii_string, Label::kNear);
+ __ add(string, Operand(offset));
+ __ jmp(&two_byte_string, Label::kNear);
// ConsString.
// Check whether the right hand side is the empty string (i.e. if
// this is really a flat string in a cons string). If that is not
// the case we would rather go to the runtime system now to flatten
// the string.
+ __ bind(&cons_string);
__ cmp(FieldOperand(string, ConsString::kSecondOffset),
Immediate(factory()->empty_string()));
__ j(not_equal, deferred->entry());
@@ -3201,6 +3221,7 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
// Two-byte string.
// Load the two-byte character code into the result register.
+ __ bind(&two_byte_string);
STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
if (instr->index()->IsConstantOperand()) {
__ movzx_w(result,

Powered by Google App Engine
This is Rietveld 408576698