[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

mjs mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:31:48 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 01f82a58021577c09b01e6aabd8d3d74b618405b
Author: mjs <mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Aug 16 07:43:56 2002 +0000

    	Phase 1 of optimization to stop allocating references through the
    	collector. This step clearly splits evaluating to a reference and
    	evaluating to a value, and moves all of the reference-specific
    	operations from Value to Reference. A special ConstReference class
    	helps out for the one case where you need special reference
    	operations if the result is a reference, and not otherwise.
    
    	Also, Reference now inherits privately from Value, and there is a
    	new ReferenceList class that inherits privately from List, so the
    	uses of Reference and Value are now completely orthogonal. This
    	means that as the next step, their implementations can be
    	completely disentangled.
    
    	This step has no actual performance impact.
    
            * kjs/collector.cpp:
            (Collector::collect):
            * kjs/nodes.cpp:
            (Node::evaluateReference):
            (ResolveNode::evaluate):
            (ResolveNode::evaluateReference):
            (ElementNode::evaluate):
            (PropertyValueNode::evaluate):
            (AccessorNode1::evaluate):
            (AccessorNode1::evaluateReference):
            (AccessorNode2::evaluate):
            (AccessorNode2::evaluateReference):
            (ArgumentListNode::evaluateList):
            (NewExprNode::evaluate):
            (FunctionCallNode::evaluate):
            (PostfixNode::evaluate):
            (DeleteNode::evaluate):
            (VoidNode::evaluate):
            (TypeOfNode::evaluate):
            (PrefixNode::evaluate):
            (UnaryPlusNode::evaluate):
            (NegateNode::evaluate):
            (BitwiseNotNode::evaluate):
            (LogicalNotNode::evaluate):
            (MultNode::evaluate):
            (AddNode::evaluate):
            (ShiftNode::evaluate):
            (RelationalNode::evaluate):
            (EqualNode::evaluate):
            (BitOperNode::evaluate):
            (BinaryLogicalNode::evaluate):
            (ConditionalNode::evaluate):
            (AssignNode::evaluate):
            (CommaNode::evaluate):
            (VarDeclNode::evaluate):
            (ExprStatementNode::execute):
            (IfNode::execute):
            (DoWhileNode::execute):
            (WhileNode::execute):
            (ForNode::execute):
            (ForInNode::execute):
            (ReturnNode::execute):
            (WithNode::execute):
            (CaseClauseNode::evaluate):
            (SwitchNode::execute):
            (ThrowNode::execute):
            * kjs/nodes.h:
            * kjs/types.cpp:
            (ConstReference::ConstReference):
            * kjs/types.h:
            * kjs/value.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1837 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index e860af3..9a5ac53 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,72 @@
+2002-08-15  Maciej Stachowiak  <mjs at apple.com>
+
+	Phase 1 of optimization to stop allocating references through the
+	collector. This step clearly splits evaluating to a reference and
+	evaluating to a value, and moves all of the reference-specific
+	operations from Value to Reference. A special ConstReference class
+	helps out for the one case where you need special reference
+	operations if the result is a reference, and not otherwise.
+
+	Also, Reference now inherits privately from Value, and there is a
+	new ReferenceList class that inherits privately from List, so the
+	uses of Reference and Value are now completely orthogonal. This
+	means that as the next step, their implementations can be
+	completely disentangled.
+	
+	This step has no actual performance impact.
+	
+        * kjs/collector.cpp:
+        (Collector::collect):
+        * kjs/nodes.cpp:
+        (Node::evaluateReference):
+        (ResolveNode::evaluate):
+        (ResolveNode::evaluateReference):
+        (ElementNode::evaluate):
+        (PropertyValueNode::evaluate):
+        (AccessorNode1::evaluate):
+        (AccessorNode1::evaluateReference):
+        (AccessorNode2::evaluate):
+        (AccessorNode2::evaluateReference):
+        (ArgumentListNode::evaluateList):
+        (NewExprNode::evaluate):
+        (FunctionCallNode::evaluate):
+        (PostfixNode::evaluate):
+        (DeleteNode::evaluate):
+        (VoidNode::evaluate):
+        (TypeOfNode::evaluate):
+        (PrefixNode::evaluate):
+        (UnaryPlusNode::evaluate):
+        (NegateNode::evaluate):
+        (BitwiseNotNode::evaluate):
+        (LogicalNotNode::evaluate):
+        (MultNode::evaluate):
+        (AddNode::evaluate):
+        (ShiftNode::evaluate):
+        (RelationalNode::evaluate):
+        (EqualNode::evaluate):
+        (BitOperNode::evaluate):
+        (BinaryLogicalNode::evaluate):
+        (ConditionalNode::evaluate):
+        (AssignNode::evaluate):
+        (CommaNode::evaluate):
+        (VarDeclNode::evaluate):
+        (ExprStatementNode::execute):
+        (IfNode::execute):
+        (DoWhileNode::execute):
+        (WhileNode::execute):
+        (ForNode::execute):
+        (ForInNode::execute):
+        (ReturnNode::execute):
+        (WithNode::execute):
+        (CaseClauseNode::evaluate):
+        (SwitchNode::execute):
+        (ThrowNode::execute):
+        * kjs/nodes.h:
+        * kjs/types.cpp:
+        (ConstReference::ConstReference):
+        * kjs/types.h:
+        * kjs/value.h:
+
 2002-08-15  Darin Adler  <darin at apple.com>
 
 	Tweaks and small bug fixes to Maciej's excellent new fixnum optimization.
diff --git a/JavaScriptCore/ChangeLog-2002-12-03 b/JavaScriptCore/ChangeLog-2002-12-03
index e860af3..9a5ac53 100644
--- a/JavaScriptCore/ChangeLog-2002-12-03
+++ b/JavaScriptCore/ChangeLog-2002-12-03
@@ -1,3 +1,72 @@
+2002-08-15  Maciej Stachowiak  <mjs at apple.com>
+
+	Phase 1 of optimization to stop allocating references through the
+	collector. This step clearly splits evaluating to a reference and
+	evaluating to a value, and moves all of the reference-specific
+	operations from Value to Reference. A special ConstReference class
+	helps out for the one case where you need special reference
+	operations if the result is a reference, and not otherwise.
+
+	Also, Reference now inherits privately from Value, and there is a
+	new ReferenceList class that inherits privately from List, so the
+	uses of Reference and Value are now completely orthogonal. This
+	means that as the next step, their implementations can be
+	completely disentangled.
+	
+	This step has no actual performance impact.
+	
+        * kjs/collector.cpp:
+        (Collector::collect):
+        * kjs/nodes.cpp:
+        (Node::evaluateReference):
+        (ResolveNode::evaluate):
+        (ResolveNode::evaluateReference):
+        (ElementNode::evaluate):
+        (PropertyValueNode::evaluate):
+        (AccessorNode1::evaluate):
+        (AccessorNode1::evaluateReference):
+        (AccessorNode2::evaluate):
+        (AccessorNode2::evaluateReference):
+        (ArgumentListNode::evaluateList):
+        (NewExprNode::evaluate):
+        (FunctionCallNode::evaluate):
+        (PostfixNode::evaluate):
+        (DeleteNode::evaluate):
+        (VoidNode::evaluate):
+        (TypeOfNode::evaluate):
+        (PrefixNode::evaluate):
+        (UnaryPlusNode::evaluate):
+        (NegateNode::evaluate):
+        (BitwiseNotNode::evaluate):
+        (LogicalNotNode::evaluate):
+        (MultNode::evaluate):
+        (AddNode::evaluate):
+        (ShiftNode::evaluate):
+        (RelationalNode::evaluate):
+        (EqualNode::evaluate):
+        (BitOperNode::evaluate):
+        (BinaryLogicalNode::evaluate):
+        (ConditionalNode::evaluate):
+        (AssignNode::evaluate):
+        (CommaNode::evaluate):
+        (VarDeclNode::evaluate):
+        (ExprStatementNode::execute):
+        (IfNode::execute):
+        (DoWhileNode::execute):
+        (WhileNode::execute):
+        (ForNode::execute):
+        (ForInNode::execute):
+        (ReturnNode::execute):
+        (WithNode::execute):
+        (CaseClauseNode::evaluate):
+        (SwitchNode::execute):
+        (ThrowNode::execute):
+        * kjs/nodes.h:
+        * kjs/types.cpp:
+        (ConstReference::ConstReference):
+        * kjs/types.h:
+        * kjs/value.h:
+
 2002-08-15  Darin Adler  <darin at apple.com>
 
 	Tweaks and small bug fixes to Maciej's excellent new fixnum optimization.
diff --git a/JavaScriptCore/ChangeLog-2003-10-25 b/JavaScriptCore/ChangeLog-2003-10-25
index e860af3..9a5ac53 100644
--- a/JavaScriptCore/ChangeLog-2003-10-25
+++ b/JavaScriptCore/ChangeLog-2003-10-25
@@ -1,3 +1,72 @@
+2002-08-15  Maciej Stachowiak  <mjs at apple.com>
+
+	Phase 1 of optimization to stop allocating references through the
+	collector. This step clearly splits evaluating to a reference and
+	evaluating to a value, and moves all of the reference-specific
+	operations from Value to Reference. A special ConstReference class
+	helps out for the one case where you need special reference
+	operations if the result is a reference, and not otherwise.
+
+	Also, Reference now inherits privately from Value, and there is a
+	new ReferenceList class that inherits privately from List, so the
+	uses of Reference and Value are now completely orthogonal. This
+	means that as the next step, their implementations can be
+	completely disentangled.
+	
+	This step has no actual performance impact.
+	
+        * kjs/collector.cpp:
+        (Collector::collect):
+        * kjs/nodes.cpp:
+        (Node::evaluateReference):
+        (ResolveNode::evaluate):
+        (ResolveNode::evaluateReference):
+        (ElementNode::evaluate):
+        (PropertyValueNode::evaluate):
+        (AccessorNode1::evaluate):
+        (AccessorNode1::evaluateReference):
+        (AccessorNode2::evaluate):
+        (AccessorNode2::evaluateReference):
+        (ArgumentListNode::evaluateList):
+        (NewExprNode::evaluate):
+        (FunctionCallNode::evaluate):
+        (PostfixNode::evaluate):
+        (DeleteNode::evaluate):
+        (VoidNode::evaluate):
+        (TypeOfNode::evaluate):
+        (PrefixNode::evaluate):
+        (UnaryPlusNode::evaluate):
+        (NegateNode::evaluate):
+        (BitwiseNotNode::evaluate):
+        (LogicalNotNode::evaluate):
+        (MultNode::evaluate):
+        (AddNode::evaluate):
+        (ShiftNode::evaluate):
+        (RelationalNode::evaluate):
+        (EqualNode::evaluate):
+        (BitOperNode::evaluate):
+        (BinaryLogicalNode::evaluate):
+        (ConditionalNode::evaluate):
+        (AssignNode::evaluate):
+        (CommaNode::evaluate):
+        (VarDeclNode::evaluate):
+        (ExprStatementNode::execute):
+        (IfNode::execute):
+        (DoWhileNode::execute):
+        (WhileNode::execute):
+        (ForNode::execute):
+        (ForInNode::execute):
+        (ReturnNode::execute):
+        (WithNode::execute):
+        (CaseClauseNode::evaluate):
+        (SwitchNode::execute):
+        (ThrowNode::execute):
+        * kjs/nodes.h:
+        * kjs/types.cpp:
+        (ConstReference::ConstReference):
+        * kjs/types.h:
+        * kjs/value.h:
+
 2002-08-15  Darin Adler  <darin at apple.com>
 
 	Tweaks and small bug fixes to Maciej's excellent new fixnum optimization.
diff --git a/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
index 440a847..a79be18 100644
--- a/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
+++ b/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
@@ -218,6 +218,7 @@
 				F68EBB8E0255D4C601FF60F7,
 				F5C290E70284F98E018635CA,
 				F50888B7030BB74C012A967E,
+				F54F0801030CD22001B5C2EB,
 			);
 			isa = PBXHeadersBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -370,6 +371,7 @@
 				F692A8870255597D01FF60F7,
 				F692A8880255597D01FF60F7,
 				F50888B6030BB74C012A967E,
+				F54F0800030CD22001B5C2EB,
 			);
 			isa = PBXGroup;
 			name = Classes;
@@ -450,6 +452,18 @@
 			isa = PBXBuildStyle;
 			name = DeploymentFat;
 		};
+		F54F0800030CD22001B5C2EB = {
+			isa = PBXFileReference;
+			name = reference_list.h;
+			path = kjs/reference_list.h;
+			refType = 4;
+		};
+		F54F0801030CD22001B5C2EB = {
+			fileRef = F54F0800030CD22001B5C2EB;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 		F58C8A1D025BD408018635CA = {
 			buildRules = (
 			);
diff --git a/JavaScriptCore/kjs/nodes.cpp b/JavaScriptCore/kjs/nodes.cpp
index 99e5b9e..5ec144a 100644
--- a/JavaScriptCore/kjs/nodes.cpp
+++ b/JavaScriptCore/kjs/nodes.cpp
@@ -66,6 +66,12 @@ using namespace KJS;
   if (Collector::outOfMemory()) \
     return Undefined(); // will be picked up by KJS_CHECKEXCEPTION
 
+#define KJS_CHECKEXCEPTIONREFERENCE \
+  if (exec->hadException()) \
+    return ConstReference(UndefinedImp::staticUndefined);; \
+  if (Collector::outOfMemory()) \
+    return ConstReference(UndefinedImp::staticUndefined); // will be picked up by KJS_CHECKEXCEPTION
+
 #define KJS_CHECKEXCEPTIONLIST \
   if (exec->hadException()) \
     return List(); \
@@ -95,6 +101,13 @@ Node::~Node()
 #endif
 }
 
+Reference Node::evaluateReference(ExecState *exec)
+{
+  Value v = evaluate(exec);
+  KJS_CHECKEXCEPTIONREFERENCE
+  return ConstReference(v.imp());
+}
+
 #ifdef KJS_DEBUG_MEM
 void Node::finalCheck()
 {
@@ -199,6 +212,11 @@ Value ThisNode::evaluate(ExecState *exec)
 // ECMA 11.1.2 & 10.1.4
 Value ResolveNode::evaluate(ExecState *exec)
 {
+  return evaluateReference(exec).getValue(exec);
+}
+
+Reference ResolveNode::evaluateReference(ExecState *exec)
+{
   const List chain = exec->context().scopeChain();
   ListIterator scope = chain.begin();
 
@@ -220,6 +238,7 @@ Value ResolveNode::evaluate(ExecState *exec)
   return Reference(Null(), ident);
 }
 
+
 // ------------------------------ GroupNode ------------------------------------
 
 void GroupNode::ref()
@@ -303,12 +322,12 @@ Value ElementNode::evaluate(ExecState *exec)
   if (list) {
     array = Object(static_cast<ObjectImp*>(list->evaluate(exec).imp()));
     KJS_CHECKEXCEPTIONVALUE
-    val = node->evaluate(exec).getValue(exec);
+    val = node->evaluate(exec);
     length = array.get(exec,lengthPropertyName).toInt32(exec);
   } else {
     Value newArr = exec->interpreter()->builtinArray().construct(exec,List::empty());
     array = Object(static_cast<ObjectImp*>(newArr.imp()));
-    val = node->evaluate(exec).getValue(exec);
+    val = node->evaluate(exec);
     KJS_CHECKEXCEPTIONVALUE
   }
 
@@ -424,9 +443,8 @@ Value PropertyValueNode::evaluate(ExecState *exec)
   }
   Value n = name->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value a = assign->evaluate(exec);
+  Value v = assign->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v = a.getValue(exec);
 
   obj.put(exec,n.toString(exec), v);
 
@@ -471,12 +489,15 @@ bool AccessorNode1::deref()
 // ECMA 11.2.1a
 Value AccessorNode1::evaluate(ExecState *exec)
 {
-  Value e1 = expr1->evaluate(exec);
-  KJS_CHECKEXCEPTIONVALUE
-  Value v1 = e1.getValue(exec);
-  Value e2 = expr2->evaluate(exec);
-  KJS_CHECKEXCEPTIONVALUE
-  Value v2 = e2.getValue(exec);
+  return evaluateReference(exec).getValue(exec);
+}
+
+Reference AccessorNode1::evaluateReference(ExecState *exec)
+{
+  Value v1 = expr1->evaluate(exec);
+  KJS_CHECKEXCEPTIONREFERENCE
+  Value v2 = expr2->evaluate(exec);
+  KJS_CHECKEXCEPTIONREFERENCE
   Object o = v1.toObject(exec);
   unsigned i;
   if (v2.toUInt32(i))
@@ -485,6 +506,7 @@ Value AccessorNode1::evaluate(ExecState *exec)
   return Reference(o, s.value());
 }
 
+
 // ------------------------------ AccessorNode2 --------------------------------
 
 void AccessorNode2::ref()
@@ -504,9 +526,13 @@ bool AccessorNode2::deref()
 // ECMA 11.2.1b
 Value AccessorNode2::evaluate(ExecState *exec)
 {
-  Value e = expr->evaluate(exec);
-  KJS_CHECKEXCEPTIONVALUE
-  Value v = e.getValue(exec);
+  return evaluateReference(exec).getValue(exec);
+}
+
+Reference AccessorNode2::evaluateReference(ExecState *exec)
+{
+  Value v = expr->evaluate(exec);
+  KJS_CHECKEXCEPTIONREFERENCE
   Object o = v.toObject(exec);
   return Reference(o, ident);
 }
@@ -555,9 +581,8 @@ List ArgumentListNode::evaluateList(ExecState *exec)
     KJS_CHECKEXCEPTIONLIST
   }
 
-  Value e = expr->evaluate(exec);
+  Value v = expr->evaluate(exec);
   KJS_CHECKEXCEPTIONLIST
-  Value v = e.getValue(exec);
 
   l.append(v);
 
@@ -623,9 +648,8 @@ bool NewExprNode::deref()
 
 Value NewExprNode::evaluate(ExecState *exec)
 {
-  Value e = expr->evaluate(exec);
+  Value v = expr->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v = e.getValue(exec);
 
   List argList;
   if (args) {
@@ -670,14 +694,14 @@ bool FunctionCallNode::deref()
 // ECMA 11.2.3
 Value FunctionCallNode::evaluate(ExecState *exec)
 {
-  Value e = expr->evaluate(exec);
+  Reference ref = expr->evaluateReference(exec);
   KJS_CHECKEXCEPTIONVALUE
 
   List argList = args->evaluateList(exec);
 
   KJS_CHECKEXCEPTIONVALUE
 
-  Value v = e.getValue(exec);
+  Value v = ref.getValue(exec);
 
   if (v.type() != ObjectType) {
 #ifndef NDEBUG
@@ -706,8 +730,9 @@ Value FunctionCallNode::evaluate(ExecState *exec)
 #endif
 
   Value thisVal;
-  if (e.type() == ReferenceType)
-    thisVal = e.getBase(exec);
+  // XXX - should check for constant reference
+  if (ref.isMutable())
+    thisVal = ref.getBase(exec);
   else
     thisVal = Null();
 
@@ -755,15 +780,15 @@ bool PostfixNode::deref()
 // ECMA 11.3
 Value PostfixNode::evaluate(ExecState *exec)
 {
-  Value e = expr->evaluate(exec);
+  Reference ref = expr->evaluateReference(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v = e.getValue(exec);
+  Value v = ref.getValue(exec);
   Number n = v.toNumber(exec);
 
   double newValue = (oper == OpPlusPlus) ? n.value() + 1 : n.value() - 1;
   Value n2 = Number(newValue);
 
-  e.putValue(exec,n2);
+  ref.putValue(exec,n2);
 
   return n;
 }
@@ -787,9 +812,9 @@ bool DeleteNode::deref()
 // ECMA 11.4.1
 Value DeleteNode::evaluate(ExecState *exec)
 {
-  Value e = expr->evaluate(exec);
+  Reference ref = expr->evaluateReference(exec);
   KJS_CHECKEXCEPTIONVALUE
-  return Boolean(e.deleteValue(exec));
+  return Boolean(ref.deleteValue(exec));
 }
 
 // ------------------------------ VoidNode -------------------------------------
@@ -813,7 +838,6 @@ Value VoidNode::evaluate(ExecState *exec)
 {
   Value dummy1 = expr->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value dummy2 = dummy1.getValue(exec);
 
   return Undefined();
 }
@@ -838,14 +862,15 @@ bool TypeOfNode::deref()
 Value TypeOfNode::evaluate(ExecState *exec)
 {
   const char *s = 0L;
-  Value e = expr->evaluate(exec);
+  Reference ref = expr->evaluateReference(exec);
   KJS_CHECKEXCEPTIONVALUE
-  if (e.type() == ReferenceType) {
-    Value b = e.getBase(exec);
+  // XXX - Really should check if this is a constant reference
+  if (ref.isMutable()) {
+    Value b = ref.getBase(exec);
     if (b.type() == NullType)
       return String("undefined");
   }
-  Value v = e.getValue(exec);
+  Value v = ref.getValue(exec);
   switch (v.type())
     {
     case UndefinedType:
@@ -893,15 +918,15 @@ bool PrefixNode::deref()
 // ECMA 11.4.4 and 11.4.5
 Value PrefixNode::evaluate(ExecState *exec)
 {
-  Value e = expr->evaluate(exec);
+  Reference ref = expr->evaluateReference(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v = e.getValue(exec);
+  Value v = ref.getValue(exec);
   Number n = v.toNumber(exec);
 
   double newValue = (oper == OpPlusPlus) ? n.value() + 1 : n.value() - 1;
   Value n2 = Number(newValue);
 
-  e.putValue(exec,n2);
+  ref.putValue(exec,n2);
 
   return n2;
 }
@@ -925,9 +950,8 @@ bool UnaryPlusNode::deref()
 // ECMA 11.4.6
 Value UnaryPlusNode::evaluate(ExecState *exec)
 {
-  Value e = expr->evaluate(exec);
+  Value v = expr->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v = e.getValue(exec);
 
   return Number(v.toNumber(exec)); /* TODO: optimize */
 }
@@ -951,9 +975,8 @@ bool NegateNode::deref()
 // ECMA 11.4.7
 Value NegateNode::evaluate(ExecState *exec)
 {
-  Value e = expr->evaluate(exec);
+  Value v = expr->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v = e.getValue(exec);
   Number n = v.toNumber(exec);
 
   double d = -n.value();
@@ -980,9 +1003,8 @@ bool BitwiseNotNode::deref()
 // ECMA 11.4.8
 Value BitwiseNotNode::evaluate(ExecState *exec)
 {
-  Value e = expr->evaluate(exec);
+  Value v = expr->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v = e.getValue(exec);
   int i32 = v.toInt32(exec);
 
   return Number(~i32);
@@ -1007,9 +1029,8 @@ bool LogicalNotNode::deref()
 // ECMA 11.4.9
 Value LogicalNotNode::evaluate(ExecState *exec)
 {
-  Value e = expr->evaluate(exec);
+  Value v = expr->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v = e.getValue(exec);
   bool b = v.toBoolean(exec);
 
   return Boolean(!b);
@@ -1038,13 +1059,11 @@ bool MultNode::deref()
 // ECMA 11.5
 Value MultNode::evaluate(ExecState *exec)
 {
-  Value t1 = term1->evaluate(exec);
+  Value v1 = term1->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v1 = t1.getValue(exec);
 
-  Value t2 = term2->evaluate(exec);
+  Value v2 = term2->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v2 = t2.getValue(exec);
 
   return mult(exec,v1, v2, oper);
 }
@@ -1072,13 +1091,11 @@ bool AddNode::deref()
 // ECMA 11.6
 Value AddNode::evaluate(ExecState *exec)
 {
-  Value t1 = term1->evaluate(exec);
+  Value v1 = term1->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v1 = t1.getValue(exec);
 
-  Value t2 = term2->evaluate(exec);
+  Value v2 = term2->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v2 = t2.getValue(exec);
 
   return add(exec,v1, v2, oper);
 }
@@ -1106,12 +1123,10 @@ bool ShiftNode::deref()
 // ECMA 11.7
 Value ShiftNode::evaluate(ExecState *exec)
 {
-  Value t1 = term1->evaluate(exec);
+  Value v1 = term1->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v1 = t1.getValue(exec);
-  Value t2 = term2->evaluate(exec);
+  Value v2 = term2->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v2 = t2.getValue(exec);
   unsigned int i2 = v2.toUInt32(exec);
   i2 &= 0x1f;
 
@@ -1157,12 +1172,10 @@ bool RelationalNode::deref()
 // ECMA 11.8
 Value RelationalNode::evaluate(ExecState *exec)
 {
-  Value e1 = expr1->evaluate(exec);
+  Value v1 = expr1->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v1 = e1.getValue(exec);
-  Value e2 = expr2->evaluate(exec);
+  Value v2 = expr2->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v2 = e2.getValue(exec);
 
   bool b;
   if (oper == OpLess || oper == OpGreaterEq) {
@@ -1228,12 +1241,10 @@ bool EqualNode::deref()
 // ECMA 11.9
 Value EqualNode::evaluate(ExecState *exec)
 {
-  Value e1 = expr1->evaluate(exec);
+  Value v1 = expr1->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value e2 = expr2->evaluate(exec);
+  Value v2 = expr2->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v1 = e1.getValue(exec);
-  Value v2 = e2.getValue(exec);
 
   bool result;
   if (oper == OpEqEq || oper == OpNotEq) {
@@ -1271,12 +1282,10 @@ bool BitOperNode::deref()
 // ECMA 11.10
 Value BitOperNode::evaluate(ExecState *exec)
 {
-  Value e1 = expr1->evaluate(exec);
+  Value v1 = expr1->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v1 = e1.getValue(exec);
-  Value e2 = expr2->evaluate(exec);
+  Value v2 = expr2->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v2 = e2.getValue(exec);
   int i1 = v1.toInt32(exec);
   int i2 = v2.toInt32(exec);
   int result;
@@ -1313,16 +1322,14 @@ bool BinaryLogicalNode::deref()
 // ECMA 11.11
 Value BinaryLogicalNode::evaluate(ExecState *exec)
 {
-  Value e1 = expr1->evaluate(exec);
+  Value v1 = expr1->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v1 = e1.getValue(exec);
   bool b1 = v1.toBoolean(exec);
   if ((!b1 && oper == OpAnd) || (b1 && oper == OpOr))
     return v1;
 
-  Value e2 = expr2->evaluate(exec);
+  Value v2 = expr2->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v2 = e2.getValue(exec);
 
   return v2;
 }
@@ -1354,18 +1361,17 @@ bool ConditionalNode::deref()
 // ECMA 11.12
 Value ConditionalNode::evaluate(ExecState *exec)
 {
-  Value e = logical->evaluate(exec);
+  Value v = logical->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v = e.getValue(exec);
   bool b = v.toBoolean(exec);
 
   if (b)
-    e = expr1->evaluate(exec);
+    v = expr1->evaluate(exec);
   else
-    e = expr2->evaluate(exec);
+    v = expr2->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
 
-  return e.getValue(exec);
+  return v;
 }
 
 // ------------------------------ AssignNode -----------------------------------
@@ -1391,21 +1397,16 @@ bool AssignNode::deref()
 // ECMA 11.13
 Value AssignNode::evaluate(ExecState *exec)
 {
-
-  Value l, e, v;
+  Reference l = left->evaluateReference(exec);
+  KJS_CHECKEXCEPTIONVALUE
+  Value e, v;
   if (oper == OpEqual) {
-    l = left->evaluate(exec);
-    KJS_CHECKEXCEPTIONVALUE
-    e = expr->evaluate(exec);
+    v = expr->evaluate(exec);
     KJS_CHECKEXCEPTIONVALUE
-    v = e.getValue(exec);
   } else {
-    l = left->evaluate(exec);
-    KJS_CHECKEXCEPTIONVALUE
     Value v1 = l.getValue(exec);
-    e = expr->evaluate(exec);
+    Value v2 = expr->evaluate(exec);
     KJS_CHECKEXCEPTIONVALUE
-    Value v2 = e.getValue(exec);
     int i1 = v1.toInt32(exec);
     int i2 = v2.toInt32(exec);
     unsigned int ui;
@@ -1481,13 +1482,12 @@ bool CommaNode::deref()
 // ECMA 11.14
 Value CommaNode::evaluate(ExecState *exec)
 {
-  Value e = expr1->evaluate(exec);
+  Value dummy = expr1->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value dummy = e.getValue(exec); // ignore return value
-  e = expr2->evaluate(exec);
+  Value v = expr2->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
 
-  return e.getValue(exec);
+  return v;
 }
 
 // ------------------------------ StatListNode ---------------------------------
@@ -1599,11 +1599,10 @@ Value VarDeclNode::evaluate(ExecState *exec)
 {
   Object variable = Object::dynamicCast(exec->context().variableObject());
 
-  Value val, tmp;
+  Value val;
   if (init) {
-      tmp = init->evaluate(exec);
+      val = init->evaluate(exec);
       KJS_CHECKEXCEPTIONVALUE
-      val = tmp.getValue(exec);
   } else {
       if ( variable.hasProperty(exec, ident ) ) // already declared ?
           return Value();
@@ -1762,9 +1761,8 @@ Completion ExprStatementNode::execute(ExecState *exec)
 {
   KJS_BREAKPOINT;
 
-  Value e = expr->evaluate(exec);
+  Value v = expr->evaluate(exec);
   KJS_CHECKEXCEPTION
-  Value v = e.getValue(exec);
 
   return Completion(Normal, v);
 }
@@ -1798,9 +1796,8 @@ Completion IfNode::execute(ExecState *exec)
 {
   KJS_BREAKPOINT;
 
-  Value e = expr->evaluate(exec);
+  Value v = expr->evaluate(exec);
   KJS_CHECKEXCEPTION
-  Value v = e.getValue(exec);
   bool b = v.toBoolean(exec);
 
   // if ... then
@@ -1863,9 +1860,8 @@ Completion DoWhileNode::execute(ExecState *exec)
       if (c.complType() != Normal)
         return c;
     }
-    be = expr->evaluate(exec);
+    bv = expr->evaluate(exec);
     KJS_CHECKEXCEPTION
-    bv = be.getValue(exec);
   } while (bv.toBoolean(exec));
 
   return Completion(Normal, value);
@@ -1907,9 +1903,8 @@ Completion WhileNode::execute(ExecState *exec)
   Value value;
 
   while (1) {
-    be = expr->evaluate(exec);
+    bv = expr->evaluate(exec);
     KJS_CHECKEXCEPTION
-    bv = be.getValue(exec);
     b = bv.toBoolean(exec);
 
     // bail out on error
@@ -1971,15 +1966,13 @@ Completion ForNode::execute(ExecState *exec)
   bool b;
 
   if (expr1) {
-    e = expr1->evaluate(exec);
+    v = expr1->evaluate(exec);
     KJS_CHECKEXCEPTION
-    v = e.getValue(exec);
   }
   while (1) {
     if (expr2) {
-      e = expr2->evaluate(exec);
+      v = expr2->evaluate(exec);
       KJS_CHECKEXCEPTION
-      v = e.getValue(exec);
       b = v.toBoolean(exec);
       if (b == false)
 	return Completion(Normal, cval);
@@ -1997,9 +1990,8 @@ Completion ForNode::execute(ExecState *exec)
       return c;
     }
     if (expr3) {
-      e = expr3->evaluate(exec);
+      v = expr3->evaluate(exec);
       KJS_CHECKEXCEPTION
-      v = e.getValue(exec);
     }
   }
 }
@@ -2063,7 +2055,7 @@ Completion ForInNode::execute(ExecState *exec)
   Value e, retval;
   Object v;
   Completion c;
-  List propList;
+  ReferenceList propList;
 
   if ( varDecl ) {
     varDecl->evaluate(exec);
@@ -2072,10 +2064,10 @@ Completion ForInNode::execute(ExecState *exec)
 
   e = expr->evaluate(exec);
   KJS_CHECKEXCEPTION
-  v = e.getValue(exec).toObject(exec);
+  v = e.toObject(exec);
   propList = v.propList(exec);
 
-  ListIterator propIt = propList.begin();
+  ReferenceListIterator propIt = propList.begin();
 
   while (propIt != propList.end()) {
     UString name = propIt->dispatchGetPropertyName(exec);
@@ -2084,9 +2076,9 @@ Completion ForInNode::execute(ExecState *exec)
       continue;
     }
 
-    e = lexpr->evaluate(exec);
+    Reference ref = lexpr->evaluateReference(exec);
     KJS_CHECKEXCEPTION
-    e.putValue(exec,String(name));
+    ref.putValue(exec,String(name));
 
     c = statement->execute(exec);
     if (c.isValueCompletion())
@@ -2166,9 +2158,8 @@ Completion ReturnNode::execute(ExecState *exec)
   if (!value)
     return Completion(ReturnValue, Undefined());
 
-  Value e = value->evaluate(exec);
+  Value v = value->evaluate(exec);
   KJS_CHECKEXCEPTION
-  Value v = e.getValue(exec);
 
   return Completion(ReturnValue, v);
 }
@@ -2198,9 +2189,8 @@ Completion WithNode::execute(ExecState *exec)
 {
   KJS_BREAKPOINT;
 
-  Value e = expr->evaluate(exec);
+  Value v = expr->evaluate(exec);
   KJS_CHECKEXCEPTION
-  Value v = e.getValue(exec);
   Object o = v.toObject(exec);
   KJS_CHECKEXCEPTION
   exec->context().imp()->pushScope(o);
@@ -2238,9 +2228,8 @@ bool CaseClauseNode::deref()
 // ECMA 12.11
 Value CaseClauseNode::evaluate(ExecState *exec)
 {
-  Value e = expr->evaluate(exec);
+  Value v = expr->evaluate(exec);
   KJS_CHECKEXCEPTIONVALUE
-  Value v = e.getValue(exec);
 
   return v;
 }
@@ -2434,9 +2423,8 @@ Completion SwitchNode::execute(ExecState *exec)
 {
   KJS_BREAKPOINT;
 
-  Value e = expr->evaluate(exec);
+  Value v = expr->evaluate(exec);
   KJS_CHECKEXCEPTION
-  Value v = e.getValue(exec);
   Completion res = block->evalBlock(exec,v);
 
   if ((res.complType() == Break) && ls.contains(res.target()))
@@ -2510,9 +2498,8 @@ Completion ThrowNode::execute(ExecState *exec)
 {
   KJS_BREAKPOINT;
 
-  Value e = expr->evaluate(exec);
+  Value v = expr->evaluate(exec);
   KJS_CHECKEXCEPTION
-  Value v = e.getValue(exec);
 
   // bail out on error
   KJS_CHECKEXCEPTION
diff --git a/JavaScriptCore/kjs/nodes.h b/JavaScriptCore/kjs/nodes.h
index 482425f..60dffe4 100644
--- a/JavaScriptCore/kjs/nodes.h
+++ b/JavaScriptCore/kjs/nodes.h
@@ -75,6 +75,7 @@ namespace KJS {
     Node();
     virtual ~Node();
     virtual Value evaluate(ExecState *exec) = 0;
+    virtual Reference evaluateReference(ExecState *exec);
     UString toString() const;
     virtual void streamTo(SourceStream &s) const = 0;
     virtual void processVarDecls(ExecState */*exec*/) {}
@@ -185,6 +186,7 @@ namespace KJS {
   public:
     ResolveNode(const UString *s) : ident(*s) { }
     Value evaluate(ExecState *exec);
+    virtual Reference evaluateReference(ExecState *exec);
     virtual void streamTo(SourceStream &s) const;
   private:
     UString ident;
@@ -284,6 +286,7 @@ namespace KJS {
     virtual void ref();
     virtual bool deref();
     Value evaluate(ExecState *exec);
+    virtual Reference evaluateReference(ExecState *exec);
     virtual void streamTo(SourceStream &s) const;
   private:
     Node *expr1;
@@ -296,6 +299,7 @@ namespace KJS {
     virtual void ref();
     virtual bool deref();
     Value evaluate(ExecState *exec);
+    virtual Reference evaluateReference(ExecState *exec);
     virtual void streamTo(SourceStream &s) const;
   private:
     Node *expr;
diff --git a/JavaScriptCore/kjs/object.cpp b/JavaScriptCore/kjs/object.cpp
index bd79c8d..f9fb7de 100644
--- a/JavaScriptCore/kjs/object.cpp
+++ b/JavaScriptCore/kjs/object.cpp
@@ -26,6 +26,7 @@
 #include "types.h"
 #include "interpreter.h"
 #include "lookup.h"
+#include "reference_list.h"
 
 #include <assert.h>
 #include <math.h>
@@ -403,9 +404,9 @@ void ObjectImp::setScope(const List &s)
   _scope = static_cast<ListImp*>(s.imp());
 }
 
-List ObjectImp::propList(ExecState *exec, bool recursive)
+ReferenceList ObjectImp::propList(ExecState *exec, bool recursive)
 {
-  List list;
+  ReferenceList list;
   if (_proto && _proto->dispatchType() == ObjectType && recursive)
     list = static_cast<ObjectImp*>(_proto)->propList(exec,recursive);
 
diff --git a/JavaScriptCore/kjs/object.h b/JavaScriptCore/kjs/object.h
index 92a84b6..86cf4a3 100644
--- a/JavaScriptCore/kjs/object.h
+++ b/JavaScriptCore/kjs/object.h
@@ -33,6 +33,7 @@
 
 #include "value.h"
 #include "types.h"
+#include "reference_list.h"
 
 namespace KJS {
 
@@ -41,6 +42,7 @@ namespace KJS {
   class HashTable;
   class HashEntry;
   class ListImp;
+  class ReferenceList;
 
   // ECMA 262-3 8.6.1
   // Attributes (only applicable to the Object type)
@@ -330,7 +332,7 @@ namespace KJS {
      * included in the list.
      * @return A List of References to properties of the object.
      **/
-    List propList(ExecState *exec, bool recursive = true);
+    ReferenceList propList(ExecState *exec, bool recursive = true);
 
     /**
      * Returns the internal value of the object. This is used for objects such
@@ -560,7 +562,7 @@ namespace KJS {
     const List scope() const;
     void setScope(const List &s);
 
-    List propList(ExecState *exec, bool recursive = true);
+    ReferenceList propList(ExecState *exec, bool recursive = true);
 
     Value internalValue() const;
     void setInternalValue(const Value &v);
@@ -688,7 +690,7 @@ namespace KJS {
   inline void Object::setScope(const List &s)
     { imp()->setScope(s); }
 
-  inline List Object::propList(ExecState *exec, bool recursive)
+  inline ReferenceList Object::propList(ExecState *exec, bool recursive)
     { return imp()->propList(exec,recursive); }
 
   inline Value Object::internalValue() const
diff --git a/JavaScriptCore/kjs/types.cpp b/JavaScriptCore/kjs/types.cpp
index ece3cdd..4b69202 100644
--- a/JavaScriptCore/kjs/types.cpp
+++ b/JavaScriptCore/kjs/types.cpp
@@ -68,6 +68,11 @@ Reference Reference::dynamicCast(const Value &v)
   return static_cast<ReferenceImp*>(v.imp());
 }
 
+ConstReference::ConstReference(ValueImp *v) : 
+  Reference((ReferenceImp *)v) 
+{
+}
+
 // ------------------------------ ListIterator ---------------------------------
 
 //d  dont add   ListIterator();
diff --git a/JavaScriptCore/kjs/types.h b/JavaScriptCore/kjs/types.h
index 3d01e70..2357d82 100644
--- a/JavaScriptCore/kjs/types.h
+++ b/JavaScriptCore/kjs/types.h
@@ -30,7 +30,11 @@
 
 namespace KJS {
 
-  class Reference : public Value {
+  class ReferenceList;
+
+  class Reference : private Value {
+    friend class ReferenceList;
+    friend class ReferenceListIterator;
   public:
     Reference(const Object& b, const UString& p);
     Reference(const Object& b, unsigned p);
@@ -48,6 +52,39 @@ namespace KJS {
      * @return The value converted to an Reference
      */
     static Reference dynamicCast(const Value &v);
+
+    /**
+     * Performs the GetBase type conversion operation on this value (ECMA 8.7)
+     *
+     * Since references are supposed to have an Object or null as their base,
+     * this method is guaranteed to return either Null() or an Object value.
+     */
+    Value getBase(ExecState *exec) const { return rep->dispatchGetBase(exec); }
+
+    /**
+     * Performs the GetPropertyName type conversion operation on this value
+     * (ECMA 8.7)
+     */
+    UString getPropertyName(ExecState *exec) const { return rep->dispatchGetPropertyName(exec); }
+
+    /**
+     * Performs the GetValue type conversion operation on this value
+     * (ECMA 8.7.1)
+     */
+    Value getValue(ExecState *exec) const { return rep->dispatchGetValue(exec); }
+
+    /**
+     * Performs the PutValue type conversion operation on this value
+     * (ECMA 8.7.1)
+     */
+    void putValue(ExecState *exec, const Value &w) { rep->dispatchPutValue(exec, w); }
+    bool deleteValue(ExecState *exec) { return rep->dispatchDeleteValue(exec); }
+    bool isMutable() { return type() == ReferenceType; }
+  };
+
+  class ConstReference : public Reference {
+  public:
+    ConstReference(ValueImp *v);
   };
 
   class List;
diff --git a/JavaScriptCore/kjs/value.h b/JavaScriptCore/kjs/value.h
index 42bbe61..d90149a 100644
--- a/JavaScriptCore/kjs/value.h
+++ b/JavaScriptCore/kjs/value.h
@@ -259,33 +259,6 @@ namespace KJS {
     Object toObject(ExecState *exec) const;
 
     /**
-     * Performs the GetBase type conversion operation on this value (ECMA 8.7)
-     *
-     * Since references are supposed to have an Object or null as their base,
-     * this method is guaranteed to return either Null() or an Object value.
-     */
-    Value getBase(ExecState *exec) const { return rep->dispatchGetBase(exec); }
-
-    /**
-     * Performs the GetPropertyName type conversion operation on this value
-     * (ECMA 8.7)
-     */
-    UString getPropertyName(ExecState *exec) const { return rep->dispatchGetPropertyName(exec); }
-
-    /**
-     * Performs the GetValue type conversion operation on this value
-     * (ECMA 8.7.1)
-     */
-    Value getValue(ExecState *exec) const { return rep->dispatchGetValue(exec); }
-
-    /**
-     * Performs the PutValue type conversion operation on this value
-     * (ECMA 8.7.1)
-     */
-    void putValue(ExecState *exec, const Value &w) { rep->dispatchPutValue(exec, w); }
-    bool deleteValue(ExecState *exec) { return rep->dispatchDeleteValue(exec); }
-
-    /**
      * Checks if we can do a lossless conversion to UInt32.
      */
     bool toUInt32(unsigned& i) const { return rep->dispatchToUInt32(i); }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list