1. 27 May, 2010 1 commit
    • eric@webkit.org's avatar
      2010-05-27 Luiz Agostini <luiz.agostini@openbossa.org> · 4ad71207
      eric@webkit.org authored
              Reviewed by Darin Adler.
      
              UTF-16 code points compare() for String objects
              https://bugs.webkit.org/show_bug.cgi?id=39701
      
              Moving compare() implementation from UString to StringImpl for it to be shared
              with String. Adding overloaded free functions codePointCompare() in StringImpl
              and WTFString. Renaming function compare in UString to codePointCompare to be
              consistent.
      
              * runtime/JSArray.cpp:
              (JSC::compareByStringPairForQSort):
              * runtime/UString.cpp:
              * runtime/UString.h:
              (JSC::codePointCompare):
              * wtf/text/StringImpl.cpp:
              (WebCore::codePointCompare):
              * wtf/text/StringImpl.h:
              * wtf/text/WTFString.cpp:
              (WebCore::codePointCompare):
              * wtf/text/WTFString.h:
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@60332 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      4ad71207
  2. 12 May, 2010 2 commits
  3. 21 Apr, 2010 1 commit
    • barraclough@apple.com's avatar
      JavaScriptCore: Bug 37906 - Remove JSC::UStringImpl; unify with StringImpl. · 185ce916
      barraclough@apple.com authored
      Reviewed by Oliver Hunt, Darin Adler.
      
      JSC::UStringImpl and WebCore::StringImpl (soon to be renamed to
      WTF::StringImpl) are almost identical.  Remove duplication of code by unifying
      the two, move missing features from UStringImpl into StringImpl & delete the
      class UStringImpl.
      
      * API/JSClassRef.cpp:
      * API/JSContextRef.cpp:
      * GNUmakefile.am:
      * JavaScriptCore.exp:
      * JavaScriptCore.pro:
      * JavaScriptCore.xcodeproj/project.pbxproj:
      * bytecode/EvalCodeCache.h:
      * bytecode/JumpTable.cpp:
      * profiler/ProfileNode.cpp:
      * runtime/Identifier.cpp:
      (JSC::Identifier::add):
      * runtime/Identifier.h:
      (JSC::Identifier::equal):
      * runtime/UString.cpp:
      * runtime/UString.h:
      (WTF::):
      * runtime/UStringImpl.cpp: Removed.
      * runtime/UStringImpl.h:
      * wtf/text/StringHash.h:
      (WebCore::StringHash::equal):
      (WebCore::CaseFoldingHash::equal):
      * wtf/text/StringImpl.cpp:
      (WebCore::StringImpl::~StringImpl):
      (WebCore::StringImpl::empty):
      (WebCore::StringImpl::sharedBuffer):
      (WebCore::equal):
      * wtf/text/StringImpl.h:
      (WebCore::StringImpl::StringImpl):
      (WebCore::StringImpl::create):
      (WebCore::StringImpl::tryCreateUninitialized):
      (WebCore::StringImpl::cost):
      (WebCore::StringImpl::isIdentifier):
      (WebCore::StringImpl::setIsIdentifier):
      (WebCore::StringImpl::computeHash):
      (WebCore::StringImpl::copyChars):
      (WebCore::StringImpl::):
      
      JavaScriptGlue: Bug 37906 - Remove JSC::UStringImpl; unify with StringImpl.
      Add forwarding header.
      
      Reviewed by Oliver Hunt, Darin Adler.
      
      * ForwardingHeaders/wtf/ASCIICType.h: Added.
      * ForwardingHeaders/wtf/text/StringImpl.h: Added.
      
      WebCore: Bug 37906 - Remove JSC::UStringImpl; unify with StringImpl.
      Add include for StringHash.h.
      
      Reviewed by Oliver Hunt, Darin Adler.
      
      * WebCore.xcodeproj/project.pbxproj:
      * bridge/c/c_class.cpp:
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@58001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      185ce916
  4. 07 Apr, 2010 1 commit
  5. 04 Apr, 2010 1 commit
    • barraclough@apple.com's avatar
      https://bugs.webkit.org/show_bug.cgi?id=37068 · 4f76aacd
      barraclough@apple.com authored
      Change UString to use a 0 rep for null strings instead of a null object.
      
      Reviewed by Oliver Hunt.
      
      No performance impact.
      
      * JavaScriptCore.exp:
      * runtime/InternalFunction.cpp:
      (JSC::InternalFunction::InternalFunction):
      * runtime/JSString.h:
      (JSC::RopeBuilder::JSString):
      * runtime/UString.cpp:
      (JSC::initializeUString):
      * runtime/UString.h:
      (JSC::UString::UString):
      (JSC::UString::data):
      (JSC::UString::size):
      (JSC::UString::isNull):
      (JSC::UString::isEmpty):
      (JSC::UString::cost):
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@57055 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      4f76aacd
  6. 31 Mar, 2010 1 commit
    • barraclough@apple.com's avatar
      Bug 36871 - Remove JSC::CString · f43597db
      barraclough@apple.com authored
      Use WTF::CString instead (which until recently was WebCore::CString).
      
      Reviewed by Geoff Garen.
      
      JavaScriptCore: 
      
      * JavaScriptCore.exp:
      * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
      * runtime/UString.cpp:
      * runtime/UString.h:
      
      JavaScriptGlue: 
      
      * ForwardingHeaders/wtf/text: Added.
      * ForwardingHeaders/wtf/text/CString.h: Added.
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@56864 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      f43597db
  7. 25 Mar, 2010 1 commit
    • barraclough@apple.com's avatar
      Bug 36611 - Cleanup JSC::CString · 5fc5928b
      barraclough@apple.com authored
      Rename CString::c_str() -> CString::data(), CString::size() -> CString::length(),
      remove UString::getCString() (all uses are wrong, should use UString::UTF8String()).
      
      Reviewed by Geoff Garen.
      
      JavaScriptCore: 
      
      * bytecode/CodeBlock.cpp:
      (JSC::CodeBlock::printUnaryOp):
      (JSC::CodeBlock::printBinaryOp):
      (JSC::CodeBlock::printConditionalJump):
      (JSC::CodeBlock::printGetByIdOp):
      (JSC::CodeBlock::printPutByIdOp):
      (JSC::printGlobalResolveInfo):
      (JSC::printStructureStubInfo):
      (JSC::CodeBlock::printStructure):
      (JSC::CodeBlock::printStructures):
      (JSC::CodeBlock::dump):
      * jsc.cpp:
      (functionPrint):
      (functionDebug):
      (runInteractive):
      (fillBufferWithContentsOfFile):
      * profiler/CallIdentifier.h:
      (JSC::CallIdentifier::c_str):
      * profiler/Profile.cpp:
      (JSC::Profile::debugPrintDataSampleStyle):
      * profiler/ProfileNode.cpp:
      (JSC::ProfileNode::debugPrintData):
      (JSC::ProfileNode::debugPrintDataSampleStyle):
      * runtime/DateConversion.cpp:
      (JSC::parseDate):
      * runtime/JSGlobalObjectFunctions.cpp:
      (JSC::encode):
      (JSC::globalFuncJSCPrint):
      * runtime/UString.cpp:
      (JSC::operator==):
      (JSC::UString::toDouble):
      * runtime/UString.h:
      (JSC::CString::length):
      (JSC::CString::data):
      
      WebCore: 
      
      * bridge/NP_jsobject.cpp:
      (_NPN_Enumerate):
      * bridge/c/c_utility.cpp:
      (JSC::Bindings::convertValueToNPVariant):
      * bridge/jni/jsc/JNIBridgeJSC.cpp:
      (JavaField::valueFromInstance):
      (JavaField::setValueToInstance):
      * bridge/jni/jsc/JavaInstanceJSC.cpp:
      (JavaInstance::invokeMethod):
      * bridge/jni/jsc/JavaStringJSC.h:
      (JSC::Bindings::JavaStringImpl::UTF8String):
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@56560 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      5fc5928b
  8. 22 Mar, 2010 1 commit
  9. 11 Mar, 2010 1 commit
    • barraclough@apple.com's avatar
      Rubber stamped by Oliver Hunt. · 939eb23b
      barraclough@apple.com authored
              
      Rename JSC::UStringImpl::data() to characters(), to match WebCore::StringImpl.
      
      JavaScriptCore: 
      
      * API/JSClassRef.cpp:
      (OpaqueJSClassContextData::OpaqueJSClassContextData):
      * bytecompiler/BytecodeGenerator.cpp:
      (JSC::keyForCharacterSwitch):
      * bytecompiler/NodesCodegen.cpp:
      (JSC::processClauseList):
      * interpreter/Interpreter.cpp:
      (JSC::Interpreter::privateExecute):
      * jit/JITStubs.cpp:
      (JSC::DEFINE_STUB_FUNCTION):
      * runtime/ArrayPrototype.cpp:
      (JSC::arrayProtoFuncToString):
      * runtime/Identifier.cpp:
      (JSC::Identifier::equal):
      (JSC::Identifier::addSlowCase):
      * runtime/JSString.cpp:
      (JSC::JSString::resolveRope):
      * runtime/UString.cpp:
      (JSC::UString::toStrictUInt32):
      (JSC::equal):
      * runtime/UString.h:
      (JSC::UString::data):
      * runtime/UStringImpl.h:
      (JSC::UStringImpl::characters):
      (JSC::UStringImpl::hash):
      (JSC::UStringImpl::setHash):
      
      WebCore: 
      
      * bridge/jni/jsc/JavaStringJSC.h:
      (JSC::Bindings::JavaStringImpl::uchars):
      * platform/text/AtomicString.cpp:
      (WebCore::AtomicString::add):
      (WebCore::AtomicString::find):
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55833 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      939eb23b
  10. 16 Feb, 2010 1 commit
    • barraclough@apple.com's avatar
      https://bugs.webkit.org/show_bug.cgi?id=34964 · 2b3ed85e
      barraclough@apple.com authored
      Leaks tool reports false memory leaks due to Rope implementation.
      
      Reviewed by Oliver Hunt.
      
      JavaScriptCore: 
      
      A rope is a recursive data structure where each node in the rope holds a set of
      pointers, each of which may reference either a string (in UStringImpl form) or
      another rope node.  A low bit in each pointer is used to distinguish between
      rope & string elements, in a fashion similar to the recently-removed
      PtrAndFlags class (see https://bugs.webkit.org/show_bug.cgi?id=33731 ).  Again,
      this causes a problem for Leaks – refactor to remove the magic pointer
      mangling.
      
      Move Rope out from JSString.h and rename to URopeImpl, to match UStringImpl.
      Give UStringImpl and URopeImpl a common parent class, UStringOrRopeImpl.
      Repurpose an otherwise invalid permutation to flags (static & should report
      memory cost) to identify ropes.
      
      This allows us to change the rope's fibers to interrogate the object rather
      than storing a bool within the low bits of the pointer (or in some cases the
      use of a common parent class removes the need to determine the type at all -
      there is a common interface to ref or get the length of either ropes or strings).
      
      * API/JSClassRef.cpp:
      (OpaqueJSClass::OpaqueJSClass):
      (OpaqueJSClassContextData::OpaqueJSClassContextData):
      * bytecompiler/BytecodeGenerator.cpp:
      (JSC::keyForCharacterSwitch):
      * interpreter/Interpreter.cpp:
      (JSC::Interpreter::privateExecute):
      * jit/JITStubs.cpp:
      (JSC::DEFINE_STUB_FUNCTION):
      * runtime/ArrayPrototype.cpp:
      (JSC::arrayProtoFuncToString):
      * runtime/Identifier.cpp:
      (JSC::Identifier::equal):
      (JSC::Identifier::addSlowCase):
      * runtime/JSString.cpp:
      (JSC::JSString::resolveRope):
      * runtime/JSString.h:
      (JSC::):
      (JSC::RopeBuilder::JSString):
      (JSC::RopeBuilder::~JSString):
      (JSC::RopeBuilder::appendStringInConstruct):
      (JSC::RopeBuilder::appendValueInConstructAndIncrementLength):
      (JSC::RopeBuilder::JSStringFinalizerStruct::JSStringFinalizerStruct):
      (JSC::RopeBuilder::JSStringFinalizerStruct::):
      * runtime/UString.cpp:
      (JSC::UString::toStrictUInt32):
      (JSC::equal):
      * runtime/UString.h:
      (JSC::UString::isEmpty):
      (JSC::UString::size):
      * runtime/UStringImpl.cpp:
      (JSC::URopeImpl::derefFibersNonRecursive):
      (JSC::URopeImpl::destructNonRecursive):
      * runtime/UStringImpl.h:
      (JSC::UStringOrRopeImpl::isRope):
      (JSC::UStringOrRopeImpl::length):
      (JSC::UStringOrRopeImpl::ref):
      (JSC::UStringOrRopeImpl::):
      (JSC::UStringOrRopeImpl::operator new):
      (JSC::UStringOrRopeImpl::UStringOrRopeImpl):
      (JSC::UStringImpl::adopt):
      (JSC::UStringImpl::createUninitialized):
      (JSC::UStringImpl::tryCreateUninitialized):
      (JSC::UStringImpl::data):
      (JSC::UStringImpl::cost):
      (JSC::UStringImpl::deref):
      (JSC::UStringImpl::UStringImpl):
      (JSC::UStringImpl::):
      (JSC::URopeImpl::tryCreateUninitialized):
      (JSC::URopeImpl::initializeFiber):
      (JSC::URopeImpl::fiberCount):
      (JSC::URopeImpl::fibers):
      (JSC::URopeImpl::deref):
      (JSC::URopeImpl::URopeImpl):
      (JSC::URopeImpl::hasOneRef):
      (JSC::UStringOrRopeImpl::deref):
      
      WebCore: 
      
      Renamed cUStringImpl::size() to UStringImpl::size()UStringImpl::length()
      (matches WebCore::StringImpl).
      
      * bridge/jni/jsc/JavaStringJSC.h:
      (JSC::Bindings::JavaStringImpl::length):
      * platform/text/AtomicString.cpp:
      (WebCore::AtomicString::add):
      (WebCore::AtomicString::find):
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54843 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      2b3ed85e
  11. 15 Feb, 2010 3 commits
    • barraclough@apple.com's avatar
      Rubber Stamped by Geoff Garen. · 98a96e3a
      barraclough@apple.com authored
      Bug 34948 - tryMakeString should fail on error in length calculation
      
      Ooops! - "bool overflow" argument should have been "bool& overflow".
      
      * runtime/UString.h:
      (JSC::sumWithOverflow):
      (JSC::tryMakeString):
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54795 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      98a96e3a
    • barraclough@apple.com's avatar
      Bug 34952 - String lengths in UString should be unsigned. · 2049d9a7
      barraclough@apple.com authored
      This matches WebCore::StringImpl, and better unifies behaviour throughout JSC.
      
      Reviewed by Geoff Garen.
      
      JavaScriptCore: 
      
      * JavaScriptCore.exp:
      * bytecode/EvalCodeCache.h:
      * runtime/Identifier.cpp:
      (JSC::Identifier::equal):
      * runtime/Identifier.h:
      * runtime/JSGlobalObjectFunctions.cpp:
      (JSC::globalFuncEscape):
      * runtime/JSONObject.cpp:
      (JSC::gap):
      (JSC::Stringifier::indent):
      * runtime/NumberPrototype.cpp:
      (JSC::numberProtoFuncToFixed):
      (JSC::numberProtoFuncToPrecision):
      * runtime/RegExp.cpp:
      (JSC::RegExp::match):
      * runtime/StringPrototype.cpp:
      (JSC::substituteBackreferencesSlow):
      (JSC::stringProtoFuncReplace):
      (JSC::stringProtoFuncSplit):
      (JSC::trimString):
      * runtime/UString.cpp:
      (JSC::UString::UString):
      (JSC::UString::from):
      (JSC::UString::getCString):
      (JSC::UString::ascii):
      (JSC::UString::operator[]):
      (JSC::UString::toStrictUInt32):
      (JSC::UString::find):
      (JSC::UString::rfind):
      (JSC::UString::substr):
      (JSC::operator<):
      (JSC::operator>):
      (JSC::compare):
      (JSC::equal):
      (JSC::UString::UTF8String):
      * runtime/UString.h:
      (JSC::UString::size):
      (JSC::operator==):
      * runtime/UStringImpl.cpp:
      (JSC::UStringImpl::create):
      * runtime/UStringImpl.h:
      (JSC::UStringImpl::create):
      (JSC::UStringImpl::size):
      (JSC::UStringImpl::computeHash):
      (JSC::UStringImpl::UStringImpl):
      
      WebCore: 
      
      * bindings/js/JSDOMWindowCustom.cpp:
      (WebCore::JSDOMWindow::atob):
      (WebCore::JSDOMWindow::btoa):
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54789 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      2049d9a7
    • barraclough@apple.com's avatar
      Bug 34948 - tryMakeString should fail on error in length calculation · 6e1038b7
      barraclough@apple.com authored
      Reviewed by Geoff Garen.
      
      The sum of the length of substrings could overflow.
      
      * runtime/UString.h:
      (JSC::sumWithOverflow):
      (JSC::tryMakeString):
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54788 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      6e1038b7
  12. 12 Feb, 2010 1 commit
    • barraclough@apple.com's avatar
      https://bugs.webkit.org/show_bug.cgi?id=33731 · 229936d0
      barraclough@apple.com authored
      Remove uses of PtrAndFlags from JIT data stuctures.
      
      Reviewed by Oliver Hunt.
      
      These break the OS X Leaks tool.  Free up a bit in CallLinkInfo, and invalid
      permutation of pointer states in MethodCallLinkInfo to represent the removed bits.
      
      * bytecode/CodeBlock.h:
      (JSC::CallLinkInfo::seenOnce):
      (JSC::CallLinkInfo::setSeen):
      (JSC::MethodCallLinkInfo::MethodCallLinkInfo):
      (JSC::MethodCallLinkInfo::seenOnce):
      (JSC::MethodCallLinkInfo::setSeen):
      * jit/JIT.cpp:
      (JSC::JIT::unlinkCall):
      * jit/JITPropertyAccess.cpp:
      (JSC::JIT::patchMethodCallProto):
      * runtime/UString.h:
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54747 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      229936d0
  13. 09 Feb, 2010 2 commits
    • barraclough@apple.com's avatar
      Three small string fixes: · 3cb3d047
      barraclough@apple.com authored
      (1) StringBuilder::release should CRASH if the buffer allocation failed.
      (2) Remove weird, dead code from JSString::tryGetValue, replace with an ASSERT.
      (3) Move UString::createFromUTF8 out to the API, as tryCreateStringFromUTF8.
          This is only used from the API, and (now) unlike other UString::create
          methods may return UString::null() to indicate failure cases.  Better
          handle these in the API.
      
      Reviewed by Oliver Hunt.
      
      * API/JSClassRef.cpp:
      (tryCreateStringFromUTF8):
      (OpaqueJSClass::OpaqueJSClass):
      (OpaqueJSClassContextData::OpaqueJSClassContextData):
      * runtime/JSString.h:
      (JSC::Fiber::tryGetValue):
      * runtime/StringBuilder.h:
      (JSC::StringBuilder::release):
      * runtime/UString.cpp:
      (JSC::UString::UString):
      (JSC::UString::from):
      (JSC::UString::find):
      * runtime/UString.h:
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54545 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      3cb3d047
    • barraclough@apple.com's avatar
      Make String.replace throw an exception on out-of-memory, rather than · a8a20144
      barraclough@apple.com authored
      returning a null (err, empty-ish) string.  Move String::replaceRange
      and String::spliceSubstringsWithSeparators out to StringPrototype -
      these were fairly specific use anyway, and we can better integrate
      throwing the JS expcetion this way.
      
      Reviewed by Oliver Hunt
      
      Also removes redundant assignment operator from UString.
      
      * JavaScriptCore.exp:
      * runtime/StringPrototype.cpp:
      (JSC::StringRange::StringRange):
      (JSC::jsSpliceSubstringsWithSeparators):
      (JSC::jsReplaceRange):
      (JSC::stringProtoFuncReplace):
      * runtime/UString.cpp:
      * runtime/UString.h:
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54531 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      a8a20144
  14. 08 Feb, 2010 1 commit
  15. 06 Feb, 2010 1 commit
    • barraclough@apple.com's avatar
      Change UStringImpl::create to CRASH if the string cannot be allocated, · e37590bc
      barraclough@apple.com authored
      rather than returning a null string (which will behave like a zero-length
      string if used).
      
      Reviewed by Geoff Garen.
      
      Also move createRep function from UString to become new overloaded
      UStringImpl::create methods.  In doing so, bring their behaviour closer to
      being in line with WebCore::StringImpl, in removing the behaviour that they
      can be used to produce null UStrings (ASSERT the char* provided is non-null).
      This behaviour of converting null C-strings to null UStrings is inefficient
      (cmompared to just using UString::null()), incompatible with WebCore::StringImpl's
      behaviour, and may generate unexpected behaviour, since in many cases a null
      UString can be used like an empty string.
      
      With these changes UStringImpl need not have a concept of null impls, we can
      start transitioning this to become an implementation detail of UString, that
      internally it chooses to use a null-object rather than an actually zero impl
      pointer.
      
      * JavaScriptCore.exp:
      * debugger/Debugger.cpp:
      (JSC::Debugger::recompileAllJSFunctions):
      * debugger/DebuggerCallFrame.cpp:
      (JSC::DebuggerCallFrame::calculatedFunctionName):
      * parser/Parser.cpp:
      (JSC::Parser::parse):
      * profiler/Profile.cpp:
      (JSC::Profile::Profile):
      * profiler/ProfileGenerator.cpp:
      (JSC::ProfileGenerator::stopProfiling):
      * runtime/Error.cpp:
      (JSC::Error::create):
      (JSC::throwError):
      * runtime/ExceptionHelpers.cpp:
      (JSC::createError):
      * runtime/Identifier.cpp:
      (JSC::Identifier::add):
      * runtime/PropertyNameArray.cpp:
      (JSC::PropertyNameArray::add):
      * runtime/UString.cpp:
      (JSC::initializeUString):
      (JSC::UString::UString):
      (JSC::UString::operator=):
      * runtime/UString.h:
      (JSC::UString::isNull):
      (JSC::UString::null):
      (JSC::UString::rep):
      (JSC::UString::UString):
      * runtime/UStringImpl.cpp:
      (JSC::UStringImpl::create):
      * runtime/UStringImpl.h:
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54464 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      e37590bc
  16. 18 Jan, 2010 5 commits
    • darin@apple.com's avatar
      Fix build by reverting the previous change. · 08a2cff7
      darin@apple.com authored
      * runtime/UString.h: Rolled out the FastAllocBase base class.
      It was making UString larger, and therefore JSString larger,
      and too big for a garbage collection cell.
      
      This raises the unpleasant possibility that many classes became
      larger because we added the FastAllocBase base class. I am
      worried about this, and it needs to be investigated.
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53444 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      08a2cff7
    • eric@webkit.org's avatar
      2010-01-18 Zoltan Horvath <zoltan@webkit.org> · 71fa0c5a
      eric@webkit.org authored
              Reviewed by Darin Adler.
      
              Allow custom memory allocation control for UString class
              https://bugs.webkit.org/show_bug.cgi?id=27831
      
              Inherits the following class from FastAllocBase because it is
              instantiated by 'new' and no need to be copyable:
      
              class name     - instantiated at:
              classs UString - JavaScriptCore/runtime/UString.cpp:160
      
              * runtime/UString.h:
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53438 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      71fa0c5a
    • darin@apple.com's avatar
      Add some ALWAYS_INLINE for key functions not inlined by some versions of GCC. · d844c03e
      darin@apple.com authored
      rdar://problem/7553780
      
      Patch by Evan Cheng <evan.cheng@apple.com> on 2010-01-18
      Reviewed by Darin Adler.
      
      * runtime/JSObject.h:
      (JSC::JSObject::getPropertySlot): ALWAYS_INLINE both overloads.
      * runtime/JSString.h:
      (JSC::JSString::JSString): ALWAYS_INLINE the version that takes a UString.
      * runtime/UString.h:
      (JSC::operator==): ALWAYS_INLINE the version that compares two UString objects.
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53437 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      d844c03e
    • ossy@webkit.org's avatar
      Rubber-stamped by Gustavo Noronha Silva. · 989d6e35
      ossy@webkit.org authored
      Rolling out r53391 and r53392 because of random crashes on buildbots.
      https://bugs.webkit.org/show_bug.cgi?id=33731
      
      * bytecode/CodeBlock.h:
      (JSC::CallLinkInfo::seenOnce):
      (JSC::CallLinkInfo::setSeen):
      (JSC::MethodCallLinkInfo::MethodCallLinkInfo):
      (JSC::MethodCallLinkInfo::seenOnce):
      (JSC::MethodCallLinkInfo::setSeen):
      * jit/JIT.cpp:
      (JSC::JIT::unlinkCall):
      * jit/JITPropertyAccess.cpp:
      (JSC::JIT::patchMethodCallProto):
      * runtime/UString.cpp:
      (JSC::UString::spliceSubstringsWithSeparators):
      (JSC::UString::replaceRange):
      * runtime/UString.h:
      * runtime/UStringImpl.cpp:
      (JSC::UStringImpl::baseSharedBuffer):
      (JSC::UStringImpl::sharedBuffer):
      (JSC::UStringImpl::~UStringImpl):
      * runtime/UStringImpl.h:
      (JSC::UntypedPtrAndBitfield::UntypedPtrAndBitfield):
      (JSC::UntypedPtrAndBitfield::asPtr):
      (JSC::UntypedPtrAndBitfield::operator&=):
      (JSC::UntypedPtrAndBitfield::operator|=):
      (JSC::UntypedPtrAndBitfield::operator&):
      (JSC::UStringImpl::create):
      (JSC::UStringImpl::cost):
      (JSC::UStringImpl::isIdentifier):
      (JSC::UStringImpl::setIsIdentifier):
      (JSC::UStringImpl::ref):
      (JSC::UStringImpl::deref):
      (JSC::UStringImpl::checkConsistency):
      (JSC::UStringImpl::UStringImpl):
      (JSC::UStringImpl::bufferOwnerString):
      (JSC::UStringImpl::bufferOwnership):
      (JSC::UStringImpl::isStatic):
      * wtf/StringHashFunctions.h:
      (WTF::stringHash):
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53400 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      989d6e35
    • barraclough@apple.com's avatar
      https://bugs.webkit.org/show_bug.cgi?id=33731 · e1dc9d10
      barraclough@apple.com authored
      Remove uses of PtrAndFlags from JIT data stuctures.
      
      Reviewed by Oliver Hunt.
      
      These break the OS X Leaks tool.  Free up a bit in CallLinkInfo, and invalid
      permutation of pointer states in MethodCallLinkInfo to represent the removed bits.
      
      * bytecode/CodeBlock.h:
      (JSC::CallLinkInfo::seenOnce):
      (JSC::CallLinkInfo::setSeen):
      (JSC::MethodCallLinkInfo::MethodCallLinkInfo):
      (JSC::MethodCallLinkInfo::seenOnce):
      (JSC::MethodCallLinkInfo::setSeen):
      * jit/JIT.cpp:
      (JSC::JIT::unlinkCall):
      * jit/JITPropertyAccess.cpp:
      (JSC::JIT::patchMethodCallProto):
      * runtime/UString.h:
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      e1dc9d10
  17. 14 Jan, 2010 1 commit
    • barraclough@apple.com's avatar
      JavaScriptCore: Make naming & behaviour of UString[Impl] methods more consistent. · b150b88f
      barraclough@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=33702
      
      Reviewed by Sam Weinig.
      
      UString::create() creates a copy of the UChar* passed, but UStringImpl::create() assumes
      that it should assume ownership of the provided buffer (with UString::createNonCopying()
      and UStringImpl::createCopying() providing the alternate behaviours).  Unify on create()
      taking a copy of the provided buffer.  For non-copying cases, use the name 'adopt', and
      make this method take a Vector<UChar>&.  For cases where non-copying construction was being
      used, other than from a Vector<UChar>, change the code to allocate the storage along with
      the UStringImpl using UStringImpl::createUninitialized().  (The adopt() method also more
      closely matches that of WebCore::StringImpl).
      
      Also, UString::createUninitialized() and UStringImpl::createUninitialized() have incompatible
      behaviours, in that the UString form sets the provided UChar* to a null or non-null value to
      indicate success or failure, but UStringImpl uses the returned PassRefPtr<UStringImpl> to
      indicate when allocation has failed (potentially leaving the output Char* uninitialized).
      This is also incompatible with WebCore::StringImpl's behaviour, in that
      StringImpl::createUninitialized() will CRASH() if unable to allocate.  Some uses of
      createUninitialized() in JSC are unsafe, since they do not test the result for null.
      UStringImpl's indication is preferable, since we may want a successful call to set the result
      buffer to 0 (specifically, StringImpl returns 0 for the buffer where createUninitialized()
      returns the empty string, which seems reasonable to catch bugs early).  UString's method
      cannot support UStringImpl's behaviour directly, since it returns an object rather than a
      pointer.
          - remove UString::createUninitialized(), replace with calls to UStringImpl::createUninitialized()
          - create a UStringImpl::tryCreateUninitialized() form UStringImpl::createUninitialized(),
            with current behaviour, make createUninitialized() crash on failure to allocate.
          - make cases in JSC that do not check the result call createUninitialized(), and cases that do
            check call tryCreateUninitialized().
      
      Rename computedHash() to existingHash(), to bring this in line wih WebCore::StringImpl.
      
      * API/JSClassRef.cpp:
      (OpaqueJSClassContextData::OpaqueJSClassContextData):
      * JavaScriptCore.exp:
      * runtime/ArrayPrototype.cpp:
      (JSC::arrayProtoFuncToString):
      * runtime/Identifier.cpp:
      (JSC::CStringTranslator::translate):
      (JSC::UCharBufferTranslator::translate):
      * runtime/JSString.cpp:
      (JSC::JSString::resolveRope):
      * runtime/Lookup.cpp:
      (JSC::HashTable::createTable):
      * runtime/Lookup.h:
      (JSC::HashTable::entry):
      * runtime/StringBuilder.h:
      (JSC::StringBuilder::release):
      * runtime/StringConstructor.cpp:
      (JSC::stringFromCharCodeSlowCase):
      * runtime/StringPrototype.cpp:
      (JSC::substituteBackreferencesSlow):
      (JSC::stringProtoFuncToLowerCase):
      (JSC::stringProtoFuncToUpperCase):
      (JSC::stringProtoFuncFontsize):
      (JSC::stringProtoFuncLink):
      * runtime/Structure.cpp:
      (JSC::Structure::despecifyDictionaryFunction):
      (JSC::Structure::get):
      (JSC::Structure::despecifyFunction):
      (JSC::Structure::put):
      (JSC::Structure::remove):
      (JSC::Structure::insertIntoPropertyMapHashTable):
      (JSC::Structure::checkConsistency):
      * runtime/Structure.h:
      (JSC::Structure::get):
      * runtime/StructureTransitionTable.h:
      (JSC::StructureTransitionTableHash::hash):
      * runtime/UString.cpp:
      (JSC::createRep):
      (JSC::UString::UString):
      (JSC::UString::spliceSubstringsWithSeparators):
      (JSC::UString::replaceRange):
      (JSC::UString::operator=):
      * runtime/UString.h:
      (JSC::UString::adopt):
      (JSC::IdentifierRepHash::hash):
      (JSC::makeString):
      * runtime/UStringImpl.h:
      (JSC::UStringImpl::adopt):
      (JSC::UStringImpl::create):
      (JSC::UStringImpl::createUninitialized):
      (JSC::UStringImpl::tryCreateUninitialized):
      (JSC::UStringImpl::existingHash):
      
      WebCore: Rubber stamped by Sam Weinig.
      
      Make naming & behaviour of UString[Impl] methods more consistent.
      https://bugs.webkit.org/show_bug.cgi?id=33702
      
      WebCore change reflecting UString method name change computedHash() -> existingHash().
      
      * platform/text/AtomicString.cpp:
      (WebCore::AtomicString::add):
      (WebCore::AtomicString::find):
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53320 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      b150b88f
  18. 21 Dec, 2009 1 commit
    • barraclough@apple.com's avatar
      https://bugs.webkit.org/show_bug.cgi?id=32831 · 1c68c3de
      barraclough@apple.com authored
      Replace UString::Rep implementation, following introduction of ropes to JSC.
      
      Reviewed by Darin Adler.
      
      JavaScriptCore: 
      
          * Remove redundant overcapacity mechanisms.
          * Reduce memory cost of Rep's.
          * Add an inline storage mechanism akin to that in WebCore's StringImpl.
      
      ~1% Sunspider progression.
      
      * JavaScriptCore.exp:
      * JavaScriptCore.xcodeproj/project.pbxproj:
      * runtime/JSString.cpp:
      (JSC::JSString::resolveRope):
      * runtime/SmallStrings.cpp:
      (JSC::SmallStringsStorage::SmallStringsStorage):
      * runtime/UString.cpp:
      (JSC::initializeUString):
      (JSC::createRep):
      (JSC::UString::createFromUTF8):
      (JSC::UString::createUninitialized):
      (JSC::UString::spliceSubstringsWithSeparators):
      (JSC::UString::replaceRange):
      (JSC::UString::ascii):
      (JSC::UString::operator=):
      (JSC::UString::toStrictUInt32):
      (JSC::equal):
      * runtime/UString.h:
      (JSC::UString::isEmpty):
      (JSC::UString::cost):
      (JSC::makeString):
      * runtime/UStringImpl.cpp: Added.
      (JSC::UStringImpl::baseSharedBuffer):
      (JSC::UStringImpl::sharedBuffer):
      (JSC::UStringImpl::destroy):
      (JSC::UStringImpl::computeHash):
      * runtime/UStringImpl.h: Added.
      (JSC::UntypedPtrAndBitfield::UntypedPtrAndBitfield):
      (JSC::UntypedPtrAndBitfield::asPtr):
      (JSC::UntypedPtrAndBitfield::operator&=):
      (JSC::UntypedPtrAndBitfield::operator|=):
      (JSC::UntypedPtrAndBitfield::operator&):
      (JSC::UStringImpl::create):
      (JSC::UStringImpl::createCopying):
      (JSC::UStringImpl::createUninitialized):
      (JSC::UStringImpl::data):
      (JSC::UStringImpl::size):
      (JSC::UStringImpl::cost):
      (JSC::UStringImpl::hash):
      (JSC::UStringImpl::computedHash):
      (JSC::UStringImpl::setHash):
      (JSC::UStringImpl::identifierTable):
      (JSC::UStringImpl::setIdentifierTable):
      (JSC::UStringImpl::ref):
      (JSC::UStringImpl::deref):
      (JSC::UStringImpl::allocChars):
      (JSC::UStringImpl::copyChars):
      (JSC::UStringImpl::computeHash):
      (JSC::UStringImpl::null):
      (JSC::UStringImpl::empty):
      (JSC::UStringImpl::checkConsistency):
      (JSC::UStringImpl::):
      (JSC::UStringImpl::UStringImpl):
      (JSC::UStringImpl::operator new):
      (JSC::UStringImpl::bufferOwnerString):
      (JSC::UStringImpl::bufferOwnership):
      (JSC::UStringImpl::isStatic):
      
      JavaScriptGlue: 
      
      * ForwardingHeaders/wtf/PossiblyNull.h: Added.
          - add forwarding header.
      
      WebCore: 
      
      * ForwardingHeaders/runtime/UStringImpl.h: Added.
          - add forwarding header.
      
      * platform/text/StringImpl.cpp:
      (WebCore::StringImpl::ustring):
          - order of arguments to UString::Rep constructor for shared strings changed.
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52463 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      1c68c3de
  19. 18 Dec, 2009 1 commit
    • barraclough@apple.com's avatar
      Add createNonCopying method to UString to make replace constructor passed bool, · e677126a
      barraclough@apple.com authored
      to make behaviour more explicit.  Add createFromUTF8 to UString (wrapping method
      on UString::Rep), since other cases of transliteration (e.g.  from ascii) are
      performed in UString constructors.  Add/use setHash & size() accessors on Rep,
      rather than accessing _hash/len directly.
      
      Reviewed by Sam Weinig.
      
      * API/JSClassRef.cpp:
      (OpaqueJSClass::OpaqueJSClass):
      * API/OpaqueJSString.cpp:
      (OpaqueJSString::ustring):
      * JavaScriptCore.exp:
      * runtime/ArrayPrototype.cpp:
      (JSC::arrayProtoFuncToString):
      * runtime/Identifier.cpp:
      (JSC::Identifier::equal):
      (JSC::CStringTranslator::translate):
      (JSC::UCharBufferTranslator::translate):
      (JSC::Identifier::addSlowCase):
      * runtime/JSString.cpp:
      (JSC::JSString::resolveRope):
      * runtime/JSString.h:
      (JSC::JSString::Rope::Fiber::refAndGetLength):
      (JSC::JSString::Rope::append):
      * runtime/StringBuilder.h:
      (JSC::StringBuilder::release):
      * runtime/StringConstructor.cpp:
      (JSC::stringFromCharCodeSlowCase):
      * runtime/StringPrototype.cpp:
      (JSC::substituteBackreferencesSlow):
      (JSC::stringProtoFuncToLowerCase):
      (JSC::stringProtoFuncToUpperCase):
      (JSC::stringProtoFuncFontsize):
      (JSC::stringProtoFuncLink):
      * runtime/UString.cpp:
      (JSC::UString::UString):
      (JSC::UString::createNonCopying):
      (JSC::UString::createFromUTF8):
      * runtime/UString.h:
      (JSC::UString::Rep::setHash):
      (JSC::UString::~UString):
      (JSC::makeString):
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52346 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      e677126a
  20. 14 Dec, 2009 1 commit
    • ggaren@apple.com's avatar
      JavaScriptCore: Changed GC from mark-sweep to mark-allocate. · 6a429819
      ggaren@apple.com authored
              
      Reviewed by Sam Weinig.
      
      Added WeakGCMap to keep WebCore blissfully ignorant about objects that
      have become garbage but haven't run their destructors yet.
              
      1% SunSpider speedup.
      7.6% v8 speedup (37% splay speedup).
      17% speedup on bench-alloc-nonretained.js.
      18% speedup on bench-alloc-retained.js.
      
      * API/JSBase.cpp:
      (JSGarbageCollect):
      * API/JSContextRef.cpp:
      * JavaScriptCore.exp:
      * JavaScriptCore.xcodeproj/project.pbxproj: Updated for renames and new
      files.
      
      * debugger/Debugger.cpp:
      (JSC::Debugger::recompileAllJSFunctions): Updated to use the Collector
      iterator abstraction.
      
      * jsc.cpp:
      (functionGC): Updated for rename.
      
      * runtime/Collector.cpp: Slightly reduced the number of allocations per
      collection, so that small workloads only allocate on collector block,
      rather than two.
      
      (JSC::Heap::Heap): Updated to use the new allocateBlock function.
      
      (JSC::Heap::destroy): Updated to use the new freeBlocks function.
      
      (JSC::Heap::allocateBlock): New function to initialize a block when
      allocating it.
      
      (JSC::Heap::freeBlock): Consolidated the responsibility for running
      destructors into this function.
      
      (JSC::Heap::freeBlocks): Updated to use freeBlock.
      
      (JSC::Heap::recordExtraCost): Sweep the heap in this reporting function,
      so that allocation, which is more common, doesn't have to check extraCost.
      
      (JSC::Heap::heapAllocate): Run destructors right before recycling a
      garbage cell. This has better cache utilization than a separate sweep phase.
      
      (JSC::Heap::resizeBlocks):
      (JSC::Heap::growBlocks):
      (JSC::Heap::shrinkBlocks): New set of functions for managing the size of
      the heap, now that the heap doesn't maintain any information about its
      size.
      
      (JSC::isPointerAligned):
      (JSC::isHalfCellAligned):
      (JSC::isPossibleCell):
      (JSC::isCellAligned):
      (JSC::Heap::markConservatively): Cleaned up this code a bit.
      
      (JSC::Heap::clearMarkBits):
      (JSC::Heap::markedCells): Some helper functions for examining the the mark
      bitmap.
      
      (JSC::Heap::sweep): Simplified this function by using a DeadObjectIterator.
      
      (JSC::Heap::markRoots): Reordered some operations for clarity.
      
      (JSC::Heap::objectCount):
      (JSC::Heap::addToStatistics):
      (JSC::Heap::statistics): Rewrote these functions to calculate an object
      count on demand, since the heap doesn't maintain this information by 
      itself.
      
      (JSC::Heap::reset): New function for resetting the heap once we've
      exhausted heap space.
      
      (JSC::Heap::collectAllGarbage): This function matches the old collect()
      behavior, but it's now an uncommon function used only by API.
      
      * runtime/Collector.h:
      (JSC::CollectorBitmap::count):
      (JSC::CollectorBitmap::isEmpty): Added some helper functions for managing
      the collector mark bitmap.
      
      (JSC::Heap::reportExtraMemoryCost): Changed reporting from cell equivalents
      to bytes, so it's easier to understand.
              
      * runtime/CollectorHeapIterator.h:
      (JSC::CollectorHeapIterator::CollectorHeapIterator):
      (JSC::CollectorHeapIterator::operator!=):
      (JSC::CollectorHeapIterator::operator*):
      (JSC::CollectorHeapIterator::advance):
      (JSC::::LiveObjectIterator):
      (JSC::::operator):
      (JSC::::DeadObjectIterator):
      (JSC::::ObjectIterator): New iterators for encapsulating details about
      heap layout, and what's live and dead on the heap.
      
      * runtime/JSArray.cpp:
      (JSC::JSArray::putSlowCase):
      (JSC::JSArray::increaseVectorLength): Delay reporting extra cost until
      we're fully constructed, so the heap mark phase won't visit us in an
      invalid state.
      
      * runtime/JSCell.h:
      (JSC::JSCell::):
      (JSC::JSCell::createDummyStructure):
      (JSC::JSCell::JSCell):
      * runtime/JSGlobalData.cpp:
      (JSC::JSGlobalData::JSGlobalData):
      * runtime/JSGlobalData.h: Added a dummy cell to simplify allocation logic.
      
      * runtime/JSString.h:
      (JSC::jsSubstring): Don't report extra cost for substrings, since they
      share a buffer that's already reported extra cost.
      
      * runtime/Tracing.d:
      * runtime/Tracing.h: Changed these dtrace hooks not to report object
      counts, since they're no longer cheap to compute.
      
      * runtime/UString.h: Updated for renames.
      
      * runtime/WeakGCMap.h: Added.
      (JSC::WeakGCMap::isEmpty):
      (JSC::WeakGCMap::uncheckedGet):
      (JSC::WeakGCMap::uncheckedBegin):
      (JSC::WeakGCMap::uncheckedEnd):
      (JSC::::get):
      (JSC::::take):
      (JSC::::set):
      (JSC::::uncheckedRemove): Mentioned above.
      
      * wtf/StdLibExtras.h:
      (WTF::bitCount): Added a bit population count function, so the heap can
      count live objects to fulfill statistics questions.
      
      JavaScriptGlue: Changed GC from mark-sweep to mark-allocate.
              
      Reviewed by Sam Weinig.
      
      * JavaScriptGlue.cpp:
      (JSCollect): Updated for rename. Fixed a bug where JSGlue would not check
      to avoid nested GC calls.
      
      WebCore: Changed GC from mark-sweep to mark-allocate.
      
      Reviewed by Sam Weinig.
      
      * ForwardingHeaders/runtime/WeakGCMap.h: Added.
      * bindings/js/GCController.cpp:
      (WebCore::collect):
      (WebCore::GCController::gcTimerFired):
      (WebCore::GCController::garbageCollectNow): Updated for rename.
      
      * bindings/js/JSDOMBinding.cpp:
      (WebCore::removeWrappers):
      (WebCore::hasCachedDOMObjectWrapperUnchecked):
      (WebCore::hasCachedDOMObjectWrapper):
      (WebCore::hasCachedDOMNodeWrapperUnchecked):
      (WebCore::forgetDOMObject):
      (WebCore::forgetDOMNode):
      (WebCore::isObservableThroughDOM):
      (WebCore::markDOMNodesForDocument):
      (WebCore::markDOMObjectWrapper):
      (WebCore::markDOMNodeWrapper):
      * bindings/js/JSDOMBinding.h: Changed DOM wrapper maps to be WeakGCMaps.
      Don't ASSERT that an item must be in the WeakGCMap when its destructor
      runs, since it might have been overwritten in the map first.
      
      * bindings/js/JSDocumentCustom.cpp:
      (WebCore::toJS): Changed Document from a DOM object wrapper to a DOM node
      wrapper, to simplify some code.
      
      * bindings/js/JSInspectedObjectWrapper.cpp:
      (WebCore::JSInspectedObjectWrapper::JSInspectedObjectWrapper):
      (WebCore::JSInspectedObjectWrapper::~JSInspectedObjectWrapper):
      * bindings/js/JSInspectorCallbackWrapper.cpp: Use a WeakGCMap for these
      wrappers.
      
      * bindings/js/JSNodeCustom.cpp:
      (WebCore::JSNode::markChildren): Updated for WeakGCMap and Document using
      a DOM node wrapper instead of a DOM object wrapper.
      
      * bindings/js/JSSVGPODTypeWrapper.h:
      (WebCore::JSSVGDynamicPODTypeWrapperCache::wrapperMap):
      (WebCore::JSSVGDynamicPODTypeWrapperCache::lookupOrCreateWrapper):
      (WebCore::JSSVGDynamicPODTypeWrapperCache::forgetWrapper):
      (WebCore::::~JSSVGDynamicPODTypeWrapper): Shined a small beam of sanity light
      on this code. Use hashtable-based lookup in JSSVGPODTypeWrapper.h instead
      of linear lookup through iteration, since that's what hashtables were
      invented for. Make JSSVGPODTypeWrapper.h responsible for reomving itself
      from the table, instead of its JS wrapper, to decouple these objects from
      GC, and because these objects are refCounted, not solely owned by their
      JS wrappers.
      
      * bindings/scripts/CodeGeneratorJS.pm:
      * dom/Document.h: Adopted changes above.
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52082 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      6a429819
  21. 13 Dec, 2009 1 commit
    • barraclough@apple.com's avatar
      https://bugs.webkit.org/show_bug.cgi?id=32496 · 1f0cbd2d
      barraclough@apple.com authored
      Switch remaining cases of string construction to use StringBuilder.
      Builds strings using a vector rather than using string append / addition.
      
      Reviewed by Sam Weinig.
      
      * JavaScriptCore.exp:
      * JavaScriptCore.xcodeproj/project.pbxproj:
      * runtime/Executable.cpp:
      (JSC::FunctionExecutable::paramString):
      * runtime/FunctionConstructor.cpp:
      (JSC::constructFunction):
      * runtime/JSGlobalObjectFunctions.cpp:
      (JSC::encode):
      (JSC::decode):
      (JSC::globalFuncEscape):
      (JSC::globalFuncUnescape):
      * runtime/JSONObject.cpp:
      (JSC::Stringifier::stringify):
      (JSC::Stringifier::indent):
      * runtime/JSString.h:
      * runtime/LiteralParser.cpp:
      (JSC::LiteralParser::Lexer::lexString):
      * runtime/NumberPrototype.cpp:
      (JSC::integerPartNoExp):
      (JSC::numberProtoFuncToFixed):
      (JSC::numberProtoFuncToPrecision):
      * runtime/Operations.h:
      (JSC::jsString):
      * runtime/StringPrototype.cpp:
      (JSC::substituteBackreferencesSlow):
      (JSC::substituteBackreferences):
      (JSC::stringProtoFuncConcat):
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52075 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      1f0cbd2d
  22. 12 Dec, 2009 1 commit
  23. 11 Dec, 2009 2 commits
    • ggaren@apple.com's avatar
      JavaScriptCore: Changed GC from mark-sweep to mark-allocate. · cf48922a
      ggaren@apple.com authored
              
      Reviewed by Sam Weinig.
      
      Added WeakGCMap to keep WebCore blissfully ignorant about objects that
      have become garbage but haven't run their destructors yet.
              
      1% SunSpider speedup.
      7.6% v8 speedup (37% splay speedup).
      17% speedup on bench-alloc-nonretained.js.
      18% speedup on bench-alloc-retained.js.
      
      * API/JSBase.cpp:
      (JSGarbageCollect):
      * API/JSContextRef.cpp:
      * JavaScriptCore.exp:
      * JavaScriptCore.xcodeproj/project.pbxproj: Updated for renames and new
      files.
      
      * debugger/Debugger.cpp:
      (JSC::Debugger::recompileAllJSFunctions): Updated to use the Collector
      iterator abstraction.
      
      * jsc.cpp:
      (functionGC): Updated for rename.
      
      * runtime/Collector.cpp: Slightly reduced the number of allocations per
      collection, so that small workloads only allocate on collector block,
      rather than two.
      
      (JSC::Heap::Heap): Updated to use the new allocateBlock function.
      
      (JSC::Heap::destroy): Updated to use the new freeBlocks function.
      
      (JSC::Heap::allocateBlock): New function to initialize a block when
      allocating it.
      
      (JSC::Heap::freeBlock): Consolidated the responsibility for running
      destructors into this function.
      
      (JSC::Heap::freeBlocks): Updated to use freeBlock.
      
      (JSC::Heap::recordExtraCost): Sweep the heap in this reporting function,
      so that allocation, which is more common, doesn't have to check extraCost.
      
      (JSC::Heap::heapAllocate): Run destructors right before recycling a
      garbage cell. This has better cache utilization than a separate sweep phase.
      
      (JSC::Heap::resizeBlocks):
      (JSC::Heap::growBlocks):
      (JSC::Heap::shrinkBlocks): New set of functions for managing the size of
      the heap, now that the heap doesn't maintain any information about its
      size.
      
      (JSC::isPointerAligned):
      (JSC::isHalfCellAligned):
      (JSC::isPossibleCell):
      (JSC::isCellAligned):
      (JSC::Heap::markConservatively): Cleaned up this code a bit.
      
      (JSC::Heap::clearMarkBits):
      (JSC::Heap::markedCells): Some helper functions for examining the the mark
      bitmap.
      
      (JSC::Heap::sweep): Simplified this function by using a DeadObjectIterator.
      
      (JSC::Heap::markRoots): Reordered some operations for clarity.
      
      (JSC::Heap::objectCount):
      (JSC::Heap::addToStatistics):
      (JSC::Heap::statistics): Rewrote these functions to calculate an object
      count on demand, since the heap doesn't maintain this information by 
      itself.
      
      (JSC::Heap::reset): New function for resetting the heap once we've
      exhausted heap space.
      
      (JSC::Heap::collectAllGarbage): This function matches the old collect()
      behavior, but it's now an uncommon function used only by API.
      
      * runtime/Collector.h:
      (JSC::CollectorBitmap::count):
      (JSC::CollectorBitmap::isEmpty): Added some helper functions for managing
      the collector mark bitmap.
      
      (JSC::Heap::reportExtraMemoryCost): Changed reporting from cell equivalents
      to bytes, so it's easier to understand.
              
      * runtime/CollectorHeapIterator.h:
      (JSC::CollectorHeapIterator::CollectorHeapIterator):
      (JSC::CollectorHeapIterator::operator!=):
      (JSC::CollectorHeapIterator::operator*):
      (JSC::CollectorHeapIterator::advance):
      (JSC::::LiveObjectIterator):
      (JSC::::operator):
      (JSC::::DeadObjectIterator):
      (JSC::::ObjectIterator): New iterators for encapsulating details about
      heap layout, and what's live and dead on the heap.
      
      * runtime/JSArray.cpp:
      (JSC::JSArray::putSlowCase):
      (JSC::JSArray::increaseVectorLength): Delay reporting extra cost until
      we're fully constructed, so the heap mark phase won't visit us in an
      invalid state.
      
      * runtime/JSCell.h:
      (JSC::JSCell::):
      (JSC::JSCell::createDummyStructure):
      (JSC::JSCell::JSCell):
      * runtime/JSGlobalData.cpp:
      (JSC::JSGlobalData::JSGlobalData):
      * runtime/JSGlobalData.h: Added a dummy cell to simplify allocation logic.
      
      * runtime/JSString.h:
      (JSC::jsSubstring): Don't report extra cost for substrings, since they
      share a buffer that's already reported extra cost.
      
      * runtime/Tracing.d:
      * runtime/Tracing.h: Changed these dtrace hooks not to report object
      counts, since they're no longer cheap to compute.
      
      * runtime/UString.h: Updated for renames.
      
      * runtime/WeakGCMap.h: Added.
      (JSC::WeakGCMap::isEmpty):
      (JSC::WeakGCMap::uncheckedGet):
      (JSC::WeakGCMap::uncheckedBegin):
      (JSC::WeakGCMap::uncheckedEnd):
      (JSC::::get):
      (JSC::::take):
      (JSC::::set):
      (JSC::::uncheckedRemove): Mentioned above.
      
      * wtf/StdLibExtras.h:
      (WTF::bitCount): Added a bit population count function, so the heap can
      count live objects to fulfill statistics questions.
      
      JavaScriptGlue: Changed GC from mark-sweep to mark-allocate.
              
      Reviewed by Sam Weinig.
      
      * JavaScriptGlue.cpp:
      (JSCollect): Updated for rename. Fixed a bug where JSGlue would not check
      to avoid nested GC calls.
      
      WebCore: Changed GC from mark-sweep to mark-allocate.
      
      Reviewed by Sam Weinig.
      
      * ForwardingHeaders/runtime/WeakGCMap.h: Added.
      * bindings/js/GCController.cpp:
      (WebCore::collect):
      (WebCore::GCController::gcTimerFired):
      (WebCore::GCController::garbageCollectNow): Updated for rename.
      
      * bindings/js/JSDOMBinding.cpp:
      (WebCore::removeWrappers):
      (WebCore::hasCachedDOMObjectWrapperUnchecked):
      (WebCore::hasCachedDOMObjectWrapper):
      (WebCore::hasCachedDOMNodeWrapperUnchecked):
      (WebCore::forgetDOMObject):
      (WebCore::forgetDOMNode):
      (WebCore::isObservableThroughDOM):
      (WebCore::markDOMNodesForDocument):
      (WebCore::markDOMObjectWrapper):
      (WebCore::markDOMNodeWrapper):
      * bindings/js/JSDOMBinding.h: Changed DOM wrapper maps to be WeakGCMaps.
      Don't ASSERT that an item must be in the WeakGCMap when its destructor
      runs, since it might have been overwritten in the map first.
      
      * bindings/js/JSDocumentCustom.cpp:
      (WebCore::toJS): Changed Document from a DOM object wrapper to a DOM node
      wrapper, to simplify some code.
      
      * bindings/js/JSInspectedObjectWrapper.cpp:
      (WebCore::JSInspectedObjectWrapper::JSInspectedObjectWrapper):
      (WebCore::JSInspectedObjectWrapper::~JSInspectedObjectWrapper):
      * bindings/js/JSInspectorCallbackWrapper.cpp: Use a WeakGCMap for these
      wrappers.
      
      * bindings/js/JSNodeCustom.cpp:
      (WebCore::JSNode::markChildren): Updated for WeakGCMap and Document using
      a DOM node wrapper instead of a DOM object wrapper.
      
      * bindings/js/JSSVGPODTypeWrapper.h:
      (WebCore::JSSVGDynamicPODTypeWrapperCache::wrapperMap):
      (WebCore::JSSVGDynamicPODTypeWrapperCache::lookupOrCreateWrapper):
      (WebCore::JSSVGDynamicPODTypeWrapperCache::forgetWrapper):
      (WebCore::::~JSSVGDynamicPODTypeWrapper): Shined a small beam of sanity
      on this code. Use hashtable-based lookup in JSSVGPODTypeWrapper.h instead
      of linear lookup through iteration, since that's what hashtables were
      invented for. Make JSSVGPODTypeWrapper.h responsible for reomving itself
      from the table, instead of its JS wrapper, to decouple these objects from
      GC, and because these objects are refCounted, not solely owned by their
      JS wrappers.
      
      * bindings/scripts/CodeGeneratorJS.pm:
      * dom/Document.h: Adopted changes above.
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52040 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      cf48922a
    • barraclough@apple.com's avatar
      https://bugs.webkit.org/show_bug.cgi?id=32454 · e82d3905
      barraclough@apple.com authored
      Refactor construction of simple strings to avoid string concatenation.
      
      Reviewed by Oliver Hunt.
      
      Building strings through concatenation has a memory and performance cost -
      a memory cost since we must over-allocate the buffer to leave space to append
      into, and performance in that the string may still require reallocation (and
      thus copying during construction).  Instead move the full construction to
      within a single function call (makeString), so that the arguments' lengths
      can be calculated and an appropriate sized buffer allocated before copying
      any characters.
      
      ~No performance change (~2% progression on date tests).
      
      * bytecode/CodeBlock.cpp:
      (JSC::escapeQuotes):
      (JSC::valueToSourceString):
      (JSC::constantName):
      (JSC::idName):
      (JSC::CodeBlock::registerName):
      (JSC::regexpToSourceString):
      (JSC::regexpName):
      * bytecompiler/NodesCodegen.cpp:
      (JSC::substitute):
      * profiler/Profiler.cpp:
      (JSC::Profiler::createCallIdentifier):
      * runtime/DateConstructor.cpp:
      (JSC::callDate):
      * runtime/DateConversion.cpp:
      (JSC::formatDate):
      (JSC::formatDateUTCVariant):
      (JSC::formatTime):
      (JSC::formatTimeUTC):
      * runtime/DateConversion.h:
      (JSC::):
      * runtime/DatePrototype.cpp:
      (JSC::dateProtoFuncToString):
      (JSC::dateProtoFuncToUTCString):
      (JSC::dateProtoFuncToDateString):
      (JSC::dateProtoFuncToTimeString):
      (JSC::dateProtoFuncToGMTString):
      * runtime/ErrorPrototype.cpp:
      (JSC::errorProtoFuncToString):
      * runtime/ExceptionHelpers.cpp:
      (JSC::createUndefinedVariableError):
      (JSC::createErrorMessage):
      (JSC::createInvalidParamError):
      * runtime/FunctionPrototype.cpp:
      (JSC::insertSemicolonIfNeeded):
      (JSC::functionProtoFuncToString):
      * runtime/ObjectPrototype.cpp:
      (JSC::objectProtoFuncToString):
      * runtime/RegExpConstructor.cpp:
      (JSC::constructRegExp):
      * runtime/RegExpObject.cpp:
      (JSC::RegExpObject::match):
      * runtime/RegExpPrototype.cpp:
      (JSC::regExpProtoFuncCompile):
      (JSC::regExpProtoFuncToString):
      * runtime/StringPrototype.cpp:
      (JSC::stringProtoFuncBig):
      (JSC::stringProtoFuncSmall):
      (JSC::stringProtoFuncBlink):
      (JSC::stringProtoFuncBold):
      (JSC::stringProtoFuncFixed):
      (JSC::stringProtoFuncItalics):
      (JSC::stringProtoFuncStrike):
      (JSC::stringProtoFuncSub):
      (JSC::stringProtoFuncSup):
      (JSC::stringProtoFuncFontcolor):
      (JSC::stringProtoFuncFontsize):
      (JSC::stringProtoFuncAnchor):
      * runtime/UString.h:
      (JSC::):
      (JSC::makeString):
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52028 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      e82d3905
  24. 18 Nov, 2009 1 commit
    • tkent@chromium.org's avatar
      2009-11-18 Kent Tamura <tkent@chromium.org> · e2a78115
      tkent@chromium.org authored
              Reviewed by Darin Adler.
      
              Move UString::from(double) implementation to new
              WTF::doubleToStringInJavaScriptFormat(), and expose it because WebCore
              code will use it.
              https://bugs.webkit.org/show_bug.cgi?id=31330
      
              - Introduce new function createRep(const char*, unsigned) and
                UString::UString(const char*, unsigned) to reduce 2 calls to strlen().
              - Fix a bug that dtoa() doesn't update *rve if the input value is NaN
                or Infinity.
      
              No new tests because this doesn't change the behavior.
      
              * JavaScriptCore.exp:
              * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
              * runtime/UString.cpp:
              (JSC::createRep):
              (JSC::UString::UString):
              (JSC::UString::from): Move the code to doubleToStringInJavaScriptFormat().
              * runtime/UString.h:
              * wtf/dtoa.cpp:
              (WTF::dtoa): Fix a bug about rve.
              (WTF::append): A helper for doubleToStringInJavaScriptFormat().
              (WTF::doubleToStringInJavaScriptFormat): Move the code from UString::from(double).
              * wtf/dtoa.h:
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51168 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      e2a78115
  25. 20 Aug, 2009 1 commit
    • ggaren@apple.com's avatar
      Added a number => string cache. · a60d51b4
      ggaren@apple.com authored
              
      Patch by Geoffrey Garen <ggaren@apple.com> on 2009-08-20
      Reviewed by Maciej Stachowiak.
      
      1.07x faster on v8 (1.7x faster on v8-splay).
      1.004x faster on SunSpider.
      
      * runtime/JSCell.h: Moved JSValue::toString to JSString.h.
      * runtime/JSGlobalData.h: Holds the cache.
      * runtime/JSNumberCell.cpp:
      (JSC::JSNumberCell::toString):
      (JSC::JSNumberCell::toThisString): Removed -0 special case.
      UString handles this now, since too many clients were
      special-casing it.
      
      * runtime/JSString.h:
      (JSC::JSValue::toString): Use the cache when converting
      an int or double to string.
      
      * runtime/Operations.h:
      (JSC::concatenateStrings): Call toString to take advantage
      of the cache.
      
      * runtime/SmallStrings.h:
      (JSC::NumericStrings::add):
      (JSC::NumericStrings::lookup): The cache.
      
      * runtime/UString.cpp:
      (JSC::UString::from): Added -0 special case mentioned above.
      Removed appendNumeric because it's mutually exclusive with the
      cache.
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@47622 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      a60d51b4
  26. 12 Aug, 2009 3 commits
  27. 21 Jul, 2009 1 commit
    • aroben@apple.com's avatar
      Roll out r46153, r46154, and r46155 · 096e7e05
      aroben@apple.com authored
              These changes were causing build failures and assertion failures on
              Windows.
      
      JavaScriptCore:
      
              * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
              * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def:
              * JavaScriptCore.xcodeproj/project.pbxproj:
              * runtime/JSArray.cpp:
              * runtime/StringPrototype.cpp:
              * runtime/UString.cpp:
              * runtime/UString.h:
              * wtf/FastMalloc.cpp:
              * wtf/FastMalloc.h:
              * wtf/Platform.h:
              * wtf/PossiblyNull.h: Removed.
      
      WebCore:
      
              * ForwardingHeaders/wtf/PossiblyNull.h: Removed.
              * platform/graphics/cg/ImageBufferCG.cpp:
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@46180 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      096e7e05
  28. 20 Jul, 2009 1 commit
  29. 26 Jun, 2009 1 commit
    • eric@webkit.org's avatar
      2009-06-26 Eric Seidel <eric@webkit.org> · 6988f542
      eric@webkit.org authored
              No review, only rolling out r45259.
      
              Roll out r45259 after crash appeared on the bots:
              plugins/undefined-property-crash.html
              ASSERTION FAILED: s <= HeapConstants<heapType>::cellSize
              (leopard-intel-debug-tests/build/JavaScriptCore/runtime/Collector.cpp:278
              void* JSC::Heap::heapAllocate(size_t) [with JSC::HeapType heapType = PrimaryHeap])
      
              * runtime/DateInstance.cpp:
              * runtime/Identifier.cpp:
              * runtime/Lookup.h:
              * runtime/RegExpConstructor.cpp:
              * runtime/RegExpObject.h:
              * runtime/ScopeChain.h:
              * runtime/UString.h:
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@45269 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      6988f542