Git Product home page Git Product logo

Comments (2)

xxuejie avatar xxuejie commented on September 4, 2024 2

Hi,

Actually, you don't need brk to implement malloc, we do have an example contract running mruby, which involves a lot of malloc, https://github.com/nervosnetwork/mruby-contracts and runs perfectly fine. The trick to this is to use a modified version of libc which works in userspace without needing brk: nervosnetwork/riscv-newlib@dbc4aa7

To answer your question more directly: we thought a lot about whether we want brk, in fact, at some earlier stage of this project, we do implement a MMU which can enable brk, but later we decided to remove it completely. The reason behind this, is that we believe CKB VM should be as simple as possible, while an MMU might help developing a contract, in production you really want the maximum performance, and the minimal attack surface. Plus, any MMU we implement here will only be nice to one kind of application, but might bring obstacles to applications with different memory usage patterns.

As a result, we decide to go without MMU nor brk in the official CKB spec, and defer to modifications in libc to implement malloc and free.

BTW: we do speak both English and Chinese but let's keep using English here for broader audience :)

from ckb-vm.

TheRealBluesun avatar TheRealBluesun commented on September 4, 2024

Thank you so much for getting back to me so quickly. Reading through, I better understand that decision -- that makes sense. I'll play around with that newlib implementation you shared. Thank you!

(ε₯½ηš„ 😊 εœ¨θΏ™ι‡Œζˆ‘δΌšεͺ用英语)

from ckb-vm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.