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

Side by Side Diff: runtime/vm/assembler_ia32.cc

Issue 2660923002: Cleaner version of IA32 stub optimization (Closed)
Patch Set: Created 3 years, 10 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 | runtime/vm/stub_code_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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // NOLINT 5 #include "vm/globals.h" // NOLINT
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 2885 matching lines...) Expand 10 before | Expand all | Expand 10 after
2896 SmiUntag(object); 2896 SmiUntag(object);
2897 j(NOT_CARRY, is_smi, kNearJump); 2897 j(NOT_CARRY, is_smi, kNearJump);
2898 // Load cid: can't use LoadClassId, object is untagged. Use TIMES_2 scale 2898 // Load cid: can't use LoadClassId, object is untagged. Use TIMES_2 scale
2899 // factor in the addressing mode to compensate for this. 2899 // factor in the addressing mode to compensate for this.
2900 movzxw(scratch, Address(object, TIMES_2, class_id_offset)); 2900 movzxw(scratch, Address(object, TIMES_2, class_id_offset));
2901 cmpl(scratch, Immediate(class_id)); 2901 cmpl(scratch, Immediate(class_id));
2902 } 2902 }
2903 2903
2904 2904
2905 void Assembler::LoadClassIdMayBeSmi(Register result, Register object) { 2905 void Assembler::LoadClassIdMayBeSmi(Register result, Register object) {
2906 ASSERT(result != object); 2906 if (result == object) {
2907 static const intptr_t kSmiCidSource = kSmiCid << RawObject::kClassIdTagPos; 2907 Label smi, join;
2908 2908
2909 // Make a dummy "Object" whose cid is kSmiCid. 2909 testl(object, Immediate(kSmiTagMask));
2910 movl(result, Immediate(reinterpret_cast<int32_t>(&kSmiCidSource) + 1)); 2910 j(EQUAL, &smi, Assembler::kNearJump);
2911 LoadClassId(result, object);
2912 jmp(&join, Assembler::kNearJump);
2911 2913
2912 // Check if object (in tmp) is a Smi. 2914 Bind(&smi);
2913 testl(object, Immediate(kSmiTagMask)); 2915 movl(result, Immediate(kSmiCid));
2914 2916
2915 // If the object is not a Smi, use the original object to load the cid. 2917 Bind(&join);
2916 // Otherwise, the dummy object is used, and the result is kSmiCid. 2918 } else {
2917 cmovne(result, object); 2919 ASSERT(result != object);
2918 LoadClassId(result, result); 2920 static const intptr_t kSmiCidSource = kSmiCid << RawObject::kClassIdTagPos;
2921
2922 // Make a dummy "Object" whose cid is kSmiCid.
2923 movl(result, Immediate(reinterpret_cast<int32_t>(&kSmiCidSource) + 1));
2924
2925 // Check if object (in tmp) is a Smi.
2926 testl(object, Immediate(kSmiTagMask));
2927
2928 // If the object is not a Smi, use the original object to load the cid.
2929 // Otherwise, the dummy object is used, and the result is kSmiCid.
2930 cmovne(result, object);
2931 LoadClassId(result, result);
2932 }
2919 } 2933 }
2920 2934
2921 2935
2922 void Assembler::LoadTaggedClassIdMayBeSmi(Register result, Register object) { 2936 void Assembler::LoadTaggedClassIdMayBeSmi(Register result, Register object) {
2923 LoadClassIdMayBeSmi(result, object); 2937 if (result == object) {
2924 // Tag the result. 2938 Label smi, join;
2925 SmiTag(result); 2939
2940 testl(object, Immediate(kSmiTagMask));
2941 j(EQUAL, &smi, Assembler::kNearJump);
2942 LoadClassId(result, object);
2943 SmiTag(result);
2944 jmp(&join, Assembler::kNearJump);
2945
2946 Bind(&smi);
2947 movl(result, Immediate(Smi::RawValue(kSmiCid)));
2948
2949 Bind(&join);
2950 } else {
2951 LoadClassIdMayBeSmi(result, object);
2952 SmiTag(result);
2953 }
2926 } 2954 }
2927 2955
2928 2956
2929 Address Assembler::ElementAddressForIntIndex(bool is_external, 2957 Address Assembler::ElementAddressForIntIndex(bool is_external,
2930 intptr_t cid, 2958 intptr_t cid,
2931 intptr_t index_scale, 2959 intptr_t index_scale,
2932 Register array, 2960 Register array,
2933 intptr_t index) { 2961 intptr_t index) {
2934 if (is_external) { 2962 if (is_external) {
2935 return Address(array, index * index_scale); 2963 return Address(array, index * index_scale);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2995 3023
2996 const char* Assembler::FpuRegisterName(FpuRegister reg) { 3024 const char* Assembler::FpuRegisterName(FpuRegister reg) {
2997 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); 3025 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters));
2998 return xmm_reg_names[reg]; 3026 return xmm_reg_names[reg];
2999 } 3027 }
3000 3028
3001 3029
3002 } // namespace dart 3030 } // namespace dart
3003 3031
3004 #endif // defined TARGET_ARCH_IA32 3032 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/stub_code_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698