-
Notifications
You must be signed in to change notification settings - Fork 682
Merge instance into context #2501
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
Merge instance into context #2501
Conversation
There was quite some confusion about terminology around instances and contexts. All the docs mentioned external contexts but functions and types were referring to instances, and the relation between these two concepts were not clear. This commit keeps (external) context as the only surviving concept. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
Part of the context rework PR series, follow-up to #2500 . |
/* The value of external context members must be preserved across initializations and cleanups. */ | ||
#ifdef JERRY_ENABLE_EXTERNAL_CONTEXT | ||
#ifndef JERRY_SYSTEM_ALLOCATOR | ||
jmem_heap_t *heap_p; /**< point to the heap aligned to JMEM_ALIGNMENT. */ |
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 would put this before or after the context, probably after would be better, since the starting offset would be fixed. Then we don't need this pointer.
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.
The instance-based approach also contained this pointer, at the end of the instance struct, even if the heap always started right after the instance. I'd keep this pointer as it allows for future developments, e.g., one that allows placing context structures and heaps in different memory regions (which is already available for the builtin global context approach but is not available for external contexts right now).
@@ -56,9 +72,17 @@ typedef struct jerry_context_data_header | |||
* The purpose of this header is storing | |||
* all global variables for Jerry | |||
*/ | |||
typedef struct | |||
struct jerry_context_t |
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.
Why do you remove the typedef?
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.
It is typedef'd in jerryscript-core.h. A typedef cannot be declared twice. jerry_context_t
is taking over the place of jerry_instance_t
, so it has to be opaquely forward declared in the public API header. But that means that only the struct can be declared here.
Note: jerry_instance_t
was handled exactly the same way.
@zherczeg Thanks for the review, your comments have been answered in-line. Please, let me know if you have further change requests (or still maintain the current ones). |
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.
LGTM
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.
LGTM
There was quite some confusion about terminology around instances
and contexts. All the docs mentioned external contexts but
functions and types were referring to instances, and the relation
between these two concepts were not clear. This commit keeps
(external) context as the only surviving concept.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu