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

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

Issue 683433003: Integrate the Irregexp Regular Expression Engine. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: more comments Created 6 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_arm64.cc ('k') | runtime/vm/intermediate_language_mips.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" // 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 "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 } 1192 }
1193 break; 1193 break;
1194 default: 1194 default:
1195 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); 1195 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid));
1196 __ movl(result, element_address); 1196 __ movl(result, element_address);
1197 break; 1197 break;
1198 } 1198 }
1199 } 1199 }
1200 1200
1201 1201
1202 Representation LoadCodeUnitsInstr::representation() const {
1203 switch (class_id()) {
1204 case kOneByteStringCid:
1205 case kExternalOneByteStringCid:
1206 case kTwoByteStringCid:
1207 case kExternalTwoByteStringCid:
1208 // TODO(zerny): kUnboxedUint32 could be a better choice.
1209 return can_pack_into_smi() ? kTagged : kUnboxedMint;
1210 default:
1211 UNIMPLEMENTED();
1212 return kTagged;
1213 }
1214 }
1215
1216
1217 LocationSummary* LoadCodeUnitsInstr::MakeLocationSummary(Isolate* isolate,
1218 bool opt) const {
1219 const intptr_t kNumInputs = 2;
1220 const intptr_t kNumTemps = 0;
1221 LocationSummary* summary = new(isolate) LocationSummary(
1222 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
1223 summary->set_in(0, Location::RequiresRegister());
1224 // The smi index is either untagged (element size == 1), or it is left smi
1225 // tagged (for all element sizes > 1).
1226 summary->set_in(1, (index_scale() == 1) ? Location::WritableRegister()
1227 : Location::RequiresRegister());
1228
1229 if (representation() == kUnboxedMint) {
1230 summary->set_out(0, Location::Pair(Location::RequiresRegister(),
1231 Location::RequiresRegister()));
1232 } else {
1233 ASSERT(representation() == kTagged);
1234 summary->set_out(0, Location::RequiresRegister());
1235 }
1236
1237 return summary;
1238 }
1239
1240
1241 void LoadCodeUnitsInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1242 const Register array = locs()->in(0).reg();
1243 const Location index = locs()->in(1);
1244
1245 Address element_address = Assembler::ElementAddressForRegIndex(
1246 IsExternal(), class_id(), index_scale(), array, index.reg());
1247
1248 if ((index_scale() == 1)) {
1249 __ SmiUntag(index.reg());
1250 }
1251
1252 if (representation() == kUnboxedMint) {
1253 ASSERT(locs()->out(0).IsPairLocation());
1254 PairLocation* result_pair = locs()->out(0).AsPairLocation();
1255 Register result1 = result_pair->At(0).reg();
1256 Register result2 = result_pair->At(1).reg();
1257 switch (class_id()) {
1258 case kOneByteStringCid:
1259 case kExternalOneByteStringCid:
1260 ASSERT(element_count() == 4);
1261 __ movl(result1, element_address);
1262 __ xorl(result2, result2);
1263 break;
1264 case kTwoByteStringCid:
1265 case kExternalTwoByteStringCid:
1266 ASSERT(element_count() == 2);
1267 __ movl(result1, element_address);
1268 __ xorl(result2, result2);
1269 break;
1270 default:
1271 UNREACHABLE();
1272 }
1273 } else {
1274 ASSERT(representation() == kTagged);
1275 Register result = locs()->out(0).reg();
1276 switch (class_id()) {
1277 case kOneByteStringCid:
1278 case kExternalOneByteStringCid:
1279 switch (element_count()) {
1280 case 1: __ movzxb(result, element_address); break;
1281 case 2: __ movzxw(result, element_address); break;
1282 default: UNREACHABLE();
1283 }
1284 __ SmiTag(result);
1285 break;
1286 case kTwoByteStringCid:
1287 case kExternalTwoByteStringCid:
1288 switch (element_count()) {
1289 case 1: __ movzxw(result, element_address); break;
1290 default: UNREACHABLE();
1291 }
1292 __ SmiTag(result);
1293 break;
1294 default:
1295 UNREACHABLE();
1296 break;
1297 }
1298 }
1299 }
1300
1301
1202 Representation StoreIndexedInstr::RequiredInputRepresentation( 1302 Representation StoreIndexedInstr::RequiredInputRepresentation(
1203 intptr_t idx) const { 1303 intptr_t idx) const {
1204 // Array can be a Dart object or a pointer to external data. 1304 // Array can be a Dart object or a pointer to external data.
1205 if (idx == 0) return kNoRepresentation; // Flexible input representation. 1305 if (idx == 0) return kNoRepresentation; // Flexible input representation.
1206 if (idx == 1) return kTagged; // Index is a smi. 1306 if (idx == 1) return kTagged; // Index is a smi.
1207 ASSERT(idx == 2); 1307 ASSERT(idx == 2);
1208 switch (class_id_) { 1308 switch (class_id_) {
1209 case kArrayCid: 1309 case kArrayCid:
1210 case kOneByteStringCid: 1310 case kOneByteStringCid:
1211 case kTypedDataInt8ArrayCid: 1311 case kTypedDataInt8ArrayCid:
(...skipping 3572 matching lines...) Expand 10 before | Expand all | Expand 10 after
4784 __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg()); 4884 __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg());
4785 __ CallRuntime(TargetFunction(), InputCount()); 4885 __ CallRuntime(TargetFunction(), InputCount());
4786 __ fstpl(Address(ESP, 0)); 4886 __ fstpl(Address(ESP, 0));
4787 __ movsd(locs()->out(0).fpu_reg(), Address(ESP, 0)); 4887 __ movsd(locs()->out(0).fpu_reg(), Address(ESP, 0));
4788 // Restore ESP. 4888 // Restore ESP.
4789 __ movl(ESP, locs()->temp(0).reg()); 4889 __ movl(ESP, locs()->temp(0).reg());
4790 } 4890 }
4791 } 4891 }
4792 4892
4793 4893
4894 LocationSummary* CaseInsensitiveCompareUC16Instr::MakeLocationSummary(
4895 Isolate* isolate, bool opt) const {
4896 const intptr_t kNumTemps = 0;
4897 LocationSummary* summary = new(isolate) LocationSummary(
4898 isolate, InputCount(), kNumTemps, LocationSummary::kCall);
4899 summary->set_in(0, Location::RegisterLocation(EAX));
4900 summary->set_in(1, Location::RegisterLocation(ECX));
4901 summary->set_in(2, Location::RegisterLocation(EDX));
4902 summary->set_in(3, Location::RegisterLocation(EBX));
4903 summary->set_out(0, Location::RegisterLocation(EAX));
4904 return summary;
4905 }
4906
4907
4908 void CaseInsensitiveCompareUC16Instr::EmitNativeCode(
4909 FlowGraphCompiler* compiler) {
4910
4911 // Save ESP. EDI is chosen because it is callee saved so we do not need to
4912 // back it up before calling into the runtime.
4913 static const Register kSavedSPReg = EDI;
4914 __ movl(kSavedSPReg, ESP);
4915 __ ReserveAlignedFrameSpace(kWordSize * TargetFunction().argument_count());
4916
4917 __ movl(Address(ESP, + 0 * kWordSize), locs()->in(0).reg());
4918 __ movl(Address(ESP, + 1 * kWordSize), locs()->in(1).reg());
4919 __ movl(Address(ESP, + 2 * kWordSize), locs()->in(2).reg());
4920 __ movl(Address(ESP, + 3 * kWordSize), locs()->in(3).reg());
4921
4922 // Call the function.
4923 __ CallRuntime(TargetFunction(), TargetFunction().argument_count());
4924
4925 // Restore ESP.
4926 __ movl(ESP, kSavedSPReg);
4927 }
4928
4929
4794 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate, 4930 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate,
4795 bool opt) const { 4931 bool opt) const {
4796 if (result_cid() == kDoubleCid) { 4932 if (result_cid() == kDoubleCid) {
4797 const intptr_t kNumInputs = 2; 4933 const intptr_t kNumInputs = 2;
4798 const intptr_t kNumTemps = 1; 4934 const intptr_t kNumTemps = 1;
4799 LocationSummary* summary = new(isolate) LocationSummary( 4935 LocationSummary* summary = new(isolate) LocationSummary(
4800 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); 4936 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
4801 summary->set_in(0, Location::RequiresFpuRegister()); 4937 summary->set_in(0, Location::RequiresFpuRegister());
4802 summary->set_in(1, Location::RequiresFpuRegister()); 4938 summary->set_in(1, Location::RequiresFpuRegister());
4803 // Reuse the left register so that code can be made shorter. 4939 // Reuse the left register so that code can be made shorter.
(...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after
6355 } 6491 }
6356 6492
6357 // We can fall through if the successor is the next block in the list. 6493 // We can fall through if the successor is the next block in the list.
6358 // Otherwise, we need a jump. 6494 // Otherwise, we need a jump.
6359 if (!compiler->CanFallThroughTo(successor())) { 6495 if (!compiler->CanFallThroughTo(successor())) {
6360 __ jmp(compiler->GetJumpLabel(successor())); 6496 __ jmp(compiler->GetJumpLabel(successor()));
6361 } 6497 }
6362 } 6498 }
6363 6499
6364 6500
6501 LocationSummary* IndirectGotoInstr::MakeLocationSummary(Isolate* isolate,
6502 bool opt) const {
6503 const intptr_t kNumInputs = 1;
6504 const intptr_t kNumTemps = 1;
6505
6506 LocationSummary* summary = new(isolate) LocationSummary(
6507 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
6508
6509 summary->set_in(0, Location::RequiresRegister());
6510 summary->set_temp(0, Location::RequiresRegister());
6511
6512 return summary;
6513 }
6514
6515
6516 void IndirectGotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
6517 Register target_address_reg = locs()->temp_slot(0)->reg();
6518
6519 // Load from [current frame pointer] + kPcMarkerSlotFromFp.
6520 __ movl(target_address_reg, Address(EBP, kPcMarkerSlotFromFp * kWordSize));
6521
6522 // Add the offset.
6523 Register offset_reg = locs()->in(0).reg();
6524 __ SmiUntag(offset_reg);
6525 __ addl(target_address_reg, offset_reg);
6526
6527 // Jump to the absolute address.
6528 __ jmp(target_address_reg);
6529 }
6530
6531
6365 LocationSummary* StrictCompareInstr::MakeLocationSummary(Isolate* isolate, 6532 LocationSummary* StrictCompareInstr::MakeLocationSummary(Isolate* isolate,
6366 bool opt) const { 6533 bool opt) const {
6367 const intptr_t kNumInputs = 2; 6534 const intptr_t kNumInputs = 2;
6368 const intptr_t kNumTemps = 0; 6535 const intptr_t kNumTemps = 0;
6369 if (needs_number_check()) { 6536 if (needs_number_check()) {
6370 LocationSummary* locs = new(isolate) LocationSummary( 6537 LocationSummary* locs = new(isolate) LocationSummary(
6371 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); 6538 isolate, kNumInputs, kNumTemps, LocationSummary::kCall);
6372 locs->set_in(0, Location::RegisterLocation(EAX)); 6539 locs->set_in(0, Location::RegisterLocation(EAX));
6373 locs->set_in(1, Location::RegisterLocation(ECX)); 6540 locs->set_in(1, Location::RegisterLocation(ECX));
6374 locs->set_out(0, Location::RegisterLocation(EAX)); 6541 locs->set_out(0, Location::RegisterLocation(EAX));
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
6608 #if defined(DEBUG) 6775 #if defined(DEBUG)
6609 __ movl(EDX, Immediate(kInvalidObjectPointer)); 6776 __ movl(EDX, Immediate(kInvalidObjectPointer));
6610 #endif 6777 #endif
6611 } 6778 }
6612 6779
6613 } // namespace dart 6780 } // namespace dart
6614 6781
6615 #undef __ 6782 #undef __
6616 6783
6617 #endif // defined TARGET_ARCH_IA32 6784 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_arm64.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698