OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 12933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12944 jsarray_map->LookupDescriptor(NULL, *length_string, &lookup); | 12944 jsarray_map->LookupDescriptor(NULL, *length_string, &lookup); |
12945 return lookup.IsReadOnly(); | 12945 return lookup.IsReadOnly(); |
12946 } | 12946 } |
12947 | 12947 |
12948 | 12948 |
12949 bool JSArray::WouldChangeReadOnlyLength(Handle<JSArray> array, | 12949 bool JSArray::WouldChangeReadOnlyLength(Handle<JSArray> array, |
12950 uint32_t index) { | 12950 uint32_t index) { |
12951 uint32_t length = 0; | 12951 uint32_t length = 0; |
12952 CHECK(array->length()->ToArrayIndex(&length)); | 12952 CHECK(array->length()->ToArrayIndex(&length)); |
12953 if (length <= index) { | 12953 if (length <= index) { |
12954 Isolate* isolate = array->GetIsolate(); | 12954 LookupIterator it(array, array->GetIsolate()->factory()->length_string(), |
12955 LookupResult lookup(isolate); | 12955 LookupIterator::CHECK_PROPERTY); |
12956 Handle<Name> length_string = isolate->factory()->length_string(); | 12956 CHECK(it.IsFound()); |
12957 array->LookupOwnRealNamedProperty(length_string, &lookup); | 12957 CHECK(it.HasProperty()); |
12958 return lookup.IsReadOnly(); | 12958 return it.IsReadOnly(); |
12959 } | 12959 } |
12960 return false; | 12960 return false; |
12961 } | 12961 } |
12962 | 12962 |
12963 | 12963 |
12964 MaybeHandle<Object> JSArray::ReadOnlyLengthError(Handle<JSArray> array) { | 12964 MaybeHandle<Object> JSArray::ReadOnlyLengthError(Handle<JSArray> array) { |
12965 Isolate* isolate = array->GetIsolate(); | 12965 Isolate* isolate = array->GetIsolate(); |
12966 Handle<Name> length = isolate->factory()->length_string(); | 12966 Handle<Name> length = isolate->factory()->length_string(); |
12967 Handle<Object> args[2] = { length, array }; | 12967 Handle<Object> args[2] = { length, array }; |
12968 Handle<Object> error = isolate->factory()->NewTypeError( | 12968 Handle<Object> error = isolate->factory()->NewTypeError( |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13332 CHECK(v8::Utils::OpenHandle(*result)->IsJSArray() || | 13332 CHECK(v8::Utils::OpenHandle(*result)->IsJSArray() || |
13333 v8::Utils::OpenHandle(*result)->HasSloppyArgumentsElements()); | 13333 v8::Utils::OpenHandle(*result)->HasSloppyArgumentsElements()); |
13334 #endif | 13334 #endif |
13335 // Rebox before returning. | 13335 // Rebox before returning. |
13336 return handle(*v8::Utils::OpenHandle(*result), isolate); | 13336 return handle(*v8::Utils::OpenHandle(*result), isolate); |
13337 } | 13337 } |
13338 | 13338 |
13339 | 13339 |
13340 Maybe<bool> JSObject::HasRealNamedProperty(Handle<JSObject> object, | 13340 Maybe<bool> JSObject::HasRealNamedProperty(Handle<JSObject> object, |
13341 Handle<Name> key) { | 13341 Handle<Name> key) { |
13342 Isolate* isolate = object->GetIsolate(); | 13342 LookupIterator it(object, key, LookupIterator::CHECK_ACCESS_CHECK); |
13343 SealHandleScope shs(isolate); | 13343 Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it); |
13344 // Check access rights if needed. | 13344 if (!maybe_result.has_value) return Maybe<bool>(); |
13345 if (object->IsAccessCheckNeeded()) { | 13345 return maybe(it.IsFound()); |
13346 if (!isolate->MayNamedAccess(object, key, v8::ACCESS_HAS)) { | |
13347 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); | |
13348 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Maybe<bool>()); | |
13349 return maybe(false); | |
13350 } | |
13351 } | |
13352 | |
13353 LookupResult result(isolate); | |
13354 object->LookupOwnRealNamedProperty(key, &result); | |
13355 return maybe(result.IsFound() && !result.IsInterceptor()); | |
13356 } | 13346 } |
13357 | 13347 |
13358 | 13348 |
13359 Maybe<bool> JSObject::HasRealElementProperty(Handle<JSObject> object, | 13349 Maybe<bool> JSObject::HasRealElementProperty(Handle<JSObject> object, |
13360 uint32_t index) { | 13350 uint32_t index) { |
13361 Isolate* isolate = object->GetIsolate(); | 13351 Isolate* isolate = object->GetIsolate(); |
13362 HandleScope scope(isolate); | 13352 HandleScope scope(isolate); |
13363 // Check access rights if needed. | 13353 // Check access rights if needed. |
13364 if (object->IsAccessCheckNeeded()) { | 13354 if (object->IsAccessCheckNeeded()) { |
13365 if (!isolate->MayIndexedAccess(object, index, v8::ACCESS_HAS)) { | 13355 if (!isolate->MayIndexedAccess(object, index, v8::ACCESS_HAS)) { |
(...skipping 14 matching lines...) Expand all Loading... |
13380 | 13370 |
13381 Maybe<PropertyAttributes> result = | 13371 Maybe<PropertyAttributes> result = |
13382 GetElementAttributeWithoutInterceptor(object, object, index, false); | 13372 GetElementAttributeWithoutInterceptor(object, object, index, false); |
13383 if (!result.has_value) return Maybe<bool>(); | 13373 if (!result.has_value) return Maybe<bool>(); |
13384 return maybe(result.value != ABSENT); | 13374 return maybe(result.value != ABSENT); |
13385 } | 13375 } |
13386 | 13376 |
13387 | 13377 |
13388 Maybe<bool> JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object, | 13378 Maybe<bool> JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object, |
13389 Handle<Name> key) { | 13379 Handle<Name> key) { |
13390 Isolate* isolate = object->GetIsolate(); | 13380 LookupIterator it(object, key, LookupIterator::CHECK_ACCESS_CHECK); |
13391 SealHandleScope shs(isolate); | 13381 Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it); |
13392 // Check access rights if needed. | 13382 if (!maybe_result.has_value) return Maybe<bool>(); |
13393 if (object->IsAccessCheckNeeded()) { | 13383 return maybe(it.IsFound() && it.property_kind() == LookupIterator::ACCESSOR); |
13394 if (!isolate->MayNamedAccess(object, key, v8::ACCESS_HAS)) { | |
13395 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); | |
13396 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Maybe<bool>()); | |
13397 return maybe(false); | |
13398 } | |
13399 } | |
13400 | |
13401 LookupResult result(isolate); | |
13402 object->LookupOwnRealNamedProperty(key, &result); | |
13403 return maybe(result.IsPropertyCallbacks()); | |
13404 } | 13384 } |
13405 | 13385 |
13406 | 13386 |
13407 int JSObject::NumberOfOwnProperties(PropertyAttributes filter) { | 13387 int JSObject::NumberOfOwnProperties(PropertyAttributes filter) { |
13408 if (HasFastProperties()) { | 13388 if (HasFastProperties()) { |
13409 Map* map = this->map(); | 13389 Map* map = this->map(); |
13410 if (filter == NONE) return map->NumberOfOwnDescriptors(); | 13390 if (filter == NONE) return map->NumberOfOwnDescriptors(); |
13411 if (filter & DONT_ENUM) { | 13391 if (filter & DONT_ENUM) { |
13412 int result = map->EnumLength(); | 13392 int result = map->EnumLength(); |
13413 if (result != kInvalidEnumCacheSentinel) return result; | 13393 if (result != kInvalidEnumCacheSentinel) return result; |
(...skipping 3140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16554 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16534 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16555 static const char* error_messages_[] = { | 16535 static const char* error_messages_[] = { |
16556 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16536 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16557 }; | 16537 }; |
16558 #undef ERROR_MESSAGES_TEXTS | 16538 #undef ERROR_MESSAGES_TEXTS |
16559 return error_messages_[reason]; | 16539 return error_messages_[reason]; |
16560 } | 16540 } |
16561 | 16541 |
16562 | 16542 |
16563 } } // namespace v8::internal | 16543 } } // namespace v8::internal |
OLD | NEW |