Reviewers: Michael Starzinger, danno,

Message:
Michael, PTAL. Danno, I ran through Mozilla tests as well, successfully with the
formulation of adding JSFunction to the test in PropertyCell::UpdateType()

Description:
Calls to HCheckFunction can be eliminated if the value is an HConstant
function, and that function handle matches the target handle.

BUG=

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

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/hydrogen-instructions.h
  M src/hydrogen-instructions.cc
  M src/objects.cc


Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index 041ef8b37408f11fcb8cdc68e26abbf3c479966e..8e7032f6ec0a285fb9fcfb70876daa0125dddb64 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -1690,6 +1690,14 @@ void HCheckFunction::PrintDataTo(StringStream* stream) {
 }


+HValue* HCheckFunction::Canonicalize() {
+  return (value()->IsConstant() &&
+          HConstant::cast(value())->UniqueValueIdsMatch(target_unique_id_))
+      ? NULL
+      : this;
+}
+
+
 const char* HCheckInstanceType::GetCheckName() {
   switch (check_) {
     case IS_SPEC_OBJECT: return "object";
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index 4227b8ee067531a4dae5a6c7d4dc21cea5f46dac..0cd2f874259ad72e95094822bf3515c0d33bbdc8 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -2838,6 +2838,8 @@ class HCheckFunction: public HUnaryOperation {
   virtual void PrintDataTo(StringStream* stream);
   virtual HType CalculateInferredType();

+  virtual HValue* Canonicalize();
+
 #ifdef DEBUG
   virtual void Verify();
 #endif
@@ -3411,6 +3413,11 @@ class HConstant: public HTemplateInstruction<0> {
     }
   }

+  bool UniqueValueIdsMatch(UniqueValueId other) {
+    if (!has_double_value_) return unique_id_ == other;
+    return false;
+  }
+
 #ifdef DEBUG
   virtual void Verify() { }
 #endif
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 2611b57aef1a6aae6f9efa3b137fab0a717d91c0..8147106aaab168b8bbfa825f92ee5c310ace1359 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -15836,7 +15836,8 @@ Type* PropertyCell::UpdateType(Handle<PropertyCell> cell,
                                Handle<Object> value) {
   Isolate* isolate = cell->GetIsolate();
   Handle<Type> old_type(cell->type(), isolate);
-  Handle<Type> new_type((value->IsSmi() || value->IsUndefined())
+  Handle<Type> new_type((value->IsSmi() || value->IsJSFunction() ||
+                         value->IsUndefined())
                         ? Type::Constant(value, isolate)
                         : Type::Any(), isolate);



--
--
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/groups/opt_out.


Reply via email to