| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "src/address-map.h" | 9 #include "src/address-map.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 // where cycles need to be broken. | 351 // where cycles need to be broken. |
| 352 if (node->opcode() != IrOpcode::kPhi) { | 352 if (node->opcode() != IrOpcode::kPhi) { |
| 353 for (int i = 0; i < node->op()->ValueInputCount(); i++) { | 353 for (int i = 0; i < node->op()->ValueInputCount(); i++) { |
| 354 if (GetInfo(node->InputAt(i))->feedback_type() == nullptr) { | 354 if (GetInfo(node->InputAt(i))->feedback_type() == nullptr) { |
| 355 return false; | 355 return false; |
| 356 } | 356 } |
| 357 } | 357 } |
| 358 } | 358 } |
| 359 | 359 |
| 360 switch (node->opcode()) { | 360 switch (node->opcode()) { |
| 361 case IrOpcode::kNumberAdd: | 361 #define DECLARE_CASE(Name) \ |
| 362 case IrOpcode::kSpeculativeNumberAdd: { | 362 case IrOpcode::k##Name: { \ |
| 363 // TODO(jarin) The ToNumber conversion is too conservative here, | 363 new_type = op_typer_.Name(FeedbackTypeOf(node->InputAt(0)), \ |
| 364 // e.g. it will treat true as 1 even though the number check will | 364 FeedbackTypeOf(node->InputAt(1))); \ |
| 365 // fail on a boolean. OperationTyper should have a function that | 365 break; \ |
| 366 // computes a more precise type. | 366 } |
| 367 Type* lhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(0))); | 367 SIMPLIFIED_NUMBER_BINOP_LIST(DECLARE_CASE) |
| 368 Type* rhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(1))); | 368 #undef DECLARE_CASE |
| 369 Type* computed_type = op_typer_.NumberAdd(lhs, rhs); | |
| 370 new_type = Type::Intersect(computed_type, info->restriction_type(), | |
| 371 graph_zone()); | |
| 372 break; | |
| 373 } | |
| 374 | 369 |
| 375 case IrOpcode::kNumberSubtract: | 370 #define DECLARE_CASE(Name) \ |
| 376 case IrOpcode::kSpeculativeNumberSubtract: { | 371 case IrOpcode::k##Name: { \ |
| 377 // TODO(jarin) The ToNumber conversion is too conservative here, | 372 new_type = \ |
| 378 // e.g. it will treat true as 1 even though the number check will | 373 Type::Intersect(op_typer_.Name(FeedbackTypeOf(node->InputAt(0)), \ |
| 379 // fail on a boolean. OperationTyper should have a function that | 374 FeedbackTypeOf(node->InputAt(1))), \ |
| 380 // computes a more precise type. | 375 info->restriction_type(), graph_zone()); \ |
| 381 Type* lhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(0))); | 376 break; \ |
| 382 Type* rhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(1))); | 377 } |
| 383 Type* computed_type = op_typer_.NumberSubtract(lhs, rhs); | 378 SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(DECLARE_CASE) |
| 384 new_type = Type::Intersect(computed_type, info->restriction_type(), | 379 #undef DECLARE_CASE |
| 385 graph_zone()); | |
| 386 break; | |
| 387 } | |
| 388 | 380 |
| 389 case IrOpcode::kNumberMultiply: | 381 #define DECLARE_CASE(Name) \ |
| 390 case IrOpcode::kSpeculativeNumberMultiply: { | 382 case IrOpcode::k##Name: { \ |
| 391 // TODO(jarin) The ToNumber conversion is too conservative here, | 383 new_type = op_typer_.Name(FeedbackTypeOf(node->InputAt(0))); \ |
| 392 // e.g. it will treat true as 1 even though the number check will | 384 break; \ |
| 393 // fail on a boolean. OperationTyper should have a function that | 385 } |
| 394 // computes a more precise type. | 386 SIMPLIFIED_NUMBER_UNOP_LIST(DECLARE_CASE) |
| 395 Type* lhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(0))); | 387 #undef DECLARE_CASE |
| 396 Type* rhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(1))); | |
| 397 Type* computed_type = op_typer_.NumberMultiply(lhs, rhs); | |
| 398 new_type = Type::Intersect(computed_type, info->restriction_type(), | |
| 399 graph_zone()); | |
| 400 break; | |
| 401 } | |
| 402 | |
| 403 case IrOpcode::kNumberDivide: | |
| 404 case IrOpcode::kSpeculativeNumberDivide: { | |
| 405 // TODO(jarin) The ToNumber conversion is too conservative here, | |
| 406 // e.g. it will treat true as 1 even though the number check will | |
| 407 // fail on a boolean. OperationTyper should have a function that | |
| 408 // computes a more precise type. | |
| 409 Type* lhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(0))); | |
| 410 Type* rhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(1))); | |
| 411 Type* computed_type = op_typer_.NumberDivide(lhs, rhs); | |
| 412 new_type = Type::Intersect(computed_type, info->restriction_type(), | |
| 413 graph_zone()); | |
| 414 break; | |
| 415 } | |
| 416 | |
| 417 case IrOpcode::kNumberModulus: | |
| 418 case IrOpcode::kSpeculativeNumberModulus: { | |
| 419 // TODO(jarin) The ToNumber conversion is too conservative here, | |
| 420 // e.g. it will treat true as 1 even though the number check will | |
| 421 // fail on a boolean. OperationTyper should have a function that | |
| 422 // computes a more precise type. | |
| 423 Type* lhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(0))); | |
| 424 Type* rhs = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(1))); | |
| 425 Type* computed_type = op_typer_.NumberModulus(lhs, rhs); | |
| 426 new_type = Type::Intersect(computed_type, info->restriction_type(), | |
| 427 graph_zone()); | |
| 428 break; | |
| 429 } | |
| 430 | 388 |
| 431 case IrOpcode::kPlainPrimitiveToNumber: | 389 case IrOpcode::kPlainPrimitiveToNumber: |
| 432 new_type = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(0))); | 390 new_type = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(0))); |
| 433 break; | 391 break; |
| 434 | 392 |
| 435 case IrOpcode::kNumberAbs: { | |
| 436 new_type = op_typer_.NumberAbs(FeedbackTypeOf(node->InputAt(0))); | |
| 437 break; | |
| 438 } | |
| 439 | |
| 440 case IrOpcode::kPhi: { | 393 case IrOpcode::kPhi: { |
| 441 new_type = TypePhi(node); | 394 new_type = TypePhi(node); |
| 442 if (type != nullptr) { | 395 if (type != nullptr) { |
| 443 new_type = Weaken(node, type, new_type); | 396 new_type = Weaken(node, type, new_type); |
| 444 } | 397 } |
| 445 break; | 398 break; |
| 446 } | 399 } |
| 447 | 400 |
| 448 case IrOpcode::kSelect: { | 401 case IrOpcode::kSelect: { |
| 449 new_type = TypeSelect(node); | 402 new_type = TypeSelect(node); |
| (...skipping 3266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3716 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3669 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
| 3717 Operator::kNoProperties); | 3670 Operator::kNoProperties); |
| 3718 to_number_operator_.set(common()->Call(desc)); | 3671 to_number_operator_.set(common()->Call(desc)); |
| 3719 } | 3672 } |
| 3720 return to_number_operator_.get(); | 3673 return to_number_operator_.get(); |
| 3721 } | 3674 } |
| 3722 | 3675 |
| 3723 } // namespace compiler | 3676 } // namespace compiler |
| 3724 } // namespace internal | 3677 } // namespace internal |
| 3725 } // namespace v8 | 3678 } // namespace v8 |
| OLD | NEW |