Re: [v8-users] Check failed: Handle not reset in first callback. How to Reset my Persistent
The example was helpful. Encapsulating the Persistent in the callacks private data object seems to be the way to roll. > // kParameter will pass a void* parameter back to the callback, > kInternalFields > // will pass the first two internal fields back to the callback, kFinalizer > // will pass a void* parameter back, but is invoked before the object is > // actually collected, so it can be resurrected. In the last case, it is > not > // possible to request a second pass callback. > enum class WeakCallbackType { kParameter, kInternalFields, kFinalizer }; Does that help? Sorry, but no not really. Resurrection? Sounds like a zombie movie (I probably don't need this) *kInternalFields - will pass the first two internal fields back to the callback* How? Why? There has to be something better that explains the callbacks better. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[v8-users] Check failed: Handle not reset in first callback. How to Reset my Persistent
With recent versions of v8 the SetWeak method has changed and the Persistent* parameter has been dropped from the destructor callback. The destructor callback function is **supposed** to Reset() the persistent or its a leak. If you don't V8 crashes and tells you this: Check failed: Handle not reset in first callback. See comments on |v8::WeakCallbackInfo Old signature: void MyClass::DestructorCallback(Isolate* pIsolate, Persistent* value, MyClass* pObj) New signature void MyClass::DestructorCallback(const WeakCallbackInfo& oValue) If I call it like this: Persistent obj(isolate, objLocal); obj.SetWeak(pMyObject, MyClass::DestructorCallback, WeakCallbackType::kParameter); How can I pass the Persistent into my DestructorCallback function so I can Reset it?? Persistent cannot be copied. So how can I Reset() it in the callback? Any help would be great. Also the WeakCallbackType::kParameter vs WeakCallbackType::kFinalizer thing has me confuzeled too. Which is the right type to use? Thanks! -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[v8-users] Re: SetCallAsFunctionHandler Error: TypeError: x is not a constructor
I found a fix. See the bug comments for how to fix V8 -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[v8-users] Re: SetCallAsFunctionHandler Error: TypeError: x is not a constructor
I just found this: https://bugs.chromium.org/p/v8/issues/detail?id=7670 I'm pretty sure that change broke my code. How do I back this change out of current sources to get things working again? -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[v8-users] SetCallAsFunctionHandler Error: TypeError: x is not a constructor
After upgrading to a newer version of V8 the constructorFunctionHandler I set with SetCallAsFunctionHandler does not seem to be working. When I try to execute the code below it produces this error: TypeError: RemoteRequest is not a constructor This sample code is unstructured and ugly, but it will reproduce the error. It worked properly in past versions v8. Thanks for the help. Mike --- #include using namespace v8; #include "include/libplatform/libplatform.h" Eternal* pRemoteRequestObjectTemplateEnternal; class RJSRemoteRequest { public: RJSRemoteRequest(){}; ~RJSRemoteRequest(){}; static void constructorFunctionHandler(const FunctionCallbackInfo& args) { Local tmplRmtRequest; if(pRemoteRequestObjectTemplateEnternal && !pRemoteRequestObjectTemplateEnternal->IsEmpty()) { tmplRmtRequest = pRemoteRequestObjectTemplateEnternal->Get(args.GetIsolate()); //Now make an real RemoteRequest C++ object and pass it. RJSRemoteRequest* pRemoteRequest = new RJSRemoteRequest(); Local localObj = tmplRmtRequest->NewInstance(); localObj->SetInternalField(0, External::New(args.GetIsolate(), pRemoteRequest)); Persistent obj(args.GetIsolate(), localObj); obj.SetWeak(pRemoteRequest, RJSRemoteRequest::JSRemoteRequest_DestructorCallback, WeakCallbackType::kFinalizer); args.GetReturnValue().Set(obj); return; } args.GetReturnValue().SetNull(); }; static void JSRemoteRequest_DestructorCallback(const WeakCallbackInfo& oValue) { delete oValue.GetParameter(); }; static void JSRemoteRequest_execute(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(v8::True(args.GetIsolate())); return; } }; int main() { std::string sTestScript("\"use strict\";\nvar rmtRequest = new RemoteRequest();\nrmtRequest.execute();"); v8::Platform* pPlatform = platform::CreateDefaultPlatform(); V8::InitializePlatform(pPlatform); V8::Initialize(); Isolate::CreateParams params; params.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); v8::Isolate* pIsolate = v8::Isolate::New(params); v8::Isolate::Scope oIsolateLock(pIsolate); //Automatically handles Enter() and Leave() of the Isolate for us. v8::HandleScope IsolateScope(pIsolate); //Create an object template where our users can embed their own objects and such. //They are then baked into the global when the context is created. Handle oObjTemplate = ObjectTemplate::New(pIsolate); void* pPrivateData = new unsigned long[10]; //Make up some privates for tester. pRemoteRequestObjectTemplateEnternal = new Eternal; Local tmplRmtRequest; tmplRmtRequest = ObjectTemplate::New(pIsolate); tmplRmtRequest->SetInternalFieldCount(2); tmplRmtRequest->SetCallAsFunctionHandler(RJSRemoteRequest::constructorFunctionHandler, External::New(pIsolate, reinterpret_cast(pPrivateData))); tmplRmtRequest->Set(String::NewFromUtf8(pIsolate, "execute"), FunctionTemplate::New(pIsolate, RJSRemoteRequest::JSRemoteRequest_execute)); pRemoteRequestObjectTemplateEnternal->Set(pIsolate, tmplRmtRequest); oObjTemplate->Set(v8::String::NewFromUtf8(pIsolate, "RemoteRequest"), tmplRmtRequest, ReadOnly); Local oContext = Context::New(pIsolate, NULL, oObjTemplate); Context::Scope context_scope(oContext); TryCatch trycatch(pIsolate); MaybeLocal sScript = v8::String::NewFromUtf8(pIsolate, sTestScript.c_str(), v8::NewStringType::kNormal, (int)sTestScript.size()); v8::Local sLocalScriptText; sScript.ToLocal(); v8::ScriptCompiler::Source source(sLocalScriptText); MaybeLocal oMaybeScript = v8::ScriptCompiler::CompileUnboundScript(pIsolate, , v8::ScriptCompiler::kNoCompileOptions); Local oScript; oMaybeScript.ToLocal();
Re: [v8-users] Re: v8 static library on windows gives linker errors
Did a little more googling and found this option for the args.gn file: v8_monolithic = true is_debug = true is_clang = false v8_target_cpu = "x64" target_cpu = "x64" v8_enable_backtrace = true v8_enable_slow_dchecks = true v8_optimized_debug = false is_component_build = false v8_static_library = true use_custom_libcxx = false use_custom_libcxx_for_host = false treat_warnings_as_errors = false v8_enable_i18n_support = false v8_use_external_startup_data = false Which is producing a single output file named: v8_monolith.lib Which when linked with my application finally has no errors! The v8_monolith.lib is unbelievably huge (nearly a gig) but at least it works. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] Re: v8 static library on windows gives linker errors
I like the idea of a single library. I tried the following based on the instructions I saw: ninja -C out.gn/x64.debug v8_monolith but got this error: ninja: Entering directory `out.gn/x64.debug' ninja: error: unknown target 'v8_monolith' > >> -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[v8-users] Re: v8 static library on windows gives linker errors
I tried linking in the v8_init.lib file to my project. The same error still exists but under another library? 1>v8_init.lib(setup-isolate-full.obj) : error LNK2019: unresolved external symbol "protected: static void __cdecl v8::internal::SetupIsolateDelegate::SetupBuiltinsInternal(class v8::internal::Isolate *)" (?SetupBuiltinsInternal@SetupIsolateDelegate@internal@v8@@KAXPEAVIsolate@23@@Z) referenced in function "public: virtual void __cdecl v8::internal::SetupIsolateDelegate::SetupBuiltins(class v8::internal::Isolate *)" (?SetupBuiltins@SetupIsolateDelegate@internal@v8@@UEAAXPEAVIsolate@23@@Z) 1>v8_init.lib(setup-isolate-full.obj) : error LNK2019: unresolved external symbol "protected: static bool __cdecl v8::internal::SetupIsolateDelegate::SetupHeapInternal(class v8::internal::Heap *)" (?SetupHeapInternal@SetupIsolateDelegate@internal@v8@@KA_NPEAVHeap@23@@Z) referenced in function "public: virtual bool __cdecl v8::internal::SetupIsolateDelegate::SetupHeap(class v8::internal::Heap *)" (?SetupHeap@SetupIsolateDelegate@internal@v8@@UEAA_NPEAVHeap@23@@Z) > > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[v8-users] Re: v8 static library on windows gives linker errors
Here's the build command i'm using: ninja -C out.gn/x64.debug -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[v8-users] v8 static library on windows gives linker errors
Trying to get the latest version of V8 on windows to successfully link with my application. I've got VC 2017 on a Windows 7 box. I'm trying to build an x64 debug static library. I've managed to get V8 to build but I'm running into the following linker errors: 1>v8_base_1.lib(isolate.obj) : error LNK2001: unresolved external symbol "public: virtual void __cdecl v8::internal::SetupIsolateDelegate::SetupBuiltins(class v8::internal::Isolate *)" (?SetupBuiltins@SetupIsolateDelegate@internal@v8@@UEAAXPEAVIsolate@23@@Z) 1>v8_base_1.lib(isolate.obj) : error LNK2001: unresolved external symbol "public: virtual bool __cdecl v8::internal::SetupIsolateDelegate::SetupHeap(class v8::internal::Heap *)" (?SetupHeap@SetupIsolateDelegate@internal@v8@@UEAA_NPEAVHeap@23@@Z) My args.gn file looks like this: is_debug = true is_clang = false v8_target_cpu = "x64" target_cpu = "x64" v8_enable_backtrace = true v8_enable_slow_dchecks = true v8_optimized_debug = false is_component_build = false v8_static_library = true use_custom_libcxx = false use_custom_libcxx_for_host = false treat_warnings_as_errors = false v8_enable_i18n_support = false v8_use_external_startup_data = false When the V8 build is complete I end up with no less than 36 separate .lib files being generated! Of those 36 I link with the following in my app: v8_base_0.lib v8_base_1.lib v8_libbase.lib v8_libplatform.lib v8_initializers.lib v8_nosnapshot.lib v8_libsampler.lib I've tried removing and adding different v8 lib files in the hope of getting a clean link. No such luck. Any ideas as to why it's producing so many output .lib files or which ones I need to successfully link? Mike M. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[v8-users] Re: Calling method on Persistent
Do I need an handle scope when I work on the Local? Not sure what that would do for me. Thanks, Mike -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[v8-users] Re: Calling method on Persistent
Do you mean something like this? Persistent obj; obj.Reset(pIsolate, blah->NewInstance()); Handle objLocal = obj.Get(pIsolate); objLocal->SetInternalField(0, External::New(pIsolate, )); objLocal->SetInternalField(1, External::New(pIsolate, )); obj.SetWeak(myPointer, MyClass::DestructorCallback); Will making a Local object still affect the original Persistent object when I call SetInternalField()? -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[v8-users] Calling method on Persistent
I've upgraded from a slightly older version of V8. I can no longer do this with a Persistent *obj->SetInternalField(0, External::New(pIsolate, ));* *error C2039: 'SetInternalField': is not a member of 'v8::Persistent>'* *1>with* *1>[* *1>T=v8::Object* *1>]* Seems the -> operator is no longer available on persistent? How can I accomplish this with newest V8? Thanks! Mike -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] Re: Building V8 on Windows with Visual Studio 2017
Also the *v8_base.lib* or any other .lib files we not created. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] Re: Building V8 on Windows with Visual Studio 2017
At the very end of the build I received this error: *C:\Dev\common\v8>ninja -C out.gn/x64.release* *ninja: Entering directory `out.gn/x64.release'* *[1/7] LINK cctest.exe cctest.exe.pdb* *FAILED: cctest.exe cctest.exe.pdb* *ninja -t msvc -e environment.x64 -- ../../third_party/llvm-build/Release+Asserts/bin/lld-link.exe /nologo /OUT:./cctest.exe /PDB:.* */cctest.exe.pdb @./cctest.exe.rsp ../../third_party/llvm-build/Release+Asserts/bin\lld-link.exe: error: : undefined symbol: mainCRTStartup* *ninja: build stopped: subcommand failed.* Looks like the tests are broken somehow... Any ideas? -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] Re: Building V8 on Windows with Visual Studio 2017
I didn't see you post until now. I solved the issue running this: C:\Dev\common\v8\tools\clang\scripts>*python.bat update.py* Which brought down all the bin files I needed into *third_party/llvm-build* and now it's compiling! > > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[v8-users] Re: Building V8 on Windows with Visual Studio 2017
Oh and I've tried running: *gclient sync *from my v8 directory: C:\Dev\common\v8>gclient sync C:\Dev\common\.gclient_entries missing, .gclient file in parent directory C:\Dev\common might not be the file you want to use. and it doesn't seem to bring down *third_party/llvm-build* Should it?? What am I missing? -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[v8-users] Building V8 on Windows with Visual Studio 2017
I'm trying to build V8 as a static library using Visual Studio 2017 (apparently 2017 is now required). I've done it in the past with VC 2015 successfully. After setting many environment variables and paths and following all the instructions multiple times it still won't work. I've got this in my PATH: C:\utility\depot_tools;C:\Utility\depot_tools\win_tools-2_7_6_bin\python\bin\ And these variables set: DEPOT_TOOLS_WIN_TOOLCHAIN = 0 GYP_MSVS_OVERRIDE_PATH = C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional GYP_MSVS_VERSION = 2017 WINDOWSSDKDIR = C:\Program Files (x86)\Windows Kits\10 My args.gn file contains this: is_debug = false target_cpu = "x64" is_component_build = false v8_static_library = true I think the build process seems to be looking for this: *../../third_party/llvm-build/Release+Asserts/bin/clang-cl.exe* Which was not installed, and I don't have. See build errors below. This repeats quite a few times for different .obj files. C:\Dev\common\v8>ninja -C out.gn/x64.release ninja: Entering directory `out.gn/x64.release' [1/1711] CXX obj/v8_libbase/bits.obj FAILED: obj/v8_libbase/bits.obj ../../third_party/llvm-build/Release+Asserts/bin/clang-cl.exe /nologo /showIncludes "-imsvc..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.14.26428\ATLMFC\include" "-imsvc..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.14.26428\include" "-imsvc..\..\..\..\..\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-imsvc..\..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-imsvc..\..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-imsvc..\..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-imsvc..\..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-imsvc..\..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" -D_CRT_RAND_S -DV8_DEPRECATION_WARNINGS -DUSE_AURA=1 -DNO_TCMALLOC -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED "-DCR_CLANG_REVISION=\"335608-1\"" -D_HAS_NODISCARD -D_HAS_EXCEPTIONS=0 -D__STD_C -D_CRT_RAND_S -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE -D_ATL_NO_OPENGL -D_WINDOWS -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS -DPSAPI_VERSION=1 -DWIN32 -D_SECURE_ATL -D_USING_V110_SDK71_ -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -DWIN32_LEAN_AND_MEAN -DNOMINMAX -D_UNICODE -DUNICODE -DNTDDI_VERSION=0x0A02 -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64 -DENABLE_MINOR_MC -DV8_INTL_SUPPORT -DENABLE_HANDLE_ZAPPING -DV8_USE_SNAPSHOT -DV8_USE_EXTERNAL_STARTUP_DATA -DV8_CONCURRENT_MARKING -DV8_EMBEDDED_BUILTINS -DV8_TARGET_ARCH_X64 -I../.. -Igen -I../.. -Igen /utf-8 /X -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -fcolor-diagnostics -fmerge-all-constants -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -fcomplete-member-pointers /Gy /FS /bigobj /d2FastFail /Zc:sizedDealloc- -fmsc-version=1911 -m64 /Brepro /W4 -Wimplicit-fallthrough -Wthread-safety /WX /wd4091 /wd4127 /wd4251 /wd4275 /wd4312 /wd4324 /wd4351 /wd4355 /wd4503 /wd4589 /wd4611 /wd4100 /wd4121 /wd4244 /wd4505 /wd4510 /wd4512 /wd4610 /wd4838 /wd4995 /wd4996 /wd4456 /wd4457 /wd4458 /wd4459 /wd4200 /wd4201 /wd4204 /wd4221 /wd4018 /wd4245 /wd4267 /wd4305 /wd4389 /wd4702 /wd4701 /wd4703 /wd4661 /wd4706 /wd4715 /wd4702 -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-address-of-packed-member -Wno-nonportable-include-path -Wno-user-defined-warnings -Wno-unused-lambda-capture -Wno-null-pointer-arithmetic -Wno-enum-compare-switch -Wno-ignored-pragma-optimize /Z7 -fno-standalone-debug /MT -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wmissing-field-initializers -Winconsistent-missing-override -Wunreachable-code -Wshorten-64-to-32 /wd4245 /wd4267 /wd4324 /wd4701 /wd4702 /wd4703 /wd4709 /wd4714 /wd4715 /wd4718 /wd4723 /wd4724 /wd4800 /O2 /Ob2 /Oy- /Zc:inline /Gw /TP /wd4577 /GR- /c ../../src/base/bits.cc /Foobj/v8_libbase/bits.obj /Fd"obj/v8_libbase_cc.pdb"CreateProcess failed: The system cannot find the file specified. How do I fix this? Do I need *third_party/llvm-build/Release+Asserts/bin/clang-cl.exe* ?? or is there some other magic switch I need to set? Thanks, Mike -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit
Re: [v8-users] Building v8 using Visual Studio 2015
Are you building & debugging with the Visual Studio IDE? Using a Visual Studio solution (.sln) file? I'm still on VS2013 and would LOVE to be able to use the IDE over DOS ninja commands. Can you point me to those instructions on how to make this happen? Thanks a lot! -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] Thread cleanup
I've got a server side implementation which uses multiple threads and a pool of Isolates. I've had unexplained V8 memory growth issues for a long time now which forces me to bounce the service every night. If V8 has any thread cleanup problem's I for one would love to see that fixed ASAP. I don't care if its automatic of if I have to call a special API. Just plug the leak. Thanks, Mike M. On Monday, October 19, 2015 at 4:18:22 PM UTC-5, Jakob Kummerow wrote: > > Yes, that's what I meant. I'd probably choose a more descriptive name, > like "DiscardThreadSpecificMetadata()" or somesuch. I'm not the right > person to approve/review an API change like this, though, so sending a > proposal to v8-dev sounds good. > > On Mon, Oct 19, 2015 at 5:30 PM, Alex Kodat> wrote: > >> Fair enough. I now understand that by "unintrusive" you meant "can't >> cause bugs" -- a very good interpretation. >> >> So would you be amenable to something like the following in v8.h (in the >> Isolate class block): >> >> /** >>* Indicates that the current thread is finished using this isolate. >>* The isolate must not be locked or entered by the current thread. >>*/ >> void ThreadDone(); >> >> ? I promise I won't touch a single existing method. If you're OK with >> this I should probably switch over to using v8-dev for any other issues? I >> appreciate the time you've given this. >> >> On Monday, October 19, 2015 at 3:01:47 AM UTC-7, Jakob Kummerow wrote: >>> >>> Well, there can be N threads acquiring and releasing locks for M >>> isolates in arbitrary sequences. I don't think extending the Locker in any >>> way would be the right approach. If anything, it should be a separate API >>> call with the semantics "I, the embedder, promise that the thread with the >>> id X will never come back, please discard any and all data associated with >>> it". >>> >>> That said, this issue isn't really on my list of things to spend time >>> on. In particular, that means I don't intend to think through the >>> implications and/or refactorings that may or may not be necessary or >>> desirable. When in doubt, I'd prefer to keep everything as it is. >>> >>> On Mon, Oct 19, 2015 at 7:56 AM, Alex Kodat wrote: >>> Sorry, I was too hasty. Obviously, one doesn't need the Isolate lock to remove PerIsolateThreadData from the linked list, one needs the thread_data_table_mutex_ lock. FWIW, it strikes me as very odd that ThreadDataTable is process-wide with a static pointer. Given that its lone data member is the chain anchor for PerIsolateThreadData objects it seems that a ThreadDataTable object could be inside the Isolate and not take up any more space and probably be protected by the Isolate lock so eliminate the need for a separate mutex. Neverthless, I was wrong and, in theory, one could have a totally Locker-independent call to free a thread's PerIsolateThreadData. But, since one could not free the current thread's PerIsolateThreadData while there is a Locker on the thread's stack, freeing PerIsolateThreadData still seems pretty tightly associated with the Locker class so I think I'd stick with my proposals. Also, FWIW, I did a bit more research and the only thing of substance that seems to survive a top_level_ && has_lock_ Locker destruction is a thread's Simulator. And while, I admit I don't fully understand the Simulator code it seems unlikely that a thread's Simulator would hold state that would need to survive an unlock/lock. Admittedly, deleting and then reconstructing a Simulator would not be cheap but I would assume someone using a Simulator would not be expecting particularly high performance, anyway? On Sunday, October 18, 2015 at 11:06:27 AM UTC-7, Alex Kodat wrote: > > Jakob, > > Thanks for that. I might just take a swing at an unintrusive patch. > Along those lines it seems that thread resource cleanup would be closely > tied to the Locker as one would need the isolate lock while freeing > PerIsolateThreadData but would presumably want to release the lock > immediately after. So it seems the most logical approach would be a > Locker > class variable called say cleanup_ that's set either with an extra > parameter on the Locker constructor or a Locker method to clean up at > destruction time (both with appropriate semantics if not top_level_ or > has_lock_). > > But just want to make sure that this couldn't be even made less > intrusive by just always cleaning up if top_level_ and has_lock_ in the > Locker destructor. As it is, in this case > ThreadManager::FreeThreadResources ends up being called which doesn't > seem > to leave a heck a lot of useful stuff around for the thread so leaving a > few
[v8-users] Re: New feature: handle eternalization
Found another bug in Eternal. The IsEmpty() method is returning an inverted value. Broken code: V8_INLINE(bool IsEmpty()) { return index_ != kInitialValue; } Should be: V8_INLINE(bool IsEmpty()) { return index_ == kInitialValue; } Here is the bug report: https://code.google.com/p/v8/issues/detail?id=2870 -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] passing callback function to JS method
I could except the function argument to the execut method is optional. If the argument exists I covert it. Otherwise I don't Using the explicit constructor would cause a scoping issue. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] passing callback function to JS method
Thanks, I'll try it. I was looking for the *ToFunction()* method... I didn't know *As()* even existed. Recent changes have broke pretty much everything I've ever done with V8. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[v8-users] Using Context::Scope with new Persistent
It seems that recent changes to Persistent have broken a simple use case. This example no longer compiles since Persistent is no longer derived from Handle. What am I missing?? PersistentContext ctx; Context::Scope context_scope(ctx); -- won't compile. cannot convert parameter 1 from 'v8::PersistentT' to 'v8::HandleT' with [ T=v8::Context ] No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[v8-users] Re: Using Context::Scope with new Persistent
You need a LocalContext not a Persistent. 1st question is why? It's seems like needless complexity. 2nd question is what is the correct way to do this? I've got many situations where I can no longer pass in a Persistent and must make a Local of various types like: PersistentScript PersistentObject PersistentContext etc... Seems like there are possibly several ways to do it: As() Cast() other? Thanks -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[v8-users] passing callback function to JS method
How do I convert an incoming argument to a LocalFunction? It's basically a script progress callback function that I need to fire in the calling script. See the following stripped down example code in yellow which used to work: void MyObject_execute(const FunctionCallbackInfoValue args) { LocalFunction funcProgress; funcProgress = Function::Cast(*args[0]); --Error here. } error C2248: 'v8::LocalT::Local' : cannot access private member declared in class 'v8::LocalT' with [ T=v8::Function ] V8\include\v8.h(430) : see declaration of 'v8::LocalT::Local' with [ T=v8::Function ] -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[v8-users] Re: New feature: handle eternalization
Dan, I think something is broken in the new Eternal API. This example code block fails to compile. Seems ObjectTemplate is missing a Cast method? EternalObjectTemplate eternal; LocalObjectTemplate tmplXFile; tmplXFile = eternal.Get(pIsolate); eternal.Set(pIsolate, tmplXFile); V8\include\v8.h(406) : error C2039: 'Cast' : is not a member of 'v8::ObjectTemplate' V8\include\v8.h(3455) : see declaration of 'v8::ObjectTemplate' V8\include\v8.h(5697) : see reference to function template instantiation 'v8::LocalT v8::LocalT::Castv8::Value(v8::Localv8::Value)' being compiled with [ T=v8::ObjectTemplate ] V8\include\v8.h(5696) : while compiling class template member function 'v8::LocalT v8::EternalT::Get(v8::Isolate *)' with [ T=v8::ObjectTemplate ] .\RXFile.cpp(452) : see reference to class template instantiation 'v8::EternalT' being compiled with [ T=v8::ObjectTemplate ] V8\include\v8.h(406) : error C2784: 'v8::LocalT v8::LocalT::Cast(v8::LocalS)' : could not deduce template argument for 'v8::LocalS' from 'v8::Value *' with [ T=v8::ObjectTemplate ] V8\include\v8.h(400) : see declaration of 'v8::LocalT::Cast' with [ T=v8::ObjectTemplate ] V8\include\v8.h(6285) : error C2440: 'static_cast' : cannot convert from 'v8::ObjectTemplate *' to 'v8::Value *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast V8\include\v8.h(5691) : see reference to function template instantiation 'v8::Value *v8::Value::CastT(T *)' being compiled with [ T=v8::ObjectTemplate ] .\RXFile.cpp(455) : see reference to function template instantiation 'void v8::EternalT::Setv8::ObjectTemplate(v8::Isolate *,v8::LocalT)' being compiled with [ T=v8::ObjectTemplate ] -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[v8-users] Re: New feature: handle eternalization
Dan, Did the new Eternal land yet? I'm porting code now and would like to use it. Mike M. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[v8-users] Re: New feature: handle eternalization
It's getting clearer but less useful. So the Eternal object stores the index for me. Right? Doesn't that mean I have to now keep the Eternal object around in my code? How is keeping an Eternal around better than keeping a Persistent around? It would be nice if the user could specify the unique index of the eternal. Then all I ever need to keep is a constant integer value. const MY_OBJECT_TEMPLATE_ID = 12345; No extra object to keep around. Once the Local is saved as an eternal I can get it back with a simple hash lookup (GetEternal()) LocalObject local = LocalObject::GetEternal(isolate, MY_OBJECT_TEMPLATE_ID ); How does that sound? -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] Re: Making v8::Persistent safe to use
Honestly right now persistent is so hard to use his suggestion would be welcome. Making the end user build his own ref counting scheme around Persistent is not better IMO. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[v8-users] Persistent MakeWeak callback signature change?
Seems the Persistent::MakeWeak has changed. I can't figure out how to fix it. static void JSLogFile_DestructorCallback(Isolate* env, PersistentValue* value, void* pNative); ... obj.MakeWeak(pIsolate, pFile, JSLogFile_DestructorCallback); THIS LINE FAILS TO COMPILE error C2664: 'void v8::PersistentT::MakeWeakRJSLogFile(v8::Isolate *,P *,void (__cdecl *)(v8::Isolate *,v8::PersistentT *,P *))' : cannot convert parameter 3 from 'void (__cdecl *)(v8::Isolate *,v8::PersistentT *,void *)' to 'void (__cdecl *)(v8::Isolate *,v8::PersistentT *,P *)' with [ T=v8::Object, P=RJSLogFile ] and [ T=v8::Value ] and [ T=v8::Object, P=RJSLogFile ] None of the functions with this name in scope match the target type What am I missing?? Thanks! -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] Persistent MakeWeak callback signature change?
Ah. That's better than void anyway. Made the change. Still errors out. Seems P * isn't matching RJSLogFile* ?? What other magic do I need to declare this properly? Some template love? static void JSLogFile_DestructorCallback(Isolate* env, PersistentValue* value, RJSLogFile* pLogFile); error C2664: 'void v8::PersistentT::MakeWeakRJSLogFile(v8::Isolate *,P *,void (__cdecl *)(v8::Isolate *,v8::PersistentT *,P *))' : cannot convert parameter 3 from 'void (__cdecl *)(v8::Isolate *,v8::PersistentT *,RJSLogFile *)' to 'void (__cdecl *)(v8::Isolate *,v8::PersistentT *,P *)' with [ T=v8::Object, P=RJSLogFile ] and [ T=v8::Value ] and [ T=v8::Object, P=RJSLogFile ] None of the functions with this name in scope match the target type -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] Persistent MakeWeak callback signature change?
I got it to compile by adding the stuff in yellow (don't know if will work however) THIS: obj.MakeWeak(pIsolate, pFile, JSLogFile_DestructorCallback); TO THIS: obj.MakeWeak*v8::Value, RJSLogFile*(pIsolate, pFile, RJSLogFile::JSLogFile_DestructorCallback); So it seams MakeWeak needs some extra special template magic... -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] Re: Making v8::Persistent safe to use
I think that's a GREAT idea! I was planning on sticking my Persistent in a ref counted object. Why not add this to Persistent instead? Seems like this idea solves lots of problems. How many does it create? -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[v8-users] Re: New feature: handle eternalization
I know this may sound stupid... but how can I kill an eternal? Really nothing lives forever. I can think of a case where i might want to destroy one. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[v8-users] Re: Persistent::WrapperClassId size reduction
255 isn't a very big number. For debugging purposes its almost nicer a have a string (i.e. Ben's BABE below) Numbers are harder on the eyes and less meaningful. On Monday, August 5, 2013 5:56:56 AM UTC-5, Dan Carney wrote: Hi all, is anyone using more than a few bits of the Persistent::WrapperClassId field? I'm not seeing a lot of uses in the wild, and I'd like to cut it down from a uint16_t to a uint8_t. Thanks, Dan -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[v8-users] Re: Holding v8:Persistent handles
Dan, When do you think the Persistent changes will be complete?? Its hard to wait. Without all the features in there it's hard to use. Sort of a mine field... -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] Re: Making v8::Persistent safe to use
Thanks for your help. Something isn't quite right in my head yet. Can you take my code snippet and re-compile it with your changes (gnarly ones too)? I think there are more errors yet in there. Thank you! -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] C++ lifetime management via shared_ptr and
Sven, This problem keeps biting embedders over and over and over. Even if Chrome does not need it... The rest of the world needs a way to GUARANTEE that C++ backed JS objects get destroyed in a reliable and predicable manner. There are many hacks people use to try to get weak callbacks to fire. This is just another attempt. Can you or anyone propose a mechansim for fixing this? I would be happy to attempt implementation if a decent proposal would come forward for: 1) Guaranteeing weak callbacks for all objects fire on shutdown of V8. (necessary for proper memory leak testing) 2) A mechansim for telling V8 to collect garbage and fire weak callbacks on demand. If we don't fix this right, everyone and their uncle will be using this solution... We have no other choice. Mike M. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] C++ lifetime management via shared_ptr and
Your specific problem is easily solved with ref-counted objects on the C++ side. I've done exactly this with your same use case. It works fine. Please lets move the problem forward in a positive manner. This is a problem that absolutely can and NEEDS to be solved. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] C++ lifetime management via shared_ptr and
But it's not going to be at the v8 level. A few years back one of the v8 devs said (in a post on this list, but i have no link handy) that v8 does not gc at shutdown because (i'm paraphrasing), it negatively impacts Chrome's shutdown time. i think most of us will agree that shutting down cleanly is better than shutting down quickly, but JS was not really intended (it was pointed out in that thread or a similar one) to be used with types which require proper destructor calls to ensure proper behaviour of the system. So, that's a positive answer in the sense that i'm positive v8 will never guaranty such a feature. v8's only _real_ concern, as far as directly adapting to customer needs, is Chromium and friends. (That's based off of my own observations over my years on this list, and not a sentiment expressed directly from anyone working on v8 (more implied by various answers they've provided).) That's not positive at all! The past doesn't matter. Nor does something that somebody said x months ago. Please spare us from meaningless speculation. Software evolves and changes all the time. (threading support via Isolates are an example of this) Passing an optional boolean to indicate that full GC at shutdown is desired is very easy to add. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[v8-users] implementing ObjectTemplate HasInstance() method
After digging into object construction using FunctionTemplate or ObjectTemplate in this post: https://groups.google.com/forum/?fromgroups=#!topic/v8-users/521aXb3Uer4 I believe the ObjectTemplate is missing a HasInstance() method for use in testing arguments to JS functions to be of a certain type. While it is possible to use FunctionTemplate for this purpose (since HasInstance() exists), the FunctionTemplate method of construction is convoluted and messy since it requires two FunctionTemplates or a hack to prevent constructor recursion. My proposal is to create HasInstance() on the ObjectTemplate class. I'm looking for guidance on the best way to accomplish this. *Questions:* 1) How can I get the ObjectTemplate that was used to create an instance of an Object? 2) How can I get the constructor for both the ObjectTemplate and the Object and compare them? My assumption is that I should be comparing the constructors for equality. The internals of v8 use a class called ObjectTemplateInfo which is somewhat confusing to me at this point. Thanks for the help! -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] How to test an Argument for InstanceOf() type
I originally created an ObjectTemplate which I also Set() in another ObjectTemplate used as argument to Context::New() It appears ObjectTemplate can't do HasInstance(). When should I use the FunctionTemplate versus ObjectTemplate?? It's a tad confusioning... -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] How to test an Argument for InstanceOf() type
I tried to use a FunctionTemplate for the object. Howerver, the FunctionTemplate does not have SetCallAsFunctionHandler() which I need to construct the object.. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] How to test an Argument for InstanceOf() type
Why? Because I can't find a complete example of how to do it any other way... I need more then a two line explanation. The lack of quality documentation and straight forward examples is outstanding. All the examples use ObjectTemplates. The embedders guide does too. Also the object I'm creating has many other methods too (not just a constructor). I create an object template, give it a SetCallAsFunctionHandler() (so I can create it in C++ land) then add a whole bunch of other methods using Set() then I Set() that object template into another ObjectTemplate which used by the Context::New() when setting up the global. That's my understanding of how it is supposed to work. Ben, I this post you were doing HasInstance() with a hack involving SetPointerInInternalField() https://groups.google.com/forum/#!topic/nodejs/PA3cNIZuFWU What that before you knew better? Thanks for the help -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] How to test an Argument for InstanceOf() type
Ben, Can you expand on your example? I'm sure this is piece of cake for you, but I'm not getting what you mean. All the samples I can find show using ObjectTemplate and the SetCallAsFunctionHandler() to handle construction from the C++ side. var o = new MyObject(); var x = new MyObject(); o.doSomething(x); In the above example doSomething() needs to simply validate its 1st argument is of type MyObject. That's it. Apparently HasInstance() (from FunctionTemplate) is for this purpose. But ObjectTemplate doesn't have a HasInstance() method. My object has to do more than just be constructed. It's got other methods too. How can I fire a C++ constructor function with a FunctionTemplate and have other methods on the object? Without a more concrete example I'm lost. I do appreciate the willingness to help. THANK YOU. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[v8-users] How to test an Argument for InstanceOf() type
If I have an object I injected into the global using an ObjectTemplate. The user creates one in script like this: var o = new MyObject(); That fires my SetCallAsFunctionHandler() which creates the object using the ObjectTemplate and NewInstance() and passes it back to javascript land. Now the script passes that object to another function doSomething which only accepts an argument of type MyObject doSomething(o); How can the C++ native implementation of doSomething() check the type of object and validate it if of type MyObject? HandleValue Class::doSomething(const Arguments args) { //Takes 1 argument that MUST be an instance of MyObject. if(args.Length()0 || !args[0]-IsObject() || !args[0]-InstanceOf(MyObject))--- Here's the magic. How do I test for a specific type of object?? Do I use the ObjectTemplate somehow? { v8::ThrowException(v8::String::New(doSomething() requires a MyObject object for parameter 1)); } ... -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[v8-users] callback Function Call receiver argument
I'm trying to do a simple callback into a JS script. The script does something like this: function OnProgress(percent) { //Do something } myObj-setProgressCallback(OnProgress); //Tell it how to call us back... My native C++ code stores the function passed to setProgressCallback in a PersistentFunction then proceeds to call it later when appropriate. The call is performed like this: HandleValue argv[1]; argv[0] = v8::Number::New(100); TryCatch try_catch; HandleValue result = myStuff-m_fnProgressCallack-Call(???, 1, argv); What is the 1st parameter to the Call() method supposed to take? What is the receiver object? Passing in an empty handle breaks it. If I pass in the function itself I get this error: called_non_callable What is the secret? -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] callback Function Call receiver argument
The script code should be: *myObj.setProgressCallback(OnProgress); //Tell it how to call us back...* There is no - operator in javascript! Its still not working however. See native C++ code below. Does that line in RED look correct? There is no ToFunction() method on args[0] so I did an ugly cast. HandleValue MyObj::setProgressCallback(const Arguments args) { //Argument validation left out for brevity //Unwrap code left out for brevity... LocalFunction funcProgress; LocalObject thisObject; if(iArgs 0) { * funcProgress = Function::Cast(*(args[0])); * thisObject = v8::Context().GetCurrent()-Global(); //Save them for later callbacks. myObject-m_fnProgressCallack = PersistentFunction::New(m_pIsolate, funcProgress); myObject-m_objProgressCallackThisObject = PersistentObject::New(m_pIsolate, thisObject); } return v8::True(); } -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] callback Function Call receiver argument
In the V8 sources the Call() method is throwing an exception. IsJSFunction() is returning false and TryGetFunctionDelegate() is setting a pending exception. execution.cc line 283. if (!callable-IsJSFunction()) { callable = TryGetFunctionDelegate(callable, pending_exception); if (*pending_exception) return callable; } *The error that is thrown is a TypeError: called_non_callable* -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] callback Function Call receiver argument
It seems that after saving off a Persistent copy of the function V8 doesn't think its a function anymore! ASSERT(args[0]-IsFunction()); -- This works. LocalFunction funcProgress; *funcProgress = Function::Cast(*args[0]);* PersistentFunction fnProgressCallack = PersistentFunction::New(args.GetIsolate(), funcProgress); * * *ASSERT(fnProgressCallack-IsFunction()); --- This fails.* What am I doing wrong here?? -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] callback Function Call receiver argument
I solved it. In my actual code I was simple using the wrong argument. Doh! argv[2] instead of argv[1]. Feeling really stupid... -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[v8-users] V8 Global Object property dump
I'm looking for a simple piece of code that can take a V8 Global Object and dump out all its properties. Basically iterate the global and print out a listing of every property and object by name and type information. This is for debugging an issue where the engine says a property doesn't exist that should be there. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[v8-users] Re: TerminateExecution() does not terminate threads calling sleep() in FunctionTemplate
Don't use sleep(). Use WaitForSingleObject() instead with a timeout equal to the number of seconds you want to sleep. Wait on an event that is never signaled unless your thread is being terminated. HANDLE hSleepEvent = CreateEvent(NULL, FALSE, FALSE, NULL); //Here's how you do the sleep WaitForSingleObject(hSleepEvent, 5000); //Wait for entire 5 seconds or until the event is signaled. //Here's how to wake up the sleeper SetEvent(hSleepEvent); //Don't forget to do this when you are done with the handle. CloseHandle(hSleepEvent); -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] V8 Global Object property dump
I'm using Visual Studio to build V8. Note sure where/how --allow-natives-syntax comes into play. Ideas? -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] V8 Global Object property dump
I embed V8 in my application(s). No shell or chromium etc.. V8 is a static library linked into my applications. What magic does *--allow-natives-syntax* do v8 or chromium? -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[v8-users] V8 v8::Persistentv8::Primitive to v8::Primitive
I'm using V8 javascript engine and storing some values in a C++ object using this: v8::Persistentv8::Primitive m_Value; I want to use the saved value to set another Primitive and return it like this: bool MyClass::Convert(v8::Primitive oValue) { oValue.Clear();//Clear() is not a valid method for Primitive. How can I clear it or set it to Null or Undefined or Empty? oValue= m_Value; } The 2nd line results in a compiler error: binary '=' : no operator found which takes a right-hand operand of type 'v8::PersistentT' (or there is no acceptable conversion) How do I get the Primitive value back out of the Persistent? I've tried to dereference m_Value. No luck. This HAS to be simple... -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] V8 v8::Persistentv8::Primitive to v8::Primitive
The method is basically a Getter(). Has no purpose other than to change the Primitive value coming in to another value. I need a SetData() and GetData() method to change the underlying Persistent Primitive to another Primitive. If stored value should not be: v8::Persistentv8::Primitive m_Value; What should it be? I'm a longtime spidermonkey guy making the move to V8. Don't spare the details... Thanks! -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups v8-users group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [v8-users] V8 debug protocol script [includesource]
On Oct 8, 2010 1:56 AM, Vincent Han ofnil...@gmail.com wrote: Hi all I'm studying V8 Debug protocol using Android 2.2 Protocol processing between Chromium and ChromDevTools is like below(only v8 protocol) request command:version response of req (version) request command:scripts arg:includeSource response of req (scripts) body: source that requested... so I modified the V8 source for EnableAgent and compile succeed. Then I connect to V8 debugger and got right response for several request like version, setbreakpoint, etc.. == request version Content-Length:47 {seq:0,type:request,command:version} response Content-Length: 128 {seq:0,type:response,command:version,success:true,body: {V8Version:2.1.3 (candidate)},refs:[],running:true} == But Android Browser is forced terminated with SIGILL when I requested scripts or frame request protocol. == request scripts Content-Length:48 {seq:11,type:request,command:scripts} lost host connection == browser is forced terminated request scripts Content-Length:93 {seq:2,type:request,command:scripts,arguments: {includeSource:true,ids:[22]}} lost host connection == browser is forced terminated == I want to get sources like between Chromium and ChromDevTools. Am I miss something? Plz help me! -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users