You can, after doing that, capture a new snapshot. That one would then include your new console implementation. However, you will need to tell the SnapshotCreator about the bindings' addresses.
Cheers, Yang On Wed, Feb 6, 2019 at 5:02 AM Jeroen Ooms <[email protected]> wrote: > I was able to work around it by deleting and setting the console > property after the context has been initiated: > > https://github.com/jeroen/V8/blob/e405e53743c8f4760fc7903553b262a6b7ebd2f0/src/bindings.cpp#L217-L232 > > > > > > On Tue, Feb 5, 2019 at 8:55 PM Yang Guo <[email protected]> wrote: > > > > Fairly sure this is just crbug.com/v8/8669 > > > > The reason is that there is already a console object in the snapshot, > and the one you set up on the global object via object template will get > overwritten. We used to assert in order to avoid mistakes by embedders. > > > > You need to cherry-pick c8567109f5536c697aea1166919e2bac23685fbd and > da2047c4a276a4d0077d00630a391917a7a1fff1, or upgrade past V8 version 7.3.400 > > > > The actual way to implement the console object though is to implement an > inspector frontend and communicate with V8 inspector via DevTools protocol. > > > > Cheers, > > > > Yang > > > > On Tue, Feb 5, 2019 at 3:30 PM Jeroen Ooms <[email protected]> > wrote: > >> > >> The V8 bindings for R create a context and then set the 'console' > property to implement console.log() and console.warn() > >> > >> v8::Local<v8::ObjectTemplate> console = > v8::ObjectTemplate::New(isolate); > >> global->Set(String::NewFromUtf8(isolate, "console"), console); > >> console->Set(String::NewFromUtf8(isolate, "log"), > >> v8::FunctionTemplate::New(isolate, ConsoleLog)); > >> ... > >> Persistent<Context> context = Context::New(isolate, NULL, global); > >> > >> This works on all systems except on Fedora (v8 6.7.17) it crashes when > initiating the context: > >> > >> # Fatal error in ../../src/objects.cc, line 5983 > >> # Debug check failed: !it.IsFound(). > >> > >> After some trial and error I discovered that it does not crash if I > change the name of the property something else than "console". Hence I > suppose this name is somehow reserved on this version of V8? Is there a > some way to override this, or alternatively test if 'global.console' has > been reserved so I should not attempt to set it? > >> > >> > >> -- > >> -- > >> v8-dev mailing list > >> [email protected] > >> http://groups.google.com/group/v8-dev > >> --- > >> You received this message because you are subscribed to the Google > Groups "v8-dev" group. > >> To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected]. > >> For more options, visit https://groups.google.com/d/optout. > > > > -- > > -- > > v8-dev mailing list > > [email protected] > > http://groups.google.com/group/v8-dev > > --- > > You received this message because you are subscribed to a topic in the > Google Groups "v8-dev" group. > > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/v8-dev/dVrKaQ6QXyE/unsubscribe. > > To unsubscribe from this group and all its topics, send an email to > [email protected]. > > For more options, visit https://groups.google.com/d/optout. > > -- > -- > v8-dev mailing list > [email protected] > http://groups.google.com/group/v8-dev > --- > You received this message because you are subscribed to the Google Groups > "v8-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev --- You received this message because you are subscribed to the Google Groups "v8-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
