Re: [v8-users] Re: Intercepting the setting of static and instance methods

2020-03-04 Thread Darin Dimitrov
=b892cf58e162a8f66cd76d7472f129fe0fb6a7d1;bpv=1;bpt=1 After exposing it, I was able to intercept the setting of any property on my function. On Tuesday, March 3, 2020 at 11:39:34 PM UTC+2, Darin Dimitrov wrote: > > Ben, yes, unfortunately the SetAccessor method doesn't allow intercepting > the setti

Re: [v8-users] Re: Intercepting the setting of static and instance methods

2020-03-03 Thread Darin Dimitrov
Ben, yes, unfortunately the SetAccessor method doesn't allow intercepting the setting of any arbitrary member (property or function) on the function. On Tuesday, March 3, 2020 at 11:21:00 PM UTC+2, Ben Noordhuis wrote: > > On Tue, Mar 3, 2020 at 1:20 PM Darin Dimitrov > wrote: &

[v8-users] Re: Intercepting the setting of static and instance methods

2020-03-03 Thread Darin Dimitrov
UTC+2, Darin Dimitrov wrote: > > I managed to intercept the setting of the instance method with the > following: > > myClassTemplate->PrototypeTemplate()->SetHandler( > NamedPropertyHandlerConfiguration(nullptr, [](Local property, Local< > Value> value,

[v8-users] Re: Intercepting the setting of static and instance methods

2020-03-02 Thread Darin Dimitrov
e called when setting the instance method on the prototype"); })); So the question remains only for the static method interception. On Monday, March 2, 2020 at 11:10:26 AM UTC+2, Darin Dimitrov wrote: > > I am embedding V8 in my application and registered a custom class > (MyClass).

[v8-users] Intercepting the setting of static and instance methods

2020-03-02 Thread Darin Dimitrov
I am embedding V8 in my application and registered a custom class (MyClass). I am looking for a way to intercept the setting of methods on this class. Here's my code: auto platform = platform::NewDefaultPlatform(); V8::InitializePlatform(platform.get()); V8::Initialize(); std::string

[v8-users] Re: WebAssembly.instantiate didn't call then nor catch in v8 embedded

2020-02-21 Thread Darin Dimitrov
I had the same problem in my Android project and used a workaround. I replaced the global.WebAssembly object with a Proxy and intercept the "compile" and "instantiate" method calls. When this method is called I start a new background thread which is polling the main looper to pump messages and

[v8-users] Intercept ES6 class extensions

2020-02-20 Thread Darin Dimitrov
I am embedding V8 and execute the following javascript: class Parent { } class Child extends Parent { } Is there some API which would allow me to register an interceptor within the isolate which will get executed when registering such class? In this case the interceptor would receive the

Re: [v8-users] API to intercept Promises in V8

2020-02-12 Thread Darin Dimitrov
d" function on the global object which will call the specified js function argument on the main thread. Of course if this can be achieved without replacing the global Promise object, that would be even better. On Tuesday, February 11, 2020 at 10:59:40 PM UTC+2, Darin Dimitrov wrote: > &

Re: [v8-users] API to intercept Promises in V8

2020-02-11 Thread Darin Dimitrov
executed: https://github.com/WebKit/webkit/blob/master/Source/JavaScriptCore/runtime/JSGlobalObject.cpp#L341 I am looking for a similar API in V8 if it exists. On Tuesday, February 11, 2020 at 10:31:18 PM UTC+2, Ben Noordhuis wrote: > > On Tue, Feb 11, 2020 at 8:42 PM Darin Dimitrov &

[v8-users] API to intercept Promises in V8

2020-02-11 Thread Darin Dimitrov
I am embedding V8 in my C++ application and I have registered a custom "test" function on the global object taking a callback as parameter: test(function() { console.log("callback"); }); The "test" function starts a new thread and executes the callback on this thread. Now I can

Re: [v8-users] WASM not working on Android (embedded)

2020-01-17 Thread Darin Dimitrov
UTC+2, Clemens Backes wrote: > > On Thu, Jan 16, 2020 at 2:23 PM Darin Dimitrov > wrote: > >> Thanks Clemens. >> >> This works fine but it blocks the main thread. What would be the best >> approach to handle this in an Android app? Would writing a custom plat

Re: [v8-users] WASM not working on Android (embedded)

2020-01-16 Thread Darin Dimitrov
now(); > do { > v8::platform::PumpMessageLoop(platform.get(), isolate); > isolate->RunMicrotasks(); > } while (std::chrono::duration_cast( >std::chrono::system_clock::now() - start) >.count() < 10); > > Hope that helps, >

[v8-users] Re: WASM not working on Android (embedded)

2020-01-15 Thread Darin Dimitrov
m's loop with Android's message loop. On Wednesday, January 15, 2020 at 10:15:49 AM UTC+2, Darin Dimitrov wrote: > > I have embedded V8 (7.8.279.19) inside my Android application and tried > executing a script that compiles a WebAssembly module. > > Unfortunately th

[v8-users] WASM not working on Android (embedded)

2020-01-15 Thread Darin Dimitrov
I have embedded V8 (7.8.279.19) inside my Android application and tried executing a script that compiles a WebAssembly module. Unfortunately the promise returned by the "WebAssembly.compile" method is never completed (neither the "then" or the "catch" methods are invoked). The same happens

[v8-users] How to properly dispose an isolate

2019-12-05 Thread Darin Dimitrov
Hello, I am embedding V8 in my C++ application and I need to create multiple isolates from different background threads. Here's my workflow: 1. Create an isolate in the main thread -> this must be a long living isolate (for the entire application lifetime) 2. Spawn multiple short living

Re: [v8-users] Getting empty function names from the "StackTrace::CurrentStackTrace" method

2019-11-19 Thread Darin Dimitrov
ame cache. Does the flag "--optimize-for-size" > cause any change in the result? That flag disables the stack frame cache > (among other things). > > On Tue, Nov 19, 2019 at 8:37 AM Darin Dimitrov > wrote: > >> Further narrowed it down to the "--no-lazy" r

Re: [v8-users] Getting empty function names from the "StackTrace::CurrentStackTrace" method

2019-11-18 Thread Darin Dimitrov
V8::SetFlagsFromString(flags.c_str(), flags.size()); Any idea why would the --no-lazy flag affect function names in stack frames? I need the --no-lazy flag because I noticed that it speeds up code cached scripts (v8::ScriptCompiler::CreateCodeCache API). On Tuesday, November 19, 2019 at 9:

Re: [v8-users] Getting empty function names from the "StackTrace::CurrentStackTrace" method

2019-11-18 Thread Darin Dimitrov
Simon, thanks for the clarification. Does this mean that there's no reliable way to get this information with the current V8 public API? I went ahead and wrote a simple example illustrating the issue and tried running it on different platforms. And the results were surprising. Here's the

[v8-users] Getting empty function names from the "StackTrace::CurrentStackTrace" method

2019-11-18 Thread Darin Dimitrov
I am embedding V8 and trying to capture the current javascript stacktrace using the "v8::StackTrace::CurrentStackTrace": Isolate* isolate = info.GetIsolate(); Local stack = v8::StackTrace::CurrentStackTrace(isolate, 10, v8 ::StackTrace::StackTraceOptions::kDetailed); *for* (*int* i = 0; i <

Re: [v8-users] CpuProfiler not collecting data in jitless mode (iOS)

2019-11-06 Thread Darin Dimitrov
I managed to find the reason for this. I forgot to enter the isolate after creating it: isolate->Enter() All looks good now. Sorry for the false alert. On Wednesday, November 6, 2019 at 10:26:41 AM UTC+2, Jakob Gruber wrote: > > +Peter Marshall > > On Wed, Nov 6, 2019 a

[v8-users] CpuProfiler not collecting data in jitless mode (iOS)

2019-11-05 Thread Darin Dimitrov
I am trying to collect function execution data using the CpuProfiler class. I ran the following test (taken from here https://github.com/v8/v8/blob/master/test/cctest/test-cpu-profiler.cc#L677): const char* src = "function loop(timeout) {\n" " this.mmm = 0;\n" " var start =

Re: [v8-users] Overriding platform specific logging feature

2019-10-09 Thread Darin Dimitrov
t; former, why not upstream it in V8? > > On Wed, Oct 9, 2019 at 2:17 PM Darin Dimitrov > wrote: > >> I am embedding V8 in an iOS application and I would like to override the >> "OS::Print" method: >> https://chromium.googlesource.com/v8/v8.git/+/3.7.12.26/sr

[v8-users] Overriding platform specific logging feature

2019-10-09 Thread Darin Dimitrov
I am embedding V8 in an iOS application and I would like to override the "OS::Print" method: https://chromium.googlesource.com/v8/v8.git/+/3.7.12.26/src/platform-posix.cc#217 This method already handles the Android case by redirecting the output to logcat: void OS::VPrint(const char* format,

[v8-users] Replacing constructor function

2019-09-25 Thread Darin Dimitrov
I am embedding V8 and I have the following javascript: var TSObject = (function (_super) { __extends(TSObject, _super); function TSObject() { return _super !== null && _super.apply(this, arguments) || this; } return TSObject; }(String)); As an embedder, I have registered

Re: [v8-users] Calling js functions in jitless (iOS)

2019-09-12 Thread Darin Dimitrov
> debugging. > > > On Thu, Sep 12, 2019 at 4:36 PM Darin Dimitrov > wrote: > >> I am embedding v8 in my iOS application and calling some js function: >> >> Local callback = ... >> >> std::vector> v8Args = ... >> >> Local result; >>

[v8-users] Calling js functions in jitless (iOS)

2019-09-12 Thread Darin Dimitrov
I am embedding v8 in my iOS application and calling some js function: Local callback = ... std::vector> v8Args = ... Local result; TryCatch tc(isolate); callback->Call(context, thiz, (*int*)v8Args.size(), v8Args.data()).ToLocal ()); This code works pretty fine but starting from this commit

Re: [v8-users] Calling function from shared library in V8 7.7.299.11

2019-09-12 Thread Darin Dimitrov
er libcxx mismatch issue and 7.7 just exposes it > incidentally? > > On Thu, Sep 12, 2019 at 2:54 PM Darin Dimitrov > wrote: > >> I am cross compiling V8 for android and I have created a shared library >> containing a simple function which adds some property to a provided

[v8-users] Calling function from shared library in V8 7.7.299.11

2019-09-12 Thread Darin Dimitrov
I am cross compiling V8 for android and I have created a shared library containing a simple function which adds some property to a provided object: extern "C" void MyFunc(Isolate* isolate, Local& obj) { Local context = isolate->GetCurrentContext(); obj->Set(context,

Re: [v8-users] Create heap snapshot for x86 from 64 bit process

2019-08-26 Thread Darin Dimitrov
Thanks Jakob, we were considering exactly this option. Just wanted to make sure we weren't missing something before going that way. On Monday, August 26, 2019 at 11:51:08 AM UTC+3, Jakob Gruber wrote: > > On Mon, Aug 26, 2019 at 10:41 AM Darin Dimitrov > wrote: > >> Is it

[v8-users] Create heap snapshot for x86 from 64 bit process

2019-08-26 Thread Darin Dimitrov
Is it possible to create heap snapshot using the "mksnapshot" tool for x86 or armeabi-v7a CPU architectures from a 64 bit process. If yes, what are the steps to build such "mksnapshot" executable? Mac OS Catalina drops support for 32 bit executables and we would like to still be able to

Re: [v8-users] jitless mode broken on ARM64

2019-08-08 Thread Darin Dimitrov
org/p/v8/issues/detail?id=9588 >> >> On Wed, Aug 7, 2019 at 1:13 PM Jakob Gruber > > wrote: >> >>> +Santiago Aboy Solanes >>> >>> On Wed, Aug 7, 2019 at 2:09 PM Darin Dimitrov >> > wrote: >>> >>>> I have cross compiled

[v8-users] jitless mode broken on ARM64

2019-08-07 Thread Darin Dimitrov
I have cross compiled V8 for iOS and running in "--jitless" mode on an arm64 device (iPhone 6). Everything has been working smoothly until the following commit which appears to have broken it:

[v8-users] Reducing V8 binary size in JIT-less mode

2019-07-01 Thread Darin Dimitrov
According to https://v8.dev/blog/jitless, starting from 7.4, V8 supports JIT-less mode making it suitable for restricted environments. My goal is to reduce the binary size by stripping the optimizing compiler code which is not needed when running in this mode. Is any configuration flag which

[v8-users] How to embed the ICU data file into my application?

2019-06-11 Thread Darin Dimitrov
I have built V8 with the "v8_enable_i18n_support=true" gn flag and I can successfully initialize it by providing the location of the "icudtl.dat" file (created during the v8 build process): bool success = V8::InitializeICU("/path_to/icudtl.dat"); I was wondering if instead of providing the

Re: [v8-users] Issues cross compiling v8 for iOS

2019-05-27 Thread Darin Dimitrov
latform-embedded-file-writer-base.cc>. > > Let me take a look and get back to you. > > Jakob > > On Mon, May 27, 2019 at 1:40 PM Darin Dimitrov > wrote: > >> I am trying to cross compile V8 for iOS ( >> https://chromium.googlesource.com/v8/v8.git/+/be47fd1c37ea

[v8-users] Issues cross compiling v8 for iOS

2019-05-27 Thread Darin Dimitrov
I am trying to cross compile V8 for iOS ( https://chromium.googlesource.com/v8/v8.git/+/be47fd1c37ead74cf5c4479043426e0376d3ff29) as described here: https://v8.dev/docs/cross-compile-ios Using Mac OS 10.14.5 and XCode 10.2.1 I am getting the following error when building *embedded.S*:

Re: [v8-users] How to set internal field on a Local

2019-03-19 Thread Darin Dimitrov
to this Local instance? On Tuesday, March 19, 2019 at 12:07:28 PM UTC+2, Ben Noordhuis wrote: > > On Tue, Mar 19, 2019 at 9:41 AM Darin Dimitrov > wrote: > > > > I am trying to associate an internal field with a Local > created from a Local: > &g

[v8-users] How to set internal field on a Local

2019-03-19 Thread Darin Dimitrov
I am trying to associate an internal field with a Local created from a Local: Local ctorFuncTemplate = FunctionTemplate::New(isolate); Local ctorFunc = ctorFuncTemplate->GetFunction(context).ToLocalChecked(); ctorFunc->SetInternalField(0, External::New(isolate, ptr)); This fails with

Re: [v8-users] Error cross compiling V8 with is_component_build=true on ARM64

2019-02-21 Thread Darin Dimitrov
is not found on Mac OS. Contrary to my Ubuntu setup, looking at the "third_party/llvm-build/Release+Asserts/bin" folder there doesn't seem to exist a "lld" or "ld.lld" or "ld64.lld" files. On Wednesday, February 20, 2019 at 3:03:58 PM UTC+2, Jakob Gruber

Re: [v8-users] Error cross compiling V8 with is_component_build=true on ARM64

2019-02-20 Thread Darin Dimitrov
ednesday, February 20, 2019 at 12:20:01 PM UTC+2, Jakob Gruber wrote: > > You are building with target_os="android"; would you expect this to not > need libandroid_support? > > On Wed, Feb 20, 2019 at 10:23 AM Darin Dimitrov > wrote: > >> I am trying to c

[v8-users] Re: Different object files generated when cross compiling V8 7.3 for Android ARM (vs V8 7.2)

2019-02-20 Thread Darin Dimitrov
Turns out that V8 is building against a custom STL passing the _LIBCPP_ABI_UNSTABLE flag. So in order to build my final executable I had to use this same STL instead of the default libc++_static.a library provided by the NDK. On Wednesday, February 13, 2019 at 9:24:34 AM UTC+2, Darin Dimitrov

[v8-users] Error cross compiling V8 with is_component_build=true on ARM64

2019-02-20 Thread Darin Dimitrov
I am trying to cross compile V8 for ARM64 with *is_component_build=true* for ARM64: gn gen outgn/release --args="is_component_build=true is_debug=false symbol_level=0 target_cpu=\"arm64\" v8_target_cpu=\"arm64\" target_os=\"android\"" ninja -v -C outgn/release v8_libplatform And getting the

[v8-users] Re: Different object files generated when cross compiling V8 7.3 for Android ARM (vs V8 7.2)

2019-02-12 Thread Darin Dimitrov
8::platform::DefaultPlatform::DefaultPlatform() that takes a C-style > pointer instead of a unique_ptr. > > I'm also not sure if v8_libplatform is meant to be redistributed in this > way, though the V8 team can say for sure. > > On Tuesday, February 12, 2019 at 8:05:19 AM UTC-8,

[v8-users] Re: Different object files generated when cross compiling V8 7.3 for Android ARM (vs V8 7.2)

2019-02-12 Thread Darin Dimitrov
use_custom_libcxx=false but in this case no -isystem is specified and the build fails as it cannot find some common includes such as and . On Monday, February 11, 2019 at 6:09:49 PM UTC+2, Darin Dimitrov wrote: > > I was able to bisect the issue to the following commit in which the V8 > DEPS wer

[v8-users] Re: Different object files generated when cross compiling V8 7.3 for Android ARM (vs V8 7.2)

2019-02-11 Thread Darin Dimitrov
I was able to bisect the issue to the following commit in which the V8 DEPS were updated: https://chromium.googlesource.com/v8/v8/+/843535b893968a89f98b295cd7b1b265ca2927c1 On Monday, February 11, 2019 at 3:13:59 PM UTC+2, Darin Dimitrov wrote: > > I am trying to cross compile V8 for A

[v8-users] Different object files generated when cross compiling V8 7.3 for Android ARM (vs V8 7.2)

2019-02-11 Thread Darin Dimitrov
I am trying to cross compile V8 for Android (ARM) on an Ubuntu host using the latest NDK 19: gn gen outgn/arm-release --args="is_debug=false symbol_level=0 target_cpu=\"arm\" v8_target_cpu=\"arm\" target_os=\"android\"" ninja -C outgn/arm-release v8_libplatform And then I try to inspect the

Re: [v8-users] mksnapshot creates invalid embedded.S on MacOS

2019-02-06 Thread Darin Dimitrov
x. Something > similar should also work for you. > > As a more general solution we should dispatch based on the target (instead > of host) OS / architecture in this entire file. Could you file a bug? I'm > also happy to accept patches for this. > > On Wed, Feb 6, 2019 a

[v8-users] mksnapshot creates invalid embedded.S on MacOS

2019-02-06 Thread Darin Dimitrov
I am trying to cross-compile V8 for ARM on MacOS. At some point of the compilation process, mksnapshot is used to create the snapshot_blob.bin file: python ../../tools/run.py ./clang_x86_v8_arm/mksnapshot --turbo_instruction_scheduling --embedded_src gen/embedded.S --embedded_variant Default

[v8-users] Re: Heap snapshot crash on ARM in V8 7.1.302.28

2018-12-10 Thread Darin Dimitrov
Strangely enough, if I create a large number of strings just after creating the isolate, everything works fine: for (int i = 0; i < 70; i++) { v8::String::NewFromUtf8(isolate, "aaa"); } On Wednesday, December 5, 2018 at 6:46:41 PM UTC+2, Darin Dimitrov wro

[v8-users] Re: Heap snapshot crash on ARM in V8 7.1.302.28

2018-12-10 Thread Darin Dimitrov
/home/ubuntu/v8-7/v8/outgn/arm-release/clang_x86_v8_arm/mksnapshot(+0x3ed7e) [0xf6bf4d7e] Illegal instruction (core dumped) Thanks again for looking into this, Darin. On Wednesday, December 5, 2018 at 6:46:41 PM UTC+2, Darin Dimitrov wrote: > > Hello, > > We are embedding v8 in

[v8-users] Heap snapshot crash on ARM in V8 7.1.302.28

2018-12-05 Thread Darin Dimitrov
Hello, We are embedding v8 in android on an ARM device and trying to load a heap snapshot generated with the mksnapshot utility: ./outgn/arm-release/clang_x86_v8_arm/mksnapshot ./test.js --startup_blob ./ snapshot.blob --profile_deserialization And we are getting the following crash at

[v8-users] Cross compiling V8 7.0.276.27 for android

2018-10-19 Thread Darin Dimitrov
I am trying to cross compile V8 7.0.276.27 for android targeting arm64. I have used the following arguments: gn gen out/arm64.release --args='is_official_build=true is_debug=false symbol_level=0 v8_use_snapshot=true v8_use_external_startup_data=false target_cpu="arm64" v8_target_cpu="arm64"