Skip to content

Node must not rely on functionality exposed through --allow-natives-syntax #20409

Description

@hashseed

As I found out here, Node enables --allow-natives-syntax in V8 during bootstrapping and disables later.

This is so v8.previewMapIterator and v8.previewSetIterator in lib/internal/v8.js can be compiled during bootstrapping, as the call %MapIteratorClone and %SetIteratorClone. There are two major flaws in this:

  • This relies on v8/src/runtime/runtime.h defining %MapIteratorClone. Note that this is an implementation detail deep inside of V8 and could change at any time without any warning. In this particular case, %MapIteratorClone is only used inside V8 for the outdated debug context implementation that we were planning to remove for a long time.
  • This also relies on the fact that once compiled, the function does not need to be compiled again. That could change in the future if V8 implements code aging for bytecode.

Well I guess now that V8 tests against Node, V8 developers are forced to not violate these wrong assumptions.

Please please remove these dependencies.

Activity

  1. added
    v8 engineIssues and PRs related to the V8 dependency.
    on Apr 29, 2018
  2. addaleax commented on Apr 29, 2018

    @addaleax
    Member

    I think we can be very empathetic to this, because it’s a problem that we’ve been running into far too many times ourselves :)

    Do you have any suggestions for how we’d best avoid this? We only use it for inspecting these objects at the moment in console.log()/util.inspect(). I guess we could use the inspector bindings, but maybe there’s a better way to achieve that goal?

    Also, one more note: We do use --allow_natives_syntax in test/parallel/test-http-same-map for %HaveSameMap. I assume the same holds there as well?

  3. bnoordhuis commented on Apr 29, 2018

    @bnoordhuis
    Member

    This one's on me, I'm afraid... the use of natives was only a stop-gap measure. It's on my todo list to file CLs to add a proper C++ API for inspecting map and set iterators, but I haven't gotten around to it yet.

  4. added a commit that references this issue on May 17, 2018
  5. 16 remaining items

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions