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

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

Issue 6303013: Fix Smi::IsValid assert in StringCharCodeAt deferred code. (Closed)
Patch Set: Made Mads happy Created 9 years, 11 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
« no previous file with comments | « no previous file | src/ia32/lithium-codegen-ia32.cc » ('j') | 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 2772 matching lines...) Expand 10 before | Expand all | Expand 10 after
2783 void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) { 2783 void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
2784 class DeferredStringCharCodeAt: public LDeferredCode { 2784 class DeferredStringCharCodeAt: public LDeferredCode {
2785 public: 2785 public:
2786 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr) 2786 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr)
2787 : LDeferredCode(codegen), instr_(instr) { } 2787 : LDeferredCode(codegen), instr_(instr) { }
2788 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); } 2788 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); }
2789 private: 2789 private:
2790 LStringCharCodeAt* instr_; 2790 LStringCharCodeAt* instr_;
2791 }; 2791 };
2792 2792
2793 DeferredStringCharCodeAt* deferred
2794 = new DeferredStringCharCodeAt(this, instr);
2795
2796 Register scratch = scratch0(); 2793 Register scratch = scratch0();
2797 Register string = ToRegister(instr->string()); 2794 Register string = ToRegister(instr->string());
2798 Register index = no_reg; 2795 Register index = no_reg;
2799 int const_index = -1; 2796 int const_index = -1;
2800 if (instr->index()->IsConstantOperand()) { 2797 if (instr->index()->IsConstantOperand()) {
2801 const_index = ToInteger32(LConstantOperand::cast(instr->index())); 2798 const_index = ToInteger32(LConstantOperand::cast(instr->index()));
2799 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
2800 if (!Smi::IsValid(const_index)) {
2801 // Guaranteed to be out of bounds because of the assert above.
2802 // So the bounds check that must dominate this instruction must
2803 // have deoptimized already.
2804 if (FLAG_debug_code) {
2805 __ Abort("StringCharCodeAt: out of bounds index.");
2806 }
2807 // No code needs to be generated.
2808 return;
2809 }
2802 } else { 2810 } else {
2803 index = ToRegister(instr->index()); 2811 index = ToRegister(instr->index());
2804 } 2812 }
2805 Register result = ToRegister(instr->result()); 2813 Register result = ToRegister(instr->result());
2806 2814
2815 DeferredStringCharCodeAt* deferred =
2816 new DeferredStringCharCodeAt(this, instr);
2817
2807 Label flat_string, ascii_string, done; 2818 Label flat_string, ascii_string, done;
2808 2819
2809 // Fetch the instance type of the receiver into result register. 2820 // Fetch the instance type of the receiver into result register.
2810 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset)); 2821 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset));
2811 __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); 2822 __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset));
2812 2823
2813 // We need special handling for non-flat strings. 2824 // We need special handling for non-flat strings.
2814 STATIC_ASSERT(kSeqStringTag == 0); 2825 STATIC_ASSERT(kSeqStringTag == 0);
2815 __ tst(result, Operand(kStringRepresentationMask)); 2826 __ tst(result, Operand(kStringRepresentationMask));
2816 __ b(eq, &flat_string); 2827 __ b(eq, &flat_string);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2880 Register result = ToRegister(instr->result()); 2891 Register result = ToRegister(instr->result());
2881 Register scratch = scratch0(); 2892 Register scratch = scratch0();
2882 2893
2883 // TODO(3095996): Get rid of this. For now, we need to make the 2894 // TODO(3095996): Get rid of this. For now, we need to make the
2884 // result register contain a valid pointer because it is already 2895 // result register contain a valid pointer because it is already
2885 // contained in the register pointer map. 2896 // contained in the register pointer map.
2886 __ mov(result, Operand(0)); 2897 __ mov(result, Operand(0));
2887 2898
2888 __ PushSafepointRegisters(); 2899 __ PushSafepointRegisters();
2889 __ push(string); 2900 __ push(string);
2890 // Push the index as a smi. 2901 // Push the index as a smi. This is safe because of the checks in
2902 // DoStringCharCodeAt above.
2891 if (instr->index()->IsConstantOperand()) { 2903 if (instr->index()->IsConstantOperand()) {
2892 int const_index = ToInteger32(LConstantOperand::cast(instr->index())); 2904 int const_index = ToInteger32(LConstantOperand::cast(instr->index()));
2893 __ mov(scratch, Operand(Smi::FromInt(const_index))); 2905 __ mov(scratch, Operand(Smi::FromInt(const_index)));
2894 __ push(scratch); 2906 __ push(scratch);
2895 } else { 2907 } else {
2896 Register index = ToRegister(instr->index()); 2908 Register index = ToRegister(instr->index());
2897 __ SmiTag(index); 2909 __ SmiTag(index);
2898 __ push(index); 2910 __ push(index);
2899 } 2911 }
2900 __ CallRuntimeSaveDoubles(Runtime::kStringCharCodeAt); 2912 __ CallRuntimeSaveDoubles(Runtime::kStringCharCodeAt);
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
3601 3613
3602 3614
3603 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { 3615 void LCodeGen::DoOsrEntry(LOsrEntry* instr) {
3604 Abort("DoOsrEntry unimplemented."); 3616 Abort("DoOsrEntry unimplemented.");
3605 } 3617 }
3606 3618
3607 3619
3608 #undef __ 3620 #undef __
3609 3621
3610 } } // namespace v8::internal 3622 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698