Assignment gets optimized away

26 views
Skip to first unread message

Alexander Praetorius

unread,
Apr 18, 2015, 9:54:12 PM4/18/15
to v8-u...@googlegroups.com
/******************************************************************************
    Sloppy description

      - No problem in ['node 0.12', 'firefox']
      - Fails in ['iojs', 'new chrome']

******************************************************************************/
// PREPARE
var defaultKeys = { '0': '', '1': '', '2': '', '3': '' };
var ROUNDS = 3;

// RUN
for (var idx=0; idx<ROUNDS; idx++) {
    
  // BUG: assignment gets optimized away for ROUNDS > 2
  var keys = { '0': '', '1': '', '2': '', '3': '' };

  // ASSERT
  assertDeepEqual(keys, defaultKeys);

  for(var i=0; i<3; i++) {
    keys[i] = 'foobar';
  }
}


/******************************************************************************
  ASSERT deep equal
******************************************************************************/
function assertDeepEqual (keys, defaultKeys, msg) {
  if (keys[0] === defaultKeys[0] &&
      keys[1] === defaultKeys[1] &&
      keys[2] === defaultKeys[2] &&
      keys[3] === defaultKeys[3]) {
  } else {
    keys        = JSON.stringify(keys,null,2);
    defaultKeys = JSON.stringify(defaultKeys,null,2);
    console.debug(keys+' === '+defaultKeys);
  }
}

Jakob Kummerow

unread,
Apr 19, 2015, 6:59:50 AM4/19/15
to v8-u...@googlegroups.com
This is crbug.com/466993, fixed in V8 4.4+.

(And no, nothing is "optimized away", it's just a bug.)

--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages