| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
| 10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 } | 153 } |
| 154 | 154 |
| 155 | 155 |
| 156 RUNTIME_FUNCTION(Runtime_GetPrototype) { | 156 RUNTIME_FUNCTION(Runtime_GetPrototype) { |
| 157 HandleScope scope(isolate); | 157 HandleScope scope(isolate); |
| 158 DCHECK(args.length() == 1); | 158 DCHECK(args.length() == 1); |
| 159 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); | 159 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); |
| 160 // We don't expect access checks to be needed on JSProxy objects. | 160 // We don't expect access checks to be needed on JSProxy objects. |
| 161 DCHECK(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); | 161 DCHECK(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); |
| 162 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); | 162 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); |
| 163 Handle<Context> context(isolate->context()); |
| 163 do { | 164 do { |
| 164 if (PrototypeIterator::GetCurrent(iter)->IsAccessCheckNeeded() && | 165 if (PrototypeIterator::GetCurrent(iter)->IsAccessCheckNeeded() && |
| 165 !isolate->MayAccess(PrototypeIterator::GetCurrent<JSObject>(iter))) { | 166 !isolate->MayAccess(context, |
| 167 PrototypeIterator::GetCurrent<JSObject>(iter))) { |
| 166 return isolate->heap()->null_value(); | 168 return isolate->heap()->null_value(); |
| 167 } | 169 } |
| 168 iter.AdvanceIgnoringProxies(); | 170 iter.AdvanceIgnoringProxies(); |
| 169 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { | 171 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { |
| 170 return *PrototypeIterator::GetCurrent(iter); | 172 return *PrototypeIterator::GetCurrent(iter); |
| 171 } | 173 } |
| 172 } while (!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)); | 174 } while (!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)); |
| 173 return *PrototypeIterator::GetCurrent(iter); | 175 return *PrototypeIterator::GetCurrent(iter); |
| 174 } | 176 } |
| 175 | 177 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 186 isolate, result, JSObject::SetPrototype(obj, prototype, false)); | 188 isolate, result, JSObject::SetPrototype(obj, prototype, false)); |
| 187 return *result; | 189 return *result; |
| 188 } | 190 } |
| 189 | 191 |
| 190 | 192 |
| 191 RUNTIME_FUNCTION(Runtime_SetPrototype) { | 193 RUNTIME_FUNCTION(Runtime_SetPrototype) { |
| 192 HandleScope scope(isolate); | 194 HandleScope scope(isolate); |
| 193 DCHECK(args.length() == 2); | 195 DCHECK(args.length() == 2); |
| 194 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 196 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 195 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); | 197 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); |
| 196 if (obj->IsAccessCheckNeeded() && !isolate->MayAccess(obj)) { | 198 if (obj->IsAccessCheckNeeded() && |
| 199 !isolate->MayAccess(handle(isolate->context()), obj)) { |
| 197 isolate->ReportFailedAccessCheck(obj); | 200 isolate->ReportFailedAccessCheck(obj); |
| 198 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 201 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 199 return isolate->heap()->undefined_value(); | 202 return isolate->heap()->undefined_value(); |
| 200 } | 203 } |
| 201 if (obj->map()->is_observed()) { | 204 if (obj->map()->is_observed()) { |
| 202 Handle<Object> old_value = | 205 Handle<Object> old_value = |
| 203 Object::GetPrototypeSkipHiddenPrototypes(isolate, obj); | 206 Object::GetPrototypeSkipHiddenPrototypes(isolate, obj); |
| 204 Handle<Object> result; | 207 Handle<Object> result; |
| 205 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 208 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 206 isolate, result, JSObject::SetPrototype(obj, prototype, true)); | 209 isolate, result, JSObject::SetPrototype(obj, prototype, true)); |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 break; | 845 break; |
| 843 } | 846 } |
| 844 } | 847 } |
| 845 } | 848 } |
| 846 } | 849 } |
| 847 next_copy_index += own; | 850 next_copy_index += own; |
| 848 } | 851 } |
| 849 | 852 |
| 850 CHECK_EQ(total_property_count, next_copy_index); | 853 CHECK_EQ(total_property_count, next_copy_index); |
| 851 | 854 |
| 852 if (object->IsAccessCheckNeeded() && !isolate->MayAccess(object)) { | 855 if (object->IsAccessCheckNeeded() && |
| 856 !isolate->MayAccess(handle(isolate->context()), object)) { |
| 853 for (int i = 0; i < total_property_count; i++) { | 857 for (int i = 0; i < total_property_count; i++) { |
| 854 Handle<Name> name(Name::cast(names->get(i))); | 858 Handle<Name> name(Name::cast(names->get(i))); |
| 855 if (name.is_identical_to(hidden_string)) continue; | 859 if (name.is_identical_to(hidden_string)) continue; |
| 856 LookupIterator it(object, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); | 860 LookupIterator it(object, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); |
| 857 if (!JSObject::AllCanRead(&it)) { | 861 if (!JSObject::AllCanRead(&it)) { |
| 858 names->set(i, *hidden_string); | 862 names->set(i, *hidden_string); |
| 859 hidden_strings++; | 863 hidden_strings++; |
| 860 } | 864 } |
| 861 } | 865 } |
| 862 } | 866 } |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1618 RUNTIME_FUNCTION(Runtime_IsAccessCheckNeeded) { | 1622 RUNTIME_FUNCTION(Runtime_IsAccessCheckNeeded) { |
| 1619 SealHandleScope shs(isolate); | 1623 SealHandleScope shs(isolate); |
| 1620 DCHECK_EQ(1, args.length()); | 1624 DCHECK_EQ(1, args.length()); |
| 1621 CONVERT_ARG_CHECKED(Object, object, 0); | 1625 CONVERT_ARG_CHECKED(Object, object, 0); |
| 1622 return isolate->heap()->ToBoolean(object->IsAccessCheckNeeded()); | 1626 return isolate->heap()->ToBoolean(object->IsAccessCheckNeeded()); |
| 1623 } | 1627 } |
| 1624 | 1628 |
| 1625 | 1629 |
| 1626 } // namespace internal | 1630 } // namespace internal |
| 1627 } // namespace v8 | 1631 } // namespace v8 |
| OLD | NEW |