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

Unified Diff: src/compiler/typer.cc

Issue 2037453003: [turbofan] Add new StringFromCharCode simplified operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Mitigate verifier blowup after early optimization. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/simplified-operator.cc ('k') | src/compiler/verifier.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/typer.cc
diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc
index 29cbc57959e0ebd90ac0a926d9716809aa94459d..54ea26314e276a7bbd76feaf17253f801e5df45c 100644
--- a/src/compiler/typer.cc
+++ b/src/compiler/typer.cc
@@ -272,6 +272,7 @@ class Typer::Visitor : public Reducer {
static Type* JSCallFunctionTyper(Type*, Typer*);
static Type* ReferenceEqualTyper(Type*, Type*, Typer*);
+ static Type* StringFromCharCodeTyper(Type*, Typer*);
Reduction UpdateType(Node* node, Type* current) {
if (NodeProperties::IsTyped(node)) {
@@ -1814,6 +1815,23 @@ Type* Typer::Visitor::TypeStringLessThanOrEqual(Node* node) {
return Type::Boolean();
}
+Type* Typer::Visitor::StringFromCharCodeTyper(Type* type, Typer* t) {
+ type = NumberToUint32(ToNumber(type, t), t);
+ Factory* f = t->isolate()->factory();
+ double min = type->Min();
+ double max = type->Max();
+ if (min == max) {
+ uint32_t code = static_cast<uint32_t>(min) & String::kMaxUtf16CodeUnitU;
+ Handle<String> string = f->LookupSingleCharacterStringFromCode(code);
+ return Type::Constant(string, t->zone());
+ }
+ return Type::String();
+}
+
+Type* Typer::Visitor::TypeStringFromCharCode(Node* node) {
+ return TypeUnaryOp(node, StringFromCharCodeTyper);
+}
+
Type* Typer::Visitor::TypeStringToNumber(Node* node) {
return TypeUnaryOp(node, ToNumber);
}
« no previous file with comments | « src/compiler/simplified-operator.cc ('k') | src/compiler/verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698