OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/isolate.h" | 5 #include "src/isolate.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 | 775 |
776 | 776 |
777 bool Isolate::IsInternallyUsedPropertyName(Object* name) { | 777 bool Isolate::IsInternallyUsedPropertyName(Object* name) { |
778 if (name->IsSymbol()) { | 778 if (name->IsSymbol()) { |
779 return Symbol::cast(name)->is_private(); | 779 return Symbol::cast(name)->is_private(); |
780 } | 780 } |
781 return name == heap()->hidden_string(); | 781 return name == heap()->hidden_string(); |
782 } | 782 } |
783 | 783 |
784 | 784 |
785 bool Isolate::MayAccess(Handle<JSObject> receiver) { | 785 bool Isolate::MayAccess(Handle<Context> accessing_context, |
| 786 Handle<JSObject> receiver) { |
786 DCHECK(receiver->IsJSGlobalProxy() || receiver->IsAccessCheckNeeded()); | 787 DCHECK(receiver->IsJSGlobalProxy() || receiver->IsAccessCheckNeeded()); |
787 | 788 |
788 // Check for compatibility between the security tokens in the | 789 // Check for compatibility between the security tokens in the |
789 // current lexical context and the accessed object. | 790 // current lexical context and the accessed object. |
790 DCHECK(context()); | |
791 | 791 |
792 { | 792 { |
793 DisallowHeapAllocation no_gc; | 793 DisallowHeapAllocation no_gc; |
794 // During bootstrapping, callback functions are not enabled yet. | 794 // During bootstrapping, callback functions are not enabled yet. |
795 if (bootstrapper()->IsActive()) return true; | 795 if (bootstrapper()->IsActive()) return true; |
796 | 796 |
797 if (receiver->IsJSGlobalProxy()) { | 797 if (receiver->IsJSGlobalProxy()) { |
798 Object* receiver_context = | 798 Object* receiver_context = |
799 JSGlobalProxy::cast(*receiver)->native_context(); | 799 JSGlobalProxy::cast(*receiver)->native_context(); |
800 if (!receiver_context->IsContext()) return false; | 800 if (!receiver_context->IsContext()) return false; |
801 | 801 |
802 // Get the native context of current top context. | 802 // Get the native context of current top context. |
803 // avoid using Isolate::native_context() because it uses Handle. | 803 // avoid using Isolate::native_context() because it uses Handle. |
804 Context* native_context = context()->global_object()->native_context(); | 804 Context* native_context = |
| 805 accessing_context->global_object()->native_context(); |
805 if (receiver_context == native_context) return true; | 806 if (receiver_context == native_context) return true; |
806 | 807 |
807 if (Context::cast(receiver_context)->security_token() == | 808 if (Context::cast(receiver_context)->security_token() == |
808 native_context->security_token()) | 809 native_context->security_token()) |
809 return true; | 810 return true; |
810 } | 811 } |
811 } | 812 } |
812 | 813 |
813 HandleScope scope(this); | 814 HandleScope scope(this); |
814 Handle<Object> data; | 815 Handle<Object> data; |
815 v8::NamedSecurityCallback callback; | 816 v8::NamedSecurityCallback callback; |
816 { DisallowHeapAllocation no_gc; | 817 { DisallowHeapAllocation no_gc; |
817 AccessCheckInfo* access_check_info = GetAccessCheckInfo(this, receiver); | 818 AccessCheckInfo* access_check_info = GetAccessCheckInfo(this, receiver); |
818 if (!access_check_info) return false; | 819 if (!access_check_info) return false; |
819 Object* fun_obj = access_check_info->named_callback(); | 820 Object* fun_obj = access_check_info->named_callback(); |
820 callback = v8::ToCData<v8::NamedSecurityCallback>(fun_obj); | 821 callback = v8::ToCData<v8::NamedSecurityCallback>(fun_obj); |
821 if (!callback) return false; | 822 if (!callback) return false; |
822 data = handle(access_check_info->data(), this); | 823 data = handle(access_check_info->data(), this); |
823 } | 824 } |
824 | 825 |
825 LOG(this, ApiSecurityCheck()); | 826 LOG(this, ApiSecurityCheck()); |
826 | 827 |
827 // Leaving JavaScript. | 828 { |
828 VMState<EXTERNAL> state(this); | 829 SaveContext save(this); |
829 Handle<Object> key = factory()->undefined_value(); | 830 set_context(accessing_context->native_context()); |
830 return callback(v8::Utils::ToLocal(receiver), v8::Utils::ToLocal(key), | 831 |
831 v8::ACCESS_HAS, v8::Utils::ToLocal(data)); | 832 // Leaving JavaScript. |
| 833 VMState<EXTERNAL> state(this); |
| 834 Handle<Object> key = factory()->undefined_value(); |
| 835 return callback(v8::Utils::ToLocal(receiver), v8::Utils::ToLocal(key), |
| 836 v8::ACCESS_HAS, v8::Utils::ToLocal(data)); |
| 837 } |
832 } | 838 } |
833 | 839 |
834 | 840 |
835 const char* const Isolate::kStackOverflowMessage = | 841 const char* const Isolate::kStackOverflowMessage = |
836 "Uncaught RangeError: Maximum call stack size exceeded"; | 842 "Uncaught RangeError: Maximum call stack size exceeded"; |
837 | 843 |
838 | 844 |
839 Object* Isolate::StackOverflow() { | 845 Object* Isolate::StackOverflow() { |
840 HandleScope scope(this); | 846 HandleScope scope(this); |
841 // At this point we cannot create an Error object using its javascript | 847 // At this point we cannot create an Error object using its javascript |
(...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2837 // Then check whether this scope intercepts. | 2843 // Then check whether this scope intercepts. |
2838 if ((flag & intercept_mask_)) { | 2844 if ((flag & intercept_mask_)) { |
2839 intercepted_flags_ |= flag; | 2845 intercepted_flags_ |= flag; |
2840 return true; | 2846 return true; |
2841 } | 2847 } |
2842 return false; | 2848 return false; |
2843 } | 2849 } |
2844 | 2850 |
2845 } // namespace internal | 2851 } // namespace internal |
2846 } // namespace v8 | 2852 } // namespace v8 |
OLD | NEW |