Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: src/isolate.cc

Issue 1516843002: [proxy] fixing harmony/proxy.js tests and improving error messages + some drive-by fixes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: WIP fix protoype walks with access checks Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 bool Isolate::IsInternallyUsedPropertyName(Handle<Object> name) { 767 bool Isolate::IsInternallyUsedPropertyName(Handle<Object> name) {
768 if (name->IsSymbol()) { 768 if (name->IsSymbol()) {
769 return Handle<Symbol>::cast(name)->is_private(); 769 return Handle<Symbol>::cast(name)->is_private();
770 } 770 }
771 return name.is_identical_to(factory()->hidden_string()); 771 return name.is_identical_to(factory()->hidden_string());
772 } 772 }
773 773
774 774
775 bool Isolate::MayAccess(Handle<Context> accessing_context, 775 bool Isolate::MayAccess(Handle<Context> accessing_context,
776 Handle<JSObject> receiver) { 776 Handle<JSObject> receiver) {
777 DCHECK(receiver->IsJSGlobalProxy() || receiver->IsAccessCheckNeeded()); 777 DCHECK(receiver->IsJSGlobalProxy() || receiver->IsJSGlobalObject() ||
778 receiver->IsAccessCheckNeeded());
778 779
779 // Check for compatibility between the security tokens in the 780 // Check for compatibility between the security tokens in the
780 // current lexical context and the accessed object. 781 // current lexical context and the accessed object.
781 782
782 { 783 {
783 DisallowHeapAllocation no_gc; 784 DisallowHeapAllocation no_gc;
784 // During bootstrapping, callback functions are not enabled yet. 785 // During bootstrapping, callback functions are not enabled yet.
785 if (bootstrapper()->IsActive()) return true; 786 if (bootstrapper()->IsActive()) return true;
786 787
787 if (receiver->IsJSGlobalProxy()) { 788 if (receiver->IsJSGlobalProxy()) {
788 Object* receiver_context = 789 Object* receiver_context =
789 JSGlobalProxy::cast(*receiver)->native_context(); 790 JSGlobalProxy::cast(*receiver)->native_context();
790 if (!receiver_context->IsContext()) return false; 791 if (!receiver_context->IsContext()) return false;
791 792
792 // Get the native context of current top context. 793 // Get the native context of current top context.
793 // avoid using Isolate::native_context() because it uses Handle. 794 // avoid using Isolate::native_context() because it uses Handle.
794 Context* native_context = 795 Context* native_context =
795 accessing_context->global_object()->native_context(); 796 accessing_context->global_object()->native_context();
796 if (receiver_context == native_context) return true; 797 if (receiver_context == native_context) return true;
797 798
798 if (Context::cast(receiver_context)->security_token() == 799 if (Context::cast(receiver_context)->security_token() ==
799 native_context->security_token()) 800 native_context->security_token())
800 return true; 801 return true;
801 } 802 }
802 } 803 }
803 804
805 {
806 DisallowHeapAllocation no_gc;
807 // During bootstrapping, callback functions are not enabled yet.
808 if (bootstrapper()->IsActive()) return true;
809
810 if (receiver->IsJSGlobalObject()) {
811 Object* receiver_context =
812 JSGlobalObject::cast(*receiver)->native_context();
813 if (!receiver_context->IsContext()) return false;
814
815 // Get the native context of current top context.
816 // avoid using Isolate::native_context() because it uses Handle.
817 Context* native_context =
818 accessing_context->global_object()->native_context();
819 if (receiver_context == native_context) return true;
820
821 if (Context::cast(receiver_context)->security_token() ==
822 native_context->security_token())
823 return true;
824 }
825 }
826
804 HandleScope scope(this); 827 HandleScope scope(this);
805 Handle<Object> data; 828 Handle<Object> data;
806 v8::AccessCheckCallback callback = nullptr; 829 v8::AccessCheckCallback callback = nullptr;
807 v8::NamedSecurityCallback named_callback = nullptr; 830 v8::NamedSecurityCallback named_callback = nullptr;
808 { DisallowHeapAllocation no_gc; 831 { DisallowHeapAllocation no_gc;
809 AccessCheckInfo* access_check_info = GetAccessCheckInfo(this, receiver); 832 AccessCheckInfo* access_check_info = GetAccessCheckInfo(this, receiver);
810 if (!access_check_info) return false; 833 if (!access_check_info) return false;
811 Object* fun_obj = access_check_info->callback(); 834 Object* fun_obj = access_check_info->callback();
812 callback = v8::ToCData<v8::AccessCheckCallback>(fun_obj); 835 callback = v8::ToCData<v8::AccessCheckCallback>(fun_obj);
813 if (!callback) { 836 if (!callback) {
(...skipping 1998 matching lines...) Expand 10 before | Expand all | Expand 10 after
2812 // Then check whether this scope intercepts. 2835 // Then check whether this scope intercepts.
2813 if ((flag & intercept_mask_)) { 2836 if ((flag & intercept_mask_)) {
2814 intercepted_flags_ |= flag; 2837 intercepted_flags_ |= flag;
2815 return true; 2838 return true;
2816 } 2839 }
2817 return false; 2840 return false;
2818 } 2841 }
2819 2842
2820 } // namespace internal 2843 } // namespace internal
2821 } // namespace v8 2844 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698