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 15233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16242 return false; | 16241 return false; |
16243 } | 16242 } |
16244 | 16243 |
16245 // Transitions from HOLEY -> PACKED are not allowed. | 16244 // Transitions from HOLEY -> PACKED are not allowed. |
16246 return !IsFastHoleyElementsKind(from_kind) || | 16245 return !IsFastHoleyElementsKind(from_kind) || |
16247 IsFastHoleyElementsKind(to_kind); | 16246 IsFastHoleyElementsKind(to_kind); |
16248 } | 16247 } |
16249 | 16248 |
16250 | 16249 |
16251 bool JSArray::HasReadOnlyLength(Handle<JSArray> array) { | 16250 bool JSArray::HasReadOnlyLength(Handle<JSArray> array) { |
16252 LookupIterator it(array, array->GetIsolate()->factory()->length_string(), | 16251 Isolate* isolate = array->GetIsolate(); |
16252 // Optimistic fast path: "length" is usually the first fast property. | |
Camillo Bruni
2016/02/22 19:25:55
right :) makes sense
| |
16253 DescriptorArray* descriptors = array->map()->instance_descriptors(); | |
16254 if (descriptors->length() >= 1 && | |
16255 descriptors->GetKey(0) == isolate->heap()->length_string()) { | |
16256 return descriptors->GetDetails(0).IsReadOnly(); | |
16257 } | |
16258 | |
16259 LookupIterator it(array, isolate->factory()->length_string(), | |
16253 LookupIterator::OWN_SKIP_INTERCEPTOR); | 16260 LookupIterator::OWN_SKIP_INTERCEPTOR); |
16254 CHECK_NE(LookupIterator::ACCESS_CHECK, it.state()); | |
16255 CHECK(it.IsFound()); | |
16256 CHECK_EQ(LookupIterator::ACCESSOR, it.state()); | 16261 CHECK_EQ(LookupIterator::ACCESSOR, it.state()); |
16257 return it.IsReadOnly(); | 16262 return it.IsReadOnly(); |
16258 } | 16263 } |
16259 | 16264 |
16260 | 16265 |
16261 bool JSArray::WouldChangeReadOnlyLength(Handle<JSArray> array, | 16266 bool JSArray::WouldChangeReadOnlyLength(Handle<JSArray> array, |
16262 uint32_t index) { | 16267 uint32_t index) { |
16263 uint32_t length = 0; | 16268 uint32_t length = 0; |
16264 CHECK(array->length()->ToArrayLength(&length)); | 16269 CHECK(array->length()->ToArrayLength(&length)); |
16265 if (length <= index) return HasReadOnlyLength(array); | 16270 if (length <= index) return HasReadOnlyLength(array); |
(...skipping 3612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
19878 if (cell->value() != *new_value) { | 19883 if (cell->value() != *new_value) { |
19879 cell->set_value(*new_value); | 19884 cell->set_value(*new_value); |
19880 Isolate* isolate = cell->GetIsolate(); | 19885 Isolate* isolate = cell->GetIsolate(); |
19881 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19886 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19882 isolate, DependentCode::kPropertyCellChangedGroup); | 19887 isolate, DependentCode::kPropertyCellChangedGroup); |
19883 } | 19888 } |
19884 } | 19889 } |
19885 | 19890 |
19886 } // namespace internal | 19891 } // namespace internal |
19887 } // namespace v8 | 19892 } // namespace v8 |
OLD | NEW |