Reviewers: Michael Starzinger,
Message:
PTAL.
Description:
Fix overwriting order of object literal properties for MATERIALIZED_LITERALs
Please review this at https://codereview.chromium.org/22982005/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/ast.cc
M test/mjsunit/object-literal-overwrite.js
Index: src/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index
2077f87d74153ba31e6fc94250a89508c3aeddda..23b680d47f4805dbb2b18a7a4cf3f8c82c6bb485
100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -273,7 +273,8 @@ void ObjectLiteral::CalculateEmitStore(Zone* zone) {
uint32_t hash = literal->Hash();
// If the key of a computed property is in the table, do not emit
// a store for the property later.
- if (property->kind() == ObjectLiteral::Property::COMPUTED &&
+ if ((property->kind() == ObjectLiteral::Property::MATERIALIZED_LITERAL
||
+ property->kind() == ObjectLiteral::Property::COMPUTED) &&
table.Lookup(literal, hash, false, allocator) != NULL) {
property->set_emit_store(false);
} else {
Index: test/mjsunit/object-literal-overwrite.js
diff --git a/test/mjsunit/object-literal-overwrite.js
b/test/mjsunit/object-literal-overwrite.js
index
5a3584df8ae853da36577b19376ba51692e0e2eb..4d19d35d12bd68c214c57bf29bda471f1864a48a
100644
--- a/test/mjsunit/object-literal-overwrite.js
+++ b/test/mjsunit/object-literal-overwrite.js
@@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// Flags: --allow-natives-syntax
+
// Check that constants and computed properties are overwriting each other
// correctly, i.e., the last initializer for any name is stored in the
object.
@@ -49,7 +51,7 @@ var foo3 = {
var foo4 = {
bar: function(b){},
- bar: 7,
+ bar: 4,
bar: function(){return 7},
};
@@ -68,6 +70,14 @@ var foo7 = {
15: 7
}
+function foo8(i) {
+ var obj = {
+ x: {a: i},
+ x: 7
+ };
+ return obj.x;
+};
+
assertEquals(7, foo1.bar);
assertEquals(7, foo2.bar);
assertEquals(7, foo3.bar);
@@ -76,6 +86,12 @@ assertEquals(7, foo5[13]);
assertEquals(7, foo6[14.31]);
assertEquals(7, foo7[15]);
+assertEquals(7, foo8(1));
+assertEquals(7, foo8(1));
+%OptimizeFunctionOnNextCall(foo8);
+assertEquals(7, foo8(1));
+
+
// Test for the classic code generator.
function fun(x) {
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.