Reviewers: dcarney,

Description:
[turbofan] Improve typing for string::length property.

[email protected]

Please review this at https://codereview.chromium.org/1028563002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+6, -1 lines):
  M src/compiler/access-builder.cc
  M src/compiler/typer.cc


Index: src/compiler/access-builder.cc
diff --git a/src/compiler/access-builder.cc b/src/compiler/access-builder.cc
index 8c8e53092b81f07dbd442b1c286a837298b1d679..589ae65366579070406cb083feefb773cdce9891 100644
--- a/src/compiler/access-builder.cc
+++ b/src/compiler/access-builder.cc
@@ -61,7 +61,8 @@ FieldAccess AccessBuilder::ForMapInstanceType() {
 // static
 FieldAccess AccessBuilder::ForStringLength() {
   return {kTaggedBase, String::kLengthOffset, Handle<Name>(),
-          Type::SignedSmall(), kMachAnyTagged};
+          Type::Intersect(Type::UnsignedSmall(), Type::TaggedSigned()),
+          kMachAnyTagged};
 }


Index: src/compiler/typer.cc
diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc
index 67e2c55b29aa59c5d4c873f8af238e588753e41d..2bf3ecd857cca9695584beda6510ad9dfdd797fd 100644
--- a/src/compiler/typer.cc
+++ b/src/compiler/typer.cc
@@ -1518,6 +1518,10 @@ Bounds Typer::Visitor::TypeJSCallRuntime(Node* node) {
     case Runtime::kInlineMathFloor:
     case Runtime::kInlineMathSqrt:
       return Bounds(Type::None(zone()), Type::Number());
+    case Runtime::kInlineStringGetLength:
+      // The string::length property is always an unsigned smi.
+      return Bounds(Type::None(), Type::Intersect(Type::UnsignedSmall(),
+                                                  Type::TaggedSigned()));
     default:
       break;
   }


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to