Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Bug 1063050 - Don't use DataView in DataBuffers. #1701

Merged
merged 2 commits into from Sep 12, 2014

Conversation

mbebenita
Copy link
Contributor

Main change here is that we no longer use DataViews to read unaligned values, instead we just read byte by byte and do a little bit shifting. The second change, is that we no longer try to be clever about when to use different kinds of views. For instance, if you look at the current implementation of readInt(), you would think that optimizing it to check for 4 byte alignment and using a i32View would be more efficient. In reality it doesn't really make a difference and can actually be slower because of more branches and possibly making the function less inline worthy. I've experimented with this a bit, and I've concluded that the best thing to do here is to keep things as simple as possible.

readInt(): number /*int*/ {
  var u8 = this._u8;
  var position = this._position;
  if (position + 4 > this._length) {
    throwEOFError();
  }
  var a = u8[position + 0];
  var b = u8[position + 1];
  var c = u8[position + 2];
  var d = u8[position + 3];
  this._position = position + 4;
  return this._littleEndian ?
    (d << 24) | (c << 16) | (b << 8) | a :
    (a << 24) | (b << 16) | (c << 8) | d;
}

@mbebenita
Copy link
Contributor Author

/botio test

@shumwaybot
Copy link

From: Bot.io (Main)


Received

Command cmd_test from @mbebenita received. Current queue size: 0

Live output at: http://areweflashyet.com:8081/5d9b52e6e29eaf6/output.txt

@shumwaybot
Copy link

From: Bot.io (Main)


Failed

Full output at http://areweflashyet.com:8081/5d9b52e6e29eaf6/output.txt

Total script time: 14.97 mins

@yurydelendik
Copy link
Contributor

/botio test

@shumwaybot
Copy link

From: Bot.io (Main)


Received

Command cmd_test from @yurydelendik received. Current queue size: 1

Live output at: http://areweflashyet.com:8081/8363286452a20b0/output.txt

@shumwaybot
Copy link

From: Bot.io (Main)


Failed

Full output at http://areweflashyet.com:8081/8363286452a20b0/output.txt

Total script time: 16.00 mins

@yurydelendik
Copy link
Contributor

/botio test

@shumwaybot
Copy link

From: Bot.io (Main)


Received

Command cmd_test from @yurydelendik received. Current queue size: 0

Live output at: http://areweflashyet.com:8081/168a4be21358cf1/output.txt

@shumwaybot
Copy link

From: Bot.io (Main)


Success

Full output at http://areweflashyet.com:8081/168a4be21358cf1/output.txt

Total script time: 15.45 mins

  • Lint: Passed
  • Reference tests: Passed
  • Trace tests: Passed
  • AVM2 tests: Passed

mbebenita added a commit that referenced this pull request Sep 12, 2014
Bug 1063050 - Don't use DataView in DataBuffers.
@mbebenita mbebenita merged commit 4bfd417 into mozilla:master Sep 12, 2014
@mbebenita
Copy link
Contributor Author

It may make sense to revisit the way we handle read/write doubles, reading 8 bytes one at a time doesn't see too great.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants