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

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

Issue 10831049: Improve constant element index access code generation (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 8 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
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/hydrogen.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 2761 matching lines...) Expand 10 before | Expand all | Expand 10 after
2772 2772
2773 // There are two words between the frame pointer and the last argument. 2773 // There are two words between the frame pointer and the last argument.
2774 // Subtracting from length accounts for one of them add one more. 2774 // Subtracting from length accounts for one of them add one more.
2775 __ add(length, length, Operand(1)); 2775 __ add(length, length, Operand(1));
2776 __ ldr(result, MemOperand(arguments, length, LSL, kPointerSizeLog2)); 2776 __ ldr(result, MemOperand(arguments, length, LSL, kPointerSizeLog2));
2777 } 2777 }
2778 2778
2779 2779
2780 void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { 2780 void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) {
2781 Register elements = ToRegister(instr->elements()); 2781 Register elements = ToRegister(instr->elements());
2782 Register key = EmitLoadRegister(instr->key(), scratch0());
2783 Register result = ToRegister(instr->result()); 2782 Register result = ToRegister(instr->result());
2784 Register scratch = scratch0(); 2783 Register scratch = scratch0();
2785 2784
2786 // Load the result. 2785 if (instr->key()->IsConstantOperand()) {
2787 if (instr->hydrogen()->key()->representation().IsTagged()) { 2786 LConstantOperand* const_operand = LConstantOperand::cast(instr->key());
2788 __ add(scratch, elements, 2787 int offset =
2789 Operand(key, LSL, kPointerSizeLog2 - kSmiTagSize)); 2788 (ToInteger32(const_operand) + instr->additional_index()) * kPointerSize
2789 + FixedArray::kHeaderSize;
2790 __ ldr(result, FieldMemOperand(elements, offset));
2790 } else { 2791 } else {
2791 __ add(scratch, elements, Operand(key, LSL, kPointerSizeLog2)); 2792 Register key = EmitLoadRegister(instr->key(), scratch0());
2793 // Even though the HLoadKeyedFastElement instruction forces the input
2794 // representation for the key to be an integer, the input gets replaced
2795 // during bound check elimination with the index argument to the bounds
2796 // check, which can be tagged, so that case must be handled here, too.
2797 if (instr->hydrogen()->key()->representation().IsTagged()) {
2798 __ add(scratch, elements,
2799 Operand(key, LSL, kPointerSizeLog2 - kSmiTagSize));
2800 } else {
2801 __ add(scratch, elements, Operand(key, LSL, kPointerSizeLog2));
2802 }
2803 uint32_t offset = FixedArray::kHeaderSize +
2804 (instr->additional_index() << kPointerSizeLog2);
2805 __ ldr(result, FieldMemOperand(scratch, offset));
2792 } 2806 }
2793 uint32_t offset = FixedArray::kHeaderSize +
2794 (instr->additional_index() << kPointerSizeLog2);
2795 __ ldr(result, FieldMemOperand(scratch, offset));
2796 2807
2797 // Check for the hole value. 2808 // Check for the hole value.
2798 if (instr->hydrogen()->RequiresHoleCheck()) { 2809 if (instr->hydrogen()->RequiresHoleCheck()) {
2799 if (IsFastSmiElementsKind(instr->hydrogen()->elements_kind())) { 2810 if (IsFastSmiElementsKind(instr->hydrogen()->elements_kind())) {
2800 __ tst(result, Operand(kSmiTagMask)); 2811 __ tst(result, Operand(kSmiTagMask));
2801 DeoptimizeIf(ne, instr->environment()); 2812 DeoptimizeIf(ne, instr->environment());
2802 } else { 2813 } else {
2803 __ LoadRoot(scratch, Heap::kTheHoleValueRootIndex); 2814 __ LoadRoot(scratch, Heap::kTheHoleValueRootIndex);
2804 __ cmp(result, scratch); 2815 __ cmp(result, scratch);
2805 DeoptimizeIf(eq, instr->environment()); 2816 DeoptimizeIf(eq, instr->environment());
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
3816 // Name is always in r2. 3827 // Name is always in r2.
3817 __ mov(r2, Operand(instr->name())); 3828 __ mov(r2, Operand(instr->name()));
3818 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode) 3829 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode)
3819 ? isolate()->builtins()->StoreIC_Initialize_Strict() 3830 ? isolate()->builtins()->StoreIC_Initialize_Strict()
3820 : isolate()->builtins()->StoreIC_Initialize(); 3831 : isolate()->builtins()->StoreIC_Initialize();
3821 CallCode(ic, RelocInfo::CODE_TARGET, instr); 3832 CallCode(ic, RelocInfo::CODE_TARGET, instr);
3822 } 3833 }
3823 3834
3824 3835
3825 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { 3836 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
3826 __ cmp(ToRegister(instr->index()), ToRegister(instr->length())); 3837 if (instr->index()->IsConstantOperand()) {
3838 int constant_index =
3839 ToInteger32(LConstantOperand::cast(instr->index()));
3840 if (instr->hydrogen()->length()->representation().IsTagged()) {
3841 __ mov(ip, Operand(Smi::FromInt(constant_index)));
3842 } else {
3843 __ mov(ip, Operand(constant_index));
3844 }
3845 __ cmp(ip, ToRegister(instr->length()));
3846 } else {
3847 __ cmp(ToRegister(instr->index()), ToRegister(instr->length()));
3848 }
3827 DeoptimizeIf(hs, instr->environment()); 3849 DeoptimizeIf(hs, instr->environment());
3828 } 3850 }
3829 3851
3830 3852
3831 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { 3853 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) {
3832 Register value = ToRegister(instr->value()); 3854 Register value = ToRegister(instr->value());
3833 Register elements = ToRegister(instr->object()); 3855 Register elements = ToRegister(instr->object());
3834 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg; 3856 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg;
3835 Register scratch = scratch0(); 3857 Register scratch = scratch0();
3836 3858
3837 // Do the store. 3859 // Do the store.
3838 if (instr->key()->IsConstantOperand()) { 3860 if (instr->key()->IsConstantOperand()) {
3839 ASSERT(!instr->hydrogen()->NeedsWriteBarrier()); 3861 ASSERT(!instr->hydrogen()->NeedsWriteBarrier());
3840 LConstantOperand* const_operand = LConstantOperand::cast(instr->key()); 3862 LConstantOperand* const_operand = LConstantOperand::cast(instr->key());
3841 int offset = 3863 int offset =
3842 (ToInteger32(const_operand) + instr->additional_index()) * kPointerSize 3864 (ToInteger32(const_operand) + instr->additional_index()) * kPointerSize
3843 + FixedArray::kHeaderSize; 3865 + FixedArray::kHeaderSize;
3844 __ str(value, FieldMemOperand(elements, offset)); 3866 __ str(value, FieldMemOperand(elements, offset));
3845 } else { 3867 } else {
3868 // Even though the HLoadKeyedFastElement instruction forces the input
3869 // representation for the key to be an integer, the input gets replaced
3870 // during bound check elimination with the index argument to the bounds
3871 // check, which can be tagged, so that case must be handled here, too.
3846 if (instr->hydrogen()->key()->representation().IsTagged()) { 3872 if (instr->hydrogen()->key()->representation().IsTagged()) {
3847 __ add(scratch, elements, 3873 __ add(scratch, elements,
3848 Operand(key, LSL, kPointerSizeLog2 - kSmiTagSize)); 3874 Operand(key, LSL, kPointerSizeLog2 - kSmiTagSize));
3849 } else { 3875 } else {
3850 __ add(scratch, elements, Operand(key, LSL, kPointerSizeLog2)); 3876 __ add(scratch, elements, Operand(key, LSL, kPointerSizeLog2));
3851 } 3877 }
3852 if (instr->additional_index() != 0) { 3878 uint32_t offset = FixedArray::kHeaderSize +
3853 __ add(scratch, 3879 (instr->additional_index() << kPointerSizeLog2);
3854 scratch, 3880 __ str(value, FieldMemOperand(scratch, offset));
3855 Operand(instr->additional_index() << kPointerSizeLog2));
3856 }
3857 __ str(value, FieldMemOperand(scratch, FixedArray::kHeaderSize));
3858 } 3881 }
3859 3882
3860 if (instr->hydrogen()->NeedsWriteBarrier()) { 3883 if (instr->hydrogen()->NeedsWriteBarrier()) {
3861 HType type = instr->hydrogen()->value()->type(); 3884 HType type = instr->hydrogen()->value()->type();
3862 SmiCheck check_needed = 3885 SmiCheck check_needed =
3863 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; 3886 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
3864 // Compute address of modified element and store it into key register. 3887 // Compute address of modified element and store it into key register.
3865 __ add(key, scratch, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); 3888 __ add(key, scratch, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
3866 __ RecordWrite(elements, 3889 __ RecordWrite(elements,
3867 key, 3890 key,
(...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after
5447 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); 5470 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize));
5448 __ ldr(result, FieldMemOperand(scratch, 5471 __ ldr(result, FieldMemOperand(scratch,
5449 FixedArray::kHeaderSize - kPointerSize)); 5472 FixedArray::kHeaderSize - kPointerSize));
5450 __ bind(&done); 5473 __ bind(&done);
5451 } 5474 }
5452 5475
5453 5476
5454 #undef __ 5477 #undef __
5455 5478
5456 } } // namespace v8::internal 5479 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698