[v8-users] Sayonara, v8

2013-08-19 Thread Stephan Beal
Hello, all,

(TL;DR: bye!)

(i'm going to try to do this without a tone of contempt, and i apologize in
advance if a bit of it slips through.)

As many of you know, i've maintained the v8-juice and cvv8 (a.k.a.
v8-convert) projects since March of 2009, have implemented tens of
thousands of lines of v8 code since that time, and have written more
documentation on the topic than the whole v8 team combined. The recent
rounds of changes in v8, however, were a direct kick in the balls to both
of those projects and every one of their clients, introducing
incompatibilities which would take me weeks of full-time effort to get back
into working order (in the form of a rewrite). i don't have the energy for
that, especially when the v8 team as a whole doesn't have the energy to
document their code, raising the bar of (re)entry into v8. That's the last
time you'll hear me bitch about that, guys - my one-man unpaid projects
regularly out-document your whole team and that is DOWNRIGHT SHAMEFUL[1]!

So, here's my farewell not only from my v8 projects, but also from v8 in
general. i understand and sympathize with Google's choice to improve v8
rather than be held back by compatibility crutches, but i don't have the
energy to play the catch-up game with them, nor to evangelize v8 further.
Per a recent post on this list from one of the Chromium devs, it look the
Chrome team months to port to the new API, and i'm a single developer
with 4+ years of accumulated code. Screw it - i've got more productive/less
risky things to expend my energy on.

i am, as of this moment, abandoning my v8 projects and looking for a
capable C++ coder (or coders) to take over the v8-juice/cvv8 projects:

https://code.google.com/p/v8-juice/

With the forewarning that the more interesting parts of the internals need
a major overhault/rewrite due to the signature change of InvocationCallback
(e.g. the basis of [2]). The vast majority of the core type conversions
APIs should be unaffected.

If you are interested, please get in touch _off list_. i won't be on this
list much longer and won't see replies made here, nor will i be responding
on-list to any responses made to this post.


i wish you all Happy, Successful Hacking, and may your projects survive the
Great V8 API Upheaval of 2013 (and any future upheavals!).


[1]
https://docs.google.com/presentation/d/1plJbtQZXKBymEiw9sYy9xqnzMleWuYO461R3VrocOWQ/view
[2] https://code.google.com/p/v8-juice/wiki/V8Convert_XTo


-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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: New feature: handle eternalization

2013-08-09 Thread Stephan Beal
On Fri, Aug 9, 2013 at 8:54 PM, Mike Moening mike.moen...@gmail.com wrote:

 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.


This should do the trick:

exit(0);

;)

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] Crashing with HandleScope error before anything is done

2013-07-20 Thread Stephan Beal
On Sat, Jul 20, 2013 at 6:39 AM, Richard S blakpi...@gmail.com wrote:

 V8 is throwing an error about needing a handle scope before anything is
 even done in my app. It was working fine the other day, but when I went to
 run it it started throwing the error. I decided to take a break, and when I
 came back today it was still throwing the error.
 ...

# Fatal error in v8::HandleScope::CreateHandle()
 # Cannot create a handle without a HandleScope


Are you sure you don't have any Handles being statically initialized
somewhere? Maybe in a DLL you are linking to? That could cause this. If you
add a debug output line when you enter main(), is that line ever output
before the crash?

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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: Wrapping a C++ class, revisited

2013-07-20 Thread Stephan Beal
On Sat, Jul 20, 2013 at 3:45 PM, Richard S blakpi...@gmail.com wrote:

 Hello. I've tried following along with this and the embedder's guide, but
 my point binding only works to an extent. The constructor works, but for
 some reason when I use an invalid constructor the object in JavaScript is
 not undefined (I set the return value to be so).


The return value of a JS constructor is ignored - it is handled
automatically by the 'new' operator:

[stephan@host:~/]$ cat foo.js

function MyClass(){
return hi;
}

var x = new MyClass();
print(x instanceof MyClass);
[stephan@host:~/]$ js foo.js
true


-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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: Wrapping a C++ class, revisited

2013-07-20 Thread Stephan Beal
On Sat, Jul 20, 2013 at 5:12 PM, Richard S blakpi...@gmail.com wrote:

 Okay, then is there a way to return an undefined object on an improper
 constructor? And I still have yet to solve the problem with values not
 being what they're supposed to be :/


To signal a bad constructor, throw a JS-side exception by calling
v8::ThrowException().

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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: How to reinitialize v8 after v8::V8::Dispose();

2013-07-19 Thread Stephan Beal
On Fri, Jul 19, 2013 at 12:06 PM, Arseniy Pavlenko h0x...@gmail.com wrote:

 http://dpaste.com/hold/1310462/ - here small example

 Example sometime works, sometime crash What i am doing wrong?


As Dmitry implied: you're relying on undefined behaviour. Don't do that.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] Why doesn't v8::TryCatch catch exceptions thrown from C++?

2013-07-17 Thread Stephan Beal
On Wed, Jul 17, 2013 at 1:33 AM, Adam Klein ad...@chromium.org wrote:

 The subject says it all. I'm trying to wrap some code that uses the V8 API
 to throw exceptions (via v8::ThrowException()), and was expecting wrapping
 those calls in a v8::TryCatch to do this for me. But it seems they bypass
 my TryCatch (though with SetVerbose(true) they are at least reported to
 me). Is there something I can do to make the TryCatch completely swallow an
 exception?


Why is v8 supposed to know what TYPES of exceptions you throw and how to
convert them to JS exceptions? Some apps throw std::exception, some throw
(my::Exception const ), some throw (SomeMFCType *), and some even through
std::string. There is no 100% generic approach to that. It is easy to write
wrappers which convert such exceptions:

https://code.google.com/p/v8-juice/wiki/V8Convert_FunctionBinding#Converting_Native_Exceptions_to_JS

but it would be impossible for v8 to do that itself because it lacks the
type information.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] Wrapping a C++ class, revisited

2013-07-08 Thread Stephan Beal
On Mon, Jul 8, 2013 at 6:45 PM, Lyndsey lyndseypad...@gmail.com wrote:

 Thank you Ben.  I assume you mean something like what's being done 
 herehttp://stackoverflow.com/questions/6696706/node-js-native-addon-destructor-of-wrapped-class-doesnt-run?
 I think the problem is that I'm not using node, and that would be needed to
 do the following, correct?

 point-Wrap(args.This());  //Where Wrap is available because the C++ Point
 class extends ObjectWrap (from node.h)

 I would like to do this in pure V8 without using node.  Is that
 possible?  Am I making things too difficult?


Wrapping classes can be easily done without node but it gets really tedious
really quickly. There are several frameworks out there which can simplify
this. Here's one example (out of many) which demonstrates a generic
approach:

http://code.google.com/p/v8-juice/wiki/V8Convert_ClassCreator

but that particular one was massively broken by recent v8 API changes, so i
unfortunately cannot recommend it to you. Others on this list have authored
such tools, many of which possibly still work since the (still ongoing) v8
overhaul started, and maybe one of them can suggest a generic solution for
you.



-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] Wrapping a C++ class, revisited

2013-07-08 Thread Stephan Beal
On Mon, Jul 8, 2013 at 7:07 PM, Ben Noordhuis i...@bnoordhuis.nl wrote:

 or may not work for you, YMMV.  Node.js has the luxury of being
 allowed to assume that the executed JS code isn't hostile, unlike e.g.
 a browser.


Well worded: isn't hostile rather than is safe ;)

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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

2013-06-21 Thread Stephan Beal
On Fri , Jun 21, 2013 at 9:19 AM, Dan Carney dcar...@chromium.org wrote:

 The transition from Local to Handle won't happen for a while.  It's more
 of a cleanup step after everything else is done, and there's no urgency
 since there shouldn't be any performance impact.


Correction: there is no urgency for Chrome. There _are_ hundreds of
projects out there based on v8 other than Chrome, and none of them can plan
for fixing their code which are broken by this series of changes.

The callback signature changes alone break almost every single line of
v8-using code i've written (tens of thousands of them), and i am still
undecided as to whether to spend several weeks of my time patching for or
whether to simply drop by v8-related projects (i'm leaning strongly towards
the latter). i'm getting too old to spend weeks patching every time a
3rd-party library pulls the rug out from under me (and this isn't the first
time v8 has done it, though this is certainly the most invasive change so
far).

:(

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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 achieve scope property injection in v8?

2013-06-12 Thread Stephan Beal
On Wed, Jun 12, 2013 at 1:10 PM, Andreas Rossberg rossb...@google.comwrote:

 And what's wrong with replacing this by the following?

 {
  let out = ''
  function write(s) { o.out += s; },
  function writeln(s) { o.out += s + '\n'; }
  let obj = { title: 'whatever', otherMetaData: … }
  eval(script);
 }


i'm not working in the browser, but in principal... i think this is a
direction i can try. i can simply generate and eval the code - that hadn't
occurred to me. Thanks for the idea! i'm not generally a big fan of
generating script code because at some point the escaping becomes more
trouble than it's worth, but i think for my limited use case this might be
a viable option which fulfills my original desires/requirements.


-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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

2013-06-12 Thread Stephan Beal
On Wed, Jun 12, 2013 at 7:58 PM, Mike Moening mike.moen...@gmail.comwrote:

 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.


Thanks for that tip :).


 Please lets move the problem forward in a positive manner.
 This is a problem that absolutely can and NEEDS to be solved.


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).)

:/

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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 achieve scope property injection in v8?

2013-06-11 Thread Stephan Beal
On Tue, Jun 11, 2013 at 5:53 PM, Michael Schwartz myk...@gmail.com wrote:

 with (o) {


Yeah, i was hoping to avoid the 'with'. i assume there is no
clean/portable/sane way to do this in JS, and to be honest the idea never
occurred to me until today while tinkering on my own pet scripting engine
(which, by an accident of design, can do this from either native or script
code, but whether that's a feature or a bug is debatable).

Thanks, Andreas and Michael, for the responses.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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 access string of HandleString?

2013-06-06 Thread Stephan Beal
On Thu, Jun 6, 2013 at 5:20 PM, Bodo Kaiser i...@bodokaiser.io wrote:

 I am trying to get a const char * string out of a v8 String Object.

 Unfortunately all access result in a segmentation fault:


Try: (i'm working from memory, but i _think_ this is right:

v8::Utf8Value str( *yourStringHandle );
puts( *str );

-GetExternalAsciiStringResource()-length());



external strings are a special case of strings which are allocated
elsewhere (outside of v8), or at least that's my understanding.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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

2013-05-24 Thread Stephan Beal
On Fri, May 24, 2013 at 1:53 AM, loudersp...@gmail.com wrote:

 virtual ~Point()
 {
 assert(false); // Never called!
 }


v8 does not guaranty that it will _ever_ call your destructors. It does
_not_ clean up automatically when it shuts down. This of course makes life
difficult for types which require proper closing or close ordering (e.g.,
db statements and their drivers), but v8 is really centered on types which
can be thrown away without running a destructor.



 v8::V8::Initialize();  // Initialize v8.  (Is this needed??  If so, why
 isn't it mentioned here - https://developers.google.com/v8/embed)


i've been using v8 since 2008 and never seen/used it.


 v8::V8::LowMemoryNotification();  // I saw this mentioned as a way to
 force GC, but it doesn't help.  Even so, I would think v8::V8::Dispose
 would clear all garbage.
 v8::V8::Dispose();   // Initialize v8.  (Is this needed??  If so, why
 isn't it mentioned here - https://developers.google.com/v8/embed)


Whether or not it is needed, i don't know (i don't remember consistently
using it). It won't, however, guaranty to run any cleanup of your bound
types. In order for you to start seeing your dtor running, you need to
create many thousands of them before v8 will start cleaning them up. In
short-lived test apps the dtors are rarely run. In all of my bound native
types i tend to bind a destroy() method which manually triggers the
destruction process. Here's an example of how to do that:

https://code.google.com/p/v8-juice/source/browse/convert/include/cvv8/ClassCreator.hpp#980

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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

2013-05-24 Thread Stephan Beal
On Fri, May 24, 2013 at 9:58 PM, Jim Acquavella loudersp...@gmail.comwrote:

 Thanks Stephan!  I'm surprised and disappointed I can't guarentee my C++
 objects will be destroyed.  Can anyone from Google comment on this?  There
 must be a way to force everything allocated to be released at shutdown, no?!


That horse has been beat to death here a few times already. No - there is
no guaranty that v8 will ever call your dtors and (AFAIR) no 100% reliable
way to force it to. To be safe, bind a destructor function to your native
types.


-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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

2013-04-24 Thread Stephan Beal
On Wed, Apr 24, 2013 at 11:00 AM, Ben Noordhuis i...@bnoordhuis.nl wrote:

 ...The trick I mentioned in my other post is that you add a second
 internal field that points to some atom (usually a char
 class_name_id[] = MyClassName) that you check for in your prototype
 methods so you can be sure that args.This() is what you expect it to
 be.  Be sure to check args.This()-InternalFieldCount() as well.


Another option, as opposed to using a string, is take the address of some
internal static value. The value and type of that pointer is largely
irrelevant - it's _address_ can be used as the type identifier. In cvv8 we
use a mixture: we use the address of a static string (not its value)
defined in a template, since comparing the address is much faster than
doing a strcmp and the address is guaranteed to be unique within the app's
address space.


 We don't use that trick in node.js actually but that's because native
 objects are not exposed directly, there's (almost) always some pure JS
 object sitting in front of it.  It's a pretty good approach when
 you're not operating in a hostile environment (running untrusted
 code), it saves a lot of headaches.


Here's an example where it is important to have such a type-safety net:

Assume Foo and Bar are both client-define native types:

var x = new Foo();
var y = new Bar();
x.doBar = y.doBar;
x.doBar(); // doBar expects that 'this' is-a (Bar*)

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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

2013-04-24 Thread Stephan Beal
On Wed, Apr 24, 2013 at 1:18 PM, Ben Noordhuis i...@bnoordhuis.nl wrote:

 That's not another option - that's the same option. :-)


Yeah, technically. My point was only that it could some opaque pointer,
e.g.:

static int foo = 3;

and pass a pointer to that.

But yes, having it be a string makes debuggering easier.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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

2013-04-16 Thread Stephan Beal
The receiver is the this object you want to use (it is not optional). For
your case the global obj or even the callback itself probably suffice.

- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
On Apr 16, 2013 11:24 PM, Mike Moening mike.moen...@gmail.com wrote:

 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.




-- 
-- 
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: Force GC

2013-04-15 Thread Stephan Beal
Short answer is: v8 does not guarantee that weak ptr callbacks will EVER be
called. Yes, this is painful, but even if such a guarantee could be made,
there's no way for v8 to know the proper destruction order (important,
e.g., for db handles and prepared statements). My tip is: add a destroy()
method to your bound classes and clean up manually. try/finally blocks are
helpful here.

(sent from a mobile device - please excuse brevity, typos, and top-posting)
- stephan beal
http://wanderinghorse.net
On Apr 15, 2013 8:03 PM, Mike Moening mi...@reteksolutions.com wrote:

 I’ve been trying to figure out a way to force GC for V8.

 ** **

 Read about and tried the AdjustAmountOfExternalAllocatedMemory() and
 IdleNotification() methods.

 I tried AdjustAmountOfExternalAllocatedMemory(1024*1024*100); //100 MB
 should be enough!

 ** **

 Upon shutdown of my application (and periodically too) 

 it is crucial that my MakeWeak() IsNearDeath destructor callbacks get
 fired to properly cleanup file handles and C++ memory.

 ** **

 How can I do this?  At least with spidermonkey JS_GC() you would force it!
 

 ** **

 I’m using memory diagnostics tools that report false leaks since GC isn’t
 fired…

 ** **

 Mike Moening

 ** **

 *Retail Technology Solutions Inc.*

 23235 Texas Avenue

 Suite 125

 Lakeville, MN 55044

 direct: 952-461-3770

 ** **


-- 
-- 
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] Is it valid to not close a scope?

2013-04-14 Thread Stephan Beal
On Sun, Apr 14, 2013 at 5:30 PM, bodo.kai...@enabre.com wrote:

 Hello,

 I want to use a function which acts as internal exception shortcut
 unfortunately I cannot pass the current scope so I would create a new one.
 Is this whole strategy valid? If not how would it look right?


My understanding, based on previous discussions on this list, is that a
HandleScope is not needed at all if the code in question is being called
from JS space (because such a call has an implicit HandleScope around it).
Based on my own experience, your InvocationCallback and exception-thrower
look perfectly koster to me, but i would drop both of the HandleScopes -
IMO they are not needed because your InvocationCallback will be called from
JS-space in response to a Function call, and such calls have an implicit
Scope provided by the engine.


 HandleValue SomeMethod(const Arguments args) {

 HandleScope scope:

 if (!args[0]-IsObject() || args[0]-IsArray())


if i'm not mistaken (and i might be), IsObject() will(???) also return true
for an Array because an Array is-a Object.


 return ThrowTypeError(Argument must be a object literal.);
  return scope.Close(args[0]-ToObject());
 };

 NODE_MODULE(test, init);



-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] Is it valid to not close a scope?

2013-04-14 Thread Stephan Beal
On Sun, Apr 14, 2013 at 5:51 PM, Bodo Kaiser bodo.kai...@enabre.com wrote:

 I require scope.Close() to return a value


That's a common misconception. i've been using v8 for 4+ years now and i
_never_ use HandleScopes (and can return values just fine). A HandleScope,
from what i can gather, is just a hint to the GC to help clean up
temporary/local-only values.


 . My sorrow is that I could get problems with GC because I did not close
 the scope or something.
 But you do not confirm these sorrows?


When you call a function from JS:

myFunction()

and that then calls your C++ InvocationCallback, there is an implicit scope
being created in the call, so there is no need to create an extra one in
your app (unless you are calling the code from C++ without first going
through the JS engine, but such cases are rare in practice).



 To the second:
 Yes that is why there is args[0]-IsArray()


That's my point: IsArray() is useless here because the order of operations
ensure that IsObject() will always trump IsArray(). i.e. if it's an array
then IsObject() will return true and the IsArray() call is not needed (it
will never actually be called due to the short-circuiting logic of the OR
operator). (NOTE, however, that i am ASSUMING (without having tested), that
IsObject() will indeed return true for a Function or Array Object. The API
docs are not clear on this distinction.)

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] Is it valid to not close a scope?

2013-04-14 Thread Stephan Beal
On Sun, Apr 14, 2013 at 6:06 PM, Bodo Kaiser bodo.kai...@enabre.com wrote:

 I think you oversaw the ! (so !obj-IsObject()).
 OR will stop on the first true else it will go through each expression.
 !obj-IsObject() will so filter the primitive values else I agree :)


Doh, you're absolutely right. Mae culpa!

Regarding:

 obj-Get(String::New(key));

Now, i don't know a shortcut for that. :(

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] write to a txt file (S.O. Windows)

2013-04-06 Thread Stephan Beal
JS has _no_ i/o function (and neither does v8, since it only implements
core JS). To write anything to anywhere with v8 you'll need to add your own
function to do so. See the sample shell for examples.


On Sat, Apr 6, 2013 at 5:18 PM, Paolo Pellegrini
pellegrinip...@gmail.comwrote:

 I would like to write to a text file using javascript V8.
 my operating system is Windows!, how can I do?

 --
 --
 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.






-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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 can I bind functions on the fly?

2013-04-01 Thread Stephan Beal
On Mon, Apr 1, 2013 at 3:20 PM, danijar pfis...@gmail.com wrote:

 But is there a way to bind C++ functions to an already created context at
 runtime? Or maybe it is possible to recreate the context and adopt the
 state of the old context to a new one?


If i understand your question correctly, you simply need to add them to
your 'globals' object. You can get the global object later (without a
direct reference) with Context::GetCurrent()-Global().


-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] Why is there an access violation in this minimal example?

2013-04-01 Thread Stephan Beal
On Mon, Apr 1, 2013 at 3:15 PM, danijar pfis...@gmail.com wrote:

 v8::Isolate* isolate = v8::Isolate::GetCurrent();
 ...



v8::InvocationCallback* function =
 Function.targetv8::InvocationCallback();



v8::Isolate* isolate = context-GetIsolate();
 ...v8::Isolate* isolate = context-GetIsolate();


The error is a null-pointer exception. Are you 100% certain that the above
calls return non-NULL?


 v8::HandleScope handle_scope(args.GetIsolate());
 if (first) first = false;
 else printf( );
 v8::String::Utf8Value str(args[i]);
 const char* cstr = *str ? *str : string conversion failed;
 printf(%s, cstr);


FWIW, using printf() for this purpose is way overkill (go look at the
internals of any printf() impl for why)., The first printf() can be
replaced by putchar(' ') and the second one with puts() (which adds a
newline to the end). i know this is a pedantic detail, and is not really
relevant for example code, but the problem is that people tend to
copy/paste example code for use in real programs, under the assumption that
the example code shows best practices (using printf() when one of its more
efficient counterparts will suffice is not best practice).

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] Why is there an access violation in this minimal example?

2013-04-01 Thread Stephan Beal
On Mon, Apr 1, 2013 at 4:57 PM, danijar pfis...@gmail.com wrote:

 It crashes at context-Global(); because of access violation as before. I
 also tried to access the context using v8::Context::GetCurrent()-Global()
 but the result is the same.


i remember having a similar problem long ago (2+ years), where
Context::GetCurrent() was returning NULL, but i unfortunately don't
remember (A) what caused it or (B) what solved it for me :/.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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: Segmentation fault

2013-03-20 Thread Stephan Beal
On Wed, Mar 20, 2013 at 10:50 AM, Егор Яковлев goga@gmail.com wrote:

 I am really stupid. I forgot to return the value of the
 function serverSendRequest.

 Can i do this function void?


To emulate a void return in v8, simply return v8::Undefined(), which is a
shared Value instance.


-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] compiling process of scripts

2013-03-08 Thread Stephan Beal
On Fri, Mar 8, 2013 at 10:37 AM, sc scha...@gmail.com wrote:

 i have a very general question about the compiling process of javascript
 scripts via v8.(maybe the question is too broad)
 i'm currently trying to modify the compiler::compile function in
 compiler.cc so that it hijacks the source code adds very simple prints
 after every row in the source code and returns
 this as the new source to compile


You do understand that that's doomed to failure, right? Consider this code
and where you print/debugging statements would be injected:

for( var i;
 i  12;
++i )
{
}


-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] Simple way of running html embedded js

2013-03-07 Thread Stephan Beal
On Thu, Mar 7, 2013 at 5:30 PM, Sandor Hadas sourcesamp...@gmail.comwrote:

 So my question is:
 What is the simplest way (without depending on another big library like
 v8-juice) to define the object model?  Something really-really-really
 simple...


There is no simple/trivial way to do it. The DOM is specified by a
different standard than the core JS language (a basic fact the vast
majority of JS literature never mentions, i grumblingly add) and
implementing it implies a great deal of effort. (Even with the help of
v8-juice, vu8, v8-convert, silkjs, etc., it's still far from trivial.)


 I guess there are some people who did this already since that looks a
 fairly basic use of V8.


At some point there was an effort, started by John Resig (of jQuery fame),
based on the Rhino JS engine, called env.js (currently at
http://www.envjs.com). env.js implemented _much_ (but not all) of the DOM
API in JS, meaning it could be used in headless JS engines (like Rhino
(John's original target platform) and v8). Last i checked (a couple of
years ago) it was still missing some of the more interesting functionality,
like setTimeout() and XHR (both of which require some degree of
native-code-level support).

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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: Simple way of running html embedded js

2013-03-07 Thread Stephan Beal
On Thu, Mar 7, 2013 at 9:36 PM, Sandor Hadas sourcesamp...@gmail.comwrote:

 4) It runs javascript in its black (gray) box and removes all javascript;
 it replaces those with actual generated html code, so only html resides
 with no javascript script nodes inside


This behaviour does not at all describe how HTML/DOM processors work, so...

Am I the first person looking for something like this?


i suspect the answer is yes.

The fact that a script can access the DOM immediate gives it access to
elements of a page far outside of the spot where the SCRIPT tag lives, and
it can change those elements many times during the duration of a script.
The concept of replacing a SCRIPT tag with its generated output is not
new in and of itself (there are non-JS tools specifically for doing
that[1]) but does not at all describe how JS and the related DOM APIs work.

[1] the Fossil SCM (http://fossil-scm.org) includes a very basic script
processor which does that, and that is used to add (minor) level of
server-side dynamics to many of its generated pages. There is a standalone
release/fork of that processor here:
http://fossil.wanderinghorse.net/repos/th1-sgb/

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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 library as so]

2013-02-26 Thread Stephan Beal
On Wed, Feb 27, 2013 at 8:06 AM, nagarjuna atluri nagajun...@gmail.comwrote:

 Thanks for the info, but both the methods does not generate shared library
 for v8 in gyp build system, can any one help me out...


What exactly are the symptoms? Errors or simply no .so's? If the build runs
but no SOs are generated - i had a similar (completely unexplainable)
problem on one particular version of Ubuntu. The build ran without errors
but the generated SOs were completely empty (not size 0, but also no C
symbols). i _think_ it was 11.04 or 11.10, but i don't recall with
certainty. i do remember that after moving away from that installation
(first to another Linux distro, then back to a newer Ubuntu) the problem
disappeared.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] Segmentation fault when creating new v8 context.

2013-02-22 Thread Stephan Beal
On Thu, Feb 21, 2013 at 3:44 PM, Sven Panne svenpa...@chromium.org wrote:

 I don't even know what to compile from
 https://code.google.com/p/v8-juice/source/browse/, the trunk seems to be
 out of date, it uses e.g. GetPointerFromInternalField and friends which are
 not part of v8's external API anymore.


The main project tree there is historical and no longer maintained. Only
the /convert directory (the one i sent the links to) is current vis-a-vis
v8's API (or was, until 2 days ago), and we removed
GetPointerFromInternalField() from it over the holidays because its
deprecation/behaviour change broke our class-binding mechanism.

Note that we are really willing to help embedders, but digging through
 someone else's code with only vague hints is a huge waste of time.


As is digging through v8 to find what v8 changes broke our (unchanged)
code. So nobody wins.

While trying to create a reproducible test case for you, i found 2 things:

a) the Hello World example in the v8 docs no longer compile due to API
changes. https://developers.google.com/v8/get_started

b) the assertion problem has magically disappeared in the meantime (using
r13713).

 Another hint: The external v8 API is undergoing some changes, mainly
making the
 use of an Isolate explicit and mandatory

Where can we find documentation on how to do this? i'm currently looking
over the v8 docs (https://developers.google.com/v8/) and i see neither hide
nor hair of Isolates.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] GetPointerFromInternalField deprecated?

2013-02-22 Thread Stephan Beal
On Fri, Feb 22, 2013 at 11:26 PM, Flying Jester foolkingcr...@gmail.comwrote:

 This obviously doesn't work with a 1 to 1 replacement with the aligned
 version of the function.


Welcome to the club :). What i ended up doing (because the Aligned version
kept inexplicably asserting when given pointers allocated with (new T)),
was to use an explicit v8::External wrapper to hold my pointer and
replacing the PointerTo/FromInternalField calls with the normal
InternalFields calls.

Example usages:
set:
https://code.google.com/p/v8-juice/source/browse/convert/include/cvv8/ClassCreator.hpp#776
get:
https://code.google.com/p/v8-juice/source/browse/convert/include/cvv8/ClassCreator.hpp#603

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] Segmentation fault when creating new v8 context.

2013-02-21 Thread Stephan Beal
On Wed, Feb 20, 2013 at 4:34 PM, Егор Яковлев goga@gmail.com wrote:

 I have the same problem.

 I built v8 for x64 architecture on Ubuntu 12.04 using gyp. And now i try
 to run the Hello World example. But i have Segmentation fault (core
 dumped). This error occurs when creating new v8 context.


Same here, using:

[stephan@host:~/src/google/v8]$ svn info
Path: .
URL: http://v8.googlecode.com/svn/trunk
Repository Root: http://v8.googlecode.com/svn
Repository UUID: ce2b1a6d-e550-0410-aec6-3dcde31c8c00
Revision: 13700
Node Kind: directory
Schedule: normal
Last Changed Author: yang...@chromium.org
Last Changed Rev: 13692
Last Changed Date: 2013-02-19 14:55:47 +0100 (Tue, 19 Feb 2013)


Ubuntu 12.04 on x64, gcc 4.6.3.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] Segmentation fault when creating new v8 context.

2013-02-21 Thread Stephan Beal
On Thu, Feb 21, 2013 at 9:54 AM, Stephan Beal sgb...@googlemail.com wrote:

 On Wed, Feb 20, 2013 at 4:34 PM, Егор Яковлев goga@gmail.com wrote:

 I have the same problem.

 I built v8 for x64 architecture on Ubuntu 12.04 using gyp. And now i try
 to run the Hello World example. But i have Segmentation fault (core
 dumped). This error occurs when creating new v8 context.


 Same here, using:

 [stephan@host:~/src/google/v8]$ svn info
 Path: .
 URL: http://v8.googlecode.com/svn/trunk
 Repository Root: http://v8.googlecode.com/svn
 Repository UUID: ce2b1a6d-e550-0410-aec6-3dcde31c8c00


And on the bleeding edge:

[stephan@host:~/src/google/v8]$ svn info
Path: .
URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Repository Root: http://v8.googlecode.com/svn
Repository UUID: ce2b1a6d-e550-0410-aec6-3dcde31c8c00
Revision: 13700
Node Kind: directory
Schedule: normal
Last Changed Author: yang...@chromium.org
Last Changed Rev: 13700
Last Changed Date: 2013-02-20 15:29:40 +0100 (Wed, 20 Feb 2013)


-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] Segmentation fault when creating new v8 context.

2013-02-21 Thread Stephan Beal
On Thu, Feb 21, 2013 at 9:54 AM, Stephan Beal sgb...@googlemail.com wrote:

 Same here, using:

 [stephan@host:~/src/google/v8]$ svn info
 Path: .
 URL: http://v8.googlecode.com/svn/trunk
 Repository Root: http://v8.googlecode.com/svn
 Repository UUID: ce2b1a6d-e550-0410-aec6-3dcde31c8c00
 Revision: 13700


i've been able to narrow this down to being introduced somewhere between:

-r{20130215T00Z} (OK)
and
-r{20130220T00Z} (Not OK)

but my boss (who wants me doing something completely different) is losing
patience with me, so i won't be able to investigate it further.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] Segmentation fault when creating new v8 context.

2013-02-21 Thread Stephan Beal
On Thu, Feb 21, 2013 at 11:39 AM, Stephan Beal sgb...@googlemail.comwrote:

 i've been able to narrow this down to being introduced somewhere between:

 -r{20130215T00Z} (OK)
 and
 -r{20130220T00Z} (Not OK)


One more...

-r{20130218T00Z}

does not exhibit this problem.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] Segmentation fault when creating new v8 context.

2013-02-21 Thread Stephan Beal
On Thu, Feb 21, 2013 at 12:42 PM, Sven Panne svenpa...@chromium.org wrote:

 What are the detailed steps to reproduce this?


- Update to the latest version
- rebuild any custom v8 client app of your choice which has worked for the
past year or more.
- start that app
- crash at startup:

#
# Fatal error in ../src/v8threads.cc, line 53
# CHECK(isolate != __null) failed
#

 C stack trace ===

 1: V8_Fatal
 2: v8::Locker::Initialize(v8::Isolate*)
 3: v8::Locker::Locker(v8::Isolate*)
 4: ??
 5: ??
 6: ??
 7: ??
 8: __libc_start_main
 9: ??


All of my v8 apps crash at startup with the current trunk v8. The last
working versions i was able to test was -r{20130218T00Z}, which
resolves to -r13679.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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] Segmentation fault when creating new v8 context.

2013-02-21 Thread Stephan Beal
On Thu, Feb 21, 2013 at 2:03 PM, Sven Panne svenpa...@chromium.org wrote:

 OK, my apps are d8 and Chrome, and both work. :-) Seriously, we need more
 detailed steps and not just some fuzzy prose. It could


i understand that, but you cannot expect us to go decompose our apps every
time new v8 behaviour breaks something as basic as application startup
(this isn't the first time in the past 6 months my apps start mysteriously
breaking due to mysterious v8 changes). Here's what i know, without going
so far as to write a new app which demonstrates this problem (i have
several which demonstrate it already)...

-r{20130218T00Z} works for me
-r{20130220T00Z} does not work for me


 very well be the case that some applications embedding v8 worked only by
 accident, so a stand-alone reproduction is really needed, e.g. a single
 small C/C++ file embedding v8 which crashes for you when compiled and run.


The apps i have which break with the newer versions have worked for 18+
months without any modifications on my side. If they only worked by
accident then something is horribly wrong with v8 (because my apps are all
modeled after the shell example app and the sparse documentation from the
v8 team). None of my apps are extremely trivial, so i have no trivial
example. All of them use the same startup process, however, and that is
where v8 is failing for several of us. Here's an example which crashes:

https://code.google.com/p/v8-juice/source/browse/convert/addons/shell-skel/shell.cpp#65

during initialization, which happens here:

https://code.google.com/p/v8-juice/source/browse/convert/include/cvv8/V8Shell.hpp#175

the part which craps out is the v8::Locker constructor, which is literally
the first value initialized in my app after main() is entered, before any
of my app-specific code gets run. The crash dump and backtrace look like:

[stephan@host:~/cvs/v8-juice/convert/addons/shell-skel]$ gdb --args ./shell
test.js
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html

This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type show copying
and show warranty for details.
This GDB was configured as x86_64-linux-gnu.
For bug reporting instructions, please see:
http://bugs.launchpad.net/gdb-linaro/...
Reading symbols from
/home/stephan/cvs/v8-juice/convert/addons/shell-skel/shell...done.
(gdb) r
Starting program:
/home/stephan/cvs/v8-juice/convert/addons/shell-skel/shell test.js
[Thread debugging using libthread_db enabled]
Using host libthread_db library /lib/x86_64-linux-gnu/libthread_db.so.1.


#
# Fatal error in ../src/v8threads.cc, line 53
# CHECK(isolate != __null) failed
#

 C stack trace ===

 1: V8_Fatal
 2: v8::Locker::Initialize(v8::Isolate*)
 3: v8::Locker::Locker(v8::Isolate*)
 4: ??
 5: ??
 6: ??
 7: ??
 8: __libc_start_main
 9: ??

 JS stack trace is not available ===


 Isolate for the thread is not initialized =


Program received signal SIGTRAP, Trace/breakpoint trap.
v8::internal::OS::DebugBreak () at ../src/platform-linux.cc:427
warning: Source file is more recent than executable.
427 #elif defined(__mips__)
(gdb) bt
#0  v8::internal::OS::DebugBreak () at ../src/platform-linux.cc:427
#1  0x776fcfff in v8::internal::OS::Abort () at
../src/platform-linux.cc:409
#2  0x7732281e in V8_Fatal (file=0x7779e749
../src/v8threads.cc, line=53, format=0x7779e45e CHECK(%s) failed)
at ../src/checks.cc:59
#3  0x7761f569 in v8::Locker::Initialize (this=0x7fffe160,
isolate=0x0) at ../src/v8threads.cc:53
#4  0x7734e5ff in v8::Locker::Locker (this=0x7fffe160,
isolate=0x0) at ../src/../include/v8.h:4003
#5  0x00404c99 in cvv8::Detail::V8MaybeLockertrue::V8MaybeLocker
(this=0x7fffe160) at ../../include/cvv8/V8Shell.hpp:33
#6  0x00404555 in cvv8::V8Shelltrue::V8Shell
(this=0x7fffe160, globalObjectName=0x0, argc=2, argv=0x7fffe338,
argOffset=1) at ../../include/cvv8/V8Shell.hpp:181
#7  0x00403c7c in v8_main (argc=2, argv=0x7fffe338) at
shell.cpp:65
#8  0x00403f7b in main (argc=2, argv=0x7fffe338) at
shell.cpp:136



The problem is obviously the NULL Isolate. My v8 client code has _never_
(in the 4-some-odd years i've been using v8) explicitly used an Isolate, so
i find the it worked by accident hypothesis hard to swallow.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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

Re: [v8-users] NewInstance failing

2013-02-14 Thread Stephan Beal
On Thu, Feb 14, 2013 at 6:01 PM, Greg Martin g...@softsprocket.com wrote:

 I've tried preceding the call with a TryCatch but it still terminates. I
 don't know why and don't know how to find out why.


That sounds suspiciously like a v8-internal assertion is being triggered.
If that is the case - link against a debug build of v8 and it will dump
tons of info to stderr when an assertion is triggered (quite often
explaining exactly what when wrong and where it happened). A non-debug
build silently dies in such a case.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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 handles by value

2013-01-22 Thread Stephan Beal
On Wed, Nov 14, 2012 at 1:30 PM, Jakob Kummerow jkumme...@chromium.orgwrote:

 Handles are essentially pointers to pointers. The indirection is necessary
 because the target object might be moved around by the GC. There is no need
 to pass handles by reference, because passing the handle by value is just
 as efficient. Note that passing the *handle* by value does not mean that
 the *object* that the handle points to is passed by value -- think of it as
 passing the object by handle, which is the GC-safe way of passing the
 object by reference.


To expand on that just a tiny bit: when passing handles by const reference
it is still possible to call non-const methods of the referenced
Value/Object because the Value it points to is not const (only the handle
reference is const).

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
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()

2013-01-21 Thread Stephan Beal
On Mon, Jan 21, 2013 at 1:53 PM, ioannis ioanni...@gmail.com wrote:

   // (2) If args[0] is a global object then remove the object form
 global scope
   LocalObject global = self-CreationContext()-Global();


This part is not necessary. You already do:


   // (3) Delete the c++ object and call its destructors
   delete p;

   // (4) SetInternalField to null
   self-SetInternalField(0, Null());


which will (if your binding code takes some care) avoid the case that a
client steps on a now-invalid native (or a _different_ native which was
reallocated at the same address).

But to answer your question: i can't. i don't think there is a way to do
that.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] [v8 library as so]

2013-01-17 Thread Stephan Beal
On Thu, Jan 17, 2013 at 4:45 PM, nagarjuna atluri nagajun...@gmail.comwrote:

 Can any one please let me know the procedure to build V8 as
 shared library in gyp build system.
 Basically i m having chrome browser code.


https://code.google.com/p/v8/wiki/BuildingWithGYP

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] [v8 library as so]

2013-01-17 Thread Stephan Beal
On Thu, Jan 17, 2013 at 5:00 PM, nagarjuna atluri nagajun...@gmail.comwrote:

 Thanks for the reply
 but wanted to know in which gyp  file we have to set the options


There are no file-level options to set - it's all command-line driven.
Running it as documented at that wiki page will build a .so file. (Note
that there is no support for building a static library, at least on Linux.)

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] How can I convert a argument to v8::Array?

2013-01-15 Thread Stephan Beal
On Tue, Jan 15, 2013 at 3:16 AM, amourfou amourfo...@gmail.com wrote:

 In the following source codes, if args[0] is array object, let me know how
 to convert it to v8::Array or handle it.
 ...   if (args[0]-IsArray() == true)
 {
 HandleArray ar( Array::Cast(args[0]) );
 }
 }



-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] V8 build on Linux using GYP

2013-01-10 Thread Stephan Beal
On Thu, Jan 10, 2013 at 5:44 AM, Neha nehatripathi28...@gmail.com wrote:

 I tried strictaliasing=off option along with make native. This worked. The
 code got compiled with this option.
 What are the implications of using this option when i want to further use
 V8 with my application?


If you mean as a normal client, just using the v8 public API, this option
doesn't affect the client code or how the client code needs to be compiled,
it only affects how gcc compiles v8.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Build statically linked v8 shell?

2013-01-10 Thread Stephan Beal
On Thu, Jan 10, 2013 at 7:58 AM, Joe Millenbach jmillenb...@gmail.comwrote:

 If I make a patch that added the option, could it be accepted?  Or is
 this functionality that is not desired?


FWIW: v8 uses networking classes in some of the debugging code, and on
Linux the networking libraries cannot be linked statically (for voodoo
reasons which i don't recall). This ticket suggests that one might also
have problems when statically linking against pthreads on linux:
http://sourceware.org/bugzilla/show_bug.cgi?id=10652

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Build statically linked v8 shell?

2013-01-10 Thread Stephan Beal
On Thu, Jan 10, 2013 at 10:37 PM, Joe Millenbach jmillenb...@gmail.comwrote:

 platform-posix.cc:(.text._ZN2v88internal11POSIXSocket7ConnectEPKcS3_+0x8d):
 warning: Using 'getaddrinfo' in statically linked applications
 requires at runtime the shared libraries from the glibc version used
 for linking


That's the networking libraries problem i vaguely mentioned above. You
_can_ link statically to them but it won't be a true static link - at
runtime the app will still (perhaps indirectly) need the networking DLL(s).
When static linking of v8 broke for me (way back when) due to this problem
i thought, WTF are they using networking code for? It turns out that it's
only used in the debugger (or was at the time). Maybe (not sure) it's
possible to build without that component, and therefore without the
networking requirement.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Re: SetAlignedPointerInInternalField() assertion

2013-01-03 Thread Stephan Beal
On Thu, Jan 3, 2013 at 11:54 AM, Sven Panne svenpa...@chromium.org wrote:

 Could you give detailed steps to reproduce your problem? Have you checked
 that the pointer in question at the point of the assertion is *really*
 aligned (i.e. has 0 as its last bit)?


Hi,

Detailed steps to reproduce the problem require a huge amount of underlying
library code, which wouldn't be all that helpful for you :/. i have in the
mean time worked around the problem altogether by using SetInternalField(n,
External::New(...)) instead of SetPointerInInternalField() (which i
_thought_ was just a thin wrapper around the former, but is apparently
not). i have only verified that the pointers are *really* aligned in the
sense that my man pages say:

   The malloc() and calloc() functions return a pointer to the
allocated memory that is  suitably  aligned  for
   any  kind  of  variable.

i can't ever in my life remember having seen a malloc'd address which is
_not_ an even number.

If the system allocator is not returning aligned memory then i'm probably
screwed anyway, so i still suspect a problem/mis-assumption in v8 here
(because all of my memory is coming from the standard allocators resp. (new
T)). That said, using External::New directly works perfectly fine for what
i'm doing, so i don't need any specific alignment requirements. Switching
to External also incidentally fixed a regression i was experiencing
involving accessing internal fields post-destruction (after WeakPtr
cleanup), where Object values would suddenly assert with is not an Object
in certain contexts. It seems that that problem (reported in another post
on the same day) was a side-effect of the alignment-related changes resp.
my use of SetPointerIn...() in conjunction with those changes.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

[v8-users] Re: SetAlignedPointerInInternalField() assertion

2012-12-23 Thread Stephan Beal
On Sat, Dec 22, 2012 at 2:00 PM, Stephan Beal sgb...@googlemail.com wrote:

 #
 # Fatal error in v8::Object::SetAlignedPointerInInternalField()
 # Pointer is not aligned
 #

 Is there a known problem for x64 with these routines or is there another
 replacement we should be using instead of the deprecated
 SetPointerInInternalField()?

 gcc 4.6.3 on Ubuntu 12.04, Linux 3.2.0 on x64. v8 trunk r13274.


i can confirm that this is also happening in a 32-bit VM with the same
OS/compiler, hosted on the above 64-bit system, but a colleague reports
that it is not happening on his Windows (32-bit) box.

The only pointers i am using as internal fields are allocated either on the
stack or via the system allocator, so i would certainly expect them to be
aligned properly. Using Get/SetPointerInInternalField() works flawlessly as
before but break my normal build process because i use -Werror and they are
marked as deprecated.

Any pointers (as it were) would be appreciated.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

[v8-users] SetAlignedPointerInInternalField() assertion

2012-12-22 Thread Stephan Beal
Hello, v8 devs,

after several months of being offline i'm coming back into the world and a
colleague pointed out this change to me:

https://code.google.com/p/v8/source/detail?r=12849path=/branches/bleeding_edge/include/v8.h

Summary:
Added highly efficient Object::SetAlignedPointerInInternalField and
Object::GetAlignedPointerFromInternalField functions for 2-byte-aligned
pointers. Their non-aligned counterparts
Object::GetPointerFromInternalField and
Object::SetPointerInInternalField are now deprecated utility functions.


So we did a drop-in replace of those routines with their new equivalents
and now get (on x64, but not i32) alignment assertions on objects created
using the system allocator (new T).

demo.cpp:199:MyType(): MyType::MyType() @ 0x1fba880

#
# Fatal error in v8::Object::SetAlignedPointerInInternalField()
# Pointer is not aligned
#

Is there a known problem for x64 with these routines or is there another
replacement we should be using instead of the deprecated
SetPointerInInternalField()?

gcc 4.6.3 on Ubuntu 12.04, Linux 3.2.0 on x64. v8 trunk r13274.

:-?

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

[v8-users] Painful regression in Object destruction behaviour

2012-12-22 Thread Stephan Beal
Hi, devs,

i have just found a regression (from sometime since last summer) in the
handling of Object destruction. Consider this JS code:

assert(m.destroy(), 'm.destroy()');
assertThrows( function() {m.doFoo();} );

(m is a bound Native object)

m.destroy() simply triggers the WeakPtr destructor callback and Dispose()s
the handle. What USED to happen after that was that any method calls could
still be made on m (like the call to m.doFoo() above) but my framework
would see that the Native binding in that Object (i.e. an Internal Field)
was missing and would trigger a JS-side exception. What now happens is that
the call to m.doFoo() triggers a v8 assertion as a side-effect of my code
trying to figure out of m still points to a valid native. So m.doFoo() now
results in the following assertion:

ConvertDemo.hpp:246:~BoundSubNative(): @0x1a47880 is destructing
ConvertDemo.hpp:53:~BoundNative(): @0x1a47880 is destructing.
Assertion OK: m.destroy()


#
# Fatal error in ../src/objects-inl.h, line 2386
# CHECK(object-IsJSObject()) failed
#

 C stack trace ===

 1: V8_Fatal
 2: v8::internal::JSObject::cast(v8::internal::Object*)
 3: ??
 4: v8::Object::GetPointerFromInternalField(int)
 5: ??
 6: ??
 7: ??
 8: ??
 9: cvv8::Detail::MethodToInCaVoidBoundNative, void (),
(BoundNative::doFoo()), true::Call(v8::Arguments const)
10: ??
11: ??
12: ??
13: ??


i don't know if this change was intentional but it hoses an inordinate
amount of my code which assert()s that my framework can correctly avoid
stepping on a deallocated native pointer (after the WeakPtr destruction
callback is called on it). It also makes it painfully simple to crash the
native app from script code, the avoidance of which is the whole purpose of
my framework catching post-destruction access to deallocated natives.

(Yes, i know that GetPointerFromInternalField() is deprecated but
GetAlignedPointerFromInternalField() asserts with not-aligned errors on
x64!)

Is this a bug or a feature which i need to go rewire my code to deal with?

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

[v8-users] Re: Painful regression in Object destruction behaviour

2012-12-22 Thread Stephan Beal
On Sat, Dec 22, 2012 at 2:27 PM, Stephan Beal sgb...@googlemail.com wrote:

 Hi, devs,

 i have just found a regression (from sometime since last summer) in the
 handling of Object destruction. Consider this JS code:
 ...

# Fatal error in ../src/objects-inl.h, line 2386
 # CHECK(object-IsJSObject()) failed
 #


The worst part is that i verify that Value-IsObject() before attempting
the GetPointerFromInternalField():

ResultType operator()( v8::Handlev8::Value const  h ) const
{
if( h.IsEmpty() || ! h-IsObject() ) return NULL;
else
{
void * ext = NULL;
v8::Handlev8::Value proto(h);
while( !ext  !proto.IsEmpty()  proto-IsObject() )
{
v8::Localv8::Object const  obj( v8::Object::Cast(
*proto ) );
ext = (obj-InternalFieldCount() != InternalFieldCount)
? NULL
: obj-GetPointerFromInternalField(
InternalFieldIndex );
if( ! ext )
{
if( !SearchPrototypeChain ) break;
else proto = obj-GetPrototype();
}
}
return ext ? static_castResultType(ext) : NULL;
}
}

so this appears to be a genuine bug in v8, in that IsObject() is returning
true, Object::Cast() is functioning (not asserting), but
GetPointerFromInternalField() is triggering a not-an-object assertion.


-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] [Beginner question] How to link a plugin

2012-09-28 Thread Stephan Beal
On Fri, Sep 28, 2012 at 7:07 AM, Moritz Willig moritz.wil...@gmail.comwrote:

 i know NodeJS and have already build some Projects with it. But I want to
 learn how to solve this problem this in general. As far as i see does
 NodeJS also provide Plugins but they have to be linked statically into the
 program (or have to be written in JS itself).


FWIW: there is no in general solution to this problem from a v8
perspective because v8 does not define any sort of native-side plugin
interface and the behaviour of DLLs is unspecified by the C++ standard.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] [Beginner question] How to link a plugin

2012-09-28 Thread Stephan Beal
On Fri, Sep 28, 2012 at 2:36 PM, Michael Schwartz myk...@gmail.com wrote:

 The problem is you have v8 as a static library.  It needs to be a shared
 one and the shared library (testplugin) needs to be linked against libv8.so
 and every other library it calls.

 See this for an example build script:
 https://github.com/mschwartz/SilkJS-redis/blob/master/build.js


And here's an article which covers some of the details in a
project-agnostic manner:

http://wanderinghorse.net/computing/papers/#classloading_cpp


-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] [Beginner question] How to link a plugin

2012-09-28 Thread Stephan Beal
On Fri, Sep 28, 2012 at 3:39 PM, Michael Schwartz myk...@gmail.com wrote:

 I didn't see anything useful at the link.


It explains, for example, why static libs are sometimes problematic in
conjunction with C++ templates and plugins (because unreferenced symbols do
not get linked in to the client).


 The issue is you have a .so that's getting loaded via dlopen().  That .so
 needs to call functions in the v8 library that is statically linked into
 the main program.


For example. And if those do not get referenced from client code then they
don't (or might not) get linked in.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Is there any way to get a list of objects within a running JS engine with a JavaScript command?

2012-09-18 Thread Stephan Beal
On Mon, Sep 17, 2012 at 1:55 PM, Christoph T. tor...@gmail.com wrote:

 I'd like to code an aspect oriented language extension for JavaScript. My
 aspects should be defined in JavaScript. To weave in my advices I need a
 list of all objects which are currently available within the current
 context, to match their names e.g. against a regular expression to find out
 if the new advice should be woven in. Is there a function within JavaScript
 I can call to simply get this list?


This can only be done on a per-object basis, but you can get access to the
top-level list of objects via the global object with code similar to the
following (run in the global scope):

var k, v;
for( k in this ) {
  if(!this.hasOwnProperty(k)) continue;
  v = this[k];
  ... do your bit here ...
}

AFAIK there is no standard way to get the names of vars from a scope, e.g.:

function foo(){
  var x, y, z;
  ... there is no standard way to derive the names x/y/z here ...
  ... either you know them or you don't ...
}

and i'm not sure that there's even a non-standard way to do it.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Very high call overhead to a specific C++ object member function

2012-09-13 Thread Stephan Beal
On Tue, Sep 11, 2012 at 5:24 PM, Stuart Allen stu...@lttlrck.com wrote:

 My C++ time stamp resolution was misleading. All is well after all. I
 should have known it was me and sending the mail late was a bad omen.

 Sorry for wasting your time.


FWIW this _was_ actually a problem in some early v8 version (several years
ago), and subsequent optimizations closed the gap between member and
non-member calls. i don't have the ticket number handy (and it doesn't
really matter any more), but there was actually a time where the difference
between member and non-member calls was tremendous.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Re: ia32 bug?

2012-09-07 Thread Stephan Beal
On Fri, Sep 7, 2012 at 5:25 PM, Jakob Kummerow jkumme...@chromium.orgwrote:

 The part of the V8 API documentation that applies here is how to wrap an
 External (that was created in C++!) safely before passing it into JS (where
 it can't be used anyway! It can only be read from C++). And that's by
 storing it as in internal field of a valid JS object, not as a property
 that's accessible on the JavaScript side. Because the latter would be
 inherently unsafe.

 ...



   * Keep External's implementation basically as it is. i.e. either a Smi
 or a Foreign. If we do this, we should not keep External as a subclass of
 Value (perhaps a subclass of Data?) and we should remove the IsExternal
 predicate. This means that e.g. SilkJS has to change, following
 https://developers.**google.com/v8/embed#dynamichttps://developers.google.com/v8/embed#dynamic.
 As it is, one can easily crash SilkJS by pure JavaScript.


 I'm in favor of this. I guess we could provide a convenience function that
 wraps an External as an internal field into an otherwise empty object and
 returns that, but it would have to be called explicitly.


FWIW, making an External not-a Value would break break ALL class bindings
i've ever done (that's no small number of them), as well as every class
binding in every framework i'm currently aware of (which of course is not
all of them). That's a degree of incompatibility where i would have to pack
up and move elsewhere (that's the reason i left Qt and the Autotools - too
many incompatible changes breaking too many of my apps, causing me to spend
too much time fixing things other people broke).

In the beginning i used External directly as properties (because there
was no documentation warning me otherwise), but quickly found that passing
them around in JS segfaults (and i belong to the school of thought that
script code is a sandbox and should never be able to segfault a native
app). So i starting storing my (void*) via External in an InternalField
(because that's how the API is apparently designed to be used). i've bound
hundreds of classes using this approach, and i'd rather abandon my v8-using
projects than go back and rework them all.

:-[

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Re: ia32 bug?

2012-09-07 Thread Stephan Beal
On Fri, Sep 7, 2012 at 5:57 PM, mschwartz myk...@gmail.com wrote:

 As I see it, the API you exposed in your header files and documentation is
 something of a contract, and I abided by it.  My code has worked extremely
 well and quite robustly for well over a year.  You change the API, you
 break my code and expect me to edit tens of thousands of lines of C++ code
 and the deal with the potential instabilities those changes will introduce.



Amen, brother.

As a compromise, may I suggest an alternative to External::New()?  How
 about you implement an Opaque::New() that satisfies whatever you feel
 necessary under the hood?


+1

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Visual Studio 2012(ComboBox -SlectedItem)

2012-09-06 Thread Stephan Beal
On Thu, Sep 6, 2012 at 7:40 AM, vemuri revathi vemuri1...@gmail.com wrote:

   i need your help, i am trying to create an example app which uses
 combobox, i have entered the values/combobox items what i want is when i
 click on a particular year it should be redirected to a particular page.


v8 has no idea what a checkbox is, and the following is not v8 code:


 i have used the following code
  if(yy.SelectedItem.ToString()==1960||1972||1984||1996||2008)
 {
 this.Frame.Navigate(typeof(Rabbit));
 }





 or 2nd type is the correct way
 if(yy.SelectedItem.ToString()=={1960,1972,1984,1996,2008})


Nor is {#,#,#...} any sort of legal JS construct. (Perhaps you meant [#,
#, ...]?)


 what i wnat is if we click on any of the above years it should navigate to
 the following page givenThere are no errors ,can you

please tell me is this a correct format in declaring the values..


v8 doesn't know what a web page is, nor what a click event is. Those are
browser-side constructs.

i.e. this is not the proper group for your question.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] 64-bit integers

2012-07-27 Thread Stephan Beal
On Fri, Jul 27, 2012 at 2:42 PM, Joran Greef jo...@ronomon.com wrote:

 Would it be possible to have proper support for native 64-bit integers and
 operations in Javascript?


JS as a language does not specify them. It specifies a Number type and
(IIRC) 51 (52? 53?) bits of integer precision.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] De-optimization of hot function when constructor adds methods directly to object

2012-07-19 Thread Stephan Beal
On Thu, Jul 19, 2012 at 3:04 AM, jMerliN jmer...@jmerlin.net wrote:

 So I can't get my head around why this happens (I haven't dug through
 v8's code to try to figure it out either), but this is really
 inconsistent to me with how v8 constructs hidden classes in general.
 The following is running in Node.js v0.8.2 (V8 v3.11.10.12).


FWIW: v8's internal optimizations are internal implementation details, and
any client code which optimizes specifically for them will, long term,
require more maintenance and possibly have more bugs/regressions. It is, in
general, poor practice for client code to assume that it knows ANYTHING
with certainty about a 3rd-party library beyond what is documented in
the library's API docs... errr... well, okay, that might be the problem
right there.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] How to access Object content in C++

2012-07-13 Thread Stephan Beal
Your code is correct but Object.toString() (which is what you do with the
Ascii part) returns the string you are seeing.

(brevity... phone...)

- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
On Jul 13, 2012 6:42 AM, Charles Han charleszhouxiao...@gmail.com wrote:

 Hi,

 I have managed to get an array back from JavaScript within C++. However,
 when I got to access the elements of the array, I got something like this:

 [object Object]
 [object Object]
 [object Object]
 ...

 Code:

   Array* uncompressed_json_objects = Array::Cast(*uncompressed_result);
   for(int i =0; iuncompressed_json_objects-Length(); i++ )
   {
 LocalObject obj = uncompressed_json_objects-Get(i);
 String::AsciiValue ascii(obj-ToString());
 printf(%s\n, *ascii);
   }

 What's the method to get values from a V8 array objects? ()

 Thanks

 --
 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

Re: [v8-users] Re: How to access Object content in C++

2012-07-13 Thread Stephan Beal
On Fri, Jul 13, 2012 at 1:09 PM, Charles Han
charleszhouxiao...@gmail.comwrote:

 Thanks for you reply. I can see what you mean in JavaScript but I don't
 understand how the data structure in the V8 Array, especially with all the
 JSON objects in the array.

 Can you please explain a bit more?



An Array object holds arbitrary Value values, and each Value refers to one
of the following value types:

- Object
- Array
- Number
- Null
- String
- Undefined
- Function
- Regex

What your code does is extracts a value from the array (the value just
happens to be-a Object) and then calls toString() on it. The result of
calling toString() on an Object is [Object object], which is why you see
that output. There is no generic, 1-size-fits-all object-to-string
conversion. If you want to output the contents of an Object, you must first
fetch those contents from the object or use a generic object-to-string
mechanism like JSON.stringify().

On a related note: PLEASE don't use printf() for this type of thing. The v8
example code uses it and is a sign that an absolutely C++ beginner wrote
that code (or that whoever wrote it doesn't care much for code quality). In
C++ one uses std::cout and std::cerr for this type of simple output, not
printf(), and _especially_ when only outputting a string as-is with no
formatting. The peformance difference between:

printf(%s\n, foo)

and:

puts(foo)

is absolutely staggering (the second one is MUCH more efficient), but the
end result is identical. printf() has its place, but (printf(%s\n,...))
is ALWAYS a poor choice - puts(...) is faster, uses less stack space, and
is not subject to formatting-related injection bugs.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Re: NamedPropertyHandlers on Function object

2012-07-13 Thread Stephan Beal
On Fri, Jul 13, 2012 at 4:36 PM, mschwartz myk...@gmail.com wrote:

 The possibilities I see for its use are to protect the global object from
 extraneous modification and tracking changes to the global object.


Would that not be applicable for the recent thread about how to reset the
global object for re-use?


 Another issue that comes up on this list from time to time is the ability
 to reset the global object between requests in a server-side HTTP
 scenario.  If you can track changes made during one request, you can undo
 them between requests.


That's what i get for not reading ahead before asking questions :/. Undo
might not always be feasible because changes could have side-effects which
the global object does not directly see. For example:

var foo = {}; // in global scope. Global knows about foo, but...

// in client code:

foo.bar = ...;

the global observer probably could not catch that and therefore not
generically revert it.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Re: How to access Object content in C++

2012-07-13 Thread Stephan Beal
On Sat, Jul 14, 2012 at 1:21 AM, Charles Han
charleszhouxiao...@gmail.comwrote:

 BTW, are the JSON.parse and JSON.stringify built into the V8 lib? so I
 don't have to have the javascript file.


Yes, an RFC-compliant JSON object is built in.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Destructors, a proposal of sorts

2012-07-12 Thread Stephan Beal
Sorry for top posting (tablet gmail makes it difficult to do otherwise)...

I should have specied that correct, well-defined behaviour is far, far more
important to me than gc-related lags. For me it has never been a question
of performance, but of well-defined (non- performance- related) behaviours
and returning resources to their owners. Yes, i use finalizers for all of
my bound native types, but that is so that they have well-defined behaviour
and has 0 to do with speed. Obviously that requirement is out of scope for
chromium, which is fine in and of itself but very negatively impacts v8's
re-use in other projects because we embedders often have to expend undue
amounts of energy shoe-horning finalization into not only our c++ code but
also into our docs and users. (Yes, it's our own fault, but without
bindings to interesting natives js is not much use.)
On Jul 12, 2012 8:43 AM, Sven Panne svenpa...@chromium.org wrote:

 The beating continues... ;-)

 Regarding Boehm's finalization is rarely needed: I think statement
 generally holds, *except* for the case we are discussing, namely writing a
 binding for a library with explicit allocation/deallocation where the
 deallocation part is not exposed in the binding. While it is very
 convenient for the user of such a binding, it simply wipes some complexity
 of the original library under the carpet, hoping for a magic solution from
 the binding language/runtime.

 When one uses finalizers for this magic solution, one faces another
 problem, namely the usual tradeoff between latency and throughput: For the
 vast majority of use cases of a GC, throughput is much, much more important
 than latency. In theory one could write a basically zero-latency GC (e.g.
 by doing reference counting on strongly connected components) where
 finalizers would fire immediately, but the overhead is so huge that no real
 collector I know of does it this way. So using finalizers in the real world
 will always involve some kind of delay, and you simply have to live with
 that.

 If the delay is intolerable and you have certain points in your
 application/library/framework where you know something about the lifetime
 of the underlying library objects (which seems to be the case for our
 example), you can deallocate the dead ones by hand, using the finalizer
 calls from the GC only as an additional hint to do this early. Having
 written several library bindings for myself, I am quite aware of the fact
 that the additional complexity of doing this in the binding layer is not
 nice, because it involves some housekeeping of the library objects there,
 but this is the price of hiding complexity from the user of the binding.

 Regarding Boehm's Section 3.3, bullet point #1:: This assertion is true,
 because in a library binding there are at least *2* objects involved, in
 our example the JavaScript canvas object plus the underlying Cairo surface.

 Cheers,
S.

 --
 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

Re: [v8-users] Destructors, a proposal of sorts

2012-07-11 Thread Stephan Beal
On Tue, Jul 10, 2012 at 4:26 PM, mschwartz myk...@gmail.com wrote:

 meant to free the programmer from making certain mistakes.  The answer
 that we should manually call a destroy() type function because we know it's
 a good time to do so suggests we should call delete (operator) as well for
 every object we call new (operator).


FWIW: for ALL of my bound natives i bind a member destroy function (and
typically use the try/finally approach to ensuring that they are cleaned
up). The exact name of the function is class-dependent but the
implementation is a template which does:

a) unbinds the native pointer from the JS Object.
b) calls the registered weak destruction callback (which almost always
calls (delete theNative)).

Afterwards, calling theBoundJSObject.anyMemberFuncWhichNeedsTheNative()
will cause a JS exception to be thrown (cannot find native 'this'
pointer), as opposed to crashing or stepping on a now-reallocated address
which might now even belong to a different class of object.

http://code.google.com/p/v8-juice/source/browse/convert/include/cvv8/ClassCreator.hpp#1017

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Destructors, a proposal of sorts

2012-07-11 Thread Stephan Beal
On Wed, Jul 11, 2012 at 4:38 PM, Andreas Rossberg rossb...@google.comwrote:

 In any case, before you conclude that finalization is the answer to your
 problems, let me +1 Sven's recommendation on reading Boehm's paper on the
 subject. Finalization is pretty much an anti-pattern. There are some rare,
 low-level use cases, but usually it creates more problems than it solves.
 That's why we only provide it in the C++ API.


Just to beat a long-dead horse for a moment...

Quoting Boem's paper:

Page 1: We argue that although finalization is rarely needed, it is often
critical when it is needed. In these cases, its absence would render the
garbage collector useless.

Rarely needed is, in my (not inconsiderable) experience, 100% wrong for
JS bindings. The vast majority of the interesting client-side NATIVE types
which we want to bind to JS require resource acquisition and a large
percentage of them require well-defined finalization/destruction in order
to guaranty proper behaviour.

Examples, just off the top of my head:

- File handles must be close()d in order to ensure that they are flushed.
Yes, the OS closes them when the process exit()s, but AFAIK they are not
automatically flush()ed.

- Database drivers, statement handles, and query cursors all have very
specific cleanup requirements, and failing to properly close() a db handle
could (though admittedly shouldn't) lead to undefined behaviour e.g. db
corruption.

- Anything which heavily relies on parent/child relationships, UI toolkits
being a prime example. Getting those working properly in JS can be a real
PITA because the child/parent relationships must be tracked in both JS and
native space in order to keep all the objects around for their proper
lifetimes. (When i first implements an ncurses binding for JS i quickly
found i had to make JS aware of all child window references to keep them
from being GC'd out from under the parent window's nose.)


We (client-side users of scripting engines) don't bind trivial classes to
native implementations. Such impls are done in JS because it's 100x times
easier to do so (e.g. the canonical Point class example). When we bind
natives its because we need native functionality which we cannot get at
from JS, and the vast majority of such functionality requires access to
interesting native resources with arbitrarily complex compositions and
cleanup requirements. i don't know of a single commonly-used C/C++ library
which does _not_ require that clients clean up resources it asked the
library to allocate for them.


Section 3.3, bullet point #1: There is usually not much of a point in
writing a finalizer that touched only the object being finalized, since
such object updates wouldn't normally be observable.

i understand that this assertion can be true, but it assumes that the
statement from Page 1 is true, which it is absolutely not for the generic
case when binding native C/C++ types to JS.

To be clear: i'm not picking no v8 here. In time since i wrote the original
gripes which Michael S. linked to in the top post of this thread, i have
since come to understand much more about the difficulties of finalization
ordering and whatnot, and have a much deeper appreciation for the nature of
the problem. Nonetheless, assertions like Boem's quotes above, in my
opinion, simply hand-wave away a _majority_ of use cases as not useful or
rarely seen, when in fact the problem is that they are just damned
difficult to solve. Obviously Boem is the top of his field, and i don't
discount his brilliance in this subject matter, but hand-waving away such
problems as being infrequent does him no credit.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Destructors, a proposal of sorts

2012-07-11 Thread Stephan Beal
On Wed, Jul 11, 2012 at 7:02 PM, Stephan Beal sgb...@googlemail.com wrote:

 Section 3.3, bullet point #1: There is usually not much of a point in
 writing a finalizer that touched only the object being finalized, since


PS: the typos are mine, not Boem's - my PDF reader won't let me copy/paste
:/.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Native objects with uncallable constructors

2012-07-11 Thread Stephan Beal
On Wed, Jul 11, 2012 at 4:57 AM, Mike Schwartz myk...@gmail.com wrote:

 Exposed constructor always throws an error.  document.createElement calls
 an unexposed factory method, which calls a protected constructor.


There is a case when a ctor needs to be exposed but should not be invoked
by clients: to allow the use of the instanceof operator.

As a concrete example, in my JSPDO (PHP PDO clone) i initially hid the
Statement class' constructor from the clients. While writing client-side
code i discovered a need to determine if an object is-a Statement[1] or not
(as opposed to a Object or Array), and ended up having to expose the ctor.
However, i took the draconian steps of explicitly documenting the ctor as
not to be used for anything other than instanceof checks, explicitly did
not document the arguments it takes, and internally intentionally make it
(slightly) difficult for clients to call the ctor (i.e. they'll only know
what to do if they read the C++ code, and if i catch them doing that i'll
change it just to break their script code ;).

Happy Hacking!

[1] = http://code.google.com/p/v8-juice/wiki/JSPDO_API#JSPDO.Statement

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Native objects with uncallable constructors

2012-07-10 Thread Stephan Beal
Briefly (i am on a tablet) : this can be done a few different ways, but
getting at the code is really tedious on a tablet :-\. I will post some
links to examples for you tomorrow. One quick idea: have the bound ctor
allow only some weird arguments and throw for everything else (and don't
document them in the js interface) . Your c++ code can then pass the weird
args to FunctionTemplate::NewInstace(). Example: require the args (null,
undefined, the real args...). Then throw if the args do not comply. There
are other (cleaner) ways, too, e.g. passing a v8::External to the ctor (js
code cannot create these).
On Jul 10, 2012 10:34 PM, Kevin James kevinwja...@gmail.com wrote:

 I want to write bindings for C++ objects whose constructors can't be
 called directly. Examples of what I'm talking about in a browser would
 be Element, ImageData, and Canvas. These are defined as functions in the
 global namespace, but if a script tries to call new Element(), an
 exception is thrown. Instead an appropriate function has to be called, for
 example document.createElement().

 How are the bindings for these objects are written? If I create a
 FunctionTemplate, I can have it's constructor always throw an Illegal
 Constructor exception, but then how will my C++ code instantiate one of
 these objects?

 Thanks.

 --
 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

Re: [v8-users] Native objects with uncallable constructors

2012-07-10 Thread Stephan Beal
I found an example of the magic args approach combined with v8::External
to differentiate how certain objects are constructed:

http://code.google.com/p/v8-juice/source/browse/trunk/src/lib/juice/PathFinder-cw.cc#72

Feel free to contact me off-list with questions about that code.
On Jul 10, 2012 11:09 PM, Stephan Beal sgb...@googlemail.com wrote:

 Briefly (i am on a tablet) : this can be done a few different ways, but
 getting at the code is really tedious on a tablet :-\. I will post some
 links to examples for you tomorrow. One quick idea: have the bound ctor
 allow only some weird arguments and throw for everything else (and don't
 document them in the js interface) . Your c++ code can then pass the weird
 args to FunctionTemplate::NewInstace(). Example: require the args (null,
 undefined, the real args...). Then throw if the args do not comply. There
 are other (cleaner) ways, too, e.g. passing a v8::External to the ctor (js
 code cannot create these).
 On Jul 10, 2012 10:34 PM, Kevin James kevinwja...@gmail.com wrote:

 I want to write bindings for C++ objects whose constructors can't be
 called directly. Examples of what I'm talking about in a browser would
 be Element, ImageData, and Canvas. These are defined as functions in the
 global namespace, but if a script tries to call new Element(), an
 exception is thrown. Instead an appropriate function has to be called, for
 example document.createElement().

 How are the bindings for these objects are written? If I create a
 FunctionTemplate, I can have it's constructor always throw an Illegal
 Constructor exception, but then how will my C++ code instantiate one of
 these objects?

 Thanks.

 --
 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

Re: [v8-users] Re: V8 and pthreads

2012-07-05 Thread Stephan Beal
On Thu, Jul 5, 2012 at 4:21 PM, mschwartz myk...@gmail.com wrote:

 // TryCatch tryCatch;
 printf(CALL\n);
 v = func-Call(context-Global(), 1, av);

 // if (v.IsEmpty()) {
 // printf(Exception!);
 // ReportException(tryCatch);
 // }



Out of curiosity: did you comment that TryCatch out because it is no longer
relevant for you or because it doesn't work? i remember having unspecified
headaches with local-scoped TryCatches, very possibly due to my
inadvertent misuse of them. If the above is how they are supposed to be
used, i'll take another look at the code i had such problems with.

Also of note is if I throw an Error() from JS in a thread, it's caught, but
 the TryCatch doesn't seem to have valid data.


Ah, that's what i get for not reading to the end before asking questions :/.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Error when linking libv8_base.a into a shared object on x64 linux

2012-07-02 Thread Stephan Beal
On Mon, Jul 2, 2012 at 1:13 PM, Michael Schwartz myk...@gmail.com wrote:

 The more interesting question is why he thinks he needs -fPIC for a static
 library.  The error message indicates the elf file contains a 32-bit
 relocation and it needs to be a 64-bit one.


FWIW: i had the same problem with libsqlite4.a (yes, 4) until i added -fPIC
to its build options.


 Position Independent Code (PIC) is typically (almost always) used in
 shared libraries.


Ubuntu likes it to always be set :/.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] V8 and pthreads

2012-07-02 Thread Stephan Beal
On Mon, Jul 2, 2012 at 1:46 PM, mschwartz myk...@gmail.com wrote:

 Anyhow, I hope the code is of interest to someone.


Absolutely. i tried to do the same in SpiderMonkey several years ago and
failed miserably. It actually worked on single-core systems (where no real
MT was going on), but as soon as i moved to 2-core it all exploded very
horribly.

Thank you for the code and link :).

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Re: Spring-cleaning tools/test.py

2012-07-02 Thread Stephan Beal
On Mon, Jul 2, 2012 at 1:58 PM, Jakob Kummerow jkumme...@chromium.orgwrote:


- distribution of testing work in the local network (think distcc).
Details will be announced when the feature is ready; of course it will be
opt-in.


A very far-fetched idea here: imagine if Google or Chromium provided public
distcc servers...

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] V8 and pthreads

2012-07-02 Thread Stephan Beal
On Mon, Jul 2, 2012 at 3:11 PM, Michael Schwartz myk...@gmail.com wrote:

 However, a long running thread could call sleep(0) or pthread_yield()
 periodically to allow the other threads to run.


From what i understand, every time the JS-side code calls back into v8
(e.g. via a function call), v8 gets a chance to interrupt it. This doesn't
protect against infinite loops which don't call back into v8, of course.
while(true){++i} would probably never yield.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] V8 and pthreads

2012-07-02 Thread Stephan Beal
On Mon, Jul 2, 2012 at 6:00 PM, Michael Schwartz myk...@gmail.com wrote:

 I'm not clear on when a thread running in v8 might be preempted.  Likely
 on entering or exiting functions (when doing stack checks, I think I
 remember reading about).


FWIW, that's also my recollection.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] instanceof Array fails after ReattachGlobal

2012-06-26 Thread Stephan Beal
On Tue, Jun 26, 2012 at 5:34 PM, MikeM mi...@reteksolutions.com wrote:

 I suppose I could keep using the same Context over and over, but I would
 need a way to wipe out any local var declarations between executions and
 only keep the built-ins.


On a similar note, you probably couldn't protect against:

Array.foo = whatever;

i suspect that the only safe way to do it is recreate the whole sandbox on
each run. Not doing so will eventually lead to weird behaviours, i
think (via sneaky modifications like custom properties on built-ins).

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] instanceof Array fails after ReattachGlobal

2012-06-26 Thread Stephan Beal
On Tue, Jun 26, 2012 at 6:27 PM, MikeM mi...@reteksolutions.com wrote:

 V8 is still a bit foreign to me.  I'm trying to break that barrier.


Welcome aboard - i hope we can help you get over the initial humps. It can
be a bumpy ride.


   How do I create a global template with a complete set of built-ins?
 I'd love some sample code that does this... :-)


From my understanding you've already done that, but you're trying to take
it a step further and transport the object from its initial context to
another one. Can that work? i don't know for certain, but i _suspect_ the
answer is something along the line of it can, with some notable caveats
like object/namespace pollution. The vast majority of apps have (in my
rather long but narrow experience) a single context which starts life early
on in main() and ends life shortly before or after main() returns
(depending on whether one manually destroys it or lets the dtor do its
work). That is of course not a rule, but is the common pattern for the
apps i've worked on (http://code.google.com/p/v8-juice).

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] instanceof Array fails after ReattachGlobal

2012-06-26 Thread Stephan Beal
On Tue, Jun 26, 2012 at 6:53 PM, Stephan Beal sgb...@googlemail.com wrote:

 Welcome aboard - i hope we can help you get over the initial humps. It can
 be a bumpy ride.


Tip #0, in case you haven't come across this already: always develop
against a debug build of libv8. Not doing so is basically futile because v8
_will_ crash when you mis-use it (and you _will_ mis-use it at times) and
the debug builds dump a surprising amount of detail about the crash to
stderr when they crash.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] instanceof Array fails after ReattachGlobal

2012-06-26 Thread Stephan Beal
On Tue, Jun 26, 2012 at 7:21 PM, MikeM mi...@reteksolutions.com wrote:

 I'm open to any method of making this happen.
 Thanks for the help!


i unfortunately cannot say much on the topic of multiple contexts and
de/serialization of v8 state across requests, but i suspect that Michael
Schwartz (who also responded earlier) can tell us something informative on
the topic. He's the architect behind http://silkjs.org/, which has a larger
scope than the library-level code i tend to write.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] instanceof Array fails after ReattachGlobal

2012-06-26 Thread Stephan Beal
On Tue, Jun 26, 2012 at 7:47 PM, Michael Schwartz myk...@gmail.com wrote:

 Something else I discovered early on in SilkJS development is that you can
 call from JS, a C++ function that calls fork() and returns.  After the
 return, you have a parent and child process resuming in JS context.  The
 child process is a literal clone of the parent, including the context and
 it's global and everything compiled in.  So if you have a pristine global
 object set up by JS and call fork() for each request, you have a pristine
 global in the child


Nice idea. To drag us off topic for a moment... i implemented fork() for
SpiderMonkey some years ago but never really trusted that the JS engine
would behave properly if forked, so i never used it. Does v8 provide any
specific guarantees in the face of forking, or are you aware of any notable
down-sides to using fork() from JS in generic client code?

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] instanceof Array fails after ReattachGlobal

2012-06-26 Thread Stephan Beal
On Tue, Jun 26, 2012 at 8:13 PM, Michael Schwartz myk...@gmail.com wrote:

o   The child process has its own copy of the parent's
 descriptors.
These descriptors reference the same underlying objects, so
that, for instance, file pointers in file objects are shared
between the child and the parent, so that an lseek(2) on a
descriptor in the child process can affect a subsequent
 read or
write by the parent.  This descriptor copying is also used
 by
the shell to establish standard input and output for newly
 cre-
ated processes as well as to set up pipes.


That's the kind of thing i was looking for. e.g. sharing a stdout handle
could be mildly problematic. Sharing an sqlite3 db file handle or a MySQL
socket (it connects to a localhost socket file by default) could be even
more-so.

Notably missing is that fork() does not clone any threads associated with
 the parent process.  I've been told by V8 committers that there are no
 threads running of consequence to the child processes.  I was initially
 concerned that maybe some thread in v8 was doing the hot spot type
 optimization of the generated machine code, but I'm told that this isn't
 done by a thread.  Maybe fork() loses some profiling information.
  Certainly fork loses the debugger; to get around this, the -d flag to the
 httpd server tells it to not fork() but to call the HttpChild's run
 function.  You can fully debug with node-inspector that way (works great!).


That's all great information, thanks. (Mis)Interactions with internal JS VM
state  were always highest on my list of suspicious behaviour. i never
personally saw problems with it, but i bailed out early on because of my
complete uncertainty with what was happening in the VM. Looking back on the
code[1] now, it was trivial to implement. i'll give this a whack in v8.

http://spiderape.svn.sourceforge.net/viewvc/spiderape/plugins/SystemFuncs/system_funcs.cpp?revision=65view=markup
line
483

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] instanceof Array fails after ReattachGlobal

2012-06-26 Thread Stephan Beal
Tue, Jun 26, 2012 at 8:26 PM, Michael Schwartz myk...@gmail.com wrote:

 You can also encounter this error with applications that fork child
 processes, all of which try to use the same connection to the MySQL server.
 This can be avoided by using a separate connection for each child process.

 Plus, I'd think that socket would become a significant bottleneck, since
 you'd be talking basically to a single thread in the MySQL server...


That's the crux of my problem: i write almost exclusively library-level
code and i can't enforce this type of policy on downstream clients in any
useful way. So my only defense against such things is either not providing
such a feature (let the client do it) or documenting them with big fat
hairy warning labels :/.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] 'Create instance of instance' or 'returning a v8::Function from NewInstance()'

2012-06-15 Thread Stephan Beal
On Fri, Jun 15, 2012 at 10:20 AM, thewilli thewi...@googlemail.com wrote:

 *var Float = new Type(Float);
 var myFloat = new Float(34.2);*

 and want to avoid factory methods like

 *var myFloat = Float.createInstance(34.2)*;



You can'd _call_ individual instances (not portably), but you can of course
do:

var Float = Somefactory.FloatFactory;
var myFloat = new Float(...);

which is not very far removed from what you demonstrate.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] [SIGSEGV] v8::HandleScope::HandleScope()

2012-06-15 Thread Stephan Beal
On Fri, Jun 15, 2012 at 12:38 PM, Vyacheslav Egorov vego...@chromium.orgwrote:

 Also ensure that the thread that invokes your even_handler owns V8
 Isolate if you have multiple threads using V8 concurrently.


Additionally, the timing of the call is important. If you do it at the very
start of main(), before setting up v8, it won't work (crash). The Most
Important Tip for v8 is what Vyacheslav said: link to the debug library
because when that one crashes it dumps a lot of useful info to the console.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Does V8 has methods to parse json in c++.

2012-06-09 Thread Stephan Beal
On Sun, Jun 10, 2012 at 12:56 AM, Chris Jimison cjimi...@gmail.com wrote:

  HandleObject result;
  if (sourceFlatten-IsSeqAsciiString()) {
result = JsonParsertrue::Parse(sourceFlatten);
  } else {
result = JsonParserfalse::Parse(sourceFlatten);
  }
  return result;
 }


i don't think that code accepts Array input.

Why not just get the JSON property from the global scope, Cast() it to an
Object, get it's parse property, cast it to a Function, and Call() that?

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] XOR two 31-bit unsigned integers much faster than XOR two 32-bit unsigned integers?

2012-05-30 Thread Stephan Beal
On Wed, May 30, 2012 at 6:25 PM, Vyacheslav Egorov vego...@chromium.orgwrote:

 c) stop doing  0 at the end;


A side question: what does 0 do? i have never seen the  operator
before this thread and never seen a 0-bit shift anywhere.

:-?

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] JavaScript Proxy object

2012-05-23 Thread Stephan Beal
On Wed, May 23, 2012 at 7:05 PM, Michael Schwartz myk...@gmail.com wrote:

 Does it remove what it consumes from argc and argv?


i just came across this years-old snippet...

 if(0)
{ /** f*** - SetFlagsFromCommandLine() changes argv such that the
  -- arg and those following it are stripped!
   */
typedef std::vectorchar * AV;
AV vargv(static_castsize_t(argc), 0);
int i;
for( i = 0; i  argc; ++i )
{
vargv[(unsigned int)i] = argv[i];
}
v8::V8::SetFlagsFromCommandLine(i, vargv[0], true);
}
else
{
// or we could use the undocumented 3rd arg:
//v8::V8::SetFlagsFromCommandLine(argc, argv, false);
}

The first comment is where i remember having problems: anything after a
-- argument is stripped completely. That was a problem for me because i
use -- to signal the start of args to pass to the client-supplied JS script
(as opposed to shell-level args).

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Re: calling setRequestHeader

2012-05-04 Thread Stephan Beal
On Fri, May 4, 2012 at 2:51 PM, souad agoun souad.ag...@gmail.com wrote:

 why v8 does not support xmlhttprequest object ?


Because core JS does not define that functionality. That is a w3c standard
based upon JS. The Rhino Book from O'Reilly is the only JS book i've seen
which discusses this distinction in detail and clearly separates the core
language APIs and (e.g.) the DOM APIs. JS defines NO I/O functionality
(whether network or file or terminal), and ANY I/O performed by JS is
being performed a non-core-language function.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] No whitespaces in string, what have I done wrong?

2012-05-02 Thread Stephan Beal
Google for std::iosteam skipws.

- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
On May 2, 2012 2:47 AM, idleman evoo...@gmail.com wrote:

 Why does all white spaces get removed in the example below?

 //C++
 HandleValue System::log(const Arguments args)
 {
 for(int i = 0, s = args.Length(); i  s; ++i) {
String::AsciiValue ascii(args[i]);
 os.write(*ascii, ascii.length())  std::endl; //os =
 std::ostream object
 }
 return Undefined();
 }

 //Then in javascript, there the System object have been exposed to
 JavaScript.
 System.log(How are you?);  //prints howareyou? not how are you?, e.g
 no whitespaces

 In the example do I get the text: Howareyou?, not How are you?, what
 does I wrong? Why are all white spaces removed? The std::ostream::write
 write oformatted output, so it does not remove any white space, so it is
 not the problem.

 Thanks in advance!

  --
 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

Re: [v8-users] How do I set what this refers to?

2012-05-02 Thread Stephan Beal
On Wed, May 2, 2012 at 6:07 PM, Andreas Rossberg rossb...@google.comwrote:

 (function() { script-text }).call(implicitThisObj)


See also Function.apply(). The only difference between apply() and call()
is how the 2nd+ argument(s) are passed to it:

myFunc.call( myObj, 1, 2 );
===
myFunc.apply( myObj, [1, 2] );

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Re: trunk fails to build

2012-04-27 Thread Stephan Beal
On Fri, Apr 27, 2012 at 7:27 PM, Michael Schwartz myk...@gmail.com wrote:

 This is on a freshly installed Ubuntu in a VM.  There is no system wide
 v8.h header.  The -I./v8-read-only/include switch is having it read the
 v8 from the include directory.


FWIW:

[stephan@host:~/src/google/trunk]$ svn info
Path: .
URL: http://v8.googlecode.com/svn/trunk
Repository Root: http://v8.googlecode.com/svn
Repository UUID: ce2b1a6d-e550-0410-aec6-3dcde31c8c00
Revision: 11461
Node Kind: directory
Schedule: normal
Last Changed Author: yang...@chromium.org
Last Changed Rev: 11442
Last Changed Date: 2012-04-26 10:21:05 +0200 (Thu, 26 Apr 2012)

 [stephan@host:~/src/google/trunk]$ make x64.debug library=shared
cmp: EOF on out/environment
GYP_GENERATORS=make \
build/gyp/gyp --generator-output=out build/all.gyp \
  -Ibuild/standalone.gypi --depth=. -Dtarget_arch=x64 \
  -S-x64  -Dcomponent=shared_library
-Dv8_can_use_vfp_instructions=true
...snip...
  TOUCH
/home/stephan/src/google/trunk/out/x64.debug/obj.target/build/All.stamp
make[1]: Leaving directory `/home/stephan/src/google/trunk/out'


== works for me

Ubuntu 12.04 w/ gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Convert LocalValue array to Arguments, or am I passing around wrapped Objects incorrectly?

2012-04-26 Thread Stephan Beal
On Thu, Apr 26, 2012 at 6:10 PM, Ryan Cole r...@rycole.com wrote:

 think I've almost got it, but I am trying to figure out how to convert a
 LocalValue array back into an Arguments instance, so that I can pass it
 to a function of mine.


AFAIR, client code cannot create Arguments objects. They are created
indirectly when we (the clients) call Function::Call().

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Convert LocalValue array to Arguments, or am I passing around wrapped Objects incorrectly?

2012-04-26 Thread Stephan Beal
On Thu, Apr 26, 2012 at 10:21 PM, Ryan Cole r...@rycole.com wrote:

 Ok. I guess that's where I need to figure out how to adjust my code, then.
 I went ahead and wrote a longer description of my situation on
 stackoverflow.com, because I felt like I could format it better and get
 the whole description out there all at once without having to re-write it
 for other places. Here's a link to that:


 http://stackoverflow.com/questions/10340552/how-to-pass-a-wrapped-c-object-to-a-javascript-callback



There is no 3-line answer, but you might find some of these docs
interesting (if only for ideas):

http://code.google.com/p/v8-juice/wiki/V8Convert
http://code.google.com/p/v8-juice/wiki/V8Convert_FunctionBinding
http://code.google.com/p/v8-juice/wiki/V8Convert_XTo
http://code.google.com/p/v8-juice/wiki/V8Convert_ClassCreator

In particular, the 2nd link (2nd to last section of the page) might be
relevant for you.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Re: [v8-users] Leaking data in SetAccessor

2012-04-14 Thread Stephan Beal
On Sat, Apr 14, 2012 at 3:59 AM, Gerhans gerh...@gmail.com wrote:

 Thanks for the reply Stephan. You're imagining a mapstring,void* kind of
 thing?


Ah, i didn't consider that each _instance_ of course has its own value. i
was thinking about saving the last one in a static.


 Seems workable, and I may have to resort to that, but I was hoping to
 understand the nature of the problem better. Is this my bug or V8's? I'm
 new to V8 so it seems likely I'm doing something wrong.


i don't see anything wrong with what you've done :(.


-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

  1   2   3   4   5   >