[Vm-dev] SqueakJS named primitives in the interpreter module
Bert Freudenberg
bert at freudenbergs.de
Mon Jan 23 15:17:42 UTC 2017
On Sat, Jan 21, 2017 at 5:06 AM, David T. Lewis <lewis at mail.msen.com> wrote:
>
> I sent a git pull request for the new primitive, so hopefully you can
> review it and include it in SqueakJS if it is not too horrible.
Awesome! Merged.
To my considerable surprise, DateAndTime>>now seems to be 70 times faster
> on SqueakJS when using this primitive along with the enhancements in the
> UTCDateAndTime repository.
Well, emulating a primitive is a lot more expensive on a slow VM like
SqueakJS still is. So I'm not too, surprised, but happy nonetheless :)
> I am inexperienced with JavaScript and Git, so in case any of this did not
> get through, the proposed new function in Squeak.Primitives is:
>
> primitiveUtcWithOffset: function(argCount) {
> var d = new Date();
> var posixMicroseconds = this.pos53BitIntFor(d.getTime() * 1000);
> var offset = -60 * d.getTimezoneOffset();
> if (argCount > 0) {
> // either an Array or a DateAndTime in new UTC format with two
> ivars
> var stWordIndexableObject = this.vm.stackValue(0);
> stWordIndexableObject.pointers[0] = posixMicroseconds;
> stWordIndexableObject.pointers[1] = offset;
> this.popNandPushIfOK(argCount + 1, stWordIndexableObject);
> return true;
> }
> var timeAndOffset = [
> posixMicroseconds,
> offset,
> ];
> this.popNandPushIfOK(argCount + 1, this.makeStArray(
> timeAndOffset));
> return true;
> },
>
It looks fine. We could try to incorporate the microsecondClock function,
but if milliseconds are good enough then this will do.
- Bert -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20170123/9aab6ec4/attachment.html>
More information about the Vm-dev
mailing list