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 12826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12837 // sure that the length stays within 32-bits (unsigned). | 12837 // sure that the length stays within 32-bits (unsigned). |
12838 if (index >= old_len && index != 0xffffffff) { | 12838 if (index >= old_len && index != 0xffffffff) { |
12839 Handle<Object> len = array->GetIsolate()->factory()->NewNumber( | 12839 Handle<Object> len = array->GetIsolate()->factory()->NewNumber( |
12840 static_cast<double>(index) + 1); | 12840 static_cast<double>(index) + 1); |
12841 array->set_length(*len); | 12841 array->set_length(*len); |
12842 } | 12842 } |
12843 } | 12843 } |
12844 | 12844 |
12845 | 12845 |
12846 bool JSArray::IsReadOnlyLengthDescriptor(Handle<Map> jsarray_map) { | 12846 bool JSArray::IsReadOnlyLengthDescriptor(Handle<Map> jsarray_map) { |
12847 Isolate* isolate = jsarray_map->GetIsolate(); | 12847 Isolate* isolate = jsarray_map->GetIsolate(); |
12848 DCHECK(!jsarray_map->is_dictionary_map()); | 12848 DCHECK(!jsarray_map->is_dictionary_map()); |
12849 LookupResult lookup(isolate); | 12849 LookupResult lookup(isolate); |
12850 Handle<Name> length_string = isolate->factory()->length_string(); | 12850 Handle<Name> length_string = isolate->factory()->length_string(); |
12851 jsarray_map->LookupDescriptor(NULL, *length_string, &lookup); | 12851 jsarray_map->LookupDescriptor(NULL, *length_string, &lookup); |
12852 return lookup.IsReadOnly(); | 12852 return lookup.IsReadOnly(); |
12853 } | 12853 } |
12854 | 12854 |
12855 | 12855 |
12856 bool JSArray::WouldChangeReadOnlyLength(Handle<JSArray> array, | 12856 bool JSArray::WouldChangeReadOnlyLength(Handle<JSArray> array, |
12857 uint32_t index) { | 12857 uint32_t index) { |
12858 uint32_t length = 0; | 12858 uint32_t length = 0; |
12859 CHECK(array->length()->ToArrayIndex(&length)); | 12859 CHECK(array->length()->ToArrayIndex(&length)); |
12860 if (length <= index) { | 12860 if (length <= index) { |
12861 LookupIterator it(array, array->GetIsolate()->factory()->length_string(), | 12861 LookupIterator it(array, array->GetIsolate()->factory()->length_string(), |
12862 LookupIterator::CHECK_PROPERTY); | 12862 LookupIterator::CHECK_PROPERTY); |
(...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14608 // Clamp undefined to NaN (default). All other types have been | 14608 // Clamp undefined to NaN (default). All other types have been |
14609 // converted to a number type further up in the call chain. | 14609 // converted to a number type further up in the call chain. |
14610 DCHECK(value->IsUndefined()); | 14610 DCHECK(value->IsUndefined()); |
14611 } | 14611 } |
14612 array->set(index, double_value); | 14612 array->set(index, double_value); |
14613 } | 14613 } |
14614 return array->GetIsolate()->factory()->NewNumber(double_value); | 14614 return array->GetIsolate()->factory()->NewNumber(double_value); |
14615 } | 14615 } |
14616 | 14616 |
14617 | 14617 |
14618 PropertyCell* GlobalObject::GetPropertyCell(LookupResult* result) { | |
14619 DCHECK(!HasFastProperties()); | |
14620 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); | |
14621 return PropertyCell::cast(value); | |
14622 } | |
14623 | |
14624 | |
14625 Handle<PropertyCell> JSGlobalObject::EnsurePropertyCell( | 14618 Handle<PropertyCell> JSGlobalObject::EnsurePropertyCell( |
14626 Handle<JSGlobalObject> global, | 14619 Handle<JSGlobalObject> global, |
14627 Handle<Name> name) { | 14620 Handle<Name> name) { |
14628 DCHECK(!global->HasFastProperties()); | 14621 DCHECK(!global->HasFastProperties()); |
14629 int entry = global->property_dictionary()->FindEntry(name); | 14622 int entry = global->property_dictionary()->FindEntry(name); |
14630 if (entry == NameDictionary::kNotFound) { | 14623 if (entry == NameDictionary::kNotFound) { |
14631 Isolate* isolate = global->GetIsolate(); | 14624 Isolate* isolate = global->GetIsolate(); |
14632 Handle<PropertyCell> cell = isolate->factory()->NewPropertyCell( | 14625 Handle<PropertyCell> cell = isolate->factory()->NewPropertyCell( |
14633 isolate->factory()->the_hole_value()); | 14626 isolate->factory()->the_hole_value()); |
14634 PropertyDetails details(NONE, NORMAL, 0); | 14627 PropertyDetails details(NONE, NORMAL, 0); |
(...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16441 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16434 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16442 static const char* error_messages_[] = { | 16435 static const char* error_messages_[] = { |
16443 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16436 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16444 }; | 16437 }; |
16445 #undef ERROR_MESSAGES_TEXTS | 16438 #undef ERROR_MESSAGES_TEXTS |
16446 return error_messages_[reason]; | 16439 return error_messages_[reason]; |
16447 } | 16440 } |
16448 | 16441 |
16449 | 16442 |
16450 } } // namespace v8::internal | 16443 } } // namespace v8::internal |
OLD | NEW |