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

Side by Side Diff: src/arm/lithium-codegen-arm.cc

Issue 8682010: Porting r10023 and r10054 to arm (pointer cache for external strings). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Adding external string handling. Created 9 years 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
« src/arm/codegen-arm.cc ('K') | « src/arm/codegen-arm.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3574 matching lines...) Expand 10 before | Expand all | Expand 10 after
3585 class DeferredStringCharCodeAt: public LDeferredCode { 3585 class DeferredStringCharCodeAt: public LDeferredCode {
3586 public: 3586 public:
3587 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr) 3587 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr)
3588 : LDeferredCode(codegen), instr_(instr) { } 3588 : LDeferredCode(codegen), instr_(instr) { }
3589 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); } 3589 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); }
3590 virtual LInstruction* instr() { return instr_; } 3590 virtual LInstruction* instr() { return instr_; }
3591 private: 3591 private:
3592 LStringCharCodeAt* instr_; 3592 LStringCharCodeAt* instr_;
3593 }; 3593 };
3594 3594
3595 Register string = ToRegister(instr->string());
3596 Register index = ToRegister(instr->index());
3597 Register result = ToRegister(instr->result());
3598
3599 DeferredStringCharCodeAt* deferred = 3595 DeferredStringCharCodeAt* deferred =
3600 new DeferredStringCharCodeAt(this, instr); 3596 new DeferredStringCharCodeAt(this, instr);
3601 3597
3602 // Fetch the instance type of the receiver into result register. 3598 StringCharLoadGenerator::Generate(masm(),
3603 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset)); 3599 ToRegister(instr->string()),
3604 __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); 3600 ToRegister(instr->index()),
3605 3601 ToRegister(instr->result()),
3606 // We need special handling for indirect strings. 3602 deferred->entry());
3607 Label check_sequential;
3608 __ tst(result, Operand(kIsIndirectStringMask));
3609 __ b(eq, &check_sequential);
3610
3611 // Dispatch on the indirect string shape: slice or cons.
3612 Label cons_string;
3613 __ tst(result, Operand(kSlicedNotConsMask));
3614 __ b(eq, &cons_string);
3615
3616 // Handle slices.
3617 Label indirect_string_loaded;
3618 __ ldr(result, FieldMemOperand(string, SlicedString::kOffsetOffset));
3619 __ add(index, index, Operand(result, ASR, kSmiTagSize));
3620 __ ldr(string, FieldMemOperand(string, SlicedString::kParentOffset));
3621 __ jmp(&indirect_string_loaded);
3622
3623 // Handle conses.
3624 // Check whether the right hand side is the empty string (i.e. if
3625 // this is really a flat string in a cons string). If that is not
3626 // the case we would rather go to the runtime system now to flatten
3627 // the string.
3628 __ bind(&cons_string);
3629 __ ldr(result, FieldMemOperand(string, ConsString::kSecondOffset));
3630 __ LoadRoot(ip, Heap::kEmptyStringRootIndex);
3631 __ cmp(result, ip);
3632 __ b(ne, deferred->entry());
3633 // Get the first of the two strings and load its instance type.
3634 __ ldr(string, FieldMemOperand(string, ConsString::kFirstOffset));
3635
3636 __ bind(&indirect_string_loaded);
3637 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset));
3638 __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset));
3639
3640 // Check whether the string is sequential. The only non-sequential
3641 // shapes we support have just been unwrapped above.
3642 // Note that if the original string is a cons or slice with an external
3643 // string as underlying string, we pass that unpacked underlying string with
3644 // the adjusted index to the runtime function.
3645 __ bind(&check_sequential);
3646 STATIC_ASSERT(kSeqStringTag == 0);
3647 __ tst(result, Operand(kStringRepresentationMask));
3648 __ b(ne, deferred->entry());
3649
3650 // Dispatch on the encoding: ASCII or two-byte.
3651 Label ascii_string;
3652 STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0);
3653 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
3654 __ tst(result, Operand(kStringEncodingMask));
3655 __ b(ne, &ascii_string);
3656
3657 // Two-byte string.
3658 // Load the two-byte character code into the result register.
3659 Label done;
3660 __ add(result,
3661 string,
3662 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag));
3663 __ ldrh(result, MemOperand(result, index, LSL, 1));
3664 __ jmp(&done);
3665
3666 // ASCII string.
3667 // Load the byte into the result register.
3668 __ bind(&ascii_string);
3669 __ add(result,
3670 string,
3671 Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag));
3672 __ ldrb(result, MemOperand(result, index));
3673
3674 __ bind(&done);
3675 __ bind(deferred->exit()); 3603 __ bind(deferred->exit());
3676 } 3604 }
3677 3605
3678 3606
3679 void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) { 3607 void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) {
3680 Register string = ToRegister(instr->string()); 3608 Register string = ToRegister(instr->string());
3681 Register result = ToRegister(instr->result()); 3609 Register result = ToRegister(instr->result());
3682 Register scratch = scratch0(); 3610 Register scratch = scratch0();
3683 3611
3684 // TODO(3095996): Get rid of this. For now, we need to make the 3612 // TODO(3095996): Get rid of this. For now, we need to make the
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
4682 ASSERT(osr_pc_offset_ == -1); 4610 ASSERT(osr_pc_offset_ == -1);
4683 osr_pc_offset_ = masm()->pc_offset(); 4611 osr_pc_offset_ = masm()->pc_offset();
4684 } 4612 }
4685 4613
4686 4614
4687 4615
4688 4616
4689 #undef __ 4617 #undef __
4690 4618
4691 } } // namespace v8::internal 4619 } } // namespace v8::internal
OLDNEW
« src/arm/codegen-arm.cc ('K') | « src/arm/codegen-arm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698