Changeset 65344 in webkit for trunk/JavaScriptCore
- Timestamp:
- Aug 13, 2010, 6:28:27 PM (15 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r65311 r65344 1 2010-08-13 Gavin Barraclough <[email protected]> 2 3 Rubber stamped by Sam Weinig. 4 Switch String::/UString::ascii() to return a CString. 5 6 * JavaScriptCore.exp: 7 * JavaScriptCore.xcodeproj/project.pbxproj: 8 * bytecode/CodeBlock.cpp: 9 (JSC::CodeBlock::dump): 10 * bytecode/SamplingTool.cpp: 11 (JSC::SamplingTool::dump): 12 * interpreter/CallFrame.cpp: 13 (JSC::CallFrame::dumpCaller): 14 * jsc.cpp: 15 (runWithScripts): 16 (runInteractive): 17 * runtime/Identifier.h: 18 (JSC::Identifier::ascii): 19 * runtime/ScopeChain.cpp: 20 (JSC::ScopeChainNode::print): 21 * runtime/UString.cpp: 22 (JSC::UString::ascii): 23 (JSC::UString::latin1): 24 * runtime/UString.h: 25 * wtf/text/StringImpl.cpp: 26 (WTF::StringImpl::asciiOLD): 27 * wtf/text/StringImpl.h: 28 * wtf/text/WTFString.cpp: 29 (WTF::String::ascii): 30 (WTF::String::latin1): 31 * wtf/text/WTFString.h: 32 1 33 2010-08-13 Gabor Loki <[email protected]> 2 34 -
trunk/JavaScriptCore/JavaScriptCore.exp
r65305 r65344 334 334 __ZN3WTF10StringImpl4findEti 335 335 __ZN3WTF10StringImpl5adoptERNS_12StringBufferE 336 __ZN3WTF10StringImpl5asciiEv337 336 __ZN3WTF10StringImpl5emptyEv 338 337 __ZN3WTF10StringImpl5lowerEv -
trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r65305 r65344 2327 2327 buildConfigurationList = 149C277108902AFE008A9EFC /* Build configuration list for PBXProject "JavaScriptCore" */; 2328 2328 compatibilityVersion = "Xcode 2.4"; 2329 developmentRegion = English; 2329 2330 hasScannedForEncodings = 1; 2330 2331 knownRegions = ( -
trunk/JavaScriptCore/bytecode/CodeBlock.cpp
r65305 r65344 354 354 size_t i = 0; 355 355 do { 356 printf(" id%u = %s\n", static_cast<unsigned>(i), m_identifiers[i]. ascii());356 printf(" id%u = %s\n", static_cast<unsigned>(i), m_identifiers[i].ustring().utf8().data()); 357 357 ++i; 358 358 } while (i != m_identifiers.size()); … … 364 364 size_t i = 0; 365 365 do { 366 printf(" k%u = %s\n", registerIndex, valueToSourceString(exec, m_constantRegisters[i].jsValue()). ascii());366 printf(" k%u = %s\n", registerIndex, valueToSourceString(exec, m_constantRegisters[i].jsValue()).utf8().data()); 367 367 ++i; 368 368 ++registerIndex; … … 374 374 size_t i = 0; 375 375 do { 376 printf(" re%u = %s\n", static_cast<unsigned>(i), regexpToSourceString(m_rareData->m_regexps[i].get()). ascii());376 printf(" re%u = %s\n", static_cast<unsigned>(i), regexpToSourceString(m_rareData->m_regexps[i].get()).utf8().data()); 377 377 ++i; 378 378 } while (i < m_rareData->m_regexps.size()); … … 455 455 ASSERT(!((i + m_rareData->m_characterSwitchJumpTables[i].min) & ~0xFFFF)); 456 456 UChar ch = static_cast<UChar>(entry + m_rareData->m_characterSwitchJumpTables[i].min); 457 printf("\t\t\"%s\" => %04d\n", UString(&ch, 1). ascii(), *iter);457 printf("\t\t\"%s\" => %04d\n", UString(&ch, 1).utf8().data(), *iter); 458 458 } 459 459 printf(" }\n"); … … 469 469 StringJumpTable::StringOffsetTable::const_iterator end = m_rareData->m_stringSwitchJumpTables[i].offsetTable.end(); 470 470 for (StringJumpTable::StringOffsetTable::const_iterator iter = m_rareData->m_stringSwitchJumpTables[i].offsetTable.begin(); iter != end; ++iter) 471 printf("\t\t\"%s\" => %04d\n", UString(iter->first). ascii(), iter->second.branchOffset);471 printf("\t\t\"%s\" => %04d\n", UString(iter->first).utf8().data(), iter->second.branchOffset); 472 472 printf(" }\n"); 473 473 ++i; … … 715 715 JSValue scope = JSValue((++it)->u.jsCell); 716 716 int id0 = (++it)->u.operand; 717 printf("[%4d] resolve_global\t %s, %s, %s\n", location, registerName(exec, r0).data(), valueToSourceString(exec, scope). ascii(), idName(id0, m_identifiers[id0]).data());717 printf("[%4d] resolve_global\t %s, %s, %s\n", location, registerName(exec, r0).data(), valueToSourceString(exec, scope).utf8().data(), idName(id0, m_identifiers[id0]).data()); 718 718 it += 2; 719 719 break; … … 724 724 int id0 = (++it)->u.operand; 725 725 int depth = it[2].u.operand; 726 printf("[%4d] resolve_global_dynamic\t %s, %s, %s, %d\n", location, registerName(exec, r0).data(), valueToSourceString(exec, scope). ascii(), idName(id0, m_identifiers[id0]).data(), depth);726 printf("[%4d] resolve_global_dynamic\t %s, %s, %s, %d\n", location, registerName(exec, r0).data(), valueToSourceString(exec, scope).utf8().data(), idName(id0, m_identifiers[id0]).data(), depth); 727 727 it += 3; 728 728 break; … … 746 746 JSValue scope = JSValue((++it)->u.jsCell); 747 747 int index = (++it)->u.operand; 748 printf("[%4d] get_global_var\t %s, %s, %d\n", location, registerName(exec, r0).data(), valueToSourceString(exec, scope). ascii(), index);748 printf("[%4d] get_global_var\t %s, %s, %d\n", location, registerName(exec, r0).data(), valueToSourceString(exec, scope).utf8().data(), index); 749 749 break; 750 750 } … … 753 753 int index = (++it)->u.operand; 754 754 int r0 = (++it)->u.operand; 755 printf("[%4d] put_global_var\t %s, %d, %s\n", location, valueToSourceString(exec, scope). ascii(), index, registerName(exec, r0).data());755 printf("[%4d] put_global_var\t %s, %d, %s\n", location, valueToSourceString(exec, scope).utf8().data(), index, registerName(exec, r0).data()); 756 756 break; 757 757 } -
trunk/JavaScriptCore/bytecode/SamplingTool.cpp
r58911 r65344 338 338 if (blockPercent >= 1) { 339 339 //Instruction* code = codeBlock->instructions().begin(); 340 printf("#%d: %s:%d: %d / %lld (%.3f%%)\n", i + 1, record->m_executable->sourceURL(). ascii(), codeBlock->lineNumberForBytecodeOffset(exec, 0), record->m_sampleCount, m_sampleCount, blockPercent);340 printf("#%d: %s:%d: %d / %lld (%.3f%%)\n", i + 1, record->m_executable->sourceURL().utf8().data(), codeBlock->lineNumberForBytecodeOffset(exec, 0), record->m_sampleCount, m_sampleCount, blockPercent); 341 341 if (i < 10) { 342 342 HashMap<unsigned,unsigned> lineCounts; -
trunk/JavaScriptCore/interpreter/CallFrame.cpp
r61553 r65344 41 41 42 42 interpreter()->retrieveLastCaller(this, signedLineNumber, sourceID, urlString, function); 43 printf("Callpoint => %s:%d\n", urlString. ascii(), signedLineNumber);43 printf("Callpoint => %s:%d\n", urlString.utf8().data(), signedLineNumber); 44 44 } 45 45 -
trunk/JavaScriptCore/jsc.cpp
r65305 r65344 393 393 if (dump) { 394 394 if (completion.complType() == Throw) 395 printf("Exception: %s\n", completion.value().toString(globalObject->globalExec()). ascii());395 printf("Exception: %s\n", completion.value().toString(globalObject->globalExec()).utf8().data()); 396 396 else 397 printf("End: %s\n", completion.value().toString(globalObject->globalExec()). ascii());397 printf("End: %s\n", completion.value().toString(globalObject->globalExec()).utf8().data()); 398 398 } 399 399 … … 441 441 #endif 442 442 if (completion.complType() == Throw) 443 printf("Exception: %s\n", completion.value().toString(globalObject->globalExec()). ascii());443 printf("Exception: %s\n", completion.value().toString(globalObject->globalExec()).utf8().data()); 444 444 else 445 445 printf("%s\n", completion.value().toString(globalObject->globalExec()).utf8().data()); -
trunk/JavaScriptCore/runtime/Identifier.h
r65305 r65344 51 51 int length() const { return m_string.length(); } 52 52 53 const char*ascii() const { return m_string.ascii(); }53 CString ascii() const { return m_string.ascii(); } 54 54 55 55 static Identifier from(ExecState* exec, unsigned y); -
trunk/JavaScriptCore/runtime/ScopeChain.cpp
r48774 r65344 44 44 for (PropertyNameArray::const_iterator propIter = propertyNames.begin(); propIter != propEnd; propIter++) { 45 45 Identifier name = *propIter; 46 fprintf(stderr, "%s, ", name. ascii());46 fprintf(stderr, "%s, ", name.ustring().utf8().data()); 47 47 } 48 48 fprintf(stderr, "\n"); -
trunk/JavaScriptCore/runtime/UString.cpp
r65305 r65344 205 205 } 206 206 207 char* UString::ascii() const208 {209 static char* asciiBuffer = 0;210 211 unsigned len = length();212 unsigned neededSize = len + 1;213 delete[] asciiBuffer;214 asciiBuffer = new char[neededSize];215 216 const UChar* p = characters();217 char* q = asciiBuffer;218 const UChar* limit = p + len;219 while (p != limit) {220 *q = static_cast<char>(p[0]);221 ++p;222 ++q;223 }224 *q = '\0';225 226 return asciiBuffer;227 }228 229 207 static inline bool isInfinity(double number) 230 208 { … … 584 562 } 585 563 564 CString UString::ascii() const 565 { 566 // Basic Latin1 (ISO) encoding - Unicode characters 0..255 are 567 // preserved, characters outside of this range are converted to '?'. 568 569 unsigned length = this->length(); 570 const UChar* characters = this->characters(); 571 572 char* characterBuffer; 573 CString result = CString::newUninitialized(length, characterBuffer); 574 575 for (unsigned i = 0; i < length; ++i) { 576 UChar ch = characters[i]; 577 characterBuffer[i] = ch && (ch < 0x20 || ch >= 0x7f) ? '?' : ch; 578 } 579 580 return result; 581 } 582 583 CString UString::latin1() const 584 { 585 // Basic Latin1 (ISO) encoding - Unicode characters 0..255 are 586 // preserved, characters outside of this range are converted to '?'. 587 588 unsigned length = this->length(); 589 const UChar* characters = this->characters(); 590 591 char* characterBuffer; 592 CString result = CString::newUninitialized(length, characterBuffer); 593 594 for (unsigned i = 0; i < length; ++i) { 595 UChar ch = characters[i]; 596 characterBuffer[i] = ch > 0xff ? '?' : ch; 597 } 598 599 return result; 600 } 601 586 602 // Helper to write a three-byte UTF-8 code point to the buffer, caller must check room is available. 587 603 static inline void putUTF8Triple(char*& buffer, UChar ch) -
trunk/JavaScriptCore/runtime/UString.h
r65305 r65344 88 88 } 89 89 90 CString ascii() const; 91 CString latin1() const; 90 92 CString utf8(bool strict = false) const; 91 93 … … 120 122 121 123 UString substr(unsigned pos = 0, unsigned len = 0xFFFFFFFF) const; 122 123 // NOTE: This method should only be used for *debugging* purposes as it124 // is neither Unicode safe nor free from side effects nor thread-safe.125 char* ascii() const;126 124 127 125 private: -
trunk/JavaScriptCore/wtf/text/StringImpl.cpp
r65021 r65344 884 884 } 885 885 886 Vector<char> StringImpl::ascii()887 {888 Vector<char> buffer(m_length + 1);889 for (unsigned i = 0; i != m_length; ++i) {890 UChar c = m_data[i];891 if ((c >= 0x20 && c < 0x7F) || c == 0x00)892 buffer[i] = static_cast<char>(c);893 else894 buffer[i] = '?';895 }896 buffer[m_length] = '\0';897 return buffer;898 }899 900 886 WTF::Unicode::Direction StringImpl::defaultWritingDirection() 901 887 { -
trunk/JavaScriptCore/wtf/text/StringImpl.h
r65021 r65344 307 307 PassRefPtr<StringImpl> replace(unsigned index, unsigned len, StringImpl*); 308 308 309 Vector<char> ascii();310 311 309 WTF::Unicode::Direction defaultWritingDirection(); 312 310 -
trunk/JavaScriptCore/wtf/text/WTFString.cpp
r65305 r65344 613 613 } 614 614 615 Vector<char> String::ascii() const 616 { 617 if (m_impl) 618 return m_impl->ascii(); 619 620 const char* nullMsg = "(null impl)"; 621 Vector<char, 2048> buffer; 622 for (int i = 0; nullMsg[i]; ++i) 623 buffer.append(nullMsg[i]); 624 625 buffer.append('\0'); 626 return buffer; 627 } 628 629 CString String::latin1() const 615 CString String::ascii() const 630 616 { 631 617 // Basic Latin1 (ISO) encoding - Unicode characters 0..255 are … … 640 626 for (unsigned i = 0; i < length; ++i) { 641 627 UChar ch = characters[i]; 642 characterBuffer[i] = ch > 255 ? '?' : ch; 628 characterBuffer[i] = ch && (ch < 0x20 || ch > 0x7f) ? '?' : ch; 629 } 630 631 return result; 632 } 633 634 CString String::latin1() const 635 { 636 // Basic Latin1 (ISO) encoding - Unicode characters 0..255 are 637 // preserved, characters outside of this range are converted to '?'. 638 639 unsigned length = this->length(); 640 const UChar* characters = this->characters(); 641 642 char* characterBuffer; 643 CString result = CString::newUninitialized(length, characterBuffer); 644 645 for (unsigned i = 0; i < length; ++i) { 646 UChar ch = characters[i]; 647 characterBuffer[i] = ch > 0xff ? '?' : ch; 643 648 } 644 649 -
trunk/JavaScriptCore/wtf/text/WTFString.h
r65305 r65344 126 126 } 127 127 128 CString ascii() const; 128 129 CString latin1() const; 129 130 CString utf8(bool strict = false) const; … … 278 279 operator BString() const; 279 280 #endif 280 281 Vector<char> ascii() const;282 281 283 282 static String fromUTF8(const char*, size_t);
Note:
See TracChangeset
for help on using the changeset viewer.