Changeset 198168 in webkit
- Timestamp:
- Mar 14, 2016, 4:20:27 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r198167 r198168 1 2016-03-14 Mark Lam <mark.lam@apple.com> 2 3 Need to distinguish between Symbol() and Symbol(""). 4 https://bugs.webkit.org/show_bug.cgi?id=155438 5 6 Reviewed by Saam Barati. 7 8 * runtime/PrivateName.h: 9 (JSC::PrivateName::PrivateName): 10 1 11 2016-03-14 Oliver Hunt <oliver@apple.com> 2 12 -
trunk/Source/JavaScriptCore/runtime/PrivateName.h
r184828 r198168 1 1 /* 2 * Copyright (C) 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2012, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 34 34 public: 35 35 PrivateName() 36 : m_uid(StringImpl::create SymbolEmpty())36 : m_uid(StringImpl::createNullSymbol()) 37 37 { 38 38 } -
trunk/Source/WTF/ChangeLog
r198093 r198168 1 2016-03-14 Mark Lam <mark.lam@apple.com> 2 3 Need to distinguish between Symbol() and Symbol(""). 4 https://bugs.webkit.org/show_bug.cgi?id=155438 5 6 Reviewed by Saam Barati. 7 8 While toString of both Symbol() and Symbol("") yields "Symbol()", Function.name 9 should yield "" and "[]" respectively. Hence, we need to tell between the two. 10 This functionality will be needed later in https://bugs.webkit.org/show_bug.cgi?id=155437. 11 12 We achieve this by creating another singleton instance like the empty StringImpl 13 as the null StringImpl. isNullSymbol() tests if the Stringimpl instance is a 14 symbol, and its substring is the null() singleton. 15 16 * wtf/text/StringImpl.cpp: 17 (WTF::StringImpl::createSymbol): 18 (WTF::StringImpl::createNullSymbol): 19 (WTF::StringImpl::containsOnlyWhitespace): 20 (WTF::StringImpl::createSymbolEmpty): Deleted. 21 * wtf/text/StringImpl.h: 22 (WTF::StringImpl::tryCreateUninitialized): 23 (WTF::StringImpl::stringKind): 24 (WTF::StringImpl::isSymbol): 25 (WTF::StringImpl::isAtomic): 26 (WTF::StringImpl::isNullSymbol): 27 * wtf/text/StringStatics.cpp: 28 (WTF::StringImpl::null): 29 1 30 2016-03-13 Joseph Pecoraro <pecoraro@apple.com> 2 31 -
trunk/Source/WTF/wtf/text/StringImpl.cpp
r196223 r198168 307 307 } 308 308 309 Ref<SymbolImpl> StringImpl::create SymbolEmpty()310 { 311 return createSymbol( empty());309 Ref<SymbolImpl> StringImpl::createNullSymbol() 310 { 311 return createSymbol(null()); 312 312 } 313 313 -
trunk/Source/WTF/wtf/text/StringImpl.h
r198019 r198168 409 409 } 410 410 411 WTF_EXPORT_STRING_API static Ref<SymbolImpl> create SymbolEmpty();411 WTF_EXPORT_STRING_API static Ref<SymbolImpl> createNullSymbol(); 412 412 WTF_EXPORT_STRING_API static Ref<SymbolImpl> createSymbol(PassRefPtr<StringImpl> rep); 413 413 … … 485 485 bool isSymbol() const { return m_hashAndFlags & s_hashFlagStringKindIsSymbol; } 486 486 bool isAtomic() const { return m_hashAndFlags & s_hashFlagStringKindIsAtomic; } 487 bool isNullSymbol() const { return isSymbol() && (substringBuffer() == null()); } 487 488 488 489 void setIsAtomic(bool isAtomic) … … 864 865 WTF_EXPORT_PRIVATE NEVER_INLINE unsigned hashSlowCase() const; 865 866 WTF_EXPORT_PRIVATE static unsigned nextHashForSymbol(); 867 WTF_EXPORT_PRIVATE static StringImpl* null(); 866 868 867 869 // The bottom bit in the ref count indicates a static (immortal) string. -
trunk/Source/WTF/wtf/text/StringStatics.cpp
r183624 r198168 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All Rights Reserved.2 * Copyright (C) 2010, 2016 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 41 41 42 42 namespace WTF { 43 44 StringImpl* StringImpl::null() 45 { 46 static NeverDestroyed<StringImpl> nullString(ConstructEmptyString); 47 return &nullString.get(); 48 } 43 49 44 50 StringImpl* StringImpl::empty() -
trunk/Tools/ChangeLog
r198141 r198168 1 2016-03-14 Mark Lam <mark.lam@apple.com> 2 3 Need to distinguish between Symbol() and Symbol(""). 4 https://bugs.webkit.org/show_bug.cgi?id=155438 5 6 Reviewed by Saam Barati. 7 8 * TestWebKitAPI/Tests/WTF/StringImpl.cpp: 9 (TestWebKitAPI::TEST): 10 - Test that the a symbol with an empty string is not equivalent to a null symbol. 11 1 12 2016-03-14 David Kilzer <ddkilzer@apple.com> 2 13 -
trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp
r198019 r198168 1 1 /* 2 * Copyright (C) 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2012, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 514 514 } 515 515 516 TEST(WTF, StringImplCreate SymbolEmpty)517 { 518 RefPtr<StringImpl> reference = StringImpl::create SymbolEmpty();516 TEST(WTF, StringImplCreateNullSymbol) 517 { 518 RefPtr<StringImpl> reference = StringImpl::createNullSymbol(); 519 519 ASSERT_TRUE(reference->isSymbol()); 520 ASSERT_TRUE(reference->isNullSymbol()); 520 521 ASSERT_FALSE(reference->isAtomic()); 521 522 ASSERT_EQ(0u, reference->length()); … … 528 529 RefPtr<StringImpl> reference = StringImpl::createSymbol(original); 529 530 ASSERT_TRUE(reference->isSymbol()); 531 ASSERT_FALSE(reference->isNullSymbol()); 530 532 ASSERT_FALSE(reference->isAtomic()); 531 533 ASSERT_FALSE(original->isSymbol()); … … 533 535 ASSERT_EQ(original->length(), reference->length()); 534 536 ASSERT_TRUE(equal(reference.get(), "original")); 537 538 RefPtr<StringImpl> empty = stringFromUTF8(""); 539 RefPtr<StringImpl> emptyReference = StringImpl::createSymbol(empty); 540 ASSERT_TRUE(emptyReference->isSymbol()); 541 ASSERT_FALSE(emptyReference->isNullSymbol()); 542 ASSERT_FALSE(emptyReference->isAtomic()); 543 ASSERT_FALSE(empty->isSymbol()); 544 ASSERT_FALSE(empty->isNullSymbol()); 545 ASSERT_TRUE(empty->isAtomic()); 546 ASSERT_EQ(empty->length(), emptyReference->length()); 547 ASSERT_TRUE(equal(emptyReference.get(), "")); 535 548 } 536 549 … … 549 562 } 550 563 551 TEST(WTF, StringImpl SymbolEmptyToAtomicString)552 { 553 RefPtr<StringImpl> reference = StringImpl::create SymbolEmpty();564 TEST(WTF, StringImplNullSymbolToAtomicString) 565 { 566 RefPtr<StringImpl> reference = StringImpl::createNullSymbol(); 554 567 ASSERT_TRUE(reference->isSymbol()); 555 568 ASSERT_FALSE(reference->isAtomic());
Note:
See TracChangeset
for help on using the changeset viewer.