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 <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include <fstream> // NOLINT(readability/streams) | 7 #include <fstream> // NOLINT(readability/streams) |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 if (!constructor->shared()->IsApiFunction()) return NULL; | 737 if (!constructor->shared()->IsApiFunction()) return NULL; |
738 | 738 |
739 Object* data_obj = | 739 Object* data_obj = |
740 constructor->shared()->get_api_func_data()->access_check_info(); | 740 constructor->shared()->get_api_func_data()->access_check_info(); |
741 if (data_obj == isolate->heap()->undefined_value()) return NULL; | 741 if (data_obj == isolate->heap()->undefined_value()) return NULL; |
742 | 742 |
743 return AccessCheckInfo::cast(data_obj); | 743 return AccessCheckInfo::cast(data_obj); |
744 } | 744 } |
745 | 745 |
746 | 746 |
747 static void ThrowAccessCheckError(Isolate* isolate) { | |
748 Handle<String> message = | |
749 isolate->factory()->InternalizeUtf8String("no access"); | |
750 isolate->ScheduleThrow(*isolate->factory()->NewTypeError(message)); | |
751 } | |
752 | |
753 | |
754 void Isolate::ReportFailedAccessCheck(Handle<JSObject> receiver) { | 747 void Isolate::ReportFailedAccessCheck(Handle<JSObject> receiver) { |
755 if (!thread_local_top()->failed_access_check_callback_) { | 748 if (!thread_local_top()->failed_access_check_callback_) { |
756 return ThrowAccessCheckError(this); | 749 return ScheduleThrow(*factory()->NewTypeError(MessageTemplate::kNoAccess)); |
757 } | 750 } |
758 | 751 |
759 DCHECK(receiver->IsAccessCheckNeeded()); | 752 DCHECK(receiver->IsAccessCheckNeeded()); |
760 DCHECK(context()); | 753 DCHECK(context()); |
761 | 754 |
762 // Get the data object from access check info. | 755 // Get the data object from access check info. |
763 HandleScope scope(this); | 756 HandleScope scope(this); |
764 Handle<Object> data; | 757 Handle<Object> data; |
765 { DisallowHeapAllocation no_gc; | 758 { DisallowHeapAllocation no_gc; |
766 AccessCheckInfo* access_check_info = GetAccessCheckInfo(this, receiver); | 759 AccessCheckInfo* access_check_info = GetAccessCheckInfo(this, receiver); |
767 if (!access_check_info) { | 760 if (!access_check_info) { |
768 AllowHeapAllocation doesnt_matter_anymore; | 761 AllowHeapAllocation doesnt_matter_anymore; |
769 return ThrowAccessCheckError(this); | 762 return ScheduleThrow( |
| 763 *factory()->NewTypeError(MessageTemplate::kNoAccess)); |
770 } | 764 } |
771 data = handle(access_check_info->data(), this); | 765 data = handle(access_check_info->data(), this); |
772 } | 766 } |
773 | 767 |
774 // Leaving JavaScript. | 768 // Leaving JavaScript. |
775 VMState<EXTERNAL> state(this); | 769 VMState<EXTERNAL> state(this); |
776 thread_local_top()->failed_access_check_callback_( | 770 thread_local_top()->failed_access_check_callback_( |
777 v8::Utils::ToLocal(receiver), v8::ACCESS_HAS, v8::Utils::ToLocal(data)); | 771 v8::Utils::ToLocal(receiver), v8::ACCESS_HAS, v8::Utils::ToLocal(data)); |
778 } | 772 } |
779 | 773 |
(...skipping 1998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2778 if (prev_ && prev_->Intercept(flag)) return true; | 2772 if (prev_ && prev_->Intercept(flag)) return true; |
2779 // Then check whether this scope intercepts. | 2773 // Then check whether this scope intercepts. |
2780 if ((flag & intercept_mask_)) { | 2774 if ((flag & intercept_mask_)) { |
2781 intercepted_flags_ |= flag; | 2775 intercepted_flags_ |= flag; |
2782 return true; | 2776 return true; |
2783 } | 2777 } |
2784 return false; | 2778 return false; |
2785 } | 2779 } |
2786 | 2780 |
2787 } } // namespace v8::internal | 2781 } } // namespace v8::internal |
OLD | NEW |