Skip to content

New .mrb format. #964

Merged
matz merged 1 commit into
mruby:masterfrom
masuidrive:new_mrb_format
Mar 27, 2013
Merged

New .mrb format. #964
matz merged 1 commit into
mruby:masterfrom
masuidrive:new_mrb_format

Conversation

@masuidrive

Copy link
Copy Markdown
Contributor

This patch is made from #944.

It's cleared Matz request.

  • endian neutral
  • binary (should be compact than current mrb)
  • with CRC check sum

And I made .mrb binary file dump tool.
https://github.com/masuidrive/mrbdump

It's dump and format verification tool.

@matsumotory

Copy link
Copy Markdown
Member

It's nice!

@monaka

monaka commented Mar 8, 2013

Copy link
Copy Markdown
Contributor

Nit-picking, it's better to use uint8_t instead of "unsigned char". Type "char" is not always 8bits in C99 spec.

And I wonder it could separate stdio dependency from the patch. But it should be discussed by the another issue after this patch is merged.

@monaka

monaka commented Mar 8, 2013

Copy link
Copy Markdown
Contributor

BTW, Just for confirmation of consent.
Matz's version will be obsolete? I have no objection if it will be. Everyone (at least all committers) think so?

@masuidrive

Copy link
Copy Markdown
Contributor Author

I think so. Current Matz version will be obsolete.

@bovi

bovi commented Mar 8, 2013

Copy link
Copy Markdown
Member

Do I understand it right that the main idea behind this new format is to make it possible to better integrate debugging support by having more flexible sections? At the same time you are shrinking the overall size by changing to a binary format? I would just like to summarise the discussion from #944 due to the reason that it seems to me that two targets are tried to been reached which are eliminate each other -> having more flexibility and at the same time making the code more compact.

@masuidrive

Copy link
Copy Markdown
Contributor Author

This patch gave extendable and compaction.
New format can contain debugging and other informations.

@masuidrive

Copy link
Copy Markdown
Contributor Author

@monaka I changed code for useless unsigned char
Could you review it?

Comment thread include/mruby/irep.h Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be uint8_t ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you! I already fixed and pushed it.

@monaka

monaka commented Mar 8, 2013

Copy link
Copy Markdown
Contributor

I've not tested. But it looks ok except a point I commented in the diff.

@monaka

monaka commented Mar 8, 2013

Copy link
Copy Markdown
Contributor

I tried to build. Totally this works. But I have some comments. I'll send pull request to branch masuidrive:new_mrb_format tomorrow.

@masuidrive

Copy link
Copy Markdown
Contributor Author

@monaka Thank you.
I'll wait for your comments.

@masuidrive

Copy link
Copy Markdown
Contributor Author

@matz
I think dump.c move to tools/mrbc.
What do you think?

@monaka

monaka commented Mar 8, 2013

Copy link
Copy Markdown
Contributor

I sent pull request to masuidrive:new_mrb_format branch.

@masuidrive

Copy link
Copy Markdown
Contributor Author

@matz Could you review it?

@beoran

beoran commented Mar 9, 2013

Copy link
Copy Markdown

That image is too messy, so I made a diagram in Dia:

new_mrb_format_beoran

Download the Dia file here (use "save as" functionality of your browser):
http://www.beoran.net/eruta/uploads/diagrams/new_mrb_format.dia

matz added a commit that referenced this pull request Mar 27, 2013
@matz matz merged commit 974febd into mruby:master Mar 27, 2013
@matz

matz commented Mar 27, 2013

Copy link
Copy Markdown
Member

Now binary mrbc dump format is available.
We can now start discussion about ROM-able ISEQ a la #880.
My idea is that iseq in the dump from mrb_dump_irep_cfunc() can be switched to native byte order.
Cross-compiling will make things difficult though.

@mattn

mattn commented Mar 27, 2013

Copy link
Copy Markdown
Contributor

👍

@kyab

kyab commented Jun 20, 2013

Copy link
Copy Markdown
Contributor

I would like to implement ROM-able ISEQ on my fork.

My plan is:
Outside:

  • Use same format both for .mrb and cfunc(.c), but add endian field: 0:neutral 1: little 2: big. effective for cfunc only.
  • mrbc will have new option -E<endian>, which only effective with -B option
  • in build_config, user can specify endian for target like endian :big. default is nothing, which means neutral and does not refere ROM(neutral is same as current). this value is used into -E option for run mrbc.

Implementation

  • mrb_dump_irep() will take new argument "endian". mrb_dump_irep_binary(*.mrb case) will pass "neutral",
    mrb_dump_irep_cfunc will pass user specified value by -E<endian>.
  • load.c will read endian field, if neutral, then does not refere rom. if others, check endian on runtime, if mismatch, error(MRB_DUMP_ENDIAN_MISMATCH or something) will be returned, otherwise refer ROM directly.
  • if endian field is not neutral, skip CRC calc/check.

I think same format for both *.mrb and *.c is OK for simplicity as current mruby. But endian field is meaningless for *.mrb, and CRC is meaning for *.c. I'm not sure separate representation is better or not.

Any comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants