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

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

Issue 12225049: Add optimized loads from ExternalUint8ClampedArrays. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language_ia32.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 (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" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 case kArrayCid: 963 case kArrayCid:
964 case kImmutableArrayCid: 964 case kImmutableArrayCid:
965 return kDynamicCid; 965 return kDynamicCid;
966 case kFloat32ArrayCid : 966 case kFloat32ArrayCid :
967 case kFloat64ArrayCid : 967 case kFloat64ArrayCid :
968 return kDoubleCid; 968 return kDoubleCid;
969 case kInt8ArrayCid: 969 case kInt8ArrayCid:
970 case kUint8ArrayCid: 970 case kUint8ArrayCid:
971 case kUint8ClampedArrayCid: 971 case kUint8ClampedArrayCid:
972 case kExternalUint8ArrayCid: 972 case kExternalUint8ArrayCid:
973 case kExternalUint8ClampedArrayCid:
973 case kInt16ArrayCid: 974 case kInt16ArrayCid:
974 case kUint16ArrayCid: 975 case kUint16ArrayCid:
975 case kOneByteStringCid: 976 case kOneByteStringCid:
976 case kTwoByteStringCid: 977 case kTwoByteStringCid:
977 case kInt32ArrayCid: 978 case kInt32ArrayCid:
978 case kUint32ArrayCid: 979 case kUint32ArrayCid:
979 return kSmiCid; 980 return kSmiCid;
980 default: 981 default:
981 UNIMPLEMENTED(); 982 UNIMPLEMENTED();
982 return kSmiCid; 983 return kSmiCid;
983 } 984 }
984 } 985 }
985 986
986 987
987 Representation LoadIndexedInstr::representation() const { 988 Representation LoadIndexedInstr::representation() const {
988 switch (class_id_) { 989 switch (class_id_) {
989 case kArrayCid: 990 case kArrayCid:
990 case kImmutableArrayCid: 991 case kImmutableArrayCid:
991 case kInt8ArrayCid: 992 case kInt8ArrayCid:
992 case kUint8ArrayCid: 993 case kUint8ArrayCid:
993 case kUint8ClampedArrayCid: 994 case kUint8ClampedArrayCid:
994 case kExternalUint8ArrayCid: 995 case kExternalUint8ArrayCid:
996 case kExternalUint8ClampedArrayCid:
995 case kInt16ArrayCid: 997 case kInt16ArrayCid:
996 case kUint16ArrayCid: 998 case kUint16ArrayCid:
997 case kOneByteStringCid: 999 case kOneByteStringCid:
998 case kTwoByteStringCid: 1000 case kTwoByteStringCid:
999 case kInt32ArrayCid: 1001 case kInt32ArrayCid:
1000 case kUint32ArrayCid: 1002 case kUint32ArrayCid:
1001 return kTagged; 1003 return kTagged;
1002 case kFloat32ArrayCid : 1004 case kFloat32ArrayCid :
1003 case kFloat64ArrayCid : 1005 case kFloat64ArrayCid :
1004 return kUnboxedDouble; 1006 return kUnboxedDouble;
(...skipping 22 matching lines...) Expand all
1027 locs->set_out(Location::RequiresRegister()); 1029 locs->set_out(Location::RequiresRegister());
1028 } 1030 }
1029 return locs; 1031 return locs;
1030 } 1032 }
1031 1033
1032 1034
1033 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1035 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1034 Register array = locs()->in(0).reg(); 1036 Register array = locs()->in(0).reg();
1035 Location index = locs()->in(1); 1037 Location index = locs()->in(1);
1036 1038
1037 if (class_id() == kExternalUint8ArrayCid) { 1039 if ((class_id() == kExternalUint8ArrayCid) ||
1040 (class_id() == kExternalUint8ClampedArrayCid)) {
1038 Register result = locs()->out().reg(); 1041 Register result = locs()->out().reg();
1039 Address element_address = index.IsRegister() 1042 Address element_address = index.IsRegister()
1040 ? FlowGraphCompiler::ExternalElementAddressForRegIndex( 1043 ? FlowGraphCompiler::ExternalElementAddressForRegIndex(
1041 class_id(), index_scale(), result, index.reg()) 1044 class_id(), index_scale(), result, index.reg())
1042 : FlowGraphCompiler::ExternalElementAddressForIntIndex( 1045 : FlowGraphCompiler::ExternalElementAddressForIntIndex(
1043 class_id(), index_scale(), result, 1046 class_id(), index_scale(), result,
1044 Smi::Cast(index.constant()).Value()); 1047 Smi::Cast(index.constant()).Value());
1045 ASSERT(index_scale() == 1); 1048 ASSERT(index_scale() == 1);
1046 if (index.IsRegister()) { 1049 if (index.IsRegister()) {
1047 __ SmiUntag(index.reg()); 1050 __ SmiUntag(index.reg());
1048 } 1051 }
1049 __ movq(result, 1052 __ movq(result,
1050 FieldAddress(array, ExternalUint8Array::data_offset())); 1053 FieldAddress(array, ExternalUint8Array::data_offset()));
1051 __ movzxb(result, element_address); 1054 __ movzxb(result, element_address);
1052 __ SmiTag(result); 1055 __ SmiTag(result);
1053 if (index.IsRegister()) { 1056 if (index.IsRegister()) {
1054 __ SmiTag(index.reg()); // Re-tag. 1057 __ SmiTag(index.reg()); // Re-tag.
1055 } 1058 }
1056 return; 1059 return;
1057 } 1060 }
1058 1061
1059 FieldAddress element_address = index.IsRegister() 1062 FieldAddress element_address = index.IsRegister()
1060 ? FlowGraphCompiler::ElementAddressForRegIndex( 1063 ? FlowGraphCompiler::ElementAddressForRegIndex(
1061 class_id(), index_scale(), array, index.reg()) 1064 class_id(), index_scale(), array, index.reg())
1062 : FlowGraphCompiler::ElementAddressForIntIndex( 1065 : FlowGraphCompiler::ElementAddressForIntIndex(
1063 class_id(), index_scale(), array, 1066 class_id(), index_scale(), array,
1064 Smi::Cast(index.constant()).Value()); 1067 Smi::Cast(index.constant()).Value());
1065 1068
1066 if (representation() == kUnboxedDouble) { 1069 if (representation() == kUnboxedDouble) {
1067 if (index_scale() == 1 && index.IsRegister()) { 1070 if ((index_scale() == 1) && index.IsRegister()) {
1068 __ SmiUntag(index.reg()); 1071 __ SmiUntag(index.reg());
1069 } 1072 }
1070 1073
1071 XmmRegister result = locs()->out().fpu_reg(); 1074 XmmRegister result = locs()->out().fpu_reg();
1072 if (class_id() == kFloat32ArrayCid) { 1075 if (class_id() == kFloat32ArrayCid) {
1073 // Load single precision float. 1076 // Load single precision float.
1074 __ movss(result, element_address); 1077 __ movss(result, element_address);
1075 // Promote to double. 1078 // Promote to double.
1076 __ cvtss2sd(result, locs()->out().fpu_reg()); 1079 __ cvtss2sd(result, locs()->out().fpu_reg());
1077 } else { 1080 } else {
1078 ASSERT(class_id() == kFloat64ArrayCid); 1081 ASSERT(class_id() == kFloat64ArrayCid);
1079 __ movsd(result, element_address); 1082 __ movsd(result, element_address);
1080 } 1083 }
1081 1084
1082 if (index_scale() == 1 && index.IsRegister()) { 1085 if ((index_scale() == 1) && index.IsRegister()) {
1083 __ SmiTag(index.reg()); // Re-tag. 1086 __ SmiTag(index.reg()); // Re-tag.
1084 } 1087 }
1085 return; 1088 return;
1086 } 1089 }
1087 1090
1088 if (index_scale() == 1 && index.IsRegister()) { 1091 if ((index_scale() == 1) && index.IsRegister()) {
1089 __ SmiUntag(index.reg()); 1092 __ SmiUntag(index.reg());
1090 } 1093 }
1091 Register result = locs()->out().reg(); 1094 Register result = locs()->out().reg();
1092 switch (class_id()) { 1095 switch (class_id()) {
1093 case kInt8ArrayCid: 1096 case kInt8ArrayCid:
1094 case kUint8ArrayCid: 1097 case kUint8ArrayCid:
1095 case kUint8ClampedArrayCid: 1098 case kUint8ClampedArrayCid:
1096 case kOneByteStringCid: 1099 case kOneByteStringCid:
1097 if (class_id() == kInt8ArrayCid) { 1100 if (class_id() == kInt8ArrayCid) {
1098 __ movsxb(result, element_address); 1101 __ movsxb(result, element_address);
(...skipping 17 matching lines...) Expand all
1116 break; 1119 break;
1117 case kUint32ArrayCid: 1120 case kUint32ArrayCid:
1118 __ movl(result, element_address); 1121 __ movl(result, element_address);
1119 __ SmiTag(result); 1122 __ SmiTag(result);
1120 break; 1123 break;
1121 default: 1124 default:
1122 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); 1125 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid));
1123 __ movq(result, element_address); 1126 __ movq(result, element_address);
1124 break; 1127 break;
1125 } 1128 }
1126 if (index_scale() == 1 && index.IsRegister()) { 1129 if ((index_scale() == 1) && index.IsRegister()) {
1127 __ SmiTag(index.reg()); // Re-tag. 1130 __ SmiTag(index.reg()); // Re-tag.
1128 } 1131 }
1129 } 1132 }
1130 1133
1131 1134
1132 Representation StoreIndexedInstr::RequiredInputRepresentation( 1135 Representation StoreIndexedInstr::RequiredInputRepresentation(
1133 intptr_t idx) const { 1136 intptr_t idx) const {
1134 if ((idx == 0) || (idx == 1)) return kTagged; 1137 if ((idx == 0) || (idx == 1)) return kTagged;
1135 ASSERT(idx == 2); 1138 ASSERT(idx == 2);
1136 switch (class_id_) { 1139 switch (class_id_) {
(...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after
3040 PcDescriptors::kOther, 3043 PcDescriptors::kOther,
3041 locs()); 3044 locs());
3042 __ Drop(2); // Discard type arguments and receiver. 3045 __ Drop(2); // Discard type arguments and receiver.
3043 } 3046 }
3044 3047
3045 } // namespace dart 3048 } // namespace dart
3046 3049
3047 #undef __ 3050 #undef __
3048 3051
3049 #endif // defined TARGET_ARCH_X64 3052 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698