-
Notifications
You must be signed in to change notification settings - Fork 691
Add operational mode for jerry_gc API call. #2385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,18 @@ Option bits for [jerry_parse](#jerry_parse) and | |
| - JERRY_PARSE_NO_OPTS - no options passed | ||
| - JERRY_PARSE_STRICT_MODE - enable strict mode | ||
|
|
||
| ## jerry_gc_mode_t | ||
|
|
||
| Set garbage collection operational mode | ||
|
|
||
| - JERRY_GC_SEVERITY_LOW - free unused objects | ||
| - JERRY_GC_SEVERITY_HIGH - free as much memory as possible | ||
|
|
||
| The difference between `JERRY_GC_SEVERITY_LOW` and `JERRY_GC_SEVERITY_HIGH` | ||
| is that the former keeps memory allocated for performance improvements such | ||
| as property hash tables for large objects. The latter frees all possible | ||
| memory blocks but the performance may drop after the garbage collection. | ||
|
|
||
| ## jerry_generate_snapshot_opts_t | ||
|
|
||
| Flags for [jerry_generate_snapshot](#jerry_generate_snapshot) and | ||
|
|
@@ -705,13 +717,30 @@ Performs garbage collection. | |
|
|
||
| ```c | ||
| void | ||
| jerry_gc (void); | ||
| jerry_gc (jerry_gc_mode_t mode); | ||
| ``` | ||
|
|
||
| - `mode` - operational mode, see [jerry_gc_mode_t](#jerry_gc_mode_t) | ||
|
|
||
| **Example** | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update the example as well.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. It runs with doctest as well now. |
||
|
|
||
| [doctest]: # () | ||
|
|
||
| ```c | ||
| jerry_gc (); | ||
| #include "jerryscript.h" | ||
|
|
||
| int | ||
| main (void) | ||
| { | ||
| jerry_init (JERRY_INIT_EMPTY); | ||
|
|
||
| jerry_value_t object_value = jerry_create_object (); | ||
| jerry_release_value (object_value); | ||
|
|
||
| jerry_gc (JERRY_GC_SEVERITY_LOW); | ||
|
|
||
| jerry_cleanup (); | ||
| } | ||
| ``` | ||
|
|
||
| **See also** | ||
|
|
@@ -1601,7 +1630,7 @@ jerry_value_is_undefined (const jerry_value_t value) | |
| Returns the JavaScript type | ||
| for a given value as a [jerry_type_t](#jerry_type_t) enum value. | ||
|
|
||
| This is a similar operation as the 'typeof' operator | ||
| This is a similar operation to the 'typeof' operator | ||
| in the standard with an exception that the 'null' | ||
| value has its own enum value. | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm no native English speaker but isn't this "operation mode" or "operating mode"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to google,
operation modeis used 262M sites, whileoperational mode117M sites. Both are used by high profile (e.g. microsoft or google technical docs) sites. I think both are ok, so I don't want to change unless you insist on it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked Cambridge dictionary:
operation - noun
operational - adjective
operating - present participle
I would prefer
operationalhere.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Google: The present participle is a participle that ends in ing. It can be used with the auxilliary verb 'to be' to form the continuous tense. It always takes the 'ing' form of the verb, even irregular verbs have an '...ing' form, in fact virtually all English words that end with 'ing' are present participles.
I think
operating modeis also correct, if we emphasize doing the garbage collection in specific a way. Theoperational modesimply emphasize the behavior.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g:
operating system - a system which is running (emphasizing continuity)
operational system - a system which is capable of running (not relevant if it is doing it now)
operation system - double noun, usually a phrase or not used at all. I think the latter is true here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you've said, saying something is 'operational' means it is capable of running. Saying that the mode is operational means that the thing that is running will be able to run in that mode, but also implies that a 'not operational' mode exists, which 'won't be able to run'. This is not the case, as the mode here means a specific a way of operation, and not whether the GC can actually run, or is running.
I'm not sure what behavior you'd like to emphasize by using
operational mode, yet it feels instinctively wrong to me, and I'd say the suggestions made by @akosthekiss would be the the correct way to go.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't exactly say that. Tricky way of turning my words :)
Adjectives extends the meaning of words, while nouns do not. Think about the difference of "wooden house" and "tree house". The former uses an adjective to extend a noun, while the latter is simply a phrase.
I found "operational mode" in a well known English dictionary:
https://en.oxforddictionaries.com/definition/standby
An operational mode of an electrical appliance in which the power is switched on but the appliance is not actually functioning.
I could not find the same thing with "operation mode".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've consulted an English teacher and operation was preferred over operational. But still no native speaker chiming in on either side. As this is no API function name but a doc text only, I wont be pushing further.