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

Side by Side 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, 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 unified diff | Download patch
« no previous file with comments | « src/hydrogen.h ('k') | test/mjsunit/compiler/immutable-load-inline.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 5582 matching lines...) Expand 10 before | Expand all | Expand 10 after
5593 5593
5594 5594
5595 HInstruction* HOptimizedGraphBuilder::BuildMonomorphicAccess( 5595 HInstruction* HOptimizedGraphBuilder::BuildMonomorphicAccess(
5596 PropertyAccessInfo* info, 5596 PropertyAccessInfo* info,
5597 HValue* object, 5597 HValue* object,
5598 HValue* checked_object, 5598 HValue* checked_object,
5599 HValue* value, 5599 HValue* value,
5600 BailoutId ast_id, 5600 BailoutId ast_id,
5601 BailoutId return_id, 5601 BailoutId return_id,
5602 bool can_inline_accessor) { 5602 bool can_inline_accessor) {
5603 // See if this is a load for an immutable property
5604 if (info->IsLoad() && info->lookup()->IsFound() &&
5605 info->lookup()->IsCacheable() && info->lookup()->IsReadOnly() &&
5606 info->lookup()->IsDontDelete() && !info->map()->is_observed()) {
5607 Handle<Object> value(isolate()->heap()->the_hole_value(), isolate());
5608
5609 if (!info->has_holder()) {
5610 if (object->IsConstant() &&
5611 HConstant::cast(object)->handle(isolate())->IsJSObject()) {
5612 Handle<JSObject> js_object = HConstant::cast(object)->handle(isolate());
5613 LookupResult lookup(isolate());
5614 js_object->Lookup(*info->name(), &lookup);
5615 value = handle(lookup.GetLazyValue(), isolate());
5616 }
5617 } else {
5618 value = handle(info->lookup()->GetLazyValue(), isolate());
5619 }
5620
5621 if (!value->IsTheHole()) {
5622 AddCheckMapsUntilHolder(info->holder(), info->map(), checked_object);
5623 return New<HConstant>(value);
5624 }
5625 }
5603 5626
5604 HObjectAccess access = HObjectAccess::ForMap(); // bogus default 5627 HObjectAccess access = HObjectAccess::ForMap(); // bogus default
5605 if (info->GetJSObjectFieldAccess(&access)) { 5628 if (info->GetJSObjectFieldAccess(&access)) {
5606 ASSERT(info->IsLoad()); 5629 ASSERT(info->IsLoad());
5607 return New<HLoadNamedField>(object, checked_object, access); 5630 return New<HLoadNamedField>(object, checked_object, access);
5608 } 5631 }
5609 5632
5610 HValue* checked_holder = checked_object; 5633 HValue* checked_holder = checked_object;
5611 if (info->has_holder()) { 5634 if (info->has_holder()) {
5612 Handle<JSObject> prototype(JSObject::cast(info->map()->prototype())); 5635 Handle<JSObject> prototype(JSObject::cast(info->map()->prototype()));
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
6784 BuildConstantMapCheck(prototype, top_info()); 6807 BuildConstantMapCheck(prototype, top_info());
6785 prototype = handle(JSObject::cast(prototype->GetPrototype())); 6808 prototype = handle(JSObject::cast(prototype->GetPrototype()));
6786 } 6809 }
6787 6810
6788 HInstruction* checked_object = BuildConstantMapCheck(prototype, top_info()); 6811 HInstruction* checked_object = BuildConstantMapCheck(prototype, top_info());
6789 if (!checked_object->IsLinked()) AddInstruction(checked_object); 6812 if (!checked_object->IsLinked()) AddInstruction(checked_object);
6790 return checked_object; 6813 return checked_object;
6791 } 6814 }
6792 6815
6793 6816
6817 void HOptimizedGraphBuilder::AddCheckMapsUntilHolder(Handle<JSObject> holder,
6818 Handle<Map> receiver_map,
6819 HValue* checked_object) {
6820 if (holder.is_null()) {
6821 HInstruction::cast(checked_object)->DeleteAndReplaceWith(NULL);
6822 } else {
6823 Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype()));
6824 do {
6825 if (prototype.is_identical_to(holder)) return;
6826 BuildConstantMapCheck(prototype, top_info());
6827 prototype = handle(JSObject::cast(prototype->GetPrototype()));
6828 } while (true);
6829 }
6830 }
6831
6832
6794 void HOptimizedGraphBuilder::AddCheckPrototypeMaps(Handle<JSObject> holder, 6833 void HOptimizedGraphBuilder::AddCheckPrototypeMaps(Handle<JSObject> holder,
6795 Handle<Map> receiver_map) { 6834 Handle<Map> receiver_map) {
6796 if (!holder.is_null()) { 6835 if (!holder.is_null()) {
6797 Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype())); 6836 Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype()));
6798 BuildCheckPrototypeMaps(prototype, holder); 6837 BuildCheckPrototypeMaps(prototype, holder);
6799 } 6838 }
6800 } 6839 }
6801 6840
6802 6841
6803 HInstruction* HOptimizedGraphBuilder::NewPlainFunctionCall( 6842 HInstruction* HOptimizedGraphBuilder::NewPlainFunctionCall(
(...skipping 4697 matching lines...) Expand 10 before | Expand all | Expand 10 after
11501 if (ShouldProduceTraceOutput()) { 11540 if (ShouldProduceTraceOutput()) {
11502 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 11541 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
11503 } 11542 }
11504 11543
11505 #ifdef DEBUG 11544 #ifdef DEBUG
11506 graph_->Verify(false); // No full verify. 11545 graph_->Verify(false); // No full verify.
11507 #endif 11546 #endif
11508 } 11547 }
11509 11548
11510 } } // namespace v8::internal 11549 } } // namespace v8::internal
OLDNEW
« 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