Keeping an object in fast properties mode

57 views
Skip to first unread message

dtre...@gmail.com

unread,
Jul 3, 2014, 9:23:58 AM7/3/14
to v8-u...@googlegroups.com
Is it possible to keep an object in "fast properties mode" (versus "hash table mode", as described here: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#5-for-in ) when only assigning property values for properties that exist in the object's prototype?

Here is a small test case:


function applyMask(inputObj, mask) {
    var outputObj = Object.create(mask),
        maskKeys = Object.keys(mask);
    for (var j = 0; j < maskKeys.length; ++j) {
        var key = maskKeys[j];
        outputObj[key] = inputObj[key];
    }
    return outputObj;
}

var testMask = {
    "key0": null,
    "key1": null,
    "key2": null,
    "key3": null,
    "key4": null,
    "key5": null,
    "key6": null,
    "key7": null,
    "key8": null,
    "key9": null,
    "key10": null,
    "key11": null,
    "key12": null,
    "key13": null,
    "key14": null

    ,"key15": null
    ,"key16": null
    ,"key17": null
    ,"key18": null
    ,"key19": null
};
var testObj = {
    "otherProp": "blah blah blah",
    "key0": "value",
    "key1": "value"
};
var outputObj = applyMask(testObj, testMask);
alert(%HasFastProperties(outputObj));


If I comment out lines "key15" through "key19" within the definition of testMask, then outputObj is in fast properties mode, but as is, the alert dialog says false because outputObj is in hash table mode.

I am using Chrome 35.0.1916.153 with v8 3.25.28.18.
Reply all
Reply to author
Forward
0 new messages