[v8-users] Building in VS2013 fails for cctest project
Building in VS2013 fails for cctest project with the following warnings treated as error. 8test-cpu-profiler.cc(57): error C2220: warning treated as error - no 'object' file generated 8test-cpu-profiler.cc(57): warning C4316: 'v8::internal::ProfilerEventsProcessor' : object allocated on the heap may not be aligned 64 8test-cpu-profiler.cc(145): warning C4316: 'v8::internal::ProfilerEventsProcessor' : object allocated on the heap may not be aligned 64 8test-cpu-profiler.cc(207): warning C4316: 'v8::internal::ProfilerEventsProcessor' : object allocated on the heap may not be aligned 64 8test-cpu-profiler.cc(276): warning C4316: 'v8::internal::ProfilerEventsProcessor' : object allocated on the heap may not be aligned 64 -- -- 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: V8 how to swallow javascript uncaught exception and continue running script
Well you obviously need to catch the error raised on the javascript side and not on the c++ side try { document.write('foo'); } catch (e) { //handle error } finally { //cleanup } var str = 'hello' + 'world'; On Friday, November 8, 2013 9:56:23 AM UTC+2, Michael demiGod wrote: script: 1 document.write('foo'); 2 var str = 'hello' + 'world'; 3 ... cpp: v8::TryCatch try_catch; v8::Handle result = script-Run(); result: test.js:1: Uncaught ReferenceError: document is not defined Although I can use v8::trycatch to get exception info, I'll miss the following script. Is there any way to continue running script and get 'helloworld', ignoring the Uncaught ReferenceError of first line? -- -- 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: Overloading operators on the JS side
I think what you need is: ObjectTemplate::SetIndexedPropertyHandler On Wednesday, October 30, 2013 8:39:54 PM UTC+2, Flying Jester wrote: Let's say I have an object on the C++ side that is wrapped for use in JS. It has several member functions attached to its prototype. Is there a way to allow this object to be used, for instance, just like an array as well on the JS side, which will access values specified on the C++ side? Like this: (js) var byteArrayObject = new byteArray(Some String); //constructor defined in C++. It now holds the string as a series of bytes. var stringy = byteArrayObject.CreateString(); //stringy now holds Some String. This is simple to make work. var thirdCharacter = byteArrayObject[2]; //thirdCharacter holds m. (/js) How would this be done? Is there a way to modify how operators like brackets (or more generally, any operator) on the JS side handle objects created from constructors that are defined in C++? -- -- 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] Gargabe Collector initiated in a worker thread is causing me a crash
Okay, after a lot of trial and error, i think i got the hang of it... Had to use both Locker and Unlocker to get it to work. On Thursday, October 10, 2013 5:28:52 PM UTC+3, ioannis wrote: Well, you make it sound soo easy ... I have read the documentation in v8.h and how it was done in d8.cc but i still cant get ti to work. On Wednesday, October 9, 2013 11:37:50 AM UTC+3, Ben Noordhuis wrote: On Wed, Oct 9, 2013 at 4:15 AM, ioannis ioan...@gmail.com wrote: Ok, so i'm going nuts here, v8 v. I have a worker thread that is executed based on events raised from my object. The thread uses the same isolate and context from the JS object So the thread is initiated like below and is working. Isolate* isolate = object_-isolate_; Isolate::Scope isolate_scope(isolate); HandleScope handle_scope(isolate); Context::Scope context_scope(isolate-GetCurrentContext()); ... LocalObject new_obj(obj_templ-NewInstance()); The problem arises when v8 runs out of memory and v8 calls the garbage collector to free some space before creating the object. Then i get a crush: # # Fatal error in ..\..\src\frames.cc, line 1333 # CHECK(it.done()) failed # With the following stack: v8::internal::OS::DebugBreak() Line 953 C++ v8::internal::OS::Abort() Line 941 C++ V8_Fatal(0x00efa784, 1333, 0x00efa770, ...) Line 86 C++ v8::internal::EntryFrame::Iterate(0x04c2e498) Line 1333 C++ v8::internal::Isolate::Iterate(0x04c2e498, 0x017b4e8c) Line 497 C++ v8::internal::Isolate::Iterate(0x04c2e498) Line 508 C++ v8::internal::Heap::IterateStrongRoots(0x04c2e498, VISIT_ALL_IN_SCAVENGE) Line 6383 C++ v8::internal::Heap::IterateRoots(0x04c2e498, VISIT_ALL_IN_SCAVENGE) Line 6357 C++ v8::internal::Heap::Scavenge() Line 1395 C++ v8::internal::Heap::PerformGarbageCollection(SCAVENGER, 0x04c2e568) Line 958 C++ v8::internal::Heap::CollectGarbage(NEW_SPACE, SCAVENGER, 0x00e23fb0, 0x) Line 681 C++ v8::internal::Heap::CollectGarbage(NEW_SPACE, 0x00e23fb0) Line 546 C++ v8::internal::CopyAddConstantDescriptor({...}, {...}, {...}, FROZEN, OMIT_TRANSITION) Line 1991 C++ v8::internal::JSObject::AddConstantProperty({...}, {...}, {...}, FROZEN, INSERT_TRANSITION) Line 2011 C++ v8::internal::JSObject::AddProperty({...}, {...}, {...}, FROZEN, kNonStrictMode, MAY_BE_STORE_FROM_KEYED, PERFORM_EXTENSIBILITY_CHECK, OPTIMAL_REPRESENTATION, ALLOW_AS_CONSTANT, INSERT_TRANSITION) Line 2088 C++ v8::internal::JSObject::SetPropertyForResult({...}, 0x04c2e828, {...}, {...}, FROZEN, kNonStrictMode, MAY_BE_STORE_FROM_KEYED) Line 3958 C++ v8::internal::JSReceiver::SetProperty({...}, 0x04c2e828, {...}) Line 3421 C++ v8::internal::JSReceiver::SetProperty({...}, {...}, {...}, FROZEN, kNonStrictMode, MAY_BE_STORE_FROM_KEYED) Line 2764 C++ v8::internal::Runtime::SetObjectProperty(0x017b3560, {...}, {...}, {...}, FROZEN, kNonStrictMode) Line 5198 C++ v8::internal::__RT_impl_Runtime_SetProperty({...}, 0x017b3560) Line 5349 C++ v8::internal::Runtime_SetProperty(4, 0x04c2e9dc, 0x017b3560) Line 5324 C++ v8::internal::Invoke(false, {...}, {...}, 2, 0x04c2eb6c, 0x04c2ec5f) Line 119 C++ v8::internal::Execution::Call(0x017b3560, {...}, {...}, 2, 0x04c2eb6c, 0x04c2ec5f, false) Line 183 C++ v8::internal::Execution::ConfigureInstance(0x017b3560, {...}, {...}, 0x04c2ec5f) Line 789 C++ v8::internal::Factory::ConfigureInstance({...}, {...}, 0x04c2ec5f) Line 1634 C++ v8::internal::HandleApiCallHelper1({...}, 0x017b3560) Line 1164 C++ v8::internal::Builtin_Impl_HandleApiCallConstruct({...}, 0x017b3560) Line 1221 C++ v8::internal::Builtin_HandleApiCallConstruct(2, 0x04c2ecbc, 0x017b3560) Line 1220 C++ v8::internal::Invoke(false, {...}, {...}, 1, 0x04c2ee68, 0x04c2eebf) Line 119 C++ v8::internal::Execution::Call(0x017b3560, {...}, {...}, 1, 0x04c2ee68, 0x04c2eebf, false) Line 183 C++ v8::internal::Execution::InstantiateObject({...}, 0x04c2eebf) Line 772 C++ v8::ObjectTemplate::NewInstance() Line 5308 C++ Can someone help me out here, or give me pointer of what is going wrong here ? Thanks. V8 is not thread-safe by default. If you are calling into the runtime from different threads, you need to lock appropriately with Locker objects. -- -- 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: Customize [[Class]] internal property?
If you are using the API to build your object then you can try the following: LocalFunctionTemplate func_templ(FunctionTemplate::New());func_templ-SetClassName(String::NewSymbol(ClassName));LocalObjectTemplate obj_templ = func_templ-InstanceTemplate(); On Friday, October 11, 2013 5:04:36 AM UTC+3, ChaRles Lew wrote: Hi, i've been reading ECMAScript specification recently. I've learned that Object.prototype.toString will generate a string like [object [[Class]]] for objects. And I'm curious how can I customize the [[Class]] internal property for my objects. Or shall i just rewrite this method and fake this behavior? By the way, in Chrome when this is the window object, this.toString() = [object window] but Object.prototype.toString.call(this) = [object global] Hey...The app i'm writing has a similar behavior and will use the global object in a similar way, how shall i avoid [object global] appearing? I want to ensure (at least pretend) its [[Class]] internal property is window etc. Looking forward for advice. 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] Gargabe Collector initiated in a worker thread is causing me a crash
Well, you make it sound soo easy ... I have read the documentation in v8.h and how it was done in d8.cc but i still cant get ti to work. On Wednesday, October 9, 2013 11:37:50 AM UTC+3, Ben Noordhuis wrote: On Wed, Oct 9, 2013 at 4:15 AM, ioannis ioan...@gmail.com javascript: wrote: Ok, so i'm going nuts here, v8 v. I have a worker thread that is executed based on events raised from my object. The thread uses the same isolate and context from the JS object So the thread is initiated like below and is working. Isolate* isolate = object_-isolate_; Isolate::Scope isolate_scope(isolate); HandleScope handle_scope(isolate); Context::Scope context_scope(isolate-GetCurrentContext()); ... LocalObject new_obj(obj_templ-NewInstance()); The problem arises when v8 runs out of memory and v8 calls the garbage collector to free some space before creating the object. Then i get a crush: # # Fatal error in ..\..\src\frames.cc, line 1333 # CHECK(it.done()) failed # With the following stack: v8::internal::OS::DebugBreak() Line 953 C++ v8::internal::OS::Abort() Line 941 C++ V8_Fatal(0x00efa784, 1333, 0x00efa770, ...) Line 86 C++ v8::internal::EntryFrame::Iterate(0x04c2e498) Line 1333 C++ v8::internal::Isolate::Iterate(0x04c2e498, 0x017b4e8c) Line 497 C++ v8::internal::Isolate::Iterate(0x04c2e498) Line 508 C++ v8::internal::Heap::IterateStrongRoots(0x04c2e498, VISIT_ALL_IN_SCAVENGE) Line 6383 C++ v8::internal::Heap::IterateRoots(0x04c2e498, VISIT_ALL_IN_SCAVENGE) Line 6357 C++ v8::internal::Heap::Scavenge() Line 1395 C++ v8::internal::Heap::PerformGarbageCollection(SCAVENGER, 0x04c2e568) Line 958 C++ v8::internal::Heap::CollectGarbage(NEW_SPACE, SCAVENGER, 0x00e23fb0, 0x) Line 681 C++ v8::internal::Heap::CollectGarbage(NEW_SPACE, 0x00e23fb0) Line 546 C++ v8::internal::CopyAddConstantDescriptor({...}, {...}, {...}, FROZEN, OMIT_TRANSITION) Line 1991 C++ v8::internal::JSObject::AddConstantProperty({...}, {...}, {...}, FROZEN, INSERT_TRANSITION) Line 2011 C++ v8::internal::JSObject::AddProperty({...}, {...}, {...}, FROZEN, kNonStrictMode, MAY_BE_STORE_FROM_KEYED, PERFORM_EXTENSIBILITY_CHECK, OPTIMAL_REPRESENTATION, ALLOW_AS_CONSTANT, INSERT_TRANSITION) Line 2088 C++ v8::internal::JSObject::SetPropertyForResult({...}, 0x04c2e828, {...}, {...}, FROZEN, kNonStrictMode, MAY_BE_STORE_FROM_KEYED) Line 3958 C++ v8::internal::JSReceiver::SetProperty({...}, 0x04c2e828, {...}) Line 3421 C++ v8::internal::JSReceiver::SetProperty({...}, {...}, {...}, FROZEN, kNonStrictMode, MAY_BE_STORE_FROM_KEYED) Line 2764 C++ v8::internal::Runtime::SetObjectProperty(0x017b3560, {...}, {...}, {...}, FROZEN, kNonStrictMode) Line 5198 C++ v8::internal::__RT_impl_Runtime_SetProperty({...}, 0x017b3560) Line 5349 C++ v8::internal::Runtime_SetProperty(4, 0x04c2e9dc, 0x017b3560) Line 5324 C++ v8::internal::Invoke(false, {...}, {...}, 2, 0x04c2eb6c, 0x04c2ec5f) Line 119 C++ v8::internal::Execution::Call(0x017b3560, {...}, {...}, 2, 0x04c2eb6c, 0x04c2ec5f, false) Line 183 C++ v8::internal::Execution::ConfigureInstance(0x017b3560, {...}, {...}, 0x04c2ec5f) Line 789 C++ v8::internal::Factory::ConfigureInstance({...}, {...}, 0x04c2ec5f) Line 1634 C++ v8::internal::HandleApiCallHelper1({...}, 0x017b3560) Line 1164 C++ v8::internal::Builtin_Impl_HandleApiCallConstruct({...}, 0x017b3560) Line 1221 C++ v8::internal::Builtin_HandleApiCallConstruct(2, 0x04c2ecbc, 0x017b3560) Line 1220 C++ v8::internal::Invoke(false, {...}, {...}, 1, 0x04c2ee68, 0x04c2eebf) Line 119 C++ v8::internal::Execution::Call(0x017b3560, {...}, {...}, 1, 0x04c2ee68, 0x04c2eebf, false) Line 183 C++ v8::internal::Execution::InstantiateObject({...}, 0x04c2eebf) Line 772 C++ v8::ObjectTemplate::NewInstance() Line 5308 C++ Can someone help me out here, or give me pointer of what is going wrong here ? Thanks. V8 is not thread-safe by default. If you are calling into the runtime from different threads, you need to lock appropriately with Locker objects. -- -- 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: Issues with a Persistent in a Struct?
Persistent is defined by default with NonCopyablePersistentTraits which means that it cannot be used in structs that allow copy/assignment operations. You can explicitly define Persistent with CopyablePersistentTraits in order to allow copy/assignment operations. I use the following type definition for cleaner code typedef PersistentFunction, CopyablePersistentTraitsFunction PersistentFunction; On Tuesday, October 8, 2013 5:55:14 AM UTC+3, Gregory Hlavac wrote: 1 c:\trs\trstrunk\branch\scriptingupdate\gamecore\ScriptedMission.h(49) : see reference to class template instantiation 'v8::PersistentT' being compiled 1 with 1 [ 1 T=v8::Function 1 ] So that's the error I'm getting located at this line. struct TimerInformation { int timerRemaining; PersistentFunction TimerCompleteCallback; }; 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/groups/opt_out.
[v8-users] Gargabe Collector initiated in a worker thread is causing me a crash
Ok, so i'm going nuts here, v8 v. I have a worker thread that is executed based on events raised from my object. The thread uses the *same* isolate and context from the JS object So the thread is initiated like below and is working. Isolate* isolate = object_-isolate_;Isolate::Scope isolate_scope(isolate);HandleScope handle_scope(isolate);Context::Scope context_scope(isolate-GetCurrentContext()); ... LocalObject new_obj(obj_templ-NewInstance()); The problem arises when v8 runs out of memory and v8 calls the garbage collector to free some space before creating the object. Then i get a crush: # # Fatal error in ..\..\src\frames.cc, line 1333 # CHECK(it.done()) failed # With the following stack: v8::internal::OS::DebugBreak() Line 953 C++ v8::internal::OS::Abort() Line 941 C++ V8_Fatal(0x00efa784, 1333, 0x00efa770, ...) Line 86 C++ v8::internal::EntryFrame::Iterate(0x04c2e498) Line 1333 C++ v8::internal::Isolate::Iterate(0x04c2e498, 0x017b4e8c) Line 497 C++ v8::internal::Isolate::Iterate(0x04c2e498) Line 508 C++ v8::internal::Heap::IterateStrongRoots(0x04c2e498, VISIT_ALL_IN_SCAVENGE) Line 6383 C++ v8::internal::Heap::IterateRoots(0x04c2e498, VISIT_ALL_IN_SCAVENGE) Line 6357 C++ v8::internal::Heap::Scavenge() Line 1395 C++ v8::internal::Heap::PerformGarbageCollection(SCAVENGER, 0x04c2e568) Line 958 C++ v8::internal::Heap::CollectGarbage(NEW_SPACE, SCAVENGER, 0x00e23fb0, 0x) Line 681 C++ v8::internal::Heap::CollectGarbage(NEW_SPACE, 0x00e23fb0) Line 546 C++ v8::internal::CopyAddConstantDescriptor({...}, {...}, {...}, FROZEN, OMIT_TRANSITION) Line 1991 C++ v8::internal::JSObject::AddConstantProperty({...}, {...}, {...}, FROZEN, INSERT_TRANSITION) Line 2011 C++ v8::internal::JSObject::AddProperty({...}, {...}, {...}, FROZEN, kNonStrictMode, MAY_BE_STORE_FROM_KEYED, PERFORM_EXTENSIBILITY_CHECK, OPTIMAL_REPRESENTATION, ALLOW_AS_CONSTANT, INSERT_TRANSITION) Line 2088 C++ v8::internal::JSObject::SetPropertyForResult({...}, 0x04c2e828, {...}, {...}, FROZEN, kNonStrictMode, MAY_BE_STORE_FROM_KEYED) Line 3958 C++ v8::internal::JSReceiver::SetProperty({...}, 0x04c2e828, {...}) Line 3421 C++ v8::internal::JSReceiver::SetProperty({...}, {...}, {...}, FROZEN, kNonStrictMode, MAY_BE_STORE_FROM_KEYED) Line 2764 C++ v8::internal::Runtime::SetObjectProperty(0x017b3560, {...}, {...}, {...}, FROZEN, kNonStrictMode) Line 5198 C++ v8::internal::__RT_impl_Runtime_SetProperty({...}, 0x017b3560) Line 5349 C++ v8::internal::Runtime_SetProperty(4, 0x04c2e9dc, 0x017b3560) Line 5324 C++ v8::internal::Invoke(false, {...}, {...}, 2, 0x04c2eb6c, 0x04c2ec5f) Line 119 C++ v8::internal::Execution::Call(0x017b3560, {...}, {...}, 2, 0x04c2eb6c, 0x04c2ec5f, false) Line 183 C++ v8::internal::Execution::ConfigureInstance(0x017b3560, {...}, {...}, 0x04c2ec5f) Line 789 C++ v8::internal::Factory::ConfigureInstance({...}, {...}, 0x04c2ec5f) Line 1634 C++ v8::internal::HandleApiCallHelper1({...}, 0x017b3560) Line 1164 C++ v8::internal::Builtin_Impl_HandleApiCallConstruct({...}, 0x017b3560) Line 1221 C++ v8::internal::Builtin_HandleApiCallConstruct(2, 0x04c2ecbc, 0x017b3560) Line 1220 C++ v8::internal::Invoke(false, {...}, {...}, 1, 0x04c2ee68, 0x04c2eebf) Line 119 C++ v8::internal::Execution::Call(0x017b3560, {...}, {...}, 1, 0x04c2ee68, 0x04c2eebf, false) Line 183 C++ v8::internal::Execution::InstantiateObject({...}, 0x04c2eebf) Line 772 C++ v8::ObjectTemplate::NewInstance() Line 5308 C++ Can someone help me out here, or give me pointer of what is going wrong here ? 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] Setter/Getter for function turns function into a string when the function is called?
As far as i understand *correct me if i'am wrong* you cannot have an object member to act as both a property (using getter/setter) and a calling function. It should be one of the two. So i guess you will need an object member, a property to get/set the update value string and another object member, a function that uses the property. On Sunday, October 6, 2013 8:59:54 PM UTC+3, James Lomax wrote: Oh yeah, I should go read the docs, 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] Setter/Getter for function turns function into a string when the function is called?
Ah yes you are right, i didn't read the post to its entirety, i just assumed that you were setting the value to a string for some unknown reason :) ... Sorry, apologies for the confusion. On Sunday, October 6, 2013 11:43:21 PM UTC+3, James Lomax wrote: You can, the problem was just that I was using a handle which went out of scope to manage the function. It works because functions are just objects in JavaScript and you can call them as such. I'm AFK ATM but I just pulled the below stuff from my dropbox mess-about project if you want to see the final working code. http://pastebin.com/FTXkGmcx -- -- 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 does v8 decide when to do garbage collection?
Thanks for the pointers. This would mean that i need to keep a record of all the objects that have been created dynamically and rebuild the relationships on every GC. Isn't this a bit expensive ? I was thinking something simpler by setting/removing the Weak flag on the parent object depending on the children object count, similar to node's ObjectWrap https://github.com/joyent/node/blob/master/src/node_object_wrap.h The question is how expensive is this ? The downside of this method it would take multiple GC cycles to clear the whole object tree, as it would process one level at a time... On Saturday, September 28, 2013 11:08:36 AM UTC+3, Ben Noordhuis wrote: A full example is a bit too involved for me to type out on a Saturday morning (before my morning coffee, even) but what you probably want is to declare the parent/child relationship as an object group. You can establish one by adding a GCPrologueCallback with v8::V8::AddGCPrologueCallback(). In that callback, you define the relationship with v8::V8::SetObjectGroupId() and v8::V8::SetReferenceFromGroup(). Check include/v8.h for more details. You can find examples in test/cctest/test-api.cc and a few others. -- -- 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 does v8 decide when to do garbage collection?
So i'm going to piggyback this post for some additional questions... 1) Is it safe to call v8::V8::IdleNotification() within a WeakCallback() to scavenge additional objects that have been set as weak in WeakCallback() ? I guess not.. i get a crash. 2) Also, lets say within a function scope if an object is declared local but it is set as Weak i'm experiencing a behavior that the object becomes garbage collected although it is still in scope... ie function foo() { var obj; //declared as weak on instantiation for (...) { var child_obj; //child object of obj also declared as weak on instantiation * //at some point obj although in scope becomes garbage collected* } } So is this an expected behavior or i'm i experiencing a bug ? Thanks. On Friday, September 27, 2013 1:52:27 PM UTC+3, Ben Noordhuis wrote: On Fri, Sep 27, 2013 at 12:04 PM, Craig Thomson cr...@craigthomson.me.uk javascript: wrote: Hi, I am trying to understand a bit of the v8 source to do with garbage collection and I am hoping that someone can give me a pointer in the right direction. How does v8 decide when to do Garbage collection? Is there a timer, or is it based on how much code is executed or something more complicated? Cheers, Craig Memory pressure, basically. When an allocation fails because the JS heap is full, that's when V8 starts collecting garbage. (The actual algorithm is more complicated, of course; it may also choose to grow the JS heap, for instance.) Embedders can call v8::V8::IdleNotification() to hint that now is a good time to do some scavenging. -- -- 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 does v8 decide when to do garbage collection?
Ben thanks for the reply... For q1) i figured as much... For q2) Hmm. indeed you are right, although an object may be in scope if it is not referenced after the point where GC is initiated then it is eligible for garbage collection. Is there a way to ensure that an object remains valid throughout the function scope irrespective if it is referenced or not ? Furthermore which is the best way to establish parent/child relationships between objects (with respect to garbage collection) ? Please provide a full cycle example if possible. On Friday, September 27, 2013 10:46:21 PM UTC+3, Ben Noordhuis wrote: On Fri, Sep 27, 2013 at 7:40 PM, ioannis ioan...@gmail.com javascript: wrote: So i'm going to piggyback this post for some additional questions... 1) Is it safe to call v8::V8::IdleNotification() within a WeakCallback() to scavenge additional objects that have been set as weak in WeakCallback() ? I guess not.. i get a crash. Your WeakCallback is invoked when V8 is in the middle* of a GC cycle so no, it's not safe to call v8::V8::IdleNotification(). * A post-processing step, actually. 2) Also, lets say within a function scope if an object is declared local but it is set as Weak i'm experiencing a behavior that the object becomes garbage collected although it is still in scope... ie function foo() { var obj; //declared as weak on instantiation for (...) { var child_obj; //child object of obj also declared as weak on instantiation //at some point obj although in scope becomes garbage collected } } So is this an expected behavior or i'm i experiencing a bug ? Thanks. If the reference is not actually used, then yes, it's eligible for garbage collection. -- -- 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: Making v8::Persistent safe to use
So with the resent changes to Persistent how can we store a series of PersistentFunction handles to an STL container like map ? -- -- 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
Shouldn't the use of Handle and Local be interchangeable ? Has it been decided which of the two will be depreciated in the end ? It seems that we cannot assign a Handle value to the Eternal and we need to use Local instead ... -- -- 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: BooleanObject::New(false) always returns true
So if i understand correctly, in order to obtain the underlying value of a BooleanObject, i need to first cast the Value to BooleanObject and then call BooleanValue() Do we need to perform the same casting from Value to NumberObject and StringObject to correctly obtain the underlying value ? LocalValue false_value = BooleanObject::New(false);LocalBooleanObject false_boolean_object = false_value.AsBooleanObject();bool false_bool = false_boolean_object-BooleanValue(); // = false LocalValue true_value = BooleanObject::New(true);LocalBooleanObject true_boolean_object = true_value.AsBooleanObject();bool true_bool = true_boolean_object-BooleanValue(); // = true Thank you for the unit tests, that cleared out the but i think for the primitive_true test it is just a copy of the primitive_false test. + LocalValue primitive_true = Boolean::New(true);+ CHECK(primitive_true-IsBoolean());+ CHECK(!primitive_true-IsBooleanObject());+ CHECK(primitive_true-BooleanValue());+ CHECK(primitive_true-IsTrue());+ CHECK(!primitive_true-IsFalse()); -- -- 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] BooleanObject::New(false) always returns true
I was wandering why the following BooleanValue() statements always return true, shouldn't the first one return false ? Also why both IsTrue() and IsFalse() return false in the statements below ? Is there a bug or am i missing something here ? bool test0 = BooleanObject::New(false)-BooleanValue(); = truebool test0t = BooleanObject::New(false)-IsTrue(); = false bool test0f = BooleanObject::New(false)-IsFalse(); = false bool test1 = BooleanObject::New(true)-BooleanValue(); = true bool test1t = BooleanObject::New(true)-IsTrue(); = falsebool test1f = BooleanObject::New(true)-IsFalse(); = false 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] Help with setting local js variable to Null()
Ok, so I have the following code. The function Delete is a function property of the Point object, to ensure proper destruction of the c++ object. At point (2) i am checking whether the js variable is a global variable and set the value to Null(). Is there a way to set a local function scope js variable declared with var keyword to null through the c++ code ? //--- #define UNWRAP_INTERNAL_FIELD(holder, retval, pointer) \ HandleScope handle_scope; \ LocalObject self = holder; \ if (self-InternalFieldCount() != 1 || self-GetInternalField(0)-IsNull() == true || self-GetInternalField(0)-IsUndefined() == true) \ return retval; \ LocalExternal wrap = LocalExternal::Cast(self-GetInternalField(0)); \ Point* pointer = static_castPoint*(wrap-Value()); //--- static HandleValue Delete(const Arguments args) { UNWRAP_INTERNAL_FIELD(args.Holder(), Null(), p); // (1) Clear args[0] object properties and functions LocalArray array = self-GetPropertyNames(); for (int i = 0; (uint32_t)i array-Length(); i++) self-ForceDelete(array-Get(i)); // (2) If args[0] is a global object then remove the object form global scope LocalObject global = self-CreationContext()-Global(); array = global-GetPropertyNames(); for (int i = array-Length()-1; i = 0; i--) { HandleScope handle_scope; LocalValue name = array-Get(i); LocalObject obj = global-Get(name)-ToObject(); if (obj-InternalFieldCount() == 1 obj-GetInternalField(0)-IsNull() == false) { LocalExternal _wrap = LocalExternal::Cast(obj-GetInternalField(0)); if (wrap-Value() == _wrap-Value()) { global-Set(name, Null()); } } } // (3) Delete the c++ object and call its destructors delete p; // (4) SetInternalField to null self-SetInternalField(0, Null()); return Boolean::New(true); } -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users
Re: [v8-users] Help with setting local js variable to Null()
Thank you for the reply. Basically what I want to achieve is the following. Consider this js example After my ReleaseObject() function is called x = is still a point object At the second print(x) i would like my variable to be null, or report as null without explicitly setting it to null with x=null; if possible I also attach my constructor function, please let me know if i construct my object correctly. Thanks. function f() { // Local variable x var x = new point(123,456); print(x); //= prints [object point] x.ReleaseObject(); print(x); //= prints [object point] x=null; //want to incorporate this in x.ReleaseObject(); } //--- static HandleValue New(const Arguments args) { HandleScope handle_scope; LocalFunctionTemplate t = FunctionTemplate::New(); t-SetClassName(args.Callee()-GetName()-ToString()); t-ReadOnlyPrototype(); HandleObjectTemplate obj_templ = t-InstanceTemplate(); obj_templ-SetInternalFieldCount(1); LocalObject obj = obj_templ-NewInstance(); Point* p = new Point(args[0]-Int32Value(), args[1]-Int32Value()); obj-SetInternalField(0, External::New(p)); obj-Set(String::NewSymbol(toString), FunctionTemplate::New(Point::toString)-GetFunction(), PropertyAttribute(DontEnum | DontDelete)); obj-SetAccessor(String::NewSymbol(x), GetPointX, SetPointX); obj-SetAccessor(String::NewSymbol(y), GetPointY, SetPointY); obj-Set(String::NewSymbol(ReleaseObject), FunctionTemplate::New(Point::Delete)-GetFunction(), PropertyAttribute(DontEnum | DontDelete)); return handle_scope.Close(obj); } -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users
[v8-users] Re: Set prototype of Host Object handle question.
I have tried the above but i don;t think that it works correctly. Have you found another way to set an Object to null ? On Friday, 8 April 2011 19:29:04 UTC+3, mcot wrote: I think I solved my problem: v8::HandleScope hndl_scope; ... ... v8::Handlev8::Object obj = obj_templ-NewInstance(); v8::Handlev8::Value n = v8::Null(); obj-SetPrototype(n); ... ... return hndl_scope.Close(obj); Does this look reasonable? On Apr 8, 10:24 am, mcot atm1...@gmail.com wrote: I am having trouble with setting the prototype of an object. Basically... v8::object-SetPrototype(v8::value), I want the prototype to be either null or undefined. If I use a persistent handle for the undefined, when do I clean it up (Dispose)? -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users