| 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
| 10 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" |
| (...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 #ifdef ENABLE_SLOW_DCHECKS | 1061 #ifdef ENABLE_SLOW_DCHECKS |
| 1062 if (FLAG_enable_slow_asserts) { | 1062 if (FLAG_enable_slow_asserts) { |
| 1063 // Assert that the resource and the string are equivalent. | 1063 // Assert that the resource and the string are equivalent. |
| 1064 DCHECK(static_cast<size_t>(this->length()) == resource->length()); | 1064 DCHECK(static_cast<size_t>(this->length()) == resource->length()); |
| 1065 ScopedVector<uc16> smart_chars(this->length()); | 1065 ScopedVector<uc16> smart_chars(this->length()); |
| 1066 String::WriteToFlat(this, smart_chars.start(), 0, this->length()); | 1066 String::WriteToFlat(this, smart_chars.start(), 0, this->length()); |
| 1067 DCHECK(memcmp(smart_chars.start(), | 1067 DCHECK(memcmp(smart_chars.start(), |
| 1068 resource->data(), | 1068 resource->data(), |
| 1069 resource->length() * sizeof(smart_chars[0])) == 0); | 1069 resource->length() * sizeof(smart_chars[0])) == 0); |
| 1070 } | 1070 } |
| 1071 #endif // DEBUG | 1071 #endif // ENABLE_SLOW_DCHECKS |
| 1072 int size = this->Size(); // Byte size of the original string. | 1072 int size = this->Size(); // Byte size of the original string. |
| 1073 // Abort if size does not allow in-place conversion. | 1073 // Abort if size does not allow in-place conversion. |
| 1074 if (size < ExternalString::kShortSize) return false; | 1074 if (size < ExternalString::kShortSize) return false; |
| 1075 Heap* heap = GetHeap(); | 1075 Heap* heap = GetHeap(); |
| 1076 bool is_one_byte = this->IsOneByteRepresentation(); | 1076 bool is_one_byte = this->IsOneByteRepresentation(); |
| 1077 bool is_internalized = this->IsInternalizedString(); | 1077 bool is_internalized = this->IsInternalizedString(); |
| 1078 | 1078 |
| 1079 // Morph the string to an external string by replacing the map and | 1079 // Morph the string to an external string by replacing the map and |
| 1080 // reinitializing the fields. This won't work if the space the existing | 1080 // reinitializing the fields. This won't work if the space the existing |
| 1081 // string occupies is too small for a regular external string. | 1081 // string occupies is too small for a regular external string. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 ScopedVector<uint16_t> smart_chars(this->length()); | 1128 ScopedVector<uint16_t> smart_chars(this->length()); |
| 1129 String::WriteToFlat(this, smart_chars.start(), 0, this->length()); | 1129 String::WriteToFlat(this, smart_chars.start(), 0, this->length()); |
| 1130 DCHECK(String::IsOneByte(smart_chars.start(), this->length())); | 1130 DCHECK(String::IsOneByte(smart_chars.start(), this->length())); |
| 1131 } | 1131 } |
| 1132 ScopedVector<char> smart_chars(this->length()); | 1132 ScopedVector<char> smart_chars(this->length()); |
| 1133 String::WriteToFlat(this, smart_chars.start(), 0, this->length()); | 1133 String::WriteToFlat(this, smart_chars.start(), 0, this->length()); |
| 1134 DCHECK(memcmp(smart_chars.start(), | 1134 DCHECK(memcmp(smart_chars.start(), |
| 1135 resource->data(), | 1135 resource->data(), |
| 1136 resource->length() * sizeof(smart_chars[0])) == 0); | 1136 resource->length() * sizeof(smart_chars[0])) == 0); |
| 1137 } | 1137 } |
| 1138 #endif // DEBUG | 1138 #endif // ENABLE_SLOW_DCHECKS |
| 1139 int size = this->Size(); // Byte size of the original string. | 1139 int size = this->Size(); // Byte size of the original string. |
| 1140 // Abort if size does not allow in-place conversion. | 1140 // Abort if size does not allow in-place conversion. |
| 1141 if (size < ExternalString::kShortSize) return false; | 1141 if (size < ExternalString::kShortSize) return false; |
| 1142 Heap* heap = GetHeap(); | 1142 Heap* heap = GetHeap(); |
| 1143 bool is_internalized = this->IsInternalizedString(); | 1143 bool is_internalized = this->IsInternalizedString(); |
| 1144 | 1144 |
| 1145 // Morph the string to an external string by replacing the map and | 1145 // Morph the string to an external string by replacing the map and |
| 1146 // reinitializing the fields. This won't work if the space the existing | 1146 // reinitializing the fields. This won't work if the space the existing |
| 1147 // string occupies is too small for a regular external string. | 1147 // string occupies is too small for a regular external string. |
| 1148 // Instead, we resort to a short external string instead, omitting | 1148 // Instead, we resort to a short external string instead, omitting |
| (...skipping 10860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12009 PutPrototypeTransition(map, prototype, new_map); | 12009 PutPrototypeTransition(map, prototype, new_map); |
| 12010 new_map->set_prototype(*prototype); | 12010 new_map->set_prototype(*prototype); |
| 12011 } | 12011 } |
| 12012 return new_map; | 12012 return new_map; |
| 12013 } | 12013 } |
| 12014 | 12014 |
| 12015 | 12015 |
| 12016 MaybeHandle<Object> JSObject::SetPrototype(Handle<JSObject> object, | 12016 MaybeHandle<Object> JSObject::SetPrototype(Handle<JSObject> object, |
| 12017 Handle<Object> value, | 12017 Handle<Object> value, |
| 12018 bool from_javascript) { | 12018 bool from_javascript) { |
| 12019 #ifdef DEBUG | 12019 #if DCHECK_IS_ON |
| 12020 int size = object->Size(); | 12020 int size = object->Size(); |
| 12021 #endif | 12021 #endif |
| 12022 | 12022 |
| 12023 Isolate* isolate = object->GetIsolate(); | 12023 Isolate* isolate = object->GetIsolate(); |
| 12024 Heap* heap = isolate->heap(); | 12024 Heap* heap = isolate->heap(); |
| 12025 // Silently ignore the change if value is not a JSObject or null. | 12025 // Silently ignore the change if value is not a JSObject or null. |
| 12026 // SpiderMonkey behaves this way. | 12026 // SpiderMonkey behaves this way. |
| 12027 if (!value->IsJSReceiver() && !value->IsNull()) return value; | 12027 if (!value->IsJSReceiver() && !value->IsNull()) return value; |
| 12028 | 12028 |
| 12029 // From 8.6.2 Object Internal Methods | 12029 // From 8.6.2 Object Internal Methods |
| (...skipping 4866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16896 Handle<DependentCode> codes = | 16896 Handle<DependentCode> codes = |
| 16897 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), | 16897 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), |
| 16898 DependentCode::kPropertyCellChangedGroup, | 16898 DependentCode::kPropertyCellChangedGroup, |
| 16899 info->object_wrapper()); | 16899 info->object_wrapper()); |
| 16900 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 16900 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
| 16901 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 16901 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
| 16902 cell, info->zone()); | 16902 cell, info->zone()); |
| 16903 } | 16903 } |
| 16904 | 16904 |
| 16905 } } // namespace v8::internal | 16905 } } // namespace v8::internal |
| OLD | NEW |