OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 return line; | 694 return line; |
695 } | 695 } |
696 | 696 |
697 | 697 |
698 void CustomArguments::IterateInstance(ObjectVisitor* v) { | 698 void CustomArguments::IterateInstance(ObjectVisitor* v) { |
699 v->VisitPointers(values_, values_ + ARRAY_SIZE(values_)); | 699 v->VisitPointers(values_, values_ + ARRAY_SIZE(values_)); |
700 } | 700 } |
701 | 701 |
702 | 702 |
703 // Compute the property keys from the interceptor. | 703 // Compute the property keys from the interceptor. |
704 v8::Handle<v8::Array> GetKeysForNamedInterceptor(Handle<JSObject> receiver, | 704 v8::Handle<v8::Array> GetKeysForNamedInterceptor(Handle<JSReceiver> receiver, |
705 Handle<JSObject> object) { | 705 Handle<JSObject> object) { |
706 Isolate* isolate = receiver->GetIsolate(); | 706 Isolate* isolate = receiver->GetIsolate(); |
707 Handle<InterceptorInfo> interceptor(object->GetNamedInterceptor()); | 707 Handle<InterceptorInfo> interceptor(object->GetNamedInterceptor()); |
708 CustomArguments args(isolate, interceptor->data(), *receiver, *object); | 708 CustomArguments args(isolate, interceptor->data(), *receiver, *object); |
709 v8::AccessorInfo info(args.end()); | 709 v8::AccessorInfo info(args.end()); |
710 v8::Handle<v8::Array> result; | 710 v8::Handle<v8::Array> result; |
711 if (!interceptor->enumerator()->IsUndefined()) { | 711 if (!interceptor->enumerator()->IsUndefined()) { |
712 v8::NamedPropertyEnumerator enum_fun = | 712 v8::NamedPropertyEnumerator enum_fun = |
713 v8::ToCData<v8::NamedPropertyEnumerator>(interceptor->enumerator()); | 713 v8::ToCData<v8::NamedPropertyEnumerator>(interceptor->enumerator()); |
714 LOG(isolate, ApiObjectAccess("interceptor-named-enum", *object)); | 714 LOG(isolate, ApiObjectAccess("interceptor-named-enum", *object)); |
715 { | 715 { |
716 // Leaving JavaScript. | 716 // Leaving JavaScript. |
717 VMState state(isolate, EXTERNAL); | 717 VMState state(isolate, EXTERNAL); |
718 result = enum_fun(info); | 718 result = enum_fun(info); |
719 } | 719 } |
720 } | 720 } |
721 return result; | 721 return result; |
722 } | 722 } |
723 | 723 |
724 | 724 |
725 // Compute the element keys from the interceptor. | 725 // Compute the element keys from the interceptor. |
726 v8::Handle<v8::Array> GetKeysForIndexedInterceptor(Handle<JSObject> receiver, | 726 v8::Handle<v8::Array> GetKeysForIndexedInterceptor(Handle<JSReceiver> receiver, |
727 Handle<JSObject> object) { | 727 Handle<JSObject> object) { |
728 Isolate* isolate = receiver->GetIsolate(); | 728 Isolate* isolate = receiver->GetIsolate(); |
729 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor()); | 729 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor()); |
730 CustomArguments args(isolate, interceptor->data(), *receiver, *object); | 730 CustomArguments args(isolate, interceptor->data(), *receiver, *object); |
731 v8::AccessorInfo info(args.end()); | 731 v8::AccessorInfo info(args.end()); |
732 v8::Handle<v8::Array> result; | 732 v8::Handle<v8::Array> result; |
733 if (!interceptor->enumerator()->IsUndefined()) { | 733 if (!interceptor->enumerator()->IsUndefined()) { |
734 v8::IndexedPropertyEnumerator enum_fun = | 734 v8::IndexedPropertyEnumerator enum_fun = |
735 v8::ToCData<v8::IndexedPropertyEnumerator>(interceptor->enumerator()); | 735 v8::ToCData<v8::IndexedPropertyEnumerator>(interceptor->enumerator()); |
736 LOG(isolate, ApiObjectAccess("interceptor-indexed-enum", *object)); | 736 LOG(isolate, ApiObjectAccess("interceptor-indexed-enum", *object)); |
(...skipping 10 matching lines...) Expand all Loading... |
747 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) { | 747 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) { |
748 int len = array->length(); | 748 int len = array->length(); |
749 for (int i = 0; i < len; i++) { | 749 for (int i = 0; i < len; i++) { |
750 Object* e = array->get(i); | 750 Object* e = array->get(i); |
751 if (!(e->IsString() || e->IsNumber())) return false; | 751 if (!(e->IsString() || e->IsNumber())) return false; |
752 } | 752 } |
753 return true; | 753 return true; |
754 } | 754 } |
755 | 755 |
756 | 756 |
757 Handle<FixedArray> GetKeysInFixedArrayFor(Handle<JSObject> object, | 757 Handle<FixedArray> GetKeysInFixedArrayFor(Handle<JSReceiver> object, |
758 KeyCollectionType type) { | 758 KeyCollectionType type, |
| 759 bool* threw) { |
759 USE(ContainsOnlyValidKeys); | 760 USE(ContainsOnlyValidKeys); |
760 Isolate* isolate = object->GetIsolate(); | 761 Isolate* isolate = object->GetIsolate(); |
761 Handle<FixedArray> content = isolate->factory()->empty_fixed_array(); | 762 Handle<FixedArray> content = isolate->factory()->empty_fixed_array(); |
762 Handle<JSObject> arguments_boilerplate = Handle<JSObject>( | 763 Handle<JSObject> arguments_boilerplate = Handle<JSObject>( |
763 isolate->context()->global_context()->arguments_boilerplate(), | 764 isolate->context()->global_context()->arguments_boilerplate(), |
764 isolate); | 765 isolate); |
765 Handle<JSFunction> arguments_function = Handle<JSFunction>( | 766 Handle<JSFunction> arguments_function = Handle<JSFunction>( |
766 JSFunction::cast(arguments_boilerplate->map()->constructor()), | 767 JSFunction::cast(arguments_boilerplate->map()->constructor()), |
767 isolate); | 768 isolate); |
768 | 769 |
769 // Only collect keys if access is permitted. | 770 // Only collect keys if access is permitted. |
770 for (Handle<Object> p = object; | 771 for (Handle<Object> p = object; |
771 *p != isolate->heap()->null_value(); | 772 *p != isolate->heap()->null_value(); |
772 p = Handle<Object>(p->GetPrototype(), isolate)) { | 773 p = Handle<Object>(p->GetPrototype(), isolate)) { |
| 774 if (p->IsJSProxy()) { |
| 775 Handle<JSProxy> proxy(JSProxy::cast(*p), isolate); |
| 776 Handle<Object> args[] = { proxy }; |
| 777 Handle<Object> names = Execution::Call( |
| 778 isolate->proxy_enumerate(), object, ARRAY_SIZE(args), args, threw); |
| 779 if (*threw) return content; |
| 780 content = AddKeysFromJSArray(content, Handle<JSArray>::cast(names)); |
| 781 break; |
| 782 } |
| 783 |
773 Handle<JSObject> current(JSObject::cast(*p), isolate); | 784 Handle<JSObject> current(JSObject::cast(*p), isolate); |
774 | 785 |
775 // Check access rights if required. | 786 // Check access rights if required. |
776 if (current->IsAccessCheckNeeded() && | 787 if (current->IsAccessCheckNeeded() && |
777 !isolate->MayNamedAccess(*current, | 788 !isolate->MayNamedAccess(*current, |
778 isolate->heap()->undefined_value(), | 789 isolate->heap()->undefined_value(), |
779 v8::ACCESS_KEYS)) { | 790 v8::ACCESS_KEYS)) { |
780 isolate->ReportFailedAccessCheck(*current, v8::ACCESS_KEYS); | 791 isolate->ReportFailedAccessCheck(*current, v8::ACCESS_KEYS); |
781 break; | 792 break; |
782 } | 793 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 | 840 |
830 // If we only want local properties we bail out after the first | 841 // If we only want local properties we bail out after the first |
831 // iteration. | 842 // iteration. |
832 if (type == LOCAL_ONLY) | 843 if (type == LOCAL_ONLY) |
833 break; | 844 break; |
834 } | 845 } |
835 return content; | 846 return content; |
836 } | 847 } |
837 | 848 |
838 | 849 |
839 Handle<JSArray> GetKeysFor(Handle<JSObject> object) { | 850 Handle<JSArray> GetKeysFor(Handle<JSReceiver> object, bool* threw) { |
840 Isolate* isolate = object->GetIsolate(); | 851 Isolate* isolate = object->GetIsolate(); |
841 isolate->counters()->for_in()->Increment(); | 852 isolate->counters()->for_in()->Increment(); |
842 Handle<FixedArray> elements = GetKeysInFixedArrayFor(object, | 853 Handle<FixedArray> elements = |
843 INCLUDE_PROTOS); | 854 GetKeysInFixedArrayFor(object, INCLUDE_PROTOS, threw); |
844 return isolate->factory()->NewJSArrayWithElements(elements); | 855 return isolate->factory()->NewJSArrayWithElements(elements); |
845 } | 856 } |
846 | 857 |
847 | 858 |
848 Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object, | 859 Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object, |
849 bool cache_result) { | 860 bool cache_result) { |
850 int index = 0; | 861 int index = 0; |
851 Isolate* isolate = object->GetIsolate(); | 862 Isolate* isolate = object->GetIsolate(); |
852 if (object->HasFastProperties()) { | 863 if (object->HasFastProperties()) { |
853 if (object->map()->instance_descriptors()->HasEnumCache()) { | 864 if (object->map()->instance_descriptors()->HasEnumCache()) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 | 953 |
943 bool CompileOptimized(Handle<JSFunction> function, | 954 bool CompileOptimized(Handle<JSFunction> function, |
944 int osr_ast_id, | 955 int osr_ast_id, |
945 ClearExceptionFlag flag) { | 956 ClearExceptionFlag flag) { |
946 CompilationInfo info(function); | 957 CompilationInfo info(function); |
947 info.SetOptimizing(osr_ast_id); | 958 info.SetOptimizing(osr_ast_id); |
948 return CompileLazyHelper(&info, flag); | 959 return CompileLazyHelper(&info, flag); |
949 } | 960 } |
950 | 961 |
951 } } // namespace v8::internal | 962 } } // namespace v8::internal |
OLD | NEW |