| 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 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 accumulator->Add("=====================\n\n"); | 795 accumulator->Add("=====================\n\n"); |
| 796 } | 796 } |
| 797 | 797 |
| 798 | 798 |
| 799 void Isolate::SetFailedAccessCheckCallback( | 799 void Isolate::SetFailedAccessCheckCallback( |
| 800 v8::FailedAccessCheckCallback callback) { | 800 v8::FailedAccessCheckCallback callback) { |
| 801 thread_local_top()->failed_access_check_callback_ = callback; | 801 thread_local_top()->failed_access_check_callback_ = callback; |
| 802 } | 802 } |
| 803 | 803 |
| 804 | 804 |
| 805 static inline AccessCheckInfo* GetAccessCheckInfo(Isolate* isolate, | |
| 806 Handle<JSObject> receiver) { | |
| 807 Object* maybe_constructor = receiver->map()->GetConstructor(); | |
| 808 if (!maybe_constructor->IsJSFunction()) return NULL; | |
| 809 JSFunction* constructor = JSFunction::cast(maybe_constructor); | |
| 810 if (!constructor->shared()->IsApiFunction()) return NULL; | |
| 811 | |
| 812 Object* data_obj = | |
| 813 constructor->shared()->get_api_func_data()->access_check_info(); | |
| 814 if (data_obj->IsUndefined(isolate)) return NULL; | |
| 815 | |
| 816 return AccessCheckInfo::cast(data_obj); | |
| 817 } | |
| 818 | |
| 819 | |
| 820 void Isolate::ReportFailedAccessCheck(Handle<JSObject> receiver) { | 805 void Isolate::ReportFailedAccessCheck(Handle<JSObject> receiver) { |
| 821 if (!thread_local_top()->failed_access_check_callback_) { | 806 if (!thread_local_top()->failed_access_check_callback_) { |
| 822 return ScheduleThrow(*factory()->NewTypeError(MessageTemplate::kNoAccess)); | 807 return ScheduleThrow(*factory()->NewTypeError(MessageTemplate::kNoAccess)); |
| 823 } | 808 } |
| 824 | 809 |
| 825 DCHECK(receiver->IsAccessCheckNeeded()); | 810 DCHECK(receiver->IsAccessCheckNeeded()); |
| 826 DCHECK(context()); | 811 DCHECK(context()); |
| 827 | 812 |
| 828 // Get the data object from access check info. | 813 // Get the data object from access check info. |
| 829 HandleScope scope(this); | 814 HandleScope scope(this); |
| 830 Handle<Object> data; | 815 Handle<Object> data; |
| 831 { DisallowHeapAllocation no_gc; | 816 { DisallowHeapAllocation no_gc; |
| 832 AccessCheckInfo* access_check_info = GetAccessCheckInfo(this, receiver); | 817 AccessCheckInfo* access_check_info = AccessCheckInfo::Get(this, receiver); |
| 833 if (!access_check_info) { | 818 if (!access_check_info) { |
| 834 AllowHeapAllocation doesnt_matter_anymore; | 819 AllowHeapAllocation doesnt_matter_anymore; |
| 835 return ScheduleThrow( | 820 return ScheduleThrow( |
| 836 *factory()->NewTypeError(MessageTemplate::kNoAccess)); | 821 *factory()->NewTypeError(MessageTemplate::kNoAccess)); |
| 837 } | 822 } |
| 838 data = handle(access_check_info->data(), this); | 823 data = handle(access_check_info->data(), this); |
| 839 } | 824 } |
| 840 | 825 |
| 841 // Leaving JavaScript. | 826 // Leaving JavaScript. |
| 842 VMState<EXTERNAL> state(this); | 827 VMState<EXTERNAL> state(this); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 871 if (Context::cast(receiver_context)->security_token() == | 856 if (Context::cast(receiver_context)->security_token() == |
| 872 native_context->security_token()) | 857 native_context->security_token()) |
| 873 return true; | 858 return true; |
| 874 } | 859 } |
| 875 } | 860 } |
| 876 | 861 |
| 877 HandleScope scope(this); | 862 HandleScope scope(this); |
| 878 Handle<Object> data; | 863 Handle<Object> data; |
| 879 v8::AccessCheckCallback callback = nullptr; | 864 v8::AccessCheckCallback callback = nullptr; |
| 880 { DisallowHeapAllocation no_gc; | 865 { DisallowHeapAllocation no_gc; |
| 881 AccessCheckInfo* access_check_info = GetAccessCheckInfo(this, receiver); | 866 AccessCheckInfo* access_check_info = AccessCheckInfo::Get(this, receiver); |
| 882 if (!access_check_info) return false; | 867 if (!access_check_info) return false; |
| 883 Object* fun_obj = access_check_info->callback(); | 868 Object* fun_obj = access_check_info->callback(); |
| 884 callback = v8::ToCData<v8::AccessCheckCallback>(fun_obj); | 869 callback = v8::ToCData<v8::AccessCheckCallback>(fun_obj); |
| 885 data = handle(access_check_info->data(), this); | 870 data = handle(access_check_info->data(), this); |
| 886 } | 871 } |
| 887 | 872 |
| 888 LOG(this, ApiSecurityCheck()); | 873 LOG(this, ApiSecurityCheck()); |
| 889 | 874 |
| 890 { | 875 { |
| 891 // Leaving JavaScript. | 876 // Leaving JavaScript. |
| (...skipping 2166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3058 // Then check whether this scope intercepts. | 3043 // Then check whether this scope intercepts. |
| 3059 if ((flag & intercept_mask_)) { | 3044 if ((flag & intercept_mask_)) { |
| 3060 intercepted_flags_ |= flag; | 3045 intercepted_flags_ |= flag; |
| 3061 return true; | 3046 return true; |
| 3062 } | 3047 } |
| 3063 return false; | 3048 return false; |
| 3064 } | 3049 } |
| 3065 | 3050 |
| 3066 } // namespace internal | 3051 } // namespace internal |
| 3067 } // namespace v8 | 3052 } // namespace v8 |
| OLD | NEW |