| 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()) {
|
|
|