Changeset 1799 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp


Ignore:
Timestamp:
Aug 12, 2002, 1:14:02 PM (23 years ago)
Author:
darin
Message:

top level:

  • Tests/WebFoundation-Misc/ifnsurlextensions-test.m: (TestURLCommon): Add tests for the new WebNSURLExtras methods.
  • Tests/libiftest/IFCheckLeaks.c: (IFCheckLeaksAtExit): Remove workaround for CFPreferences race condition; it's now in WebFoundation.

JavaScriptCore:

Speed improvements. 19% faster on cvs-js-performance, 1% on cvs-static-urls.

Use global string objects for length and other common property names rather
than constantly making and destroying them. Use integer versions of get() and
other related calls rather than always making a string.

Also get rid of many unneeded constructors, destructors, copy constructors, and
assignment operators. And make some functions non-virtual.

  • kjs/internal.h:
  • kjs/internal.cpp: (NumberImp::toUInt32): Implement. (ReferenceImp::ReferenceImp): Special case for numeric property names. (ReferenceImp::getPropertyName): Moved guts here from ValueImp. Handle numeric case. (ReferenceImp::getValue): Moved guts here from ValueImp. Handle numeric case. (ReferenceImp::putValue): Moved guts here from ValueImp. Handle numeric case. (ReferenceImp::deleteValue): Added. Handle numeric case.
  • kjs/array_object.h:
  • kjs/array_object.cpp: All-new array implementation that stores the elements in a C++ array rather than in a property map. (ArrayInstanceImp::ArrayInstanceImp): Allocate the C++ array. (ArrayInstanceImp::~ArrayInstanceImp): Delete the C++ array. (ArrayInstanceImp::get): Implement both the old version and the new overload that takes an unsigned index for speed. (ArrayInstanceImp::put): Implement both the old version and the new overload that takes an unsigned index for speed. (ArrayInstanceImp::hasProperty): Implement both the old version and the new overload that takes an unsigned index for speed. (ArrayInstanceImp::deleteProperty): Implement both the old version and the new overload that takes an unsigned index for speed. (ArrayInstanceImp::setLength): Added. Used by the above to resize the array. (ArrayInstanceImp::mark): Mark the elements of the array too. (ArrayPrototypeImp::ArrayPrototypeImp): Pass the length to the array instance constructor.
  • kjs/bool_object.cpp:
  • kjs/date_object.cpp:
  • kjs/error_object.cpp:
  • kjs/function.cpp:
  • kjs/function_object.cpp:
  • kjs/math_object.cpp:
  • kjs/nodes.cpp:
  • kjs/nodes.h:
  • kjs/number_object.cpp:
  • kjs/object_object.cpp:
  • kjs/regexp_object.cpp:
  • kjs/string_object.cpp:
  • kjs/nodes2string.cpp: (SourceStream::operator<<): Add a special case for char now that you can't create a UString from a char implicitly.
  • kjs/object.h:
  • kjs/object.cpp: (ObjectImp::get): Call through to the string version if the numeric version is not implemented. (ObjectImp::put): Call through to the string version if the numeric version is not implemented. (ObjectImp::hasProperty): Call through to the string version if the numeric version is not implemented. (ObjectImp::deleteProperty): Call through to the string version if the numeric version is not implemented.
  • kjs/types.h:
  • kjs/types.cpp: (Reference::Reference): Added constructors for the numeric property name case.
  • kjs/ustring.h: Made the constructor that turns a character into a string be explicit so we don't get numbers that turn themselves into strings.
  • kjs/ustring.cpp: (UString::UString): Detect the empty string case, and use a shared empty string. (UString::find): Add an overload for single character finds. (UString::rfind): Add an overload for single character finds. (KJS::operator==): Fix bug where it would call strlen(0) if the first string was not null. Also handle non-ASCII characters consistently with the rest of the code by casting to unsigned char just in case.
  • kjs/value.h: Make ValueImp and all subclasses non-copyable and non-assignable.
  • kjs/value.cpp: (ValueImp::toUInt32): New interface, mainly useful so we can detect array indices and not turn them into strings and back. (ValueImp::toInteger): Use the new toUInt32. Probably can use more improvement. (ValueImp::toInt32): Use the new toUInt32. Probably can use more improvement. (ValueImp::toUInt16): Use the new toUInt32. Probably can use more improvement. (ValueImp::getBase): Remove handling of the Reference case. That's in ReferenceImp now. (ValueImp::getPropertyName): Remove handling of the Reference case. That's in ReferenceImp now. (ValueImp::getValue): Remove handling of the Reference case. That's in ReferenceImp now. (ValueImp::putValue): Remove handling of the Reference case. That's in ReferenceImp now. (ValueImp::deleteValue): Added. Used so we can do delete the same way we do put.

WebFoundation:

  • CacheLoader.subproj/WebHTTPResourceLoader.m: (-[WebHTTPProtocolHandler createWFLoadRequest]): Fix handling of paths with queries and some other subtle path and port number handling issues by using _web_hostWithPort and _web_pathWithQuery.
  • Misc.subproj/WebNSURLExtras.h:
  • Misc.subproj/WebNSURLExtras.m: (-[NSURL _web_hostWithPort]): Added. (-[NSURL _web_pathWithQuery]): Added.
  • CacheLoader.subproj/WebResourceLoad.m: (initLoader): Get some random preference before creating threads. This makes it impossible to run into the CFPreferences race condition.

WebCore:

  • force-clean-timestamp: Need a full build because of KJS changes.
  • khtml/ecma/kjs_window.h: Need to store an Object, not an ObjectImp, because there's no way to copy an ObjectImp. KJS changes caught this mistake.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r1623 r1799  
    118118}
    119119
    120 StatementNode::~StatementNode()
    121 {
    122 }
    123 
    124120void StatementNode::setLoc(int line0, int line1, int sourceId)
    125121{
     
    227223// ------------------------------ GroupNode ------------------------------------
    228224
    229 GroupNode::~GroupNode()
    230 {
    231 }
    232 
    233225void GroupNode::ref()
    234226{
     
    252244
    253245// ------------------------------ ElisionNode ----------------------------------
    254 
    255 ElisionNode::~ElisionNode()
    256 {
    257 }
    258246
    259247void ElisionNode::ref()
     
    281269
    282270// ------------------------------ ElementNode ----------------------------------
    283 
    284 ElementNode::~ElementNode()
    285 {
    286 }
    287271
    288272void ElementNode::ref()
     
    321305    KJS_CHECKEXCEPTIONVALUE
    322306    val = node->evaluate(exec).getValue(exec);
    323     length = array.get(exec,"length").toInt32(exec);
     307    length = array.get(exec,lengthPropertyName).toInt32(exec);
    324308  } else {
    325309    Value newArr = exec->interpreter()->builtinArray().construct(exec,List::empty());
     
    329313  }
    330314
    331   array.put(exec, UString::from(elisionLen + length), val);
     315  array.put(exec, elisionLen + length, val);
    332316
    333317  return array;
     
    335319
    336320// ------------------------------ ArrayNode ------------------------------------
    337 
    338 ArrayNode::~ArrayNode()
    339 {
    340 }
    341321
    342322void ArrayNode::ref()
     
    369349    array = Object(static_cast<ObjectImp*>(element->evaluate(exec).imp()));
    370350    KJS_CHECKEXCEPTIONVALUE
    371     length = opt ? array.get(exec,"length").toInt32(exec) : 0;
     351    length = opt ? array.get(exec,lengthPropertyName).toInt32(exec) : 0;
    372352  } else {
    373353    Value newArr = exec->interpreter()->builtinArray().construct(exec,List::empty());
     
    377357
    378358  if (opt)
    379     array.put(exec,"length", Number(elisionLen + length), DontEnum | DontDelete);
     359    array.put(exec,lengthPropertyName, Number(elisionLen + length), DontEnum | DontDelete);
    380360
    381361  return array;
     
    383363
    384364// ------------------------------ ObjectLiteralNode ----------------------------
    385 
    386 ObjectLiteralNode::~ObjectLiteralNode()
    387 {
    388 }
    389365
    390366void ObjectLiteralNode::ref()
     
    412388
    413389// ------------------------------ PropertyValueNode ----------------------------
    414 
    415 PropertyValueNode::~PropertyValueNode()
    416 {
    417 }
    418390
    419391void PropertyValueNode::ref()
     
    479451// ------------------------------ AccessorNode1 --------------------------------
    480452
    481 AccessorNode1::~AccessorNode1()
    482 {
    483 }
    484 
    485453void AccessorNode1::ref()
    486454{
     
    511479  Value v2 = e2.getValue(exec);
    512480  Object o = v1.toObject(exec);
     481  unsigned i;
     482  if (v2.toUInt32(i))
     483    return Reference(o, i);
    513484  String s = v2.toString(exec);
    514485  return Reference(o, s.value());
     
    516487
    517488// ------------------------------ AccessorNode2 --------------------------------
    518 
    519 AccessorNode2::~AccessorNode2()
    520 {
    521 }
    522489
    523490void AccessorNode2::ref()
     
    553520ArgumentListNode::ArgumentListNode(ArgumentListNode *l, Node *e)
    554521  : list(l), expr(e)
    555 {
    556 }
    557 
    558 ArgumentListNode::~ArgumentListNode()
    559522{
    560523}
     
    608571}
    609572
    610 ArgumentsNode::~ArgumentsNode()
    611 {
    612 }
    613 
    614573void ArgumentsNode::ref()
    615574{
     
    644603
    645604// ECMA 11.2.2
    646 
    647 NewExprNode::~NewExprNode()
    648 {
    649 }
    650605
    651606void NewExprNode::ref()
     
    694649
    695650// ------------------------------ FunctionCallNode -----------------------------
    696 
    697 FunctionCallNode::~FunctionCallNode()
    698 {
    699 }
    700651
    701652void FunctionCallNode::ref()
     
    788739// ------------------------------ PostfixNode ----------------------------------
    789740
    790 PostfixNode::~PostfixNode()
    791 {
    792 }
    793 
    794741void PostfixNode::ref()
    795742{
     
    824771// ------------------------------ DeleteNode -----------------------------------
    825772
    826 DeleteNode::~DeleteNode()
    827 {
    828 }
    829 
    830773void DeleteNode::ref()
    831774{
     
    847790  Value e = expr->evaluate(exec);
    848791  KJS_CHECKEXCEPTIONVALUE
    849   if (e.type() != ReferenceType)
    850     return Boolean(true);
    851   Value b = e.getBase(exec);
    852   UString n = e.getPropertyName(exec);
    853 
    854   // The spec doesn't mention what to do if the base is null... just return true
    855   if (b.type() != ObjectType) {
    856     assert(b.type() == NullType);
    857     return Boolean(true);
    858   }
    859 
    860   Object o = Object(static_cast<ObjectImp*>(b.imp()));
    861 
    862   bool ret = o.deleteProperty(exec,n);
    863 
    864   return Boolean(ret);
     792  return Boolean(e.deleteValue(exec));
    865793}
    866794
    867795// ------------------------------ VoidNode -------------------------------------
    868 
    869 VoidNode::~VoidNode()
    870 {
    871 }
    872796
    873797void VoidNode::ref()
     
    896820
    897821// ------------------------------ TypeOfNode -----------------------------------
    898 
    899 TypeOfNode::~TypeOfNode()
    900 {
    901 }
    902822
    903823void TypeOfNode::ref()
     
    957877// ------------------------------ PrefixNode -----------------------------------
    958878
    959 PrefixNode::~PrefixNode()
    960 {
    961 }
    962 
    963879void PrefixNode::ref()
    964880{
     
    993909// ------------------------------ UnaryPlusNode --------------------------------
    994910
    995 UnaryPlusNode::~UnaryPlusNode()
    996 {
    997 }
    998 
    999911void UnaryPlusNode::ref()
    1000912{
     
    1023935// ------------------------------ NegateNode -----------------------------------
    1024936
    1025 NegateNode::~NegateNode()
    1026 {
    1027 }
    1028 
    1029937void NegateNode::ref()
    1030938{
     
    1056964// ------------------------------ BitwiseNotNode -------------------------------
    1057965
    1058 BitwiseNotNode::~BitwiseNotNode()
    1059 {
    1060 }
    1061 
    1062966void BitwiseNotNode::ref()
    1063967{
     
    1087991// ------------------------------ LogicalNotNode -------------------------------
    1088992
    1089 LogicalNotNode::~LogicalNotNode()
    1090 {
    1091 }
    1092 
    1093993void LogicalNotNode::ref()
    1094994{
     
    11171017
    11181018// ------------------------------ MultNode -------------------------------------
    1119 
    1120 MultNode::~MultNode()
    1121 {
    1122 }
    11231019
    11241020void MultNode::ref()
     
    11561052// ------------------------------ AddNode --------------------------------------
    11571053
    1158 AddNode::~AddNode()
    1159 {
    1160 }
    1161 
    11621054void AddNode::ref()
    11631055{
     
    11931085
    11941086// ------------------------------ ShiftNode ------------------------------------
    1195 
    1196 ShiftNode::~ShiftNode()
    1197 {
    1198 }
    11991087
    12001088void ShiftNode::ref()
     
    12481136
    12491137// ------------------------------ RelationalNode -------------------------------
    1250 
    1251 RelationalNode::~RelationalNode()
    1252 {
    1253 }
    12541138
    12551139void RelationalNode::ref()
     
    13241208// ------------------------------ EqualNode ------------------------------------
    13251209
    1326 EqualNode::~EqualNode()
    1327 {
    1328 }
    1329 
    13301210void EqualNode::ref()
    13311211{
     
    13701250
    13711251// ------------------------------ BitOperNode ----------------------------------
    1372 
    1373 BitOperNode::~BitOperNode()
    1374 {
    1375 }
    13761252
    13771253void BitOperNode::ref()
     
    14171293// ------------------------------ BinaryLogicalNode ----------------------------
    14181294
    1419 BinaryLogicalNode::~BinaryLogicalNode()
    1420 {
    1421 }
    1422 
    14231295void BinaryLogicalNode::ref()
    14241296{
     
    14571329
    14581330// ------------------------------ ConditionalNode ------------------------------
    1459 
    1460 ConditionalNode::~ConditionalNode()
    1461 {
    1462 }
    14631331
    14641332void ConditionalNode::ref()
     
    15021370
    15031371// ------------------------------ AssignNode -----------------------------------
    1504 
    1505 AssignNode::~AssignNode()
    1506 {
    1507 }
    15081372
    15091373void AssignNode::ref()
     
    15971461// ------------------------------ CommaNode ------------------------------------
    15981462
    1599 CommaNode::~CommaNode()
    1600 {
    1601 }
    1602 
    16031463void CommaNode::ref()
    16041464{
     
    16321492
    16331493// ------------------------------ StatListNode ---------------------------------
    1634 
    1635 StatListNode::~StatListNode()
    1636 {
    1637 }
    16381494
    16391495void StatListNode::ref()
     
    16981554// ------------------------------ AssignExprNode -------------------------------
    16991555
    1700 AssignExprNode::~AssignExprNode()
    1701 {
    1702 }
    1703 
    17041556void AssignExprNode::ref()
    17051557{
     
    17261578VarDeclNode::VarDeclNode(const UString *id, AssignExprNode *in)
    17271579    : ident(*id), init(in)
    1728 {
    1729 }
    1730 
    1731 VarDeclNode::~VarDeclNode()
    17321580{
    17331581}
     
    17811629// ------------------------------ VarDeclListNode ------------------------------
    17821630
    1783 VarDeclListNode::~VarDeclListNode()
    1784 {
    1785 }
    1786 
    17871631void VarDeclListNode::ref()
    17881632{
     
    18271671// ------------------------------ VarStatementNode -----------------------------
    18281672
    1829 VarStatementNode::~VarStatementNode()
    1830 {
    1831 }
    1832 
    18331673void VarStatementNode::ref()
    18341674{
     
    18631703// ------------------------------ BlockNode ------------------------------------
    18641704
    1865 BlockNode::~BlockNode()
    1866 {
    1867 }
    1868 
    18691705void BlockNode::ref()
    18701706{
     
    19071743
    19081744// ------------------------------ ExprStatementNode ----------------------------
    1909 
    1910 ExprStatementNode::~ExprStatementNode()
    1911 {
    1912 }
    19131745
    19141746void ExprStatementNode::ref()
     
    19391771
    19401772// ------------------------------ IfNode ---------------------------------------
    1941 
    1942 IfNode::~IfNode()
    1943 {
    1944 }
    19451773
    19461774void IfNode::ref()
     
    19971825
    19981826// ------------------------------ DoWhileNode ----------------------------------
    1999 
    2000 DoWhileNode::~DoWhileNode()
    2001 {
    2002 }
    20031827
    20041828void DoWhileNode::ref()
     
    20551879// ------------------------------ WhileNode ------------------------------------
    20561880
    2057 WhileNode::~WhileNode()
    2058 {
    2059 }
    2060 
    20611881void WhileNode::ref()
    20621882{
     
    21181938
    21191939// ------------------------------ ForNode --------------------------------------
    2120 
    2121 ForNode::~ForNode()
    2122 {
    2123 }
    21241940
    21251941void ForNode::ref()
     
    22122028}
    22132029
    2214 ForInNode::~ForInNode()
    2215 {
    2216 }
    2217 
    22182030void ForInNode::ref()
    22192031{
     
    23332145// ------------------------------ ReturnNode -----------------------------------
    23342146
    2335 ReturnNode::~ReturnNode()
    2336 {
    2337 }
    2338 
    23392147void ReturnNode::ref()
    23402148{
     
    23672175
    23682176// ------------------------------ WithNode -------------------------------------
    2369 
    2370 WithNode::~WithNode()
    2371 {
    2372 }
    23732177
    23742178void WithNode::ref()
     
    24142218// ------------------------------ CaseClauseNode -------------------------------
    24152219
    2416 CaseClauseNode::~CaseClauseNode()
    2417 {
    2418 }
    2419 
    24202220void CaseClauseNode::ref()
    24212221{
     
    24632263// ------------------------------ ClauseListNode -------------------------------
    24642264
    2465 ClauseListNode::~ClauseListNode()
    2466 {
    2467 }
    2468 
    24692265void ClauseListNode::ref()
    24702266{
     
    25122308
    25132309// ------------------------------ CaseBlockNode --------------------------------
    2514 
    2515 CaseBlockNode::~CaseBlockNode()
    2516 {
    2517 }
    25182310
    25192311void CaseBlockNode::ref()
     
    26202412// ------------------------------ SwitchNode -----------------------------------
    26212413
    2622 SwitchNode::~SwitchNode()
    2623 {
    2624 }
    2625 
    26262414void SwitchNode::ref()
    26272415{
     
    26642452
    26652453// ------------------------------ LabelNode ------------------------------------
    2666 
    2667 LabelNode::~LabelNode()
    2668 {
    2669 }
    26702454
    26712455void LabelNode::ref()
     
    27082492// ------------------------------ ThrowNode ------------------------------------
    27092493
    2710 ThrowNode::~ThrowNode()
    2711 {
    2712 }
    2713 
    27142494void ThrowNode::ref()
    27152495{
     
    27422522
    27432523// ------------------------------ CatchNode ------------------------------------
    2744 
    2745 CatchNode::~CatchNode()
    2746 {
    2747 }
    27482524
    27492525void CatchNode::ref()
     
    27912567// ------------------------------ FinallyNode ----------------------------------
    27922568
    2793 FinallyNode::~FinallyNode()
    2794 {
    2795 }
    2796 
    27972569void FinallyNode::ref()
    27982570{
     
    28212593
    28222594// ------------------------------ TryNode --------------------------------------
    2823 
    2824 TryNode::~TryNode()
    2825 {
    2826 }
    28272595
    28282596void TryNode::ref()
     
    28862654// ------------------------------ ParameterNode --------------------------------
    28872655
    2888 ParameterNode::~ParameterNode()
    2889 {
    2890 }
    2891 
    28922656void ParameterNode::ref()
    28932657{
     
    29312695}
    29322696
    2933 FunctionBodyNode::~FunctionBodyNode()
    2934 {
    2935   //fprintf(stderr,"FunctionBodyNode::~FunctionBodyNode %p\n",this);
    2936 }
    2937 
    29382697void FunctionBodyNode::ref()
    29392698{
     
    29772736
    29782737// ------------------------------ FuncDeclNode ---------------------------------
    2979 
    2980 FuncDeclNode::~FuncDeclNode()
    2981 {
    2982 }
    29832738
    29842739void FuncDeclNode::ref()
     
    30122767  List empty;
    30132768  Value proto = exec->interpreter()->builtinObject().construct(exec,empty);
    3014   func.put(exec, "prototype", proto, Internal|DontDelete);
     2769  func.put(exec, prototypePropertyName, proto, Internal|DontDelete);
    30152770
    30162771  int plen = 0;
     
    30182773    fimp->addParameter(p->ident());
    30192774
    3020   func.put(exec, "length", Number(plen), ReadOnly|DontDelete|DontEnum);
     2775  func.put(exec, lengthPropertyName, Number(plen), ReadOnly|DontDelete|DontEnum);
    30212776
    30222777  exec->context().imp()->variableObject().put(exec,ident,func);
     
    30362791// ------------------------------ FuncExprNode ---------------------------------
    30372792
    3038 FuncExprNode::~FuncExprNode()
    3039 {
    3040 }
    3041 
    30422793void FuncExprNode::ref()
    30432794{
     
    30672818  List empty;
    30682819  Value proto = exec->interpreter()->builtinObject().construct(exec,empty);
    3069   fimp->put(exec, "prototype", proto, Internal|DontDelete);
     2820  fimp->put(exec, prototypePropertyName, proto, Internal|DontDelete);
    30702821
    30712822  int plen = 0;
    30722823  for(ParameterNode *p = param; p != 0L; p = p->nextParam(), plen++)
    30732824    fimp->addParameter(p->ident());
    3074   fimp->put(exec,"length", Number(plen), ReadOnly|DontDelete|DontEnum);
     2825  fimp->put(exec,lengthPropertyName, Number(plen), ReadOnly|DontDelete|DontEnum);
    30752826
    30762827  return ret;
     
    30782829
    30792830// ------------------------------ SourceElementNode ----------------------------
    3080 
    3081 SourceElementNode::~SourceElementNode()
    3082 {
    3083 }
    30842831
    30852832void SourceElementNode::ref()
     
    31242871
    31252872// ------------------------------ SourceElementsNode ---------------------------
    3126 
    3127 SourceElementsNode::~SourceElementsNode()
    3128 {
    3129 }
    31302873
    31312874void SourceElementsNode::ref()
     
    31882931    //fprintf(stderr,"ProgramNode::ProgramNode %p\n",this);
    31892932}
    3190 
    3191 ProgramNode::~ProgramNode() {
    3192     //fprintf(stderr,"ProgramNode::~ProgramNode %p\n",this);
    3193 }
Note: See TracChangeset for help on using the changeset viewer.