Revision: 20690
Author:   [email protected]
Date:     Fri Apr 11 13:07:10 2014 UTC
Log:      Inline immutable property loads

When a non-configurable, non-writable field is
read from a constant holder, the load is
eliminated and replaced with the direct value
of the field

BUG=
[email protected]

Review URL: https://codereview.chromium.org/232853002

Patch from Petka Antonov <[email protected]>.
http://code.google.com/p/v8/source/detail?r=20690

Modified:
 /branches/bleeding_edge/src/hydrogen.cc

=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Fri Apr 11 06:45:24 2014 UTC
+++ /branches/bleeding_edge/src/hydrogen.cc     Fri Apr 11 13:07:10 2014 UTC
@@ -5341,6 +5341,24 @@
 HInstruction* HOptimizedGraphBuilder::BuildLoadNamedField(
     PropertyAccessInfo* info,
     HValue* checked_object) {
+  // See if this is a load for an immutable property
+  if (checked_object->ActualValue()->IsConstant() &&
+      info->lookup()->IsCacheable() &&
+      info->lookup()->IsReadOnly() && info->lookup()->IsDontDelete()) {
+    Handle<Object> object(
+        HConstant::cast(checked_object->ActualValue())->handle(isolate()));
+
+    if (object->IsJSObject()) {
+      LookupResult lookup(isolate());
+      Handle<JSObject>::cast(object)->Lookup(*info->name(), &lookup);
+      Handle<Object> value(lookup.GetLazyValue(), isolate());
+
+      if (!value->IsTheHole()) {
+        return New<HConstant>(value);
+      }
+    }
+  }
+
   HObjectAccess access = info->access();
   if (access.representation().IsDouble()) {
     // Load the heap number.

--
--
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