| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/ast.h" | 5 #include "src/ast.h" |
| 6 | 6 |
| 7 #include <cmath> // For isfinite. | 7 #include <cmath> // For isfinite. |
| 8 #include "src/builtins.h" | 8 #include "src/builtins.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/contexts.h" | 10 #include "src/contexts.h" |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 void BinaryOperation::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { | 449 void BinaryOperation::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { |
| 450 // TODO(olivf) If this Operation is used in a test context, then the right | 450 // TODO(olivf) If this Operation is used in a test context, then the right |
| 451 // hand side has a ToBoolean stub and we want to collect the type information. | 451 // hand side has a ToBoolean stub and we want to collect the type information. |
| 452 // However the GraphBuilder expects it to be on the instruction corresponding | 452 // However the GraphBuilder expects it to be on the instruction corresponding |
| 453 // to the TestContext, therefore we have to store it here and not on the | 453 // to the TestContext, therefore we have to store it here and not on the |
| 454 // right hand operand. | 454 // right hand operand. |
| 455 set_to_boolean_types(oracle->ToBooleanTypes(right()->test_id())); | 455 set_to_boolean_types(oracle->ToBooleanTypes(right()->test_id())); |
| 456 } | 456 } |
| 457 | 457 |
| 458 | 458 |
| 459 bool BinaryOperation::ResultOverwriteAllowed() const { | |
| 460 switch (op()) { | |
| 461 case Token::COMMA: | |
| 462 case Token::OR: | |
| 463 case Token::AND: | |
| 464 return false; | |
| 465 case Token::BIT_OR: | |
| 466 case Token::BIT_XOR: | |
| 467 case Token::BIT_AND: | |
| 468 case Token::SHL: | |
| 469 case Token::SAR: | |
| 470 case Token::SHR: | |
| 471 case Token::ADD: | |
| 472 case Token::SUB: | |
| 473 case Token::MUL: | |
| 474 case Token::DIV: | |
| 475 case Token::MOD: | |
| 476 return true; | |
| 477 default: | |
| 478 UNREACHABLE(); | |
| 479 } | |
| 480 return false; | |
| 481 } | |
| 482 | |
| 483 | |
| 484 static bool IsTypeof(Expression* expr) { | 459 static bool IsTypeof(Expression* expr) { |
| 485 UnaryOperation* maybe_unary = expr->AsUnaryOperation(); | 460 UnaryOperation* maybe_unary = expr->AsUnaryOperation(); |
| 486 return maybe_unary != NULL && maybe_unary->op() == Token::TYPEOF; | 461 return maybe_unary != NULL && maybe_unary->op() == Token::TYPEOF; |
| 487 } | 462 } |
| 488 | 463 |
| 489 | 464 |
| 490 // Check for the pattern: typeof <expression> equals <string literal>. | 465 // Check for the pattern: typeof <expression> equals <string literal>. |
| 491 static bool MatchLiteralCompareTypeof(Expression* left, | 466 static bool MatchLiteralCompareTypeof(Expression* left, |
| 492 Token::Value op, | 467 Token::Value op, |
| 493 Expression* right, | 468 Expression* right, |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 // static | 1024 // static |
| 1050 bool Literal::Match(void* literal1, void* literal2) { | 1025 bool Literal::Match(void* literal1, void* literal2) { |
| 1051 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1026 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
| 1052 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1027 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
| 1053 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || | 1028 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || |
| 1054 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1029 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
| 1055 } | 1030 } |
| 1056 | 1031 |
| 1057 | 1032 |
| 1058 } } // namespace v8::internal | 1033 } } // namespace v8::internal |
| OLD | NEW |