OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 default: | 1189 default: |
1190 return this; | 1190 return this; |
1191 } | 1191 } |
1192 } | 1192 } |
1193 | 1193 |
1194 | 1194 |
1195 bool String::MakeExternal(v8::String::ExternalStringResource* resource) { | 1195 bool String::MakeExternal(v8::String::ExternalStringResource* resource) { |
1196 // Externalizing twice leaks the external resource, so it's | 1196 // Externalizing twice leaks the external resource, so it's |
1197 // prohibited by the API. | 1197 // prohibited by the API. |
1198 ASSERT(!this->IsExternalString()); | 1198 ASSERT(!this->IsExternalString()); |
1199 #ifdef DEBUG | 1199 #ifdef ENABLE_SLOW_ASSERTS |
1200 if (FLAG_enable_slow_asserts) { | 1200 if (FLAG_enable_slow_asserts) { |
1201 // Assert that the resource and the string are equivalent. | 1201 // Assert that the resource and the string are equivalent. |
1202 ASSERT(static_cast<size_t>(this->length()) == resource->length()); | 1202 ASSERT(static_cast<size_t>(this->length()) == resource->length()); |
1203 ScopedVector<uc16> smart_chars(this->length()); | 1203 ScopedVector<uc16> smart_chars(this->length()); |
1204 String::WriteToFlat(this, smart_chars.start(), 0, this->length()); | 1204 String::WriteToFlat(this, smart_chars.start(), 0, this->length()); |
1205 ASSERT(memcmp(smart_chars.start(), | 1205 ASSERT(memcmp(smart_chars.start(), |
1206 resource->data(), | 1206 resource->data(), |
1207 resource->length() * sizeof(smart_chars[0])) == 0); | 1207 resource->length() * sizeof(smart_chars[0])) == 0); |
1208 } | 1208 } |
1209 #endif // DEBUG | 1209 #endif // DEBUG |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); | 1246 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); |
1247 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { | 1247 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { |
1248 MemoryChunk::IncrementLiveBytesFromMutator(this->address(), | 1248 MemoryChunk::IncrementLiveBytesFromMutator(this->address(), |
1249 new_size - size); | 1249 new_size - size); |
1250 } | 1250 } |
1251 return true; | 1251 return true; |
1252 } | 1252 } |
1253 | 1253 |
1254 | 1254 |
1255 bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) { | 1255 bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) { |
1256 #ifdef DEBUG | 1256 #ifdef ENABLE_SLOW_ASSERTS |
1257 if (FLAG_enable_slow_asserts) { | 1257 if (FLAG_enable_slow_asserts) { |
1258 // Assert that the resource and the string are equivalent. | 1258 // Assert that the resource and the string are equivalent. |
1259 ASSERT(static_cast<size_t>(this->length()) == resource->length()); | 1259 ASSERT(static_cast<size_t>(this->length()) == resource->length()); |
1260 if (this->IsTwoByteRepresentation()) { | 1260 if (this->IsTwoByteRepresentation()) { |
1261 ScopedVector<uint16_t> smart_chars(this->length()); | 1261 ScopedVector<uint16_t> smart_chars(this->length()); |
1262 String::WriteToFlat(this, smart_chars.start(), 0, this->length()); | 1262 String::WriteToFlat(this, smart_chars.start(), 0, this->length()); |
1263 ASSERT(String::IsOneByte(smart_chars.start(), this->length())); | 1263 ASSERT(String::IsOneByte(smart_chars.start(), this->length())); |
1264 } | 1264 } |
1265 ScopedVector<char> smart_chars(this->length()); | 1265 ScopedVector<char> smart_chars(this->length()); |
1266 String::WriteToFlat(this, smart_chars.start(), 0, this->length()); | 1266 String::WriteToFlat(this, smart_chars.start(), 0, this->length()); |
(...skipping 3209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4476 int index = obj->map()->Hash() % kEntries; | 4476 int index = obj->map()->Hash() % kEntries; |
4477 Handle<Object> result = handle(cache->get(index), cache->GetIsolate()); | 4477 Handle<Object> result = handle(cache->get(index), cache->GetIsolate()); |
4478 if (result->IsMap() && | 4478 if (result->IsMap() && |
4479 Handle<Map>::cast(result)->EquivalentToForNormalization(obj->map(), | 4479 Handle<Map>::cast(result)->EquivalentToForNormalization(obj->map(), |
4480 mode)) { | 4480 mode)) { |
4481 #ifdef VERIFY_HEAP | 4481 #ifdef VERIFY_HEAP |
4482 if (FLAG_verify_heap) { | 4482 if (FLAG_verify_heap) { |
4483 Handle<Map>::cast(result)->SharedMapVerify(); | 4483 Handle<Map>::cast(result)->SharedMapVerify(); |
4484 } | 4484 } |
4485 #endif | 4485 #endif |
4486 #ifdef DEBUG | 4486 #ifdef ENABLE_SLOW_ASSERTS |
4487 if (FLAG_enable_slow_asserts) { | 4487 if (FLAG_enable_slow_asserts) { |
4488 // The cached map should match newly created normalized map bit-by-bit, | 4488 // The cached map should match newly created normalized map bit-by-bit, |
4489 // except for the code cache, which can contain some ics which can be | 4489 // except for the code cache, which can contain some ics which can be |
4490 // applied to the shared map. | 4490 // applied to the shared map. |
4491 Handle<Map> fresh = Map::CopyNormalized(handle(obj->map()), mode, | 4491 Handle<Map> fresh = Map::CopyNormalized(handle(obj->map()), mode, |
4492 SHARED_NORMALIZED_MAP); | 4492 SHARED_NORMALIZED_MAP); |
4493 | 4493 |
4494 ASSERT(memcmp(fresh->address(), | 4494 ASSERT(memcmp(fresh->address(), |
4495 Handle<Map>::cast(result)->address(), | 4495 Handle<Map>::cast(result)->address(), |
4496 Map::kCodeCacheOffset) == 0); | 4496 Map::kCodeCacheOffset) == 0); |
(...skipping 3324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7821 return cache; | 7821 return cache; |
7822 } | 7822 } |
7823 | 7823 |
7824 | 7824 |
7825 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) { | 7825 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) { |
7826 ElementsAccessor* accessor = array->GetElementsAccessor(); | 7826 ElementsAccessor* accessor = array->GetElementsAccessor(); |
7827 MaybeObject* maybe_result = | 7827 MaybeObject* maybe_result = |
7828 accessor->AddElementsToFixedArray(array, array, this); | 7828 accessor->AddElementsToFixedArray(array, array, this); |
7829 FixedArray* result; | 7829 FixedArray* result; |
7830 if (!maybe_result->To<FixedArray>(&result)) return maybe_result; | 7830 if (!maybe_result->To<FixedArray>(&result)) return maybe_result; |
7831 #ifdef DEBUG | 7831 #ifdef ENABLE_SLOW_ASSERTS |
7832 if (FLAG_enable_slow_asserts) { | 7832 if (FLAG_enable_slow_asserts) { |
7833 for (int i = 0; i < result->length(); i++) { | 7833 for (int i = 0; i < result->length(); i++) { |
7834 Object* current = result->get(i); | 7834 Object* current = result->get(i); |
7835 ASSERT(current->IsNumber() || current->IsName()); | 7835 ASSERT(current->IsNumber() || current->IsName()); |
7836 } | 7836 } |
7837 } | 7837 } |
7838 #endif | 7838 #endif |
7839 return result; | 7839 return result; |
7840 } | 7840 } |
7841 | 7841 |
7842 | 7842 |
7843 MaybeObject* FixedArray::UnionOfKeys(FixedArray* other) { | 7843 MaybeObject* FixedArray::UnionOfKeys(FixedArray* other) { |
7844 ElementsAccessor* accessor = ElementsAccessor::ForArray(other); | 7844 ElementsAccessor* accessor = ElementsAccessor::ForArray(other); |
7845 MaybeObject* maybe_result = | 7845 MaybeObject* maybe_result = |
7846 accessor->AddElementsToFixedArray(NULL, NULL, this, other); | 7846 accessor->AddElementsToFixedArray(NULL, NULL, this, other); |
7847 FixedArray* result; | 7847 FixedArray* result; |
7848 if (!maybe_result->To(&result)) return maybe_result; | 7848 if (!maybe_result->To(&result)) return maybe_result; |
7849 #ifdef DEBUG | 7849 #ifdef ENABLE_SLOW_ASSERTS |
7850 if (FLAG_enable_slow_asserts) { | 7850 if (FLAG_enable_slow_asserts) { |
7851 for (int i = 0; i < result->length(); i++) { | 7851 for (int i = 0; i < result->length(); i++) { |
7852 Object* current = result->get(i); | 7852 Object* current = result->get(i); |
7853 ASSERT(current->IsNumber() || current->IsName()); | 7853 ASSERT(current->IsNumber() || current->IsName()); |
7854 } | 7854 } |
7855 } | 7855 } |
7856 #endif | 7856 #endif |
7857 return result; | 7857 return result; |
7858 } | 7858 } |
7859 | 7859 |
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8894 | 8894 |
8895 bool String::SlowEquals(String* other) { | 8895 bool String::SlowEquals(String* other) { |
8896 // Fast check: negative check with lengths. | 8896 // Fast check: negative check with lengths. |
8897 int len = length(); | 8897 int len = length(); |
8898 if (len != other->length()) return false; | 8898 if (len != other->length()) return false; |
8899 if (len == 0) return true; | 8899 if (len == 0) return true; |
8900 | 8900 |
8901 // Fast check: if hash code is computed for both strings | 8901 // Fast check: if hash code is computed for both strings |
8902 // a fast negative check can be performed. | 8902 // a fast negative check can be performed. |
8903 if (HasHashCode() && other->HasHashCode()) { | 8903 if (HasHashCode() && other->HasHashCode()) { |
8904 #ifdef DEBUG | 8904 #ifdef ENABLE_SLOW_ASSERTS |
8905 if (FLAG_enable_slow_asserts) { | 8905 if (FLAG_enable_slow_asserts) { |
8906 if (Hash() != other->Hash()) { | 8906 if (Hash() != other->Hash()) { |
8907 bool found_difference = false; | 8907 bool found_difference = false; |
8908 for (int i = 0; i < len; i++) { | 8908 for (int i = 0; i < len; i++) { |
8909 if (Get(i) != other->Get(i)) { | 8909 if (Get(i) != other->Get(i)) { |
8910 found_difference = true; | 8910 found_difference = true; |
8911 break; | 8911 break; |
8912 } | 8912 } |
8913 } | 8913 } |
8914 ASSERT(found_difference); | 8914 ASSERT(found_difference); |
(...skipping 7483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16398 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16398 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16399 static const char* error_messages_[] = { | 16399 static const char* error_messages_[] = { |
16400 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16400 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16401 }; | 16401 }; |
16402 #undef ERROR_MESSAGES_TEXTS | 16402 #undef ERROR_MESSAGES_TEXTS |
16403 return error_messages_[reason]; | 16403 return error_messages_[reason]; |
16404 } | 16404 } |
16405 | 16405 |
16406 | 16406 |
16407 } } // namespace v8::internal | 16407 } } // namespace v8::internal |
OLD | NEW |