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

Unified Diff: src/hydrogen.cc

Issue 220163012: Inline loading of immutable properties (Closed) Base URL: https://github.com/v8/v8.git@master
Patch Set: Support loads from prototypes as well Created 6 years, 9 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') | test/mjsunit/compiler/immutable-load-inline.js » ('j') | 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 6587ce97199ca944f8daaa8938bcbf73b23f6414..1bcdcf62efdd310c03b51e12634434486903f5e9 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -5600,6 +5600,29 @@ HInstruction* HOptimizedGraphBuilder::BuildMonomorphicAccess(
BailoutId ast_id,
BailoutId return_id,
bool can_inline_accessor) {
+ // See if this is a load for an immutable property
+ if (info->IsLoad() && info->lookup()->IsFound() &&
+ info->lookup()->IsCacheable() && info->lookup()->IsReadOnly() &&
+ info->lookup()->IsDontDelete() && !info->map()->is_observed()) {
+ Handle<Object> value(isolate()->heap()->the_hole_value(), isolate());
+
+ if (!info->has_holder()) {
+ if (object->IsConstant() &&
+ HConstant::cast(object)->handle(isolate())->IsJSObject()) {
+ Handle<JSObject> js_object = HConstant::cast(object)->handle(isolate());
+ LookupResult lookup(isolate());
+ js_object->Lookup(*info->name(), &lookup);
+ value = handle(lookup.GetLazyValue(), isolate());
+ }
+ } else {
+ value = handle(info->lookup()->GetLazyValue(), isolate());
+ }
+
+ if (!value->IsTheHole()) {
+ AddCheckMapsUntilHolder(info->holder(), info->map(), checked_object);
+ return New<HConstant>(value);
+ }
+ }
HObjectAccess access = HObjectAccess::ForMap(); // bogus default
if (info->GetJSObjectFieldAccess(&access)) {
@@ -6791,6 +6814,22 @@ HInstruction* HGraphBuilder::BuildCheckPrototypeMaps(Handle<JSObject> prototype,
}
+void HOptimizedGraphBuilder::AddCheckMapsUntilHolder(Handle<JSObject> holder,
+ Handle<Map> receiver_map,
+ HValue* checked_object) {
+ if (holder.is_null()) {
+ HInstruction::cast(checked_object)->DeleteAndReplaceWith(NULL);
+ } else {
+ Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype()));
+ do {
+ if (prototype.is_identical_to(holder)) return;
+ BuildConstantMapCheck(prototype, top_info());
+ prototype = handle(JSObject::cast(prototype->GetPrototype()));
+ } while (true);
+ }
+}
+
+
void HOptimizedGraphBuilder::AddCheckPrototypeMaps(Handle<JSObject> holder,
Handle<Map> receiver_map) {
if (!holder.is_null()) {
« no previous file with comments | « src/hydrogen.h ('k') | test/mjsunit/compiler/immutable-load-inline.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698