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/v8.h" | 5 #include "src/v8.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.h" | 9 #include "src/debug.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 return isolate->heap()->undefined_value(); | 1003 return isolate->heap()->undefined_value(); |
1004 } | 1004 } |
1005 | 1005 |
1006 | 1006 |
1007 RUNTIME_FUNCTION(Runtime_OwnKeys) { | 1007 RUNTIME_FUNCTION(Runtime_OwnKeys) { |
1008 HandleScope scope(isolate); | 1008 HandleScope scope(isolate); |
1009 DCHECK(args.length() == 1); | 1009 DCHECK(args.length() == 1); |
1010 CONVERT_ARG_CHECKED(JSObject, raw_object, 0); | 1010 CONVERT_ARG_CHECKED(JSObject, raw_object, 0); |
1011 Handle<JSObject> object(raw_object); | 1011 Handle<JSObject> object(raw_object); |
1012 | 1012 |
1013 if (object->IsJSGlobalProxy()) { | |
1014 // Do access checks before going to the global object. | |
1015 if (object->IsAccessCheckNeeded() && !isolate->MayAccess(object)) { | |
1016 isolate->ReportFailedAccessCheck(object); | |
1017 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | |
1018 return *isolate->factory()->NewJSArray(0); | |
1019 } | |
1020 | |
1021 PrototypeIterator iter(isolate, object); | |
1022 // If proxy is detached we simply return an empty array. | |
1023 if (iter.IsAtEnd()) return *isolate->factory()->NewJSArray(0); | |
1024 object = Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); | |
1025 } | |
1026 | |
1027 Handle<FixedArray> contents; | 1013 Handle<FixedArray> contents; |
1028 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1014 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1029 isolate, contents, JSReceiver::GetKeys(object, JSReceiver::OWN_ONLY)); | 1015 isolate, contents, JSReceiver::GetKeys(object, JSReceiver::OWN_ONLY)); |
1030 | 1016 |
1031 // Some fast paths through GetKeysInFixedArrayFor reuse a cached | 1017 // Some fast paths through GetKeysInFixedArrayFor reuse a cached |
1032 // property array and since the result is mutable we have to create | 1018 // property array and since the result is mutable we have to create |
1033 // a fresh clone on each invocation. | 1019 // a fresh clone on each invocation. |
1034 int length = contents->length(); | 1020 int length = contents->length(); |
1035 Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length); | 1021 Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length); |
1036 for (int i = 0; i < length; i++) { | 1022 for (int i = 0; i < length; i++) { |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | 1456 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); |
1471 | 1457 |
1472 RETURN_FAILURE_ON_EXCEPTION( | 1458 RETURN_FAILURE_ON_EXCEPTION( |
1473 isolate, | 1459 isolate, |
1474 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), | 1460 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), |
1475 setter, attrs)); | 1461 setter, attrs)); |
1476 return isolate->heap()->undefined_value(); | 1462 return isolate->heap()->undefined_value(); |
1477 } | 1463 } |
1478 } // namespace internal | 1464 } // namespace internal |
1479 } // namespace v8 | 1465 } // namespace v8 |
OLD | NEW |