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 15970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15981 if (key->FilterKey(filter)) continue; | 15981 if (key->FilterKey(filter)) continue; |
15982 keys->AddKey(key, DO_NOT_CONVERT); | 15982 keys->AddKey(key, DO_NOT_CONVERT); |
15983 } | 15983 } |
15984 } else if (IsJSGlobalObject()) { | 15984 } else if (IsJSGlobalObject()) { |
15985 GlobalDictionary::CollectKeysTo(handle(global_dictionary()), keys, filter); | 15985 GlobalDictionary::CollectKeysTo(handle(global_dictionary()), keys, filter); |
15986 } else { | 15986 } else { |
15987 NameDictionary::CollectKeysTo(handle(property_dictionary()), keys, filter); | 15987 NameDictionary::CollectKeysTo(handle(property_dictionary()), keys, filter); |
15988 } | 15988 } |
15989 } | 15989 } |
15990 | 15990 |
| 15991 bool JSObject::WasConstructedFromApiFunction() { |
| 15992 auto instance_type = map()->instance_type(); |
| 15993 bool is_api_object = instance_type == JS_API_OBJECT_TYPE || |
| 15994 instance_type == JS_SPECIAL_API_OBJECT_TYPE; |
| 15995 #ifdef ENABLE_SLOW_DCHECKS |
| 15996 if (FLAG_enable_slow_asserts) { |
| 15997 Object* maybe_constructor = map()->GetConstructor(); |
| 15998 if (!maybe_constructor->IsJSFunction()) return false; |
| 15999 JSFunction* constructor = JSFunction::cast(maybe_constructor); |
| 16000 if (constructor->shared()->IsApiFunction()) { |
| 16001 DCHECK(is_api_object); |
| 16002 } else { |
| 16003 DCHECK(!is_api_object); |
| 16004 } |
| 16005 } |
| 16006 #endif |
| 16007 return is_api_object; |
| 16008 } |
15991 | 16009 |
15992 int JSObject::NumberOfOwnElements(PropertyFilter filter) { | 16010 int JSObject::NumberOfOwnElements(PropertyFilter filter) { |
15993 // Fast case for objects with no elements. | 16011 // Fast case for objects with no elements. |
15994 if (!IsJSValue() && HasFastElements()) { | 16012 if (!IsJSValue() && HasFastElements()) { |
15995 uint32_t length = | 16013 uint32_t length = |
15996 IsJSArray() | 16014 IsJSArray() |
15997 ? static_cast<uint32_t>( | 16015 ? static_cast<uint32_t>( |
15998 Smi::cast(JSArray::cast(this)->length())->value()) | 16016 Smi::cast(JSArray::cast(this)->length())->value()) |
15999 : static_cast<uint32_t>(FixedArrayBase::cast(elements())->length()); | 16017 : static_cast<uint32_t>(FixedArrayBase::cast(elements())->length()); |
16000 if (length == 0) return 0; | 16018 if (length == 0) return 0; |
(...skipping 3285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19286 if (cell->value() != *new_value) { | 19304 if (cell->value() != *new_value) { |
19287 cell->set_value(*new_value); | 19305 cell->set_value(*new_value); |
19288 Isolate* isolate = cell->GetIsolate(); | 19306 Isolate* isolate = cell->GetIsolate(); |
19289 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19307 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19290 isolate, DependentCode::kPropertyCellChangedGroup); | 19308 isolate, DependentCode::kPropertyCellChangedGroup); |
19291 } | 19309 } |
19292 } | 19310 } |
19293 | 19311 |
19294 } // namespace internal | 19312 } // namespace internal |
19295 } // namespace v8 | 19313 } // namespace v8 |
OLD | NEW |