Skip to content
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

Sharing objects with VMs #5

Open
fwsGonzo opened this issue Nov 28, 2022 · 2 comments
Open

Sharing objects with VMs #5

fwsGonzo opened this issue Nov 28, 2022 · 2 comments
Labels
question Further information is requested

Comments

@fwsGonzo
Copy link
Owner

fwsGonzo commented Nov 28, 2022

Object sharing is the current topic of research right now. It's fairly OK to share plain-old-data, but it would be nice if it could be more dynamic somehow.

	struct GameObject objects[200]; // Page worth of objects

	/* Insert objects into memory.
	   This allows zero-copy sharing of game state. */
	static constexpr Script::gaddr_t OBJECT_AREA = 0xC000000;
	gameplay.machine().memory.insert_non_owned_memory(
		OBJECT_AREA, objects, sizeof(objects) & ~4095UL);

This is the current way of doing things.
We can now access the objects in the VMs, and if we use the same inline code interface the output should be the same.

@fwsGonzo fwsGonzo added the question Further information is requested label Nov 28, 2022
@fwsGonzo
Copy link
Owner Author

One idea here is to use the heap allocator to guarantee the object doesn't cross a page. If that were added, we could allocate and emplace objects at-will.

@fwsGonzo
Copy link
Owner Author

One idea here is to use the heap allocator to guarantee the object doesn't cross a page. If that were added, we could allocate and emplace objects at-will.

I've implemented this and it seems to work well. No real performance penalty other than a possible double-chunk split in order to handle page boundaries. Now I am wondering if there are other places that could benefit from this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant