PropertyListNode::emitNode duplicates the code to put a constant property
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Jan 2015 18:07:16 +0000 (18:07 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Jan 2015 18:07:16 +0000 (18:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140761

Reviewed by Geoffrey Garen.

Extracted PropertyListNode::emitPutConstantProperty to share the code.

Also made PropertyListNode::emitBytecode private since nobody is calling this function directly.

* bytecompiler/NodesCodegen.cpp:
(JSC::PropertyListNode::emitBytecode):
(JSC::PropertyListNode::emitPutConstantProperty): Added.
* parser/Nodes.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178918 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
Source/JavaScriptCore/parser/Nodes.h

index 137115a866c177e523426fea59491e2d77169cbf..16573036954b7307f918f934f5311174c44f8610 100644 (file)
@@ -1,3 +1,19 @@
+2015-01-22  Ryosuke Niwa  <rniwa@webkit.org>
+
+        PropertyListNode::emitNode duplicates the code to put a constant property
+        https://bugs.webkit.org/show_bug.cgi?id=140761
+
+        Reviewed by Geoffrey Garen.
+
+        Extracted PropertyListNode::emitPutConstantProperty to share the code.
+
+        Also made PropertyListNode::emitBytecode private since nobody is calling this function directly.
+
+        * bytecompiler/NodesCodegen.cpp:
+        (JSC::PropertyListNode::emitBytecode):
+        (JSC::PropertyListNode::emitPutConstantProperty): Added.
+        * parser/Nodes.h:
+
 2015-01-22  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         put_by_val_direct need to check the property is index or not for using putDirect / putDirectIndex
index 19c927725cbab47c19eb0b97b5347856174250da..b9aed8ad8228c3d26b852c13136fe80d9b69aecc 100644 (file)
@@ -291,14 +291,8 @@ RegisterID* PropertyListNode::emitBytecode(BytecodeGenerator& generator, Registe
     
     // Fast case: this loop just handles regular value properties.
     PropertyListNode* p = this;
-    for (; p && p->m_node->m_type == PropertyNode::Constant; p = p->m_next) {
-        if (p->m_node->m_name) {
-            generator.emitDirectPutById(newObj.get(), *p->m_node->name(), generator.emitNode(p->m_node->m_assign));
-            continue;
-        }
-        RefPtr<RegisterID> propertyName = generator.emitNode(p->m_node->m_expression);
-        generator.emitDirectPutByVal(newObj.get(), propertyName.get(), generator.emitNode(p->m_node->m_assign));
-    }
+    for (; p && p->m_node->m_type == PropertyNode::Constant; p = p->m_next)
+        emitPutConstantProperty(generator, newObj.get(), *p->m_node);
 
     // Were there any get/set properties?
     if (p) {
@@ -324,15 +318,10 @@ RegisterID* PropertyListNode::emitBytecode(BytecodeGenerator& generator, Registe
 
             // Handle regular values.
             if (node->m_type == PropertyNode::Constant) {
-                if (node->name()) {
-                    generator.emitDirectPutById(newObj.get(), *node->name(), generator.emitNode(node->m_assign));
-                    continue;
-                }
-                RefPtr<RegisterID> propertyName = generator.emitNode(p->m_node->m_expression);
-                generator.emitDirectPutByVal(newObj.get(), propertyName.get(), generator.emitNode(p->m_node->m_assign));
+                emitPutConstantProperty(generator, newObj.get(), *node);
                 continue;
             }
-            
+
             RegisterID* value = generator.emitNode(node->m_assign);
 
             // This is a get/set property, find its entry in the map.
@@ -377,6 +366,16 @@ RegisterID* PropertyListNode::emitBytecode(BytecodeGenerator& generator, Registe
     return generator.moveToDestinationIfNeeded(dst, newObj.get());
 }
 
+void PropertyListNode::emitPutConstantProperty(BytecodeGenerator& generator, RegisterID* newObj, PropertyNode& node)
+{
+    if (node.name()) {
+        generator.emitDirectPutById(newObj, *node.name(), generator.emitNode(node.m_assign));
+        return;
+    }
+    RefPtr<RegisterID> propertyName = generator.emitNode(node.m_expression);
+    generator.emitDirectPutByVal(newObj, propertyName.get(), generator.emitNode(node.m_assign));
+}
+
 // ------------------------------ BracketAccessorNode --------------------------------
 
 RegisterID* BracketAccessorNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
index 6f55b42fa5cce1207e880bead9b0da29614de69b..f9f2604c07f27d68fef46a55052adf5273fb9840 100644 (file)
@@ -504,9 +504,10 @@ namespace JSC {
         PropertyListNode(const JSTokenLocation&, PropertyNode*);
         PropertyListNode(const JSTokenLocation&, PropertyNode*, PropertyListNode*);
 
+    private:
         virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
+        void emitPutConstantProperty(BytecodeGenerator&, RegisterID*, PropertyNode&);
 
-    private:
         PropertyNode* m_node;
         PropertyListNode* m_next;
     };