OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 ASSIGN_RETURN_ON_EXCEPTION( | 976 ASSIGN_RETURN_ON_EXCEPTION( |
977 isolate, initial_map, | 977 isolate, initial_map, |
978 JSFunction::GetDerivedMap(isolate, constructor, new_target), JSObject); | 978 JSFunction::GetDerivedMap(isolate, constructor, new_target), JSObject); |
979 Handle<JSObject> result = | 979 Handle<JSObject> result = |
980 isolate->factory()->NewJSObjectFromMap(initial_map, NOT_TENURED, site); | 980 isolate->factory()->NewJSObjectFromMap(initial_map, NOT_TENURED, site); |
981 isolate->counters()->constructed_objects()->Increment(); | 981 isolate->counters()->constructed_objects()->Increment(); |
982 isolate->counters()->constructed_objects_runtime()->Increment(); | 982 isolate->counters()->constructed_objects_runtime()->Increment(); |
983 return result; | 983 return result; |
984 } | 984 } |
985 | 985 |
986 | 986 void JSObject::EnsureWritableFastElements(Handle<JSObject> object) { |
987 Handle<FixedArray> JSObject::EnsureWritableFastElements( | |
988 Handle<JSObject> object) { | |
989 DCHECK(object->HasFastSmiOrObjectElements() || | 987 DCHECK(object->HasFastSmiOrObjectElements() || |
990 object->HasFastStringWrapperElements()); | 988 object->HasFastStringWrapperElements()); |
991 Isolate* isolate = object->GetIsolate(); | 989 FixedArray* raw_elems = FixedArray::cast(object->elements()); |
992 Handle<FixedArray> elems(FixedArray::cast(object->elements()), isolate); | 990 Heap* heap = object->GetHeap(); |
993 if (elems->map() != isolate->heap()->fixed_cow_array_map()) return elems; | 991 if (raw_elems->map() != heap->fixed_cow_array_map()) return; |
| 992 Isolate* isolate = heap->isolate(); |
| 993 Handle<FixedArray> elems(raw_elems, isolate); |
994 Handle<FixedArray> writable_elems = isolate->factory()->CopyFixedArrayWithMap( | 994 Handle<FixedArray> writable_elems = isolate->factory()->CopyFixedArrayWithMap( |
995 elems, isolate->factory()->fixed_array_map()); | 995 elems, isolate->factory()->fixed_array_map()); |
996 object->set_elements(*writable_elems); | 996 object->set_elements(*writable_elems); |
997 isolate->counters()->cow_arrays_converted()->Increment(); | 997 isolate->counters()->cow_arrays_converted()->Increment(); |
998 return writable_elems; | |
999 } | 998 } |
1000 | 999 |
1001 | 1000 |
1002 // ES6 9.5.1 | 1001 // ES6 9.5.1 |
1003 // static | 1002 // static |
1004 MaybeHandle<Object> JSProxy::GetPrototype(Handle<JSProxy> proxy) { | 1003 MaybeHandle<Object> JSProxy::GetPrototype(Handle<JSProxy> proxy) { |
1005 Isolate* isolate = proxy->GetIsolate(); | 1004 Isolate* isolate = proxy->GetIsolate(); |
1006 Handle<String> trap_name = isolate->factory()->getPrototypeOf_string(); | 1005 Handle<String> trap_name = isolate->factory()->getPrototypeOf_string(); |
1007 | 1006 |
1008 STACK_CHECK(MaybeHandle<Object>()); | 1007 STACK_CHECK(MaybeHandle<Object>()); |
(...skipping 15212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16221 return false; | 16220 return false; |
16222 } | 16221 } |
16223 | 16222 |
16224 // Transitions from HOLEY -> PACKED are not allowed. | 16223 // Transitions from HOLEY -> PACKED are not allowed. |
16225 return !IsFastHoleyElementsKind(from_kind) || | 16224 return !IsFastHoleyElementsKind(from_kind) || |
16226 IsFastHoleyElementsKind(to_kind); | 16225 IsFastHoleyElementsKind(to_kind); |
16227 } | 16226 } |
16228 | 16227 |
16229 | 16228 |
16230 bool JSArray::HasReadOnlyLength(Handle<JSArray> array) { | 16229 bool JSArray::HasReadOnlyLength(Handle<JSArray> array) { |
16231 LookupIterator it(array, array->GetIsolate()->factory()->length_string(), | 16230 Isolate* isolate = array->GetIsolate(); |
| 16231 // Optimistic fast path: "length" is usually the first fast property. |
| 16232 DescriptorArray* descriptors = array->map()->instance_descriptors(); |
| 16233 if (descriptors->length() >= 1 && |
| 16234 descriptors->GetKey(0) == isolate->heap()->length_string()) { |
| 16235 return descriptors->GetDetails(0).IsReadOnly(); |
| 16236 } |
| 16237 |
| 16238 LookupIterator it(array, isolate->factory()->length_string(), |
16232 LookupIterator::OWN_SKIP_INTERCEPTOR); | 16239 LookupIterator::OWN_SKIP_INTERCEPTOR); |
16233 CHECK_NE(LookupIterator::ACCESS_CHECK, it.state()); | |
16234 CHECK(it.IsFound()); | |
16235 CHECK_EQ(LookupIterator::ACCESSOR, it.state()); | 16240 CHECK_EQ(LookupIterator::ACCESSOR, it.state()); |
16236 return it.IsReadOnly(); | 16241 return it.IsReadOnly(); |
16237 } | 16242 } |
16238 | 16243 |
16239 | 16244 |
16240 bool JSArray::WouldChangeReadOnlyLength(Handle<JSArray> array, | 16245 bool JSArray::WouldChangeReadOnlyLength(Handle<JSArray> array, |
16241 uint32_t index) { | 16246 uint32_t index) { |
16242 uint32_t length = 0; | 16247 uint32_t length = 0; |
16243 CHECK(array->length()->ToArrayLength(&length)); | 16248 CHECK(array->length()->ToArrayLength(&length)); |
16244 if (length <= index) return HasReadOnlyLength(array); | 16249 if (length <= index) return HasReadOnlyLength(array); |
(...skipping 3612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19857 if (cell->value() != *new_value) { | 19862 if (cell->value() != *new_value) { |
19858 cell->set_value(*new_value); | 19863 cell->set_value(*new_value); |
19859 Isolate* isolate = cell->GetIsolate(); | 19864 Isolate* isolate = cell->GetIsolate(); |
19860 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19865 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19861 isolate, DependentCode::kPropertyCellChangedGroup); | 19866 isolate, DependentCode::kPropertyCellChangedGroup); |
19862 } | 19867 } |
19863 } | 19868 } |
19864 | 19869 |
19865 } // namespace internal | 19870 } // namespace internal |
19866 } // namespace v8 | 19871 } // namespace v8 |
OLD | NEW |