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

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

Issue 2891113002: Use same range info when emitting code and computing if instruction can deopt. (Closed)
Patch Set: Add a comment to the test Created 3 years, 7 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
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/constant_propagator.h" 10 #include "vm/constant_propagator.h"
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 switch (op_kind()) { 1385 switch (op_kind()) {
1386 case Token::kBIT_AND: 1386 case Token::kBIT_AND:
1387 case Token::kBIT_OR: 1387 case Token::kBIT_OR:
1388 case Token::kBIT_XOR: 1388 case Token::kBIT_XOR:
1389 return false; 1389 return false;
1390 1390
1391 case Token::kSHR: 1391 case Token::kSHR:
1392 return false; 1392 return false;
1393 1393
1394 case Token::kSHL: 1394 case Token::kSHL:
1395 return can_overflow() || 1395 // Currently only shifts by in range constant are supported, see
1396 !RangeUtils::IsPositive(right()->definition()->range()); 1396 // BinaryInt32OpInstr::IsSupported.
1397 return can_overflow();
1397 1398
1398 case Token::kMOD: { 1399 case Token::kMOD: {
1399 UNREACHABLE(); 1400 UNREACHABLE();
1400 } 1401 }
1401 1402
1402 default: 1403 default:
1403 return can_overflow(); 1404 return can_overflow();
1404 } 1405 }
1405 } 1406 }
1406 1407
1407 1408
1408 bool BinarySmiOpInstr::ComputeCanDeoptimize() const { 1409 bool BinarySmiOpInstr::ComputeCanDeoptimize() const {
1409 switch (op_kind()) { 1410 switch (op_kind()) {
1410 case Token::kBIT_AND: 1411 case Token::kBIT_AND:
1411 case Token::kBIT_OR: 1412 case Token::kBIT_OR:
1412 case Token::kBIT_XOR: 1413 case Token::kBIT_XOR:
1413 return false; 1414 return false;
1414 1415
1415 case Token::kSHR: 1416 case Token::kSHR:
1416 return !RangeUtils::IsPositive(right()->definition()->range()); 1417 return !RangeUtils::IsPositive(right_range());
1417 1418
1418 case Token::kSHL: 1419 case Token::kSHL:
1419 return can_overflow() || 1420 return can_overflow() || !RangeUtils::IsPositive(right_range());
1420 !RangeUtils::IsPositive(right()->definition()->range());
1421 1421
1422 case Token::kMOD: { 1422 case Token::kMOD:
1423 Range* right_range = this->right()->definition()->range(); 1423 return RangeUtils::CanBeZero(right_range());
1424 return (right_range == NULL) || right_range->Overlaps(0, 0); 1424
1425 }
1426 default: 1425 default:
1427 return can_overflow(); 1426 return can_overflow();
1428 } 1427 }
1429 } 1428 }
1430 1429
1431 1430
1431 bool ShiftMintOpInstr::has_shift_count_check() const {
1432 return !RangeUtils::IsWithin(shift_range(), 0, kMintShiftCountLimit);
1433 }
1434
1435
1432 bool BinaryIntegerOpInstr::RightIsPowerOfTwoConstant() const { 1436 bool BinaryIntegerOpInstr::RightIsPowerOfTwoConstant() const {
1433 if (!right()->definition()->IsConstant()) return false; 1437 if (!right()->definition()->IsConstant()) return false;
1434 const Object& constant = right()->definition()->AsConstant()->value(); 1438 const Object& constant = right()->definition()->AsConstant()->value();
1435 if (!constant.IsSmi()) return false; 1439 if (!constant.IsSmi()) return false;
1436 const intptr_t int_value = Smi::Cast(constant).Value(); 1440 const intptr_t int_value = Smi::Cast(constant).Value();
1437 return Utils::IsPowerOfTwo(Utils::Abs(int_value)); 1441 return Utils::IsPowerOfTwo(Utils::Abs(int_value));
1438 } 1442 }
1439 1443
1440 1444
1441 static intptr_t RepresentationBits(Representation r) { 1445 static intptr_t RepresentationBits(Representation r) {
(...skipping 2795 matching lines...) Expand 10 before | Expand all | Expand 10 after
4237 UNREACHABLE(); 4241 UNREACHABLE();
4238 return ""; 4242 return "";
4239 } 4243 }
4240 4244
4241 4245
4242 const RuntimeEntry& CaseInsensitiveCompareUC16Instr::TargetFunction() const { 4246 const RuntimeEntry& CaseInsensitiveCompareUC16Instr::TargetFunction() const {
4243 return kCaseInsensitiveCompareUC16RuntimeEntry; 4247 return kCaseInsensitiveCompareUC16RuntimeEntry;
4244 } 4248 }
4245 4249
4246 4250
4247 MergedMathInstr::MergedMathInstr(ZoneGrowableArray<Value*>* inputs, 4251 TruncDivModInstr::TruncDivModInstr(Value* lhs, Value* rhs, intptr_t deopt_id)
4248 intptr_t deopt_id, 4252 : TemplateDefinition(deopt_id) {
4249 MergedMathInstr::Kind kind) 4253 SetInputAt(0, lhs);
4250 : PureDefinition(deopt_id), inputs_(inputs), kind_(kind) { 4254 SetInputAt(1, rhs);
4251 ASSERT(inputs_->length() == InputCountFor(kind_));
4252 for (intptr_t i = 0; i < inputs_->length(); ++i) {
4253 ASSERT((*inputs)[i] != NULL);
4254 (*inputs)[i]->set_instruction(this);
4255 (*inputs)[i]->set_use_index(i);
4256 }
4257 } 4255 }
4258 4256
4259 4257
4260 intptr_t MergedMathInstr::OutputIndexOf(MethodRecognizer::Kind kind) { 4258 intptr_t TruncDivModInstr::OutputIndexOf(Token::Kind token) {
4261 switch (kind) {
4262 case MethodRecognizer::kMathSin:
4263 return 1;
4264 case MethodRecognizer::kMathCos:
4265 return 0;
4266 default:
4267 UNIMPLEMENTED();
4268 return -1;
4269 }
4270 }
4271
4272
4273 intptr_t MergedMathInstr::OutputIndexOf(Token::Kind token) {
4274 switch (token) { 4259 switch (token) {
4275 case Token::kTRUNCDIV: 4260 case Token::kTRUNCDIV:
4276 return 0; 4261 return 0;
4277 case Token::kMOD: 4262 case Token::kMOD:
4278 return 1; 4263 return 1;
4279 default: 4264 default:
4280 UNIMPLEMENTED(); 4265 UNIMPLEMENTED();
4281 return -1; 4266 return -1;
4282 } 4267 }
4283 } 4268 }
(...skipping 24 matching lines...) Expand all
4308 "native function '%s' (%" Pd " arguments) cannot be found", 4293 "native function '%s' (%" Pd " arguments) cannot be found",
4309 native_name().ToCString(), function().NumParameters()); 4294 native_name().ToCString(), function().NumParameters());
4310 } 4295 }
4311 set_is_auto_scope(auto_setup_scope); 4296 set_is_auto_scope(auto_setup_scope);
4312 set_native_c_function(native_function); 4297 set_native_c_function(native_function);
4313 } 4298 }
4314 4299
4315 #undef __ 4300 #undef __
4316 4301
4317 } // namespace dart 4302 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698