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 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "v8.h" | 8 #include "v8.h" |
9 | 9 |
10 #include "accessors.h" | 10 #include "accessors.h" |
(...skipping 14799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14810 CONVERT_ARG_CHECKED(JSObject, obj1, 0); | 14810 CONVERT_ARG_CHECKED(JSObject, obj1, 0); |
14811 CONVERT_ARG_CHECKED(JSObject, obj2, 1); | 14811 CONVERT_ARG_CHECKED(JSObject, obj2, 1); |
14812 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); | 14812 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); |
14813 } | 14813 } |
14814 | 14814 |
14815 | 14815 |
14816 RUNTIME_FUNCTION(Runtime_IsAccessCheckNeeded) { | 14816 RUNTIME_FUNCTION(Runtime_IsAccessCheckNeeded) { |
14817 SealHandleScope shs(isolate); | 14817 SealHandleScope shs(isolate); |
14818 ASSERT(args.length() == 1); | 14818 ASSERT(args.length() == 1); |
14819 CONVERT_ARG_CHECKED(HeapObject, obj, 0); | 14819 CONVERT_ARG_CHECKED(HeapObject, obj, 0); |
14820 return isolate->heap()->ToBoolean(obj->IsAccessCheckNeeded()); | 14820 return isolate->heap()->ToBoolean(obj->map()->is_access_check_needed()); |
14821 } | 14821 } |
14822 | 14822 |
14823 | 14823 |
14824 RUNTIME_FUNCTION(Runtime_IsObserved) { | 14824 RUNTIME_FUNCTION(Runtime_IsObserved) { |
14825 SealHandleScope shs(isolate); | 14825 SealHandleScope shs(isolate); |
14826 ASSERT(args.length() == 1); | 14826 ASSERT(args.length() == 1); |
14827 | 14827 |
14828 if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value(); | 14828 if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value(); |
14829 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); | 14829 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); |
14830 if (obj->IsJSGlobalProxy()) { | 14830 if (obj->IsJSGlobalProxy()) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14895 // isolate. If it's called more often, the map should be moved into the | 14895 // isolate. If it's called more often, the map should be moved into the |
14896 // strong root list. | 14896 // strong root list. |
14897 Handle<Map> map = | 14897 Handle<Map> map = |
14898 isolate->factory()->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); | 14898 isolate->factory()->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); |
14899 Handle<JSWeakMap> weakmap = | 14899 Handle<JSWeakMap> weakmap = |
14900 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map)); | 14900 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map)); |
14901 return *WeakCollectionInitialize(isolate, weakmap); | 14901 return *WeakCollectionInitialize(isolate, weakmap); |
14902 } | 14902 } |
14903 | 14903 |
14904 | 14904 |
14905 static bool ContextsHaveSameOrigin(Handle<Context> context1, | |
14906 Handle<Context> context2) { | |
14907 return *context1 == *context2 || | |
rossberg
2014/04/30 11:28:32
Drop this micro opt (i.e., just check the security
rafaelw
2014/05/02 03:22:32
Done.
| |
14908 context1->security_token() == context2->security_token(); | |
14909 } | |
14910 | |
14911 | |
14905 RUNTIME_FUNCTION(Runtime_IsAccessAllowedForObserver) { | 14912 RUNTIME_FUNCTION(Runtime_IsAccessAllowedForObserver) { |
rossberg
2014/04/30 11:28:32
Rename this to talk about SameOrigin, not Access.
rafaelw
2014/05/02 03:22:32
Done.
| |
14906 HandleScope scope(isolate); | 14913 HandleScope scope(isolate); |
14907 ASSERT(args.length() == 3); | 14914 ASSERT(args.length() == 3); |
14908 CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0); | 14915 CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0); |
14909 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1); | 14916 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1); |
rossberg
2014/04/30 11:28:32
Side note: shouldn't this be JSReceiver, to includ
rafaelw
2014/05/02 03:22:32
Per offline discussion with Adam, we're going to a
| |
14910 RUNTIME_ASSERT(object->map()->is_access_check_needed()); | 14917 RUNTIME_ASSERT(object->map()->is_access_check_needed()); |
14911 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); | 14918 CONVERT_ARG_HANDLE_CHECKED(JSObject, record, 2); |
14912 SaveContext save(isolate); | 14919 |
14913 isolate->set_context(observer->context()); | 14920 Handle<Context> observer_context(observer->context()->native_context(), |
14914 if (!isolate->MayNamedAccess( | 14921 isolate); |
14915 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { | 14922 Handle<Context> object_context(object->GetCreationContext()); |
14916 return isolate->heap()->false_value(); | 14923 Handle<Context> record_context(record->GetCreationContext()); |
14917 } | 14924 |
14918 bool access_allowed = false; | 14925 return isolate->heap()->ToBoolean( |
14919 uint32_t index = 0; | 14926 ContextsHaveSameOrigin(object_context, observer_context) && |
14920 if (key->ToArrayIndex(&index) || | 14927 ContextsHaveSameOrigin(object_context, record_context)); |
14921 (key->IsString() && String::cast(*key)->AsArrayIndex(&index))) { | |
14922 access_allowed = | |
14923 isolate->MayIndexedAccess(object, index, v8::ACCESS_GET) && | |
14924 isolate->MayIndexedAccess(object, index, v8::ACCESS_HAS); | |
14925 } else { | |
14926 access_allowed = | |
14927 isolate->MayNamedAccess(object, key, v8::ACCESS_GET) && | |
14928 isolate->MayNamedAccess(object, key, v8::ACCESS_HAS); | |
14929 } | |
14930 return isolate->heap()->ToBoolean(access_allowed); | |
14931 } | 14928 } |
14932 | 14929 |
14933 | 14930 |
14931 RUNTIME_FUNCTION(Runtime_ObjectWasCreatedInCurrentOrigin) { | |
14932 HandleScope scope(isolate); | |
14933 ASSERT(args.length() == 1); | |
14934 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | |
14935 | |
14936 if (!receiver->map()->is_access_check_needed()) | |
14937 return isolate->heap()->true_value(); | |
rossberg
2014/04/30 11:28:32
Is this safe? It seems this would allow you to app
rafaelw
2014/05/02 03:22:32
This isn't really a concern since if we had access
| |
14938 | |
14939 // Given that proxies aren't currently exposed through the API, it's | |
14940 // hard to imagine how they could end up with the access check needed bit set. | |
14941 ASSERT(!receiver->IsJSProxy()); | |
14942 | |
14943 Handle<JSObject> object = Handle<JSObject>::cast(receiver); | |
14944 Handle<Context> creation_context(object->GetCreationContext(), isolate); | |
14945 return isolate->heap()->ToBoolean( | |
14946 ContextsHaveSameOrigin(creation_context, isolate->native_context())); | |
14947 } | |
14948 | |
14949 | |
14934 static Object* ArrayConstructorCommon(Isolate* isolate, | 14950 static Object* ArrayConstructorCommon(Isolate* isolate, |
14935 Handle<JSFunction> constructor, | 14951 Handle<JSFunction> constructor, |
14936 Handle<AllocationSite> site, | 14952 Handle<AllocationSite> site, |
14937 Arguments* caller_args) { | 14953 Arguments* caller_args) { |
14938 Factory* factory = isolate->factory(); | 14954 Factory* factory = isolate->factory(); |
14939 | 14955 |
14940 bool holey = false; | 14956 bool holey = false; |
14941 bool can_use_type_feedback = true; | 14957 bool can_use_type_feedback = true; |
14942 if (caller_args->length() == 1) { | 14958 if (caller_args->length() == 1) { |
14943 Handle<Object> argument_one = caller_args->at<Object>(0); | 14959 Handle<Object> argument_one = caller_args->at<Object>(0); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15139 } | 15155 } |
15140 return NULL; | 15156 return NULL; |
15141 } | 15157 } |
15142 | 15158 |
15143 | 15159 |
15144 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15160 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15145 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15161 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15146 } | 15162 } |
15147 | 15163 |
15148 } } // namespace v8::internal | 15164 } } // namespace v8::internal |
OLD | NEW |