OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 5605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5616 AddInstruction(new(zone()) HSoftDeoptimize); | 5616 AddInstruction(new(zone()) HSoftDeoptimize); |
5617 current_block()->MarkAsDeoptimizing(); | 5617 current_block()->MarkAsDeoptimizing(); |
5618 } | 5618 } |
5619 ASSERT(expr->key()->IsPropertyName()); | 5619 ASSERT(expr->key()->IsPropertyName()); |
5620 Handle<Object> name = expr->key()->AsLiteral()->handle(); | 5620 Handle<Object> name = expr->key()->AsLiteral()->handle(); |
5621 HValue* context = environment()->LookupContext(); | 5621 HValue* context = environment()->LookupContext(); |
5622 return new(zone()) HLoadNamedGeneric(context, obj, name); | 5622 return new(zone()) HLoadNamedGeneric(context, obj, name); |
5623 } | 5623 } |
5624 | 5624 |
5625 | 5625 |
| 5626 static void LookupInPrototypes(Handle<Map> map, |
| 5627 Handle<String> name, |
| 5628 LookupResult* lookup) { |
| 5629 while (map->prototype()->IsJSObject()) { |
| 5630 Handle<JSObject> holder(JSObject::cast(map->prototype())); |
| 5631 map = Handle<Map>(holder->map()); |
| 5632 map->LookupDescriptor(*holder, *name, lookup); |
| 5633 if (lookup->IsFound()) return; |
| 5634 } |
| 5635 lookup->NotFound(); |
| 5636 } |
| 5637 |
| 5638 |
| 5639 HInstruction* HGraphBuilder::BuildCallGetter(HValue* obj, |
| 5640 Property* expr, |
| 5641 Handle<Map> map, |
| 5642 Handle<Object> callback, |
| 5643 Handle<JSObject> holder) { |
| 5644 if (!callback->IsAccessorPair()) return BuildLoadNamedGeneric(obj, expr); |
| 5645 Handle<Object> getter(Handle<AccessorPair>::cast(callback)->getter()); |
| 5646 Handle<JSFunction> function(Handle<JSFunction>::cast(getter)); |
| 5647 AddCheckConstantFunction(holder, obj, map, true); |
| 5648 AddInstruction(new(zone()) HPushArgument(obj)); |
| 5649 return new(zone()) HCallConstantFunction(function, 1); |
| 5650 } |
| 5651 |
| 5652 |
5626 HInstruction* HGraphBuilder::BuildLoadNamed(HValue* obj, | 5653 HInstruction* HGraphBuilder::BuildLoadNamed(HValue* obj, |
5627 Property* expr, | 5654 Property* expr, |
5628 Handle<Map> map, | 5655 Handle<Map> map, |
5629 Handle<String> name) { | 5656 Handle<String> name) { |
5630 LookupResult lookup(isolate()); | 5657 LookupResult lookup(isolate()); |
5631 map->LookupDescriptor(NULL, *name, &lookup); | 5658 map->LookupDescriptor(NULL, *name, &lookup); |
5632 if (lookup.IsField()) { | 5659 if (lookup.IsField()) { |
5633 return BuildLoadNamedField(obj, | 5660 return BuildLoadNamedField(obj, |
5634 expr, | 5661 expr, |
5635 map, | 5662 map, |
5636 &lookup, | 5663 &lookup, |
5637 true); | 5664 true); |
5638 } else if (lookup.IsConstantFunction()) { | 5665 } else if (lookup.IsConstantFunction()) { |
5639 AddInstruction(new(zone()) HCheckNonSmi(obj)); | 5666 AddInstruction(new(zone()) HCheckNonSmi(obj)); |
5640 AddInstruction(HCheckMaps::NewWithTransitions(obj, map, zone())); | 5667 AddInstruction(HCheckMaps::NewWithTransitions(obj, map, zone())); |
5641 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map)); | 5668 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map)); |
5642 return new(zone()) HConstant(function, Representation::Tagged()); | 5669 return new(zone()) HConstant(function, Representation::Tagged()); |
| 5670 } else if (lookup.IsPropertyCallbacks()) { |
| 5671 Handle<Object> callback(lookup.GetValueFromMap(*map)); |
| 5672 Handle<JSObject> holder; |
| 5673 return BuildCallGetter(obj, expr, map, callback, holder); |
5643 } else { | 5674 } else { |
| 5675 LookupInPrototypes(map, name, &lookup); |
| 5676 if (lookup.IsPropertyCallbacks()) { |
| 5677 Handle<Object> callback(lookup.GetValue()); |
| 5678 Handle<JSObject> holder(lookup.holder()); |
| 5679 return BuildCallGetter(obj, expr, map, callback, holder); |
| 5680 } |
5644 return BuildLoadNamedGeneric(obj, expr); | 5681 return BuildLoadNamedGeneric(obj, expr); |
5645 } | 5682 } |
5646 } | 5683 } |
5647 | 5684 |
5648 | 5685 |
5649 HInstruction* HGraphBuilder::BuildLoadKeyedGeneric(HValue* object, | 5686 HInstruction* HGraphBuilder::BuildLoadKeyedGeneric(HValue* object, |
5650 HValue* key) { | 5687 HValue* key) { |
5651 HValue* context = environment()->LookupContext(); | 5688 HValue* context = environment()->LookupContext(); |
5652 return new(zone()) HLoadKeyedGeneric(context, object, key); | 5689 return new(zone()) HLoadKeyedGeneric(context, object, key); |
5653 } | 5690 } |
(...skipping 3865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9519 } | 9556 } |
9520 } | 9557 } |
9521 | 9558 |
9522 #ifdef DEBUG | 9559 #ifdef DEBUG |
9523 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 9560 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
9524 if (allocator_ != NULL) allocator_->Verify(); | 9561 if (allocator_ != NULL) allocator_->Verify(); |
9525 #endif | 9562 #endif |
9526 } | 9563 } |
9527 | 9564 |
9528 } } // namespace v8::internal | 9565 } } // namespace v8::internal |
OLD | NEW |