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

Unified Diff: src/hydrogen.cc

Issue 232853002: Inline immutable property loads (Closed) Base URL: https://github.com/v8/v8.git@master
Patch Set: Created 6 years, 8 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 | « no previous file | 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 7d2939bc250e68c02e7ba7d072383e8fc86d1202..a780b66cae6fe131dc20157e92ceabf02b7e839f 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -5343,6 +5343,25 @@ HCheckMaps* HOptimizedGraphBuilder::AddCheckMap(HValue* object,
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()) {
+ Handle<Object> value(isolate()->heap()->the_hole_value(), isolate());
Toon Verwaest 2014/04/10 11:58:31 Why do you pre-declare value to the hole rather th
p.antonov 2014/04/11 12:09:37 Done.
+ LookupResult lookup(isolate());
+ Handle<JSObject>::cast(object)->Lookup(*info->name(), &lookup);
+ value = handle(lookup.GetLazyValue(), isolate());
+
+ if (!value->IsTheHole()) {
+ return New<HConstant>(value);
+ }
+ }
+ }
+
HObjectAccess access = info->access();
if (access.representation().IsDouble()) {
// Load the heap number.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698