| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 | 729 |
| 730 // Support function for computing call IC miss stubs. | 730 // Support function for computing call IC miss stubs. |
| 731 Handle<Code> ComputeCallMiss(int argc) { | 731 Handle<Code> ComputeCallMiss(int argc) { |
| 732 CALL_HEAP_FUNCTION(StubCache::ComputeCallMiss(argc), Code); | 732 CALL_HEAP_FUNCTION(StubCache::ComputeCallMiss(argc), Code); |
| 733 } | 733 } |
| 734 | 734 |
| 735 | 735 |
| 736 | 736 |
| 737 Object* LoadCallbackProperty(Arguments args) { | 737 Object* LoadCallbackProperty(Arguments args) { |
| 738 Handle<JSObject> recv = args.at<JSObject>(0); | 738 Handle<JSObject> recv = args.at<JSObject>(0); |
| 739 AccessorInfo* callback = AccessorInfo::cast(args[1]); | 739 Handle<JSObject> holder = args.at<JSObject>(1); |
| 740 AccessorInfo* callback = AccessorInfo::cast(args[2]); |
| 741 Handle<Object> data = args.at<Object>(3); |
| 740 Address getter_address = v8::ToCData<Address>(callback->getter()); | 742 Address getter_address = v8::ToCData<Address>(callback->getter()); |
| 741 v8::AccessorGetter fun = FUNCTION_CAST<v8::AccessorGetter>(getter_address); | 743 v8::AccessorGetter fun = FUNCTION_CAST<v8::AccessorGetter>(getter_address); |
| 742 ASSERT(fun != NULL); | 744 ASSERT(fun != NULL); |
| 743 Handle<String> name = args.at<String>(2); | 745 Handle<String> name = args.at<String>(4); |
| 744 Handle<JSObject> holder = args.at<JSObject>(3); | |
| 745 HandleScope scope; | |
| 746 Handle<Object> data(callback->data()); | |
| 747 LOG(ApiNamedPropertyAccess("load", *recv, *name)); | |
| 748 // NOTE: If we can align the structure of an AccessorInfo with the | 746 // NOTE: If we can align the structure of an AccessorInfo with the |
| 749 // locations of the arguments to this function maybe we don't have | 747 // locations of the arguments to this function maybe we don't have |
| 750 // to explicitly create the structure but can just pass a pointer | 748 // to explicitly create the structure but can just pass a pointer |
| 751 // into the stack. | 749 // into the stack. |
| 750 LOG(ApiNamedPropertyAccess("load", *recv, *name)); |
| 752 v8::AccessorInfo info(v8::Utils::ToLocal(recv), | 751 v8::AccessorInfo info(v8::Utils::ToLocal(recv), |
| 753 v8::Utils::ToLocal(data), | 752 v8::Utils::ToLocal(data), |
| 754 v8::Utils::ToLocal(holder)); | 753 v8::Utils::ToLocal(holder)); |
| 754 HandleScope scope; |
| 755 v8::Handle<v8::Value> result; | 755 v8::Handle<v8::Value> result; |
| 756 { | 756 { |
| 757 // Leaving JavaScript. | 757 // Leaving JavaScript. |
| 758 VMState state(EXTERNAL); | 758 VMState state(EXTERNAL); |
| 759 result = fun(v8::Utils::ToLocal(name), info); | 759 result = fun(v8::Utils::ToLocal(name), info); |
| 760 } | 760 } |
| 761 RETURN_IF_SCHEDULED_EXCEPTION(); | 761 RETURN_IF_SCHEDULED_EXCEPTION(); |
| 762 if (result.IsEmpty()) return Heap::undefined_value(); | 762 if (result.IsEmpty()) return Heap::undefined_value(); |
| 763 return *v8::Utils::OpenHandle(*result); | 763 return *v8::Utils::OpenHandle(*result); |
| 764 } | 764 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 782 // Leaving JavaScript. | 782 // Leaving JavaScript. |
| 783 VMState state(EXTERNAL); | 783 VMState state(EXTERNAL); |
| 784 fun(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); | 784 fun(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); |
| 785 } | 785 } |
| 786 RETURN_IF_SCHEDULED_EXCEPTION(); | 786 RETURN_IF_SCHEDULED_EXCEPTION(); |
| 787 return *value; | 787 return *value; |
| 788 } | 788 } |
| 789 | 789 |
| 790 | 790 |
| 791 Object* LoadInterceptorProperty(Arguments args) { | 791 Object* LoadInterceptorProperty(Arguments args) { |
| 792 JSObject* recv = JSObject::cast(args[0]); | 792 Handle<JSObject> receiver_handle = args.at<JSObject>(0); |
| 793 JSObject* holder = JSObject::cast(args[1]); | 793 Handle<JSObject> holder_handle = args.at<JSObject>(1); |
| 794 String* name = String::cast(args[2]); | 794 Handle<String> name_handle = args.at<String>(2); |
| 795 Smi* lookup_hint = Smi::cast(args[3]); | 795 Smi* lookup_hint = Smi::cast(args[3]); |
| 796 ASSERT(holder->HasNamedInterceptor()); | 796 Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(4); |
| 797 PropertyAttributes attr = NONE; | 797 Handle<Object> data_handle = args.at<Object>(5); |
| 798 | 798 |
| 799 Object* result = holder->GetInterceptorPropertyWithLookupHint( | 799 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); |
| 800 recv, lookup_hint, name, &attr); | 800 v8::NamedPropertyGetter getter = |
| 801 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address); |
| 802 ASSERT(getter != NULL); |
| 803 |
| 804 PropertyAttributes attributes = ABSENT; |
| 805 Object* result = Heap::undefined_value(); |
| 806 |
| 807 { |
| 808 // Use the interceptor getter. |
| 809 v8::AccessorInfo info(v8::Utils::ToLocal(receiver_handle), |
| 810 v8::Utils::ToLocal(data_handle), |
| 811 v8::Utils::ToLocal(holder_handle)); |
| 812 HandleScope scope; |
| 813 v8::Handle<v8::Value> r; |
| 814 { |
| 815 // Leaving JavaScript. |
| 816 VMState state(EXTERNAL); |
| 817 r = getter(v8::Utils::ToLocal(name_handle), info); |
| 818 } |
| 819 RETURN_IF_SCHEDULED_EXCEPTION(); |
| 820 if (!r.IsEmpty()) { |
| 821 return *v8::Utils::OpenHandle(*r); |
| 822 } |
| 823 } |
| 824 |
| 825 int property_index = lookup_hint->value(); |
| 826 if (property_index >= 0) { |
| 827 result = holder_handle->FastPropertyAt(property_index); |
| 828 } else { |
| 829 switch (property_index) { |
| 830 case JSObject::kLookupInPrototype: { |
| 831 Object* pt = holder_handle->GetPrototype(); |
| 832 if (pt == Heap::null_value()) return Heap::undefined_value(); |
| 833 result = pt->GetPropertyWithReceiver( |
| 834 *receiver_handle, |
| 835 *name_handle, |
| 836 &attributes); |
| 837 RETURN_IF_SCHEDULED_EXCEPTION(); |
| 838 } |
| 839 break; |
| 840 |
| 841 case JSObject::kLookupInHolder: |
| 842 result = holder_handle->GetPropertyPostInterceptor( |
| 843 *receiver_handle, |
| 844 *name_handle, |
| 845 &attributes); |
| 846 RETURN_IF_SCHEDULED_EXCEPTION(); |
| 847 break; |
| 848 |
| 849 default: |
| 850 UNREACHABLE(); |
| 851 } |
| 852 } |
| 853 |
| 801 if (result->IsFailure()) return result; | 854 if (result->IsFailure()) return result; |
| 802 | 855 if (attributes != ABSENT) return result; |
| 803 // If the property is present, return it. | |
| 804 if (attr != ABSENT) return result; | |
| 805 | 856 |
| 806 // If the top frame is an internal frame, this is really a call | 857 // If the top frame is an internal frame, this is really a call |
| 807 // IC. In this case, we simply return the undefined result which | 858 // IC. In this case, we simply return the undefined result which |
| 808 // will lead to an exception when trying to invoke the result as a | 859 // will lead to an exception when trying to invoke the result as a |
| 809 // function. | 860 // function. |
| 810 StackFrameIterator it; | 861 StackFrameIterator it; |
| 811 it.Advance(); // skip exit frame | 862 it.Advance(); // skip exit frame |
| 812 if (it.frame()->is_internal()) return result; | 863 if (it.frame()->is_internal()) return result; |
| 813 | 864 |
| 814 // If the load is non-contextual, just return the undefined result. | 865 // If the load is non-contextual, just return the undefined result. |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 int argc = arguments_.immediate(); | 1060 int argc = arguments_.immediate(); |
| 1010 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, | 1061 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, |
| 1011 type, | 1062 type, |
| 1012 in_loop_, | 1063 in_loop_, |
| 1013 argc); | 1064 argc); |
| 1014 return GetCodeWithFlags(flags, name); | 1065 return GetCodeWithFlags(flags, name); |
| 1015 } | 1066 } |
| 1016 | 1067 |
| 1017 | 1068 |
| 1018 } } // namespace v8::internal | 1069 } } // namespace v8::internal |
| OLD | NEW |