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

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

Issue 11411142: Support loads from Uint8Array and ExternalUint8Array in the optimizing compiler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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.cc ('k') | runtime/vm/intermediate_language_x64.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
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 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 } else { 1162 } else {
1163 locs->set_out(Location::RequiresRegister()); 1163 locs->set_out(Location::RequiresRegister());
1164 } 1164 }
1165 return locs; 1165 return locs;
1166 } 1166 }
1167 1167
1168 1168
1169 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1169 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1170 Register array = locs()->in(0).reg(); 1170 Register array = locs()->in(0).reg();
1171 Location index = locs()->in(1); 1171 Location index = locs()->in(1);
1172
1173 if (class_id() == kExternalUint8ArrayCid) {
1174 Register result = locs()->out().reg();
1175 Address element_address = index.IsRegister()
1176 ? Address(result, index.reg(), TIMES_1, 0)
1177 : Address(result, Smi::Cast(index.constant()).Value());
1178 if (index.IsRegister()) {
1179 __ SmiUntag(index.reg());
1180 }
1181 __ movl(result,
1182 FieldAddress(array, ExternalUint8Array::external_data_offset()));
1183 __ movl(result,
1184 Address(result, ExternalByteArrayData<uint8_t>::data_offset()));
1185 __ movzxb(result, element_address);
1186 __ SmiTag(result);
1187 if (index.IsRegister()) {
1188 __ SmiTag(index.reg()); // Re-tag.
1189 }
1190 return;
1191 }
1192
1172 FieldAddress element_address = index.IsRegister() ? 1193 FieldAddress element_address = index.IsRegister() ?
1173 FlowGraphCompiler::ElementAddressForRegIndex( 1194 FlowGraphCompiler::ElementAddressForRegIndex(
1174 class_id(), array, index.reg()) : 1195 class_id(), array, index.reg()) :
1175 FlowGraphCompiler::ElementAddressForIntIndex( 1196 FlowGraphCompiler::ElementAddressForIntIndex(
1176 class_id(), array, Smi::Cast(index.constant()).Value()); 1197 class_id(), array, Smi::Cast(index.constant()).Value());
1177 1198
1178 if (representation() == kUnboxedDouble) { 1199 if (representation() == kUnboxedDouble) {
1200 XmmRegister result = locs()->out().xmm_reg();
1179 if (class_id() == kFloat32ArrayCid) { 1201 if (class_id() == kFloat32ArrayCid) {
1180 // Load single precision float. 1202 // Load single precision float.
1181 __ movss(locs()->out().xmm_reg(), element_address); 1203 __ movss(result, element_address);
1182 // Promote to double. 1204 // Promote to double.
1183 __ cvtss2sd(locs()->out().xmm_reg(), locs()->out().xmm_reg()); 1205 __ cvtss2sd(result, locs()->out().xmm_reg());
1184 } else { 1206 } else {
1185 ASSERT(class_id() == kFloat64ArrayCid); 1207 ASSERT(class_id() == kFloat64ArrayCid);
1186 __ movsd(locs()->out().xmm_reg(), element_address); 1208 __ movsd(result, element_address);
1187 } 1209 }
1188 } else { 1210 return;
1189 __ movl(locs()->out().reg(), element_address);
1190 } 1211 }
1212
1213 Register result = locs()->out().reg();
1214 if (class_id() == kUint8ArrayCid) {
1215 if (index.IsRegister()) {
1216 __ SmiUntag(index.reg());
1217 }
1218 __ movzxb(result, element_address);
1219 __ SmiTag(result);
1220 if (index.IsRegister()) {
1221 __ SmiTag(index.reg()); // Re-tag.
1222 }
1223 return;
1224 }
1225
1226 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid));
1227 __ movl(result, element_address);
1191 } 1228 }
1192 1229
1193 1230
1194 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { 1231 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const {
1195 const intptr_t kNumInputs = 3; 1232 const intptr_t kNumInputs = 3;
1196 const intptr_t kNumTemps = class_id() == kFloat32ArrayCid ? 1 : 0; 1233 const intptr_t kNumTemps = class_id() == kFloat32ArrayCid ? 1 : 0;
1197 LocationSummary* locs = 1234 LocationSummary* locs =
1198 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 1235 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
1199 if (class_id() == kFloat32ArrayCid) { 1236 if (class_id() == kFloat32ArrayCid) {
1200 locs->set_temp(0, Location::RequiresXmmRegister()); 1237 locs->set_temp(0, Location::RequiresXmmRegister());
(...skipping 30 matching lines...) Expand all
1231 // Store. 1268 // Store.
1232 __ movss(element_address, locs()->temp(0).xmm_reg()); 1269 __ movss(element_address, locs()->temp(0).xmm_reg());
1233 return; 1270 return;
1234 } 1271 }
1235 1272
1236 if (class_id() == kFloat64ArrayCid) { 1273 if (class_id() == kFloat64ArrayCid) {
1237 __ movsd(element_address, locs()->in(2).xmm_reg()); 1274 __ movsd(element_address, locs()->in(2).xmm_reg());
1238 return; 1275 return;
1239 } 1276 }
1240 1277
1278 ASSERT(class_id() == kArrayCid);
1241 if (ShouldEmitStoreBarrier()) { 1279 if (ShouldEmitStoreBarrier()) {
1242 Register value = locs()->in(2).reg(); 1280 Register value = locs()->in(2).reg();
1243 __ StoreIntoObject(array, element_address, value); 1281 __ StoreIntoObject(array, element_address, value);
1244 return; 1282 return;
1245 } 1283 }
1246 1284
1247 if (locs()->in(2).IsConstant()) { 1285 if (locs()->in(2).IsConstant()) {
1248 const Object& constant = locs()->in(2).constant(); 1286 const Object& constant = locs()->in(2).constant();
1249 __ StoreIntoObjectNoBarrier(array, element_address, constant); 1287 __ StoreIntoObjectNoBarrier(array, element_address, constant);
1250 } else { 1288 } else {
(...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after
2752 __ pcmpeqq(XMM0, XMM0); // Generate all 1's. 2790 __ pcmpeqq(XMM0, XMM0); // Generate all 1's.
2753 __ pxor(value, XMM0); 2791 __ pxor(value, XMM0);
2754 } 2792 }
2755 2793
2756 2794
2757 } // namespace dart 2795 } // namespace dart
2758 2796
2759 #undef __ 2797 #undef __
2760 2798
2761 #endif // defined TARGET_ARCH_X64 2799 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698