Changeset 172401 in webkit for trunk/Source/JavaScriptCore/tests


Ignore:
Timestamp:
Aug 11, 2014, 11:59:44 AM (11 years ago)
Author:
[email protected]
Message:

for-in optimization should also make sure the base matches the object being iterated
https://bugs.webkit.org/show_bug.cgi?id=135782

Reviewed by Geoffrey Garen.

If we access a different base object with the same index, we shouldn't try to randomly
load from that object's backing store.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitGetByVal):
(JSC::BytecodeGenerator::pushIndexedForInScope):
(JSC::BytecodeGenerator::pushStructureForInScope):

  • bytecompiler/BytecodeGenerator.h:

(JSC::ForInContext::ForInContext):
(JSC::ForInContext::base):
(JSC::StructureForInContext::StructureForInContext):
(JSC::IndexedForInContext::IndexedForInContext):

  • bytecompiler/NodesCodegen.cpp:

(JSC::ForInNode::emitMultiLoopBytecode):

  • tests/stress/for-in-tests.js:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/tests/stress/for-in-tests.js

    r172176 r172401  
    7676    foo(null);
    7777})();
     78(function() {
     79    var foo = function(a, b) {
     80        for (var p in a) {
     81            var f1 = a[p];
     82            var f2 = b[p];
     83            if (f1 === f2)
     84                continue;
     85            a[p] = b[p];
     86        }
     87    };
     88    noInline(foo);
     89    for (var i = 0; i < 10000; ++i) {
     90        var o1 = {};
     91        var o2 = {};
     92        o2.x = 42;
     93        o2.y = 53;
     94        foo(o1, o2);
     95        if (o1.x !== o2.x)
     96            throw new Error("bad result: " + o1.x + "!==" + o2.x);
     97        if (o1.y !== o2.y)
     98            throw new Error("bad result: " + o1.y + "!==" + o2.y);
     99    }
     100})();
Note: See TracChangeset for help on using the changeset viewer.