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

Side by Side Diff: runtime/vm/intermediate_language_x64.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 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) 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_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 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 locs->set_out(Location::RequiresRegister()); 1031 locs->set_out(Location::RequiresRegister());
1032 } 1032 }
1033 return locs; 1033 return locs;
1034 } 1034 }
1035 1035
1036 1036
1037 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1037 void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1038 Register array = locs()->in(0).reg(); 1038 Register array = locs()->in(0).reg();
1039 Location index = locs()->in(1); 1039 Location index = locs()->in(1);
1040 1040
1041 if (class_id() == kExternalUint8ArrayCid) {
1042 Register result = locs()->out().reg();
1043 Address element_address = index.IsRegister()
1044 ? Address(result, index.reg(), TIMES_1, 0)
1045 : Address(result, Smi::Cast(index.constant()).Value());
1046 if (index.IsRegister()) {
1047 __ SmiUntag(index.reg());
1048 }
1049 __ movq(result,
1050 FieldAddress(array, ExternalUint8Array::external_data_offset()));
1051 __ movq(result,
1052 Address(result, ExternalByteArrayData<uint8_t>::data_offset()));
1053 __ movzxb(result, element_address);
1054 __ SmiTag(result);
1055 if (index.IsRegister()) {
1056 __ SmiTag(index.reg()); // Re-tag.
1057 }
1058 return;
1059 }
1060
1041 FieldAddress element_address = index.IsRegister() ? 1061 FieldAddress element_address = index.IsRegister() ?
1042 FlowGraphCompiler::ElementAddressForRegIndex( 1062 FlowGraphCompiler::ElementAddressForRegIndex(
1043 class_id(), array, index.reg()) : 1063 class_id(), array, index.reg()) :
1044 FlowGraphCompiler::ElementAddressForIntIndex( 1064 FlowGraphCompiler::ElementAddressForIntIndex(
1045 class_id(), array, Smi::Cast(index.constant()).Value()); 1065 class_id(), array, Smi::Cast(index.constant()).Value());
1046 1066
1047 if (representation() == kUnboxedDouble) { 1067 if (representation() == kUnboxedDouble) {
1068 XmmRegister result = locs()->out().xmm_reg();
1048 if (class_id() == kFloat32ArrayCid) { 1069 if (class_id() == kFloat32ArrayCid) {
1049 // Load single precision float. 1070 // Load single precision float.
1050 __ movss(locs()->out().xmm_reg(), element_address); 1071 __ movss(result, element_address);
1051 // Promote to double. 1072 // Promote to double.
1052 __ cvtss2sd(locs()->out().xmm_reg(), locs()->out().xmm_reg()); 1073 __ cvtss2sd(result, locs()->out().xmm_reg());
1053 } else { 1074 } else {
1054 ASSERT(class_id() == kFloat64ArrayCid); 1075 ASSERT(class_id() == kFloat64ArrayCid);
1055 __ movsd(locs()->out().xmm_reg(), element_address); 1076 __ movsd(result, element_address);
1056 } 1077 }
1057 } else { 1078 return;
1058 __ movq(locs()->out().reg(), element_address);
1059 } 1079 }
1080
1081 Register result = locs()->out().reg();
1082 if (class_id() == kUint8ArrayCid) {
1083 if (index.IsRegister()) {
1084 __ SmiUntag(index.reg());
1085 }
1086 __ movzxb(result, element_address);
1087 __ SmiTag(result);
1088 if (index.IsRegister()) {
1089 __ SmiTag(index.reg()); // Re-tag.
1090 }
1091 return;
1092 }
1093
1094 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid));
1095 __ movq(result, element_address);
1060 } 1096 }
1061 1097
1062 1098
1063 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { 1099 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const {
1064 const intptr_t kNumInputs = 3; 1100 const intptr_t kNumInputs = 3;
1065 const intptr_t kNumTemps = class_id() == kFloat32ArrayCid ? 1 : 0; 1101 const intptr_t kNumTemps = class_id() == kFloat32ArrayCid ? 1 : 0;
1066 LocationSummary* locs = 1102 LocationSummary* locs =
1067 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 1103 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
1068 if (class_id() == kFloat32ArrayCid) { 1104 if (class_id() == kFloat32ArrayCid) {
1069 locs->set_temp(0, Location::RequiresXmmRegister()); 1105 locs->set_temp(0, Location::RequiresXmmRegister());
(...skipping 29 matching lines...) Expand all
1099 // Store. 1135 // Store.
1100 __ movss(element_address, locs()->temp(0).xmm_reg()); 1136 __ movss(element_address, locs()->temp(0).xmm_reg());
1101 return; 1137 return;
1102 } 1138 }
1103 1139
1104 if (class_id() == kFloat64ArrayCid) { 1140 if (class_id() == kFloat64ArrayCid) {
1105 __ movsd(element_address, locs()->in(2).xmm_reg()); 1141 __ movsd(element_address, locs()->in(2).xmm_reg());
1106 return; 1142 return;
1107 } 1143 }
1108 1144
1145 ASSERT(class_id() == kArrayCid);
1109 if (ShouldEmitStoreBarrier()) { 1146 if (ShouldEmitStoreBarrier()) {
1110 Register value = locs()->in(2).reg(); 1147 Register value = locs()->in(2).reg();
1111 __ StoreIntoObject(array, element_address, value); 1148 __ StoreIntoObject(array, element_address, value);
1112 return; 1149 return;
1113 } 1150 }
1114 1151
1115 if (locs()->in(2).IsConstant()) { 1152 if (locs()->in(2).IsConstant()) {
1116 const Object& constant = locs()->in(2).constant(); 1153 const Object& constant = locs()->in(2).constant();
1117 __ StoreObject(element_address, constant); 1154 __ StoreObject(element_address, constant);
1118 } else { 1155 } else {
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
2397 2434
2398 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2435 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2399 UNIMPLEMENTED(); 2436 UNIMPLEMENTED();
2400 } 2437 }
2401 2438
2402 } // namespace dart 2439 } // namespace dart
2403 2440
2404 #undef __ 2441 #undef __
2405 2442
2406 #endif // defined TARGET_ARCH_X64 2443 #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