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

Unified Diff: src/compiler/js-type-hint-lowering.cc

Issue 2802113003: [turbofan] Introduce a SpeculativeToNumber operator. (Closed)
Patch Set: Paint it green! Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/js-type-hint-lowering.h ('k') | src/compiler/js-typed-lowering.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-type-hint-lowering.cc
diff --git a/src/compiler/js-type-hint-lowering.cc b/src/compiler/js-type-hint-lowering.cc
index a7ed1c3d0f8599755cd0570c63fa1a0be3d401d0..7c70b1ea119a5fcdeae08b86e63c0f0d462205ef 100644
--- a/src/compiler/js-type-hint-lowering.cc
+++ b/src/compiler/js-type-hint-lowering.cc
@@ -14,6 +14,30 @@ namespace v8 {
namespace internal {
namespace compiler {
+namespace {
+
+bool BinaryOperationHintToNumberOperationHint(
+ BinaryOperationHint binop_hint, NumberOperationHint* number_hint) {
+ switch (binop_hint) {
+ case BinaryOperationHint::kSignedSmall:
+ *number_hint = NumberOperationHint::kSignedSmall;
+ return true;
+ case BinaryOperationHint::kSigned32:
+ *number_hint = NumberOperationHint::kSigned32;
+ return true;
+ case BinaryOperationHint::kNumberOrOddball:
+ *number_hint = NumberOperationHint::kNumberOrOddball;
+ return true;
+ case BinaryOperationHint::kAny:
+ case BinaryOperationHint::kNone:
+ case BinaryOperationHint::kString:
+ break;
+ }
+ return false;
+}
+
+} // namespace
+
class JSSpeculativeBinopBuilder final {
public:
JSSpeculativeBinopBuilder(const JSTypeHintLowering* lowering,
@@ -40,22 +64,8 @@ class JSSpeculativeBinopBuilder final {
}
bool GetBinaryNumberOperationHint(NumberOperationHint* hint) {
- switch (GetBinaryOperationHint()) {
- case BinaryOperationHint::kSignedSmall:
- *hint = NumberOperationHint::kSignedSmall;
- return true;
- case BinaryOperationHint::kSigned32:
- *hint = NumberOperationHint::kSigned32;
- return true;
- case BinaryOperationHint::kNumberOrOddball:
- *hint = NumberOperationHint::kNumberOrOddball;
- return true;
- case BinaryOperationHint::kAny:
- case BinaryOperationHint::kNone:
- case BinaryOperationHint::kString:
- break;
- }
- return false;
+ return BinaryOperationHintToNumberOperationHint(GetBinaryOperationHint(),
+ hint);
}
bool GetCompareNumberOperationHint(NumberOperationHint* hint) {
@@ -228,6 +238,22 @@ Reduction JSTypeHintLowering::ReduceBinaryOperation(const Operator* op,
return Reduction();
}
+Reduction JSTypeHintLowering::ReduceToNumberOperation(Node* input, Node* effect,
+ Node* control,
+ FeedbackSlot slot) const {
+ DCHECK(!slot.IsInvalid());
+ BinaryOpICNexus nexus(feedback_vector(), slot);
+ NumberOperationHint hint;
+ if (BinaryOperationHintToNumberOperationHint(
+ nexus.GetBinaryOperationFeedback(), &hint)) {
+ Node* node = jsgraph()->graph()->NewNode(
+ jsgraph()->simplified()->SpeculativeToNumber(hint), input, effect,
+ control);
+ return Reduction(node);
+ }
+ return Reduction();
+}
+
Reduction JSTypeHintLowering::ReduceLoadNamedOperation(
const Operator* op, Node* obj, Node* effect, Node* control,
FeedbackSlot slot) const {
« no previous file with comments | « src/compiler/js-type-hint-lowering.h ('k') | src/compiler/js-typed-lowering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698