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

Unified Diff: src/code-stub-assembler.cc

Issue 2813623003: [csa] Add IsNumber and IsNumberNormalized predicates (Closed)
Patch Set: Address comments 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/code-stub-assembler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stub-assembler.cc
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc
index 03c80d2ed424cf755e3da7f93648f23b53ba36eb..340f2891a3e51ca55cc48e8bcdde7ec03ce61eed 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -3152,6 +3152,35 @@ Node* CodeStubAssembler::IsJSRegExp(Node* object) {
return HasInstanceType(object, JS_REGEXP_TYPE);
}
+Node* CodeStubAssembler::IsNumber(Node* object) {
+ return Select(TaggedIsSmi(object), [=] { return Int32Constant(1); },
+ [=] { return IsHeapNumber(object); },
+ MachineRepresentation::kWord32);
+}
+
+Node* CodeStubAssembler::IsNumberNormalized(Node* number) {
+ CSA_ASSERT(this, IsNumber(number));
+
+ VARIABLE(var_result, MachineRepresentation::kWord32, Int32Constant(1));
+ Label out(this);
+
+ GotoIf(TaggedIsSmi(number), &out);
+
+ Node* const value = LoadHeapNumberValue(number);
+ Node* const smi_min = Float64Constant(static_cast<double>(Smi::kMinValue));
+ Node* const smi_max = Float64Constant(static_cast<double>(Smi::kMaxValue));
+
+ GotoIf(Float64LessThan(value, smi_min), &out);
+ GotoIf(Float64GreaterThan(value, smi_max), &out);
+ GotoIfNot(Float64Equal(value, value), &out); // NaN.
+
+ var_result.Bind(Int32Constant(0));
+ Goto(&out);
+
+ BIND(&out);
+ return var_result.value();
+}
+
Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index,
ParameterMode parameter_mode) {
CSA_ASSERT(this, IsString(string));
« no previous file with comments | « src/code-stub-assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698