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

Unified Diff: src/hydrogen.cc

Issue 10735023: Added Crankshaft support for JavaScript getters. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Whitespace changes. Created 8 years, 5 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/hydrogen.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index dfde504339875da64727170e4d82ffa504adcad6..539b48aafcf79caf13af88043bfd82f1947b1431 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -5623,6 +5623,33 @@ HInstruction* HGraphBuilder::BuildLoadNamedGeneric(HValue* obj,
}
+static void LookupInPrototypes(Handle<Map> map,
+ Handle<String> name,
+ LookupResult* lookup) {
+ while (map->prototype()->IsJSObject()) {
+ Handle<JSObject> holder(JSObject::cast(map->prototype()));
+ map = Handle<Map>(holder->map());
+ map->LookupDescriptor(*holder, *name, lookup);
+ if (lookup->IsFound()) return;
+ }
+ lookup->NotFound();
+}
+
+
+HInstruction* HGraphBuilder::BuildCallGetter(HValue* obj,
+ Property* expr,
+ Handle<Map> map,
+ Handle<Object> callback,
+ Handle<JSObject> holder) {
+ if (!callback->IsAccessorPair()) return BuildLoadNamedGeneric(obj, expr);
+ Handle<Object> getter(Handle<AccessorPair>::cast(callback)->getter());
+ Handle<JSFunction> function(Handle<JSFunction>::cast(getter));
+ AddCheckConstantFunction(holder, obj, map, true);
+ AddInstruction(new(zone()) HPushArgument(obj));
+ return new(zone()) HCallConstantFunction(function, 1);
+}
+
+
HInstruction* HGraphBuilder::BuildLoadNamed(HValue* obj,
Property* expr,
Handle<Map> map,
@@ -5640,7 +5667,17 @@ HInstruction* HGraphBuilder::BuildLoadNamed(HValue* obj,
AddInstruction(HCheckMaps::NewWithTransitions(obj, map, zone()));
Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map));
return new(zone()) HConstant(function, Representation::Tagged());
+ } else if (lookup.IsPropertyCallbacks()) {
+ Handle<Object> callback(lookup.GetValueFromMap(*map));
+ Handle<JSObject> holder;
+ return BuildCallGetter(obj, expr, map, callback, holder);
} else {
+ LookupInPrototypes(map, name, &lookup);
+ if (lookup.IsPropertyCallbacks()) {
+ Handle<Object> callback(lookup.GetValue());
+ Handle<JSObject> holder(lookup.holder());
+ return BuildCallGetter(obj, expr, map, callback, holder);
+ }
return BuildLoadNamedGeneric(obj, expr);
}
}
« no previous file with comments | « src/hydrogen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698