Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

chakrashim: Improve AddLocal and Object::GetPropertyAttributes #101

Merged
merged 1 commit into from
Jul 28, 2016

Conversation

kunalspathak
Copy link
Member

Checklist
  • make -j4 test (UNIX), or vcbuild test nosign (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

chakrashim

Description of change

HandleScope was simulated in chakrashim by saving references
in JavascriptArray which involved calling JsSetIndexedProperty
API. Although this API is not slow, but there is an overhead of
calling JSRT APIs. It regress performance if AddLocal is called
often. To avoid that, converted the function in javascript which
would call array.push of bulk references we recorded so far.

Also, I converted Object::GetPropertyAttributes to javascript
function which should save 6 JSRT calls. I have also added
CHAKRA-TODO comments for functions that should be easily
converted to javascript functions.

@@ -568,6 +568,31 @@
// CHAKRA-TODO: Need to add JSRT API to detect this
return false;
};
utils.saveInHandleScope = function(array) {
for (var i = 1; i < arguments.length; i++) {
array.push(arguments[i]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

push accepts multiple args. Could avoid this loop?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I know. I was trying to avoid lengthy formals (8 in this case).

@jianchun
Copy link

LGTM, one last nit comment. Thanks!

@jianchun
Copy link

:shipit:

`HandleScope` was simulated in chakrashim by saving references
in `JavascriptArray` which involved calling `JsSetIndexedProperty`
API. Although this API is not slow, but there is an overhead of
calling JSRT APIs. It regress performance if `AddLocal` is called
often. To avoid that, gathered elements in `_locals` stack and
then bulk pushed them to array.

* Earlier we called `JsCreateArray` with length 1 to create the
above array. This creates an array of head segment size 4
(rounding) but since we are pushing `kOnStackLocals`, we would
fill up the head segment and allocate newer segment. Instead if we
pass length 0 to `JsCreateArray` it creates a head segment of size
16 and we don't have to initialize another segment till count reaches
16.

* Also, I converted `Object::GetPropertyAttributes` to javascript
function which should save 6 JSRT calls. I have also added
`CHAKRA-TODO` comments for functions that should be easily
converted to javascript functions.

PR-URL: nodejs#101
Reviewed-By: Jianchun Xu <Jianchun.Xu@microsoft.com>
@kunalspathak kunalspathak merged commit acb4225 into nodejs:chakracore-master Jul 28, 2016
@kunalspathak kunalspathak deleted the addlocal branch July 29, 2016 00:59
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.

2 participants