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

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

Issue 10916090: Support immediate operands for array bounds checks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comment Created 8 years, 3 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 | « no previous file | 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 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 1428
1429 __ cmpl(ESP, 1429 __ cmpl(ESP,
1430 Address::Absolute(Isolate::Current()->stack_limit_address())); 1430 Address::Absolute(Isolate::Current()->stack_limit_address()));
1431 __ j(BELOW_EQUAL, slow_path->entry_label()); 1431 __ j(BELOW_EQUAL, slow_path->entry_label());
1432 __ Bind(slow_path->exit_label()); 1432 __ Bind(slow_path->exit_label());
1433 } 1433 }
1434 1434
1435 1435
1436 LocationSummary* BinarySmiOpComp::MakeLocationSummary() const { 1436 LocationSummary* BinarySmiOpComp::MakeLocationSummary() const {
1437 const intptr_t kNumInputs = 2; 1437 const intptr_t kNumInputs = 2;
1438
1439 ConstantComp* right_constant = right()->definition()->AsConstant();
1440 if ((right_constant != NULL) &&
1441 (op_kind() != Token::kTRUNCDIV) &&
1442 (op_kind() != Token::kSHL)) {
1443 const intptr_t kNumTemps = 0;
1444 LocationSummary* summary =
1445 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
1446 summary->set_in(0, Location::RequiresRegister());
1447 summary->set_in(1, Location::Constant(right_constant->value()));
1448 summary->set_out(Location::SameAsFirstInput());
1449 return summary;
1450 }
1451
1452 if (op_kind() == Token::kTRUNCDIV) { 1438 if (op_kind() == Token::kTRUNCDIV) {
1453 const intptr_t kNumTemps = 3; 1439 const intptr_t kNumTemps = 3;
1454 LocationSummary* summary = 1440 LocationSummary* summary =
1455 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 1441 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
1456 summary->set_in(0, Location::RegisterLocation(EAX)); 1442 summary->set_in(0, Location::RegisterLocation(EAX));
1457 summary->set_in(1, Location::RegisterLocation(ECX)); 1443 summary->set_in(1, Location::RegisterLocation(ECX));
1458 summary->set_out(Location::SameAsFirstInput()); 1444 summary->set_out(Location::SameAsFirstInput());
1459 summary->set_temp(0, Location::RegisterLocation(EBX)); 1445 summary->set_temp(0, Location::RegisterLocation(EBX));
1460 // Will be used for for sign extension. 1446 // Will be used for for sign extension.
1461 summary->set_temp(1, Location::RegisterLocation(EDX)); 1447 summary->set_temp(1, Location::RegisterLocation(EDX));
1462 summary->set_temp(2, Location::RequiresRegister()); 1448 summary->set_temp(2, Location::RequiresRegister());
1463 return summary; 1449 return summary;
1464 } else if (op_kind() == Token::kSHR) { 1450 } else if (op_kind() == Token::kSHR) {
1465 const intptr_t kNumTemps = 0; 1451 const intptr_t kNumTemps = 0;
1466 LocationSummary* summary = 1452 LocationSummary* summary =
1467 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 1453 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
1468 summary->set_in(0, Location::RequiresRegister()); 1454 summary->set_in(0, Location::RequiresRegister());
1469 summary->set_in(1, Location::RegisterLocation(ECX)); 1455 summary->set_in(1, Location::FixedRegisterOrConstant(right(), ECX));
1470 summary->set_out(Location::SameAsFirstInput()); 1456 summary->set_out(Location::SameAsFirstInput());
1471 return summary; 1457 return summary;
1472 } else if (op_kind() == Token::kSHL) { 1458 } else if (op_kind() == Token::kSHL) {
1473 // Two Smi operands can easily overflow into Mint. 1459 // Two Smi operands can easily overflow into Mint.
1474 const intptr_t kNumTemps = 2; 1460 const intptr_t kNumTemps = 2;
1475 LocationSummary* summary = 1461 LocationSummary* summary =
1476 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); 1462 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
1477 summary->set_in(0, Location::RegisterLocation(EAX)); 1463 summary->set_in(0, Location::RegisterLocation(EAX));
1478 summary->set_in(1, Location::RegisterLocation(EDX)); 1464 summary->set_in(1, Location::RegisterLocation(EDX));
1479 summary->set_temp(0, Location::RegisterLocation(EBX)); 1465 summary->set_temp(0, Location::RegisterLocation(EBX));
1480 summary->set_temp(1, Location::RegisterLocation(ECX)); 1466 summary->set_temp(1, Location::RegisterLocation(ECX));
1481 summary->set_out(Location::RegisterLocation(EAX)); 1467 summary->set_out(Location::RegisterLocation(EAX));
1482 return summary; 1468 return summary;
1483 } else { 1469 } else {
1484 const intptr_t kNumTemps = 0; 1470 const intptr_t kNumTemps = 0;
1485 LocationSummary* summary = 1471 LocationSummary* summary =
1486 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 1472 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
1487 summary->set_in(0, Location::RequiresRegister()); 1473 summary->set_in(0, Location::RequiresRegister());
1488 summary->set_in(1, Location::RequiresRegister()); 1474 summary->set_in(1, Location::RegisterOrConstant(right()));
1489 summary->set_out(Location::SameAsFirstInput()); 1475 summary->set_out(Location::SameAsFirstInput());
1490 return summary; 1476 return summary;
1491 } 1477 }
1492 } 1478 }
1493 1479
1494 1480
1495 void BinarySmiOpComp::EmitNativeCode(FlowGraphCompiler* compiler) { 1481 void BinarySmiOpComp::EmitNativeCode(FlowGraphCompiler* compiler) {
1496 Register left = locs()->in(0).reg(); 1482 Register left = locs()->in(0).reg();
1497 Register result = locs()->out().reg(); 1483 Register result = locs()->out().reg();
1498 ASSERT(left == result); 1484 ASSERT(left == result);
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 void CheckSmiComp::EmitNativeCode(FlowGraphCompiler* compiler) { 2204 void CheckSmiComp::EmitNativeCode(FlowGraphCompiler* compiler) {
2219 Register value = locs()->in(0).reg(); 2205 Register value = locs()->in(0).reg();
2220 Label* deopt = compiler->AddDeoptStub(deopt_id(), 2206 Label* deopt = compiler->AddDeoptStub(deopt_id(),
2221 kDeoptCheckSmi); 2207 kDeoptCheckSmi);
2222 __ testl(value, Immediate(kSmiTagMask)); 2208 __ testl(value, Immediate(kSmiTagMask));
2223 __ j(NOT_ZERO, deopt); 2209 __ j(NOT_ZERO, deopt);
2224 } 2210 }
2225 2211
2226 2212
2227 LocationSummary* CheckArrayBoundComp::MakeLocationSummary() const { 2213 LocationSummary* CheckArrayBoundComp::MakeLocationSummary() const {
2228 return LocationSummary::Make(2, 2214 const intptr_t kNumInputs = 2;
2229 Location::NoLocation(), 2215 const intptr_t kNumTemps = 0;
2230 LocationSummary::kNoCall); 2216 LocationSummary* locs =
2217 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
2218 locs->set_in(0, Location::RequiresRegister());
2219 locs->set_in(1, Location::RegisterOrConstant(index()));
2220 return locs;
2231 } 2221 }
2232 2222
2233 2223
2234 void CheckArrayBoundComp::EmitNativeCode(FlowGraphCompiler* compiler) { 2224 void CheckArrayBoundComp::EmitNativeCode(FlowGraphCompiler* compiler) {
2235 Register receiver = locs()->in(0).reg(); 2225 Register receiver = locs()->in(0).reg();
2236 Register index = locs()->in(1).reg();
2237 2226
2238 const DeoptReasonId deopt_reason = 2227 const DeoptReasonId deopt_reason =
2239 (array_type() == kGrowableObjectArrayCid) ? 2228 (array_type() == kGrowableObjectArrayCid) ?
2240 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; 2229 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray;
2241 Label* deopt = compiler->AddDeoptStub(deopt_id(), 2230 Label* deopt = compiler->AddDeoptStub(deopt_id(),
2242 deopt_reason); 2231 deopt_reason);
2243 switch (array_type()) { 2232 ASSERT(array_type() == kArrayCid ||
2244 case kArrayCid: 2233 array_type() == kImmutableArrayCid ||
2245 case kImmutableArrayCid: 2234 array_type() == kGrowableObjectArrayCid);
2246 __ cmpl(index, FieldAddress(receiver, Array::length_offset())); 2235 intptr_t length_offset = (array_type() == kGrowableObjectArrayCid)
2247 break; 2236 ? GrowableObjectArray::length_offset()
2248 case kGrowableObjectArrayCid: 2237 : Array::length_offset();
2249 __ cmpl(index, 2238
2250 FieldAddress(receiver, GrowableObjectArray::length_offset())); 2239 if (locs()->in(1).IsConstant()) {
2251 break; 2240 const Object& constant = locs()->in(1).constant();
2241 ASSERT(constant.IsSmi());
2242 const int32_t imm =
2243 reinterpret_cast<int32_t>(constant.raw());
2244 __ cmpl(FieldAddress(receiver, length_offset), Immediate(imm));
2245 __ j(BELOW_EQUAL, deopt);
2246 } else {
2247 Register index = locs()->in(1).reg();
2248 __ cmpl(index, FieldAddress(receiver, length_offset));
2249 __ j(ABOVE_EQUAL, deopt);
2252 } 2250 }
2253 __ j(ABOVE_EQUAL, deopt);
2254 } 2251 }
2255 2252
2256 2253
2257 } // namespace dart 2254 } // namespace dart
2258 2255
2259 #undef __ 2256 #undef __
2260 2257
2261 #endif // defined TARGET_ARCH_X64 2258 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698