Re: [v8-users] Why does CompileUnbound require a context?

2017-01-30 Thread tblodt
I discovered there's at least one more thing that CompileUnbound does with 
the current context. There's a call to isolate->debug()->OnAfterCompile() 
in Compiler::GetFunctionFromEval, which sends the Debugger.scriptParsed 
event--if the current context is being debugged. If the current context is 
not being debugged, the event disappears, never to be seen again (unless, 
presumably, a debugger is attached to the context the script is compiled 
in). I learned this the hard way.

~Theodore

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Minimal example of the v8-inspector c++ api

2017-01-27 Thread tblodt
I've been trying to use the v8-inspector C++ api in my app, but it doesn't 
seem to be working. I have a feeling I'm probably misunderstanding 
something simple due to the lack of documentation and comments in 
v8-inspector.h. Could someone create a minimal example of using the 
v8-inspector c++ api to do some simple debugging?

~Theodore

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Re: C++ object prototype still not working

2017-01-07 Thread tblodt
I've got a V8 library on github that isn't abandoned: 
https://github.com/tbodt/v8py. I've gotten pretty much everything to work 
with it. It's a Python extension module, though...

Hope this helps.
~Theodore

On Wednesday, December 21, 2016 at 9:33:02 AM UTC-8, kent williams wrote:
>
> I think this has been way more frustrating than it should be.
>
> I've done a LOT of googling to figure this out, and gotten some advice 
> from people on this list and I still don't have a working version of this.
>
> My spec is simple: I want to create an object type that will encapsulate 
> private data, and define a number of methods to manipulate the private data.
>
> My current version:
> https://gist.github.com/Chaircrusher/48d53ee78567ca213f7a858e91e4771d
>
> Right now it compiles with errors and runs.  The constructor is called, 
> the constructor is called, but the methods to the object are apparently not 
> installed properly.
>
> There 3is a problem here, and I can't believe it's just me.
>
> 1. The Embedder's guide has no comprehensive working example.  Using it as 
> a clue didn't really suggest a solution.
>
> 2. Following -- as suggested -- the example in v8/test/cctest/test-api.cc 
> doesn't work (see ConstructorForObject test) 
>
> 3. Following this example doesn't work -- 
> https://groups.google.com/d/msg/v8-users/aVGp6jMJbA4/d7kMawQyAwAJ
>
> 4. There are many moving parts to getting v8 to actually run a script; 
> most of these amount to copying boilerplate code that could (and should!) 
> be encapsulated in some kind of convenience object. 
>
> 5. There are various libraries littering github, but they seem to be 
> abandoned, usually when an update to v8 broke the api they depended on.
>
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Why does CompileUnbound require a context?

2017-01-07 Thread tblodt
I'd like to compile a script without any context active or present. When I 
tried to use CompileUnbound, it crashed because there was no current 
context. Is there some way I can do this?

~Theodore

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Re: Good SIMPLE v8 C++ wrapping example?

2016-12-23 Thread tblodt
SetPrototype and Set can fail, so they return optionals. FromJust asserts 
that the optional is not empty (and crashes the program if it is empty).

On Monday, December 19, 2016 at 10:18:31 AM UTC-8, kent williams wrote:
>
> That example has some weird:
> Line 11341:
>
> This->SetPrototype(context, proto).FromJust();
>
> What is the FromJust() for? Does that method have side effects? 
> Same deal at 11347:
> This->Set(context, v8_str("a"), args[0]).FromJust(); 
>
>
>>
>> https://cs.chromium.org/chromium/src/v8/test/cctest/test-api.cc?q=test-api.cc=package:chromium=11365
>>
>> Cheers,
>>
>> Yang
>>
>>
>>
>>
>> On Wednesday, December 14, 2016 at 11:53:31 PM UTC+1, kent williams wrote:
>>>
>>> Call me silly but I've spent this afternoon looking at v8/samples and 
>>> the various web pages/blog entries (and the embedder's guide) and not 
>>> getting a clear picture of how to create a new object type with methods and 
>>> a constructor in v8.
>>>
>>> Is there a good example out there?
>>>
>>> In my particular case, I have this implemented using SpiderMonkey, which 
>>> seems a lot more straightforward.  It has the JS_InitClass call where you 
>>> pass in a constructor, a destructor, and an array of method descriptors.
>>>
>>> In v8, it seems spread out and confusing.  There's this: 
>>> https://gist.github.com/mythagel/4527961 but end up sidetracked by 
>>> decoding all the C++11 junk.
>>>
>>> If that's it, I'll just buckle down and figure it out. But if someone 
>>> can point me at something to start from, I'd be much obliged!
>>>
>>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Re: What is required for the JS Environment to persist across script evaluations?

2016-12-03 Thread tblodt
Basically, you create a context and then run multiple scripts in the same 
context.

~Theodore

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Re: Missing symbol ___asan_version_mismatch_check_v8

2016-12-01 Thread tblodt
That didn't work. V8 insisted on linking with the asan runtime included 
with it's special version of clang, so mkpeephole wouldn't run because it 
couldn't find ___asan_version_mismatch_check_apple_800. I'm going to try 
playing with the executable path.

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Re: Missing symbol ___asan_version_mismatch_check_v8

2016-12-01 Thread tblodt
Well, I looked a little more closely at the compiler options and discovered 
that my library is not, in fact, getting compiled with ASAN. Only V8 is.

Now the problem is that if I compile the library with the same compiler as 
V8, it can't find @executable_path/libclang_rt.asan_osx_dynamic.dylib, but 
if I compile it with the system version of clang, I still get a missing 
___asan_version_mismatch_check_v8, because the binary includes 
___asan_version_mismatch_check_apple_800 instead.

I'm going to try compiling V8 with system clang, hopefully that'll work.

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Re: Missing symbol ___asan_version_mismatch_check_v8

2016-12-01 Thread tblodt
I just tried compiling my library with the same prebuilt compiler used for 
v8 (third_party/llvm-build/Release+Asserts/bin/clang), and it still didn't 
work.

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Re: Missing symbol ___asan_version_mismatch_check_v8

2016-12-01 Thread tblodt
Also, d8 loads fine.

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Missing symbol ___asan_version_mismatch_check_v8

2016-12-01 Thread tblodt
I'm trying to build both V8 and my library that embeds with the address 
sanitizer, and I'm getting this error when trying to load my library:

dlopen(v8py.so, 2): Symbol not found: ___asan_version_mismatch_check_v8
  Referenced from: v8py.so
  Expected in: flat namespace
 in v8py.so

What's going on?

Potentially relevant information:

   - My library is a dynamic-link library that statically links with V8. 
   I'm building V8 with -fPIC so that this can work.
   - V8 is being built with the prebuilt version of clang downloaded by 
   gclient sync, and my library is built with the version of clang that comes 
   with macos.
   - I can't find ___asan_version_mismatch_check_v8 anywhere in the V8 
   source, or anywhere on Google or Github. So I have no idea what it's for or 
   what it does.

~Theodore

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Re: eval in current C++ scope

2016-11-25 Thread tblodt
A HandleScope does not store any key-value pairs.

It sounds like what you need is to create multiple Contexts. If that's not 
quite what you want, I'd suggest creating objects using Object::New and 
using them as the receiver in CompileFunctionInContext.

~Theodore

On Wednesday, November 23, 2016 at 4:17:48 PM UTC-8, Francisco Tolmasky 
wrote:
>
> I'd like to replicate the effect of eval in a C++ function. In other 
> words, I'd like to be able to eval and affect the current HandleScope. So 
> if I do "var x = 10", I'd like the HandleScope to get a x added, not for 
> the Context's global to receive the x. Is this possible?
>
> I suppose a parallel question is, can I "push" a scope for Script->Run? 
> Basically, I'd like successive Runs to modify the same scope, not the 
> global, the same way successive evals.
>
> Thanks,
>
> Francisco
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] InternalFieldCount seems to be ignored when ConstructorBehavior is kThrow

2016-11-25 Thread tblodt
When I set the constructor behavior on my FunctionTemplate to kThrow 
(instead of the default kAllow), then create an object from the template 
using InstanceTemplate()->NewInstance(), it seems like the 
InternalFieldCount on the InstanceTemplate is ignored, and the object that 
gets created has 0 internal fields. This only happens when I set the 
constructor behavior to kThrow. Is this a bug? How can I get the object to 
have the right number of internal fields?

~Theodore

PS: I'm using the version of V8 at branch-heads/5.4.

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] How to set the class name of the global object

2016-11-23 Thread tblodt
I'm trying to get behavior similar to that of the global object in a Chrome 
JavaScript context through the V8 API. I've created a FunctionTemplate, 
called SetClassName on the template, set various properties on its 
PrototypeTemplate and InstanceTemplate, and then used the InstanceTemplate 
to create a context. However, when I run 
Object.prototype.toString.call(this), I get [object Object], instead of 
what I set the class name to. How does Chrome make it so that 
Object.prototype.toString.call(this) is [object Window]?

Thanks,
~Theodore

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Re: Per-isolate FunctionTemplate cache

2016-11-21 Thread tblodt
Here's what Jochen originally said:

v8 has an per-isolate cache of function templates. As the string is 
> referenced by the function template, it will never go out of scope.
> I'd recommend to create a weak handle to the function you create via 
> GetFunction() instead


https://groups.google.com/d/msg/v8-users/Rshbi2HKYCM/LgwY-iJeAQAJ

He later clarified "the function template won't ever get gc'd after you've 
instantiated it once."

What I really want to know is why this is the case, and what purpose it 
serves.

~Theodore

On Sunday, November 20, 2016 at 2:09:38 PM UTC-8, tbl...@icloud.com wrote:
>
> Jochen Eisinger said that "v8 has an per-isolate cache of function 
> templates". I have a few questions about this cache:
>
> If I create multiple FunctionTemplates with different callback data but 
> the same callback function and everything else, does it only create one 
> function template and use the cache for the rest?
> If not, why does the cache exist?
>
> ~Theodore
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] What's the correct way to build V8 as a static library on macOS?

2016-11-20 Thread tblodt
I tried building with GN, but I was not able to get it to generate any 
lib*.a files. So that didn't work for me.

I'm currently building with Gyp, but my build doesn't seem to have snapshot 
support enabled. There is a libv8_nosnapshot.a file, but no libv8.a file.

What's the officially correct way?

~Theodore

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [v8-users] Setting an execution limit

2016-11-20 Thread tblodt
I don't think there's any way. V8 JavaScript code is compiled to native 
code, and no instrumentation is really possible on that.

On Sunday, November 20, 2016 at 10:18:24 AM UTC-8, James Lovejoy wrote:
>
> Really I need something a little more deterministic than a time limit. Is 
> there a way to set an instruction limit? Or perhaps something similar to 
> lua_sethook (http://pgl.yoyo.org/luai/i/lua_sethook) in Lua which calls a 
> callback every given number of instructions.
>
> On Sun, Nov 20, 2016 at 4:02 AM, Ben Noordhuis  > wrote:
>
>> On Sat, Nov 19, 2016 at 10:11 PM, James Lovejoy > > wrote:
>> > Hi,
>> >
>> > Is there a way to set a hard execution limit in the V8 engine? I want 
>> to be
>> > able to prevent things like infinite loops and recursions. I realise 
>> that
>> > since V8 compiles to machine code I don't get a program counter or 
>> anything.
>> > I feel like setting the "stack limit" is the right way to go but the 
>> usage
>> > of this feature from the documentation is unclear. Can someone guide me 
>> as
>> > to how to achieve such a limit?
>> >
>> > James
>>
>> If 'execution limit' means 'time limit': start a watchdog thread and
>> call v8::Isolate::TerminateExecution() from that thread on timeout.
>> It must be a thread, it's not safe to call from a signal handler.
>>
>> --
>> --
>> v8-users mailing list
>> v8-u...@googlegroups.com 
>> http://groups.google.com/group/v8-users
>> ---
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "v8-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/v8-users/Qwdd66xCtTU/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> v8-users+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Per-isolate FunctionTemplate cache

2016-11-20 Thread tblodt
Jochen Eisinger said that "v8 has an per-isolate cache of function 
templates". I have a few questions about this cache:

If I create multiple FunctionTemplates with different callback data but the 
same callback function and everything else, does it only create one 
function template and use the cache for the rest?
If not, why does the cache exist?

~Theodore

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [v8-users] Re: Weak callback for function callback data never getting called

2016-10-05 Thread tblodt
Actually, that didn't work. Any other ideas? Any techniques for debugging 
GC (like getting information on where an object is referenced?)

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [v8-users] Re: Weak callback for function callback data never getting called

2016-10-05 Thread tblodt
Why didn't I think of that?

Put a(mother) handle scope inside the for loop
>

Also, autocorrect failure ^ 

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [v8-users] Re: Weak callback for function callback data never getting called

2016-10-05 Thread tblodt
Thanks for all your feedback. I tried attaching the weak callback to the 
function instead of the callback data, and I tried a tight loop 
with AdjustAmountOfExternalAllocatedMemory. But the weak callback still 
isn't getting called. Here's the updated main function:

int main() {
V8::InitializeICU();
Platform *current_platform = platform::CreateDefaultPlatform();
V8::InitializePlatform(current_platform);
V8::Initialize();
V8::SetFlagsFromString("--expose_gc", strlen("--expose_gc"));
Isolate::CreateParams params;
params.array_buffer_allocator = new MallocAllocator();
Isolate *isolate = Isolate::New(params);
Isolate::Scope is(isolate);
HandleScope hs(isolate);

Local context = Context::New(isolate);
Context::Scope cs(context);
Local key = String::NewFromUtf8(isolate, "test", 
NewStringType::kNormal).ToLocalChecked();

for (int i = 0; ; i++) {
Persistent *weak_func = new Persistent();

Local templ = FunctionTemplate::New(isolate, 
func_callback);
Local func = templ->GetFunction(context).ToLocalChecked();

weak_func->Reset(isolate, func);
weak_func->MarkIndependent();
weak_func->SetWeak(weak_func, weak_callback, 
WeakCallbackType::kParameter);
isolate->AdjustAmountOfExternalAllocatedMemory(1);
printf("%d\r", i);
/* context->Global()->Set(context, key, func).FromJust(); */
/* context->Global()->Delete(context, key).FromJust(); */
}


isolate->RequestGarbageCollectionForTesting(Isolate::GarbageCollectionType::kFullGarbageCollection);
return 0;
}

Uncommenting the two commented lines doesn't make any difference. What am I 
doing wrong now?

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Weak callback for function callback data never getting called

2016-10-02 Thread tblodt
I'm using FunctionTemplate to create a function that has callback data, and 
I want to get a callback when the function is no longer reachable from 
Javascript so I can do some cleanup associated with the callback data. I'm 
trying to do this with a weak reference callback, but I'm having some 
trouble getting the weak callback to actually get called.

MVCE:

#include 
#include 
#include 
#include 

using namespace v8;

class MallocAllocator : public ArrayBuffer::Allocator {
public:
virtual void *Allocate(size_t size) {
void *data = AllocateUninitialized(size);
if (data != NULL)
memset(data, 0, size);
return data;
}
virtual void *AllocateUninitialized(size_t size) {
return malloc(size);
}
virtual void Free(void *data, size_t size) {
free(data);
}
};

void func_callback(const FunctionCallbackInfo ) {}

void weak_callback(const WeakCallbackInfo ) {
Persistent *handle = info.GetParameter();
printf("weak callback called with %p\n", handle);
delete handle;
}

int main() {
V8::InitializeICU();
Platform *current_platform = platform::CreateDefaultPlatform();
V8::InitializePlatform(current_platform);
V8::Initialize();
V8::SetFlagsFromString("--expose_gc", strlen("--expose_gc"));
Isolate::CreateParams params;
params.array_buffer_allocator = new MallocAllocator();
Isolate *isolate = Isolate::New(params);
HandleScope hs(isolate);

Local context = Context::New(isolate);
Local key = String::NewFromUtf8(isolate, "test", NewStringType::
kNormal).ToLocalChecked();

Persistent *weak_str = new Persistent();
{
HandleScope hs(isolate);
Local str = String::NewFromUtf8(isolate, "hi there", 
NewStringType::kNormal).ToLocalChecked();

Local templ = FunctionTemplate::New(isolate, 
func_callback, str);

weak_str->Reset(isolate, str);
weak_str->SetWeak(weak_str, weak_callback, WeakCallbackType::
kParameter);
context->Global()->Set(context,
key, templ->GetFunction(context).ToLocalChecked())
.FromJust();
}

context->Global()->Delete(context, key).FromJust();

isolate->RequestGarbageCollectionForTesting(Isolate::
GarbageCollectionType::kFullGarbageCollection);
return 0;
}

In this program, weak_callback never gets called. Anyone know why?

Thanks,
~Theodore

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] What's the difference between v8::Global and v8::Persistent?

2016-10-01 Thread tblodt
The documentation comments say Persistent "allows copy and assignment", and 
Global has "move semantics". What exactly does that mean?

Thanks
~Theodore

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Re: Memory management for Functions

2016-10-01 Thread tblodt
In this example, the Persistent is allocated on the stack. If I want the 
callback to keep working after the Persistent goes out of scope, would I 
have to allocate it on the heap? Would I then have to delete the Persistent 
in the callback?

~Theodore

On Tuesday, March 15, 2016 at 11:12:23 AM UTC-7, Ian Bull wrote:
>
> Thank-you very much Pavel,
>
> This particular solution resulted in a core dump, but I noticed that the 
> SetWeak method that takes a WeakCallbackData is deprecated. When I used the 
> SetWeak method that takes the WeakCallbackInfo, things work as expected. 
>
> Thanks again,
> Ian
>
> ```
>
> Stack: [0x000111a61000,0x000111b61000],  sp=0x000111b5da08,  
> free space=1010k
>
> Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native 
> code)
>
> C  [libj2v8_macosx_x86_64.dylib+0x57f2]  v8::base::OS::Abort()+0x12
>
> C  [libj2v8_macosx_x86_64.dylib+0x2da7e1]  
> v8::internal::GlobalHandles::Node::PostGarbageCollectionProcessing(v8::internal::Isolate*)+0x1d1
>
> C  [libj2v8_macosx_x86_64.dylib+0x2dace5]  
> v8::internal::GlobalHandles::PostGarbageCollectionProcessing(v8::internal::GarbageCollector,
>  
> v8::GCCallbackFlags)+0x95
>
> C  [libj2v8_macosx_x86_64.dylib+0x2e81f0]  
> v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, 
> v8::GCCallbackFlags)+0x690
>
> C  [libj2v8_macosx_x86_64.dylib+0x2e775c]  
> v8::internal::Heap::CollectGarbage(v8::internal::GarbageCollector, char 
> const*, char const*, v8::GCCallbackFlags)+0x21c
>
> C  [libj2v8_macosx_x86_64.dylib+0x2b34e1]  
> v8::internal::Factory::NewFixedArray(int, v8::internal::PretenureFlag)+0x61
>
> ```
>
> On Tuesday, 15 March 2016 00:03:03 UTC-7, Pavel Medvedev wrote:
>>
>> Hi Ian,
>>
>> To delete user data on GC you need to create a weak persistent handle for 
>> your External. A user supplied callback function would be invoked on GC of 
>> this weak Persistent, and you can delete your data there, like this:
>>
>> MethodDescriptor* md = new MethodDescriptor();
>>
>> Local ext =  External::New(isolate, md);
>> Persistent pext(isolate, ext);
>> pext.SetWeak(data, [](v8::WeakCallbackData 
>> const& data)
>> {
>> MethodDescriptor* md = data.GetParameter();
>> delete md;
>> });
>>
>> Function::New(isolate, callback, External::New(isolate, md))
>>
>>
>> Note that GC could be called some time later (even it could)
>>
>> On Tuesday, March 15, 2016 at 12:15:10 AM UTC+3, Ian Bull wrote:
>>>
>>> I'm creating a Function with a C++ callback as follows:
>>>
>>> MethodDescriptor* md = new MethodDescriptor();
>>>
>>> md -> someFields = someValue;
>>>
>>> Function::New(isolate, callback, External::New(isolate, md))
>>>
>>>
>>> In this case I associate a MethodDescriptor (md) with the function so 
>>> that when my callback is invoked I can get information about this 
>>> particular instance. How can I get notified (via a callback or destructor) 
>>> that this Function has been GC'd so I can clean-up the memory I allocated 
>>> for the MethodDescriptor?
>>>
>>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Re: PersistentBase::MarkIndependent()

2016-09-30 Thread tblodt
Anybody know the answer to this? (bump)

On Friday, April 17, 2015 at 12:19:05 PM UTC-7, Jane Chen wrote:
>
> On v8 3.24:
>
>   /**
>* Marks the reference to this object independent. Garbage collector is 
> free
>* to ignore any object groups containing this object. Weak callback for 
> an
>* independent handle should not assume that it will be preceded by a 
> global
>* GC prologue callback or followed by a global GC epilogue callback.
>*/
>   V8_INLINE void MarkIndependent();
>
> I'd like to understand the above better.  In what kind of scenario do I 
> want to mark a persistent handle independent?  What kind of impact does it 
> have on GC?
>
> Thanks!
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.