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

Side by Side Diff: src/arm/lithium-codegen-arm.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3406 matching lines...) Expand 10 before | Expand all | Expand 10 after
3417 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr) 3417 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr)
3418 : LDeferredCode(codegen), instr_(instr) { } 3418 : LDeferredCode(codegen), instr_(instr) { }
3419 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); } 3419 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); }
3420 private: 3420 private:
3421 LStringCharCodeAt* instr_; 3421 LStringCharCodeAt* instr_;
3422 }; 3422 };
3423 3423
3424 Register scratch = scratch0(); 3424 Register scratch = scratch0();
3425 Register string = ToRegister(instr->string()); 3425 Register string = ToRegister(instr->string());
3426 Register index = no_reg; 3426 Register index = no_reg;
3427 int const_index = -1; 3427 int const_index = 0;
3428 if (instr->index()->IsConstantOperand()) { 3428 if (instr->index()->IsConstantOperand()) {
3429 const_index = ToInteger32(LConstantOperand::cast(instr->index())); 3429 const_index = ToInteger32(LConstantOperand::cast(instr->index()));
3430 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); 3430 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
3431 if (!Smi::IsValid(const_index)) { 3431 if (!Smi::IsValid(const_index)) {
3432 // Guaranteed to be out of bounds because of the assert above. 3432 // Guaranteed to be out of bounds because of the assert above.
3433 // So the bounds check that must dominate this instruction must 3433 // So the bounds check that must dominate this instruction must
3434 // have deoptimized already. 3434 // have deoptimized already.
3435 if (FLAG_debug_code) { 3435 if (FLAG_debug_code) {
3436 __ Abort("StringCharCodeAt: out of bounds index."); 3436 __ Abort("StringCharCodeAt: out of bounds index.");
3437 } 3437 }
3438 // No code needs to be generated. 3438 // No code needs to be generated.
3439 return; 3439 return;
3440 } 3440 }
3441 } else { 3441 } else {
3442 index = ToRegister(instr->index()); 3442 index = ToRegister(instr->index());
3443 } 3443 }
3444 Register result = ToRegister(instr->result()); 3444 Register result = ToRegister(instr->result());
3445 3445
3446 DeferredStringCharCodeAt* deferred = 3446 DeferredStringCharCodeAt* deferred =
3447 new DeferredStringCharCodeAt(this, instr); 3447 new DeferredStringCharCodeAt(this, instr);
3448 3448
3449 Label flat_string, ascii_string, done; 3449 Label flat_string, ascii_string, cons_string, two_byte_string, done;
3450 3450
3451 // Fetch the instance type of the receiver into result register. 3451 // Fetch the instance type of the receiver into result register.
3452 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset)); 3452 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset));
3453 __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); 3453 __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset));
3454 3454
3455 // We need special handling for non-flat strings. 3455 // We need special handling for non-flat strings.
3456 STATIC_ASSERT(kSeqStringTag == 0); 3456 STATIC_ASSERT(kSeqStringTag == 0);
3457 __ tst(result, Operand(kStringRepresentationMask)); 3457 __ tst(result, Operand(kStringRepresentationMask));
3458 __ b(eq, &flat_string); 3458 __ b(eq, &flat_string);
3459 3459
3460 // Handle non-flat strings. 3460 // Handle non-flat strings.
3461 __ tst(result, Operand(kIsConsStringMask)); 3461 __ and_(result, result, Operand(kStringRepresentationMask));
3462 __ cmp(result, Operand(kConsStringTag));
3463 __ b(eq, &cons_string);
3464 __ cmp(result, Operand(kExternalStringTag));
3462 __ b(eq, deferred->entry()); 3465 __ b(eq, deferred->entry());
3463 3466
3467 // SlicedString.
3468 // Unpack slice, add offset and retrieve the result char.
3469 __ ldr(scratch, FieldMemOperand(string, SlicedString::kOffsetOffset));
3470 __ ldr(string, FieldMemOperand(string, SlicedString::kParentOffset));
3471 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset));
3472 __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset));
3473 // Check for 1-byte or 2-byte string.
3474 STATIC_ASSERT(kAsciiStringTag != 0);
3475 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0);
3476 __ tst(result, Operand(kStringEncodingMask));
3477 __ add(string, string, scratch, LeaveCC, eq);
3478 __ b(eq, &two_byte_string);
3479 __ add(string, string, Operand(scratch, ASR, 1));
3480 __ jmp(&ascii_string);
3481
3464 // ConsString. 3482 // ConsString.
3465 // Check whether the right hand side is the empty string (i.e. if 3483 // Check whether the right hand side is the empty string (i.e. if
3466 // this is really a flat string in a cons string). If that is not 3484 // this is really a flat string in a cons string). If that is not
3467 // the case we would rather go to the runtime system now to flatten 3485 // the case we would rather go to the runtime system now to flatten
3468 // the string. 3486 // the string.
3487 __ bind(&cons_string);
3469 __ ldr(scratch, FieldMemOperand(string, ConsString::kSecondOffset)); 3488 __ ldr(scratch, FieldMemOperand(string, ConsString::kSecondOffset));
3470 __ LoadRoot(ip, Heap::kEmptyStringRootIndex); 3489 __ LoadRoot(ip, Heap::kEmptyStringRootIndex);
3471 __ cmp(scratch, ip); 3490 __ cmp(scratch, ip);
3472 __ b(ne, deferred->entry()); 3491 __ b(ne, deferred->entry());
3473 // Get the first of the two strings and load its instance type. 3492 // Get the first of the two strings and load its instance type.
3474 __ ldr(string, FieldMemOperand(string, ConsString::kFirstOffset)); 3493 __ ldr(string, FieldMemOperand(string, ConsString::kFirstOffset));
3475 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset)); 3494 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset));
3476 __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); 3495 __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset));
3477 // If the first cons component is also non-flat, then go to runtime. 3496 // If the first cons component is also non-flat, then go to runtime.
3478 STATIC_ASSERT(kSeqStringTag == 0); 3497 STATIC_ASSERT(kSeqStringTag == 0);
3479 __ tst(result, Operand(kStringRepresentationMask)); 3498 __ tst(result, Operand(kStringRepresentationMask));
3480 __ b(ne, deferred->entry()); 3499 __ b(ne, deferred->entry());
3481 3500
3482 // Check for 1-byte or 2-byte string. 3501 // Check for 1-byte or 2-byte string.
3483 __ bind(&flat_string); 3502 __ bind(&flat_string);
3484 STATIC_ASSERT(kAsciiStringTag != 0); 3503 STATIC_ASSERT(kAsciiStringTag != 0);
3485 __ tst(result, Operand(kStringEncodingMask)); 3504 __ tst(result, Operand(kStringEncodingMask));
3486 __ b(ne, &ascii_string); 3505 __ b(ne, &ascii_string);
3487 3506
3488 // 2-byte string. 3507 // 2-byte string.
3489 // Load the 2-byte character code into the result register. 3508 // Load the 2-byte character code into the result register.
3509 __ bind(&two_byte_string);
3490 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); 3510 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
3491 if (instr->index()->IsConstantOperand()) { 3511 if (instr->index()->IsConstantOperand()) {
3492 __ ldrh(result, 3512 __ ldrh(result,
3493 FieldMemOperand(string, 3513 FieldMemOperand(string,
3494 SeqTwoByteString::kHeaderSize + 2 * const_index)); 3514 SeqTwoByteString::kHeaderSize + 2 * const_index));
3495 } else { 3515 } else {
3496 __ add(scratch, 3516 __ add(scratch,
3497 string, 3517 string,
3498 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); 3518 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag));
3499 __ ldrh(result, MemOperand(scratch, index, LSL, 1)); 3519 __ ldrh(result, MemOperand(scratch, index, LSL, 1));
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
4485 ASSERT(osr_pc_offset_ == -1); 4505 ASSERT(osr_pc_offset_ == -1);
4486 osr_pc_offset_ = masm()->pc_offset(); 4506 osr_pc_offset_ = masm()->pc_offset();
4487 } 4507 }
4488 4508
4489 4509
4490 4510
4491 4511
4492 #undef __ 4512 #undef __
4493 4513
4494 } } // namespace v8::internal 4514 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698