Re: [v8-users] Arraybuffer

2018-09-10 Thread dan Med
ATM I’m writing with my phone, here in EU is almost midnight so I will
write u an email tomorrow fully detailed.

Btw how do I call append ???
I’m interested in how v8 works and manages JavaScript code that’s all.

When I talk about typedarray or anything else I referr to the JavaScript
side, so create an arraybuffer it will invoke that class in v8, then build
a view or not it depends how do I make v8 to call the append method ?

On Mon, 10 Sep 2018 at 23:46, @soylentgraham 
wrote:

> > First, how big is the data member of the object ?
>
> As I said before. Capacity is the size of the memory allocated that data
> points at.
>
>
> > Is it as big as the actual array buffer length which I declare on
> JavaScript
>
> It will be either as big, or bigger. It can grow.
> bytes_used will be the size that matches javascript.
>
>
> > which I can build on top of it a typedarray ?
>
> This is a slightly different question, (and needs clarifying)
> When you create a typedarray in C++, it needs an array buffer.
> When you create a typedarray in javascript, it will have an array buffer
> behind it. (which you may or may not have created in javascript or c++,
> there are several ways of approaching this)
>
>
> > So, when a typedarray is build on top of an areaybuffer instance, how do
> I get to call the arraybufferbuilder::append ?
>
> Aha! a more specific question!
> Are you trying to call arraybufferbuilder::append in javascript, or c++?
> Why? are you trying to make a typedarray bigger? (in javascript or c++?)
> I believe once created they're a fixed size in javascript.
> I have a feeling on the c++ side, you can't change the size once created
> (but I may be wrong, you have direct access to the buffer's buffercontents
> via the bufferview...)
>
> Can you make your question a lot more specific? post some code?
>
>
> On Monday, 10 September 2018 22:38:16 UTC+1, dan Med wrote:
>>
>> First, how big is the data member of the object ? Is it as big as the
>> actual array buffer length which I declare on JavaScript and which I can
>> build on top of it a typedarray ?
>>
>> No, I’m just trying to understand how v8 works, I know it is a big thing
>> but at least how it moves then I might read the code and understand, extra
>> parts.
>>
>> So, when a typedarray is build on top of an areaybuffer instance, how do
>> I get to call the arraybufferbuilder::append ?
>>
>>
>>
>>
>>
>> On Mon, 10 Sep 2018 at 23:30, @soylentgraham 
>> wrote:
>>
>>> I'm guessing you may be a bit new to unmanaged-memory languages/systems.
>>>
>>> buffer is an object, (it's structure/layout will look a bit like it's
>>> class declaration, but it's a little more complex than that) that was
>>> allocated somewhere sometime, (you can figure out where, but really you
>>> don't need to,  for this purpose it's just an object)
>>> data is a member of that object, that points to some memory (somewhere
>>> else, maybe allocated by a different system, in a different place)
>>> you have no idea (and you shouldn't need to know, or use the
>>> information) the "offset" from the buffer-object to the data. They are not
>>> necessarily related, or share the same memory space. (and in most cases,
>>> they're not even real memory addresses, they're more like identifiers)
>>>
>>> Simple Javascript scripts can look like C sometimes (a few variables
>>> here and there, a few array creations), but underneath it's doing a lot
>>> more moving things around.
>>> function x()
>>> {
>>>  var a = new array(10);
>>>  var b = new array(100);
>>> }
>>> This may look like it allocates 2 arrays, but more than likely it's
>>> doing something radically different with actual memory.
>>>
>>>
>>> > so how can i see the memory management ?
>>> As I said, you can't see the javascript side so easily (other than using
>>> the v8 debugging/inspector tools)
>>> But if you want to see the C-side memory (which MAY be where the data
>>> that buffer points at came from) you can make your own allocator that v8
>>> can use.
>>> If you then breakpoint each call, you'll know when V8 is allocating some
>>> memory to use (which may or may not be a direct object in javascript, an
>>> array or typed array in javascript may not directly allocate here)
>>>
>>>
>>> class TV8Allocator : public v8::ArrayBuffer::Allocator
>>>
>>> {
>>>
>>> public:
>>>
>>> virtual void* Allocate(size_t length) override;
>>>
>>> virtual void* AllocateUninitialized(size_t length) override;
>>>
>>> virtual void Free(void* data, size_t length) override;
>>>
>>> };
>>>
>>>
>>> void* TV8Allocator::Allocate(size_t length)
>>>
>>> {
>>>
>>> auto* Bytes = new uint8_t[length];
>>>
>>> for ( auto i=0; i>>
>>> Bytes[i] = 0;
>>>
>>> return Bytes;
>>>
>>> }
>>>
>>>
>>> void* TV8Allocator::AllocateUninitialized(size_t length)
>>>
>>> {
>>>
>>> auto* Bytes = new uint8_t[length];
>>>
>>> return Bytes;
>>>
>>> }
>>>
>>>
>>> void TV8Allocator::Free(void* data, size_t length)
>>>
>>> {
>>>
>>> auto* data8 = reinterpret_cast(data);
>>>
>>> delete[] data8;

Re: [v8-users] Arraybuffer

2018-09-10 Thread @soylentgraham
> First, how big is the data member of the object ?

As I said before. Capacity is the size of the memory allocated that data 
points at.


> Is it as big as the actual array buffer length which I declare on 
JavaScript 

It will be either as big, or bigger. It can grow.
bytes_used will be the size that matches javascript.


> which I can build on top of it a typedarray ?

This is a slightly different question, (and needs clarifying)
When you create a typedarray in C++, it needs an array buffer.
When you create a typedarray in javascript, it will have an array buffer 
behind it. (which you may or may not have created in javascript or c++, 
there are several ways of approaching this)


> So, when a typedarray is build on top of an areaybuffer instance, how do 
I get to call the arraybufferbuilder::append ? 

Aha! a more specific question!
Are you trying to call arraybufferbuilder::append in javascript, or c++?
Why? are you trying to make a typedarray bigger? (in javascript or c++?)
I believe once created they're a fixed size in javascript.
I have a feeling on the c++ side, you can't change the size once created 
(but I may be wrong, you have direct access to the buffer's buffercontents 
via the bufferview...)

Can you make your question a lot more specific? post some code?


On Monday, 10 September 2018 22:38:16 UTC+1, dan Med wrote:
>
> First, how big is the data member of the object ? Is it as big as the 
> actual array buffer length which I declare on JavaScript and which I can 
> build on top of it a typedarray ?
>
> No, I’m just trying to understand how v8 works, I know it is a big thing 
> but at least how it moves then I might read the code and understand, extra 
> parts.
>
> So, when a typedarray is build on top of an areaybuffer instance, how do I 
> get to call the arraybufferbuilder::append ? 
>
>
>
>
>
> On Mon, 10 Sep 2018 at 23:30, @soylentgraham  > wrote:
>
>> I'm guessing you may be a bit new to unmanaged-memory languages/systems. 
>>
>> buffer is an object, (it's structure/layout will look a bit like it's 
>> class declaration, but it's a little more complex than that) that was 
>> allocated somewhere sometime, (you can figure out where, but really you 
>> don't need to,  for this purpose it's just an object)
>> data is a member of that object, that points to some memory (somewhere 
>> else, maybe allocated by a different system, in a different place)
>> you have no idea (and you shouldn't need to know, or use the information) 
>> the "offset" from the buffer-object to the data. They are not necessarily 
>> related, or share the same memory space. (and in most cases, they're not 
>> even real memory addresses, they're more like identifiers)
>>
>> Simple Javascript scripts can look like C sometimes (a few variables here 
>> and there, a few array creations), but underneath it's doing a lot more 
>> moving things around.
>> function x()
>> {
>>  var a = new array(10);
>>  var b = new array(100);
>> }
>> This may look like it allocates 2 arrays, but more than likely it's doing 
>> something radically different with actual memory.
>>
>>
>> > so how can i see the memory management ? 
>> As I said, you can't see the javascript side so easily (other than using 
>> the v8 debugging/inspector tools)
>> But if you want to see the C-side memory (which MAY be where the data 
>> that buffer points at came from) you can make your own allocator that v8 
>> can use.
>> If you then breakpoint each call, you'll know when V8 is allocating some 
>> memory to use (which may or may not be a direct object in javascript, an 
>> array or typed array in javascript may not directly allocate here)
>>
>>
>> class TV8Allocator : public v8::ArrayBuffer::Allocator
>>
>> {
>>
>> public:
>>
>> virtual void* Allocate(size_t length) override;
>>
>> virtual void* AllocateUninitialized(size_t length) override;
>>
>> virtual void Free(void* data, size_t length) override;
>>
>> };
>>
>>
>> void* TV8Allocator::Allocate(size_t length)
>>
>> {
>>
>> auto* Bytes = new uint8_t[length];
>>
>> for ( auto i=0; i>
>> Bytes[i] = 0;
>>
>> return Bytes;
>>
>> }
>>
>>
>> void* TV8Allocator::AllocateUninitialized(size_t length)
>>
>> {
>>
>> auto* Bytes = new uint8_t[length];
>>
>> return Bytes;
>>
>> }
>>
>>
>> void TV8Allocator::Free(void* data, size_t length)
>>
>> {
>>
>> auto* data8 = reinterpret_cast(data);
>>
>> delete[] data8;
>>
>> }
>>
>> v8::Isolate::CreateParams create_params;
>>
>> create_params.array_buffer_allocator = 
>>
>>
>>
>> > Cause i saw the code but didn't find how it handles all the possible 
>> javascript i might write into a script file
>>
>>
>> Your computer most likely has more memory than you'll ever write in a 
>> script :)
>>
>> If you're trying to work out where your script goes... arraybuffer isn't 
>> the right place.
>>
>>
>> Do you NEED to know? What exactly are you trying to achieve? (take a 
>> step back from the code and describe what you're trying to do;
>>
>> are you trying to make an app? learn 

Re: [v8-users] Arraybuffer

2018-09-10 Thread dan Med
First, how big is the data member of the object ? Is it as big as the
actual array buffer length which I declare on JavaScript and which I can
build on top of it a typedarray ?

No, I’m just trying to understand how v8 works, I know it is a big thing
but at least how it moves then I might read the code and understand, extra
parts.

So, when a typedarray is build on top of an areaybuffer instance, how do I
get to call the arraybufferbuilder::append ?





On Mon, 10 Sep 2018 at 23:30, @soylentgraham 
wrote:

> I'm guessing you may be a bit new to unmanaged-memory languages/systems.
>
> buffer is an object, (it's structure/layout will look a bit like it's
> class declaration, but it's a little more complex than that) that was
> allocated somewhere sometime, (you can figure out where, but really you
> don't need to,  for this purpose it's just an object)
> data is a member of that object, that points to some memory (somewhere
> else, maybe allocated by a different system, in a different place)
> you have no idea (and you shouldn't need to know, or use the information)
> the "offset" from the buffer-object to the data. They are not necessarily
> related, or share the same memory space. (and in most cases, they're not
> even real memory addresses, they're more like identifiers)
>
> Simple Javascript scripts can look like C sometimes (a few variables here
> and there, a few array creations), but underneath it's doing a lot more
> moving things around.
> function x()
> {
>  var a = new array(10);
>  var b = new array(100);
> }
> This may look like it allocates 2 arrays, but more than likely it's doing
> something radically different with actual memory.
>
>
> > so how can i see the memory management ?
> As I said, you can't see the javascript side so easily (other than using
> the v8 debugging/inspector tools)
> But if you want to see the C-side memory (which MAY be where the data that
> buffer points at came from) you can make your own allocator that v8 can use.
> If you then breakpoint each call, you'll know when V8 is allocating some
> memory to use (which may or may not be a direct object in javascript, an
> array or typed array in javascript may not directly allocate here)
>
>
> class TV8Allocator : public v8::ArrayBuffer::Allocator
>
> {
>
> public:
>
> virtual void* Allocate(size_t length) override;
>
> virtual void* AllocateUninitialized(size_t length) override;
>
> virtual void Free(void* data, size_t length) override;
>
> };
>
>
> void* TV8Allocator::Allocate(size_t length)
>
> {
>
> auto* Bytes = new uint8_t[length];
>
> for ( auto i=0; i
> Bytes[i] = 0;
>
> return Bytes;
>
> }
>
>
> void* TV8Allocator::AllocateUninitialized(size_t length)
>
> {
>
> auto* Bytes = new uint8_t[length];
>
> return Bytes;
>
> }
>
>
> void TV8Allocator::Free(void* data, size_t length)
>
> {
>
> auto* data8 = reinterpret_cast(data);
>
> delete[] data8;
>
> }
>
> v8::Isolate::CreateParams create_params;
>
> create_params.array_buffer_allocator = 
>
>
>
> > Cause i saw the code but didn't find how it handles all the possible
> javascript i might write into a script file
>
>
> Your computer most likely has more memory than you'll ever write in a
> script :)
>
> If you're trying to work out where your script goes... arraybuffer isn't
> the right place.
>
>
> Do you NEED to know? What exactly are you trying to achieve? (take a step
> back from the code and describe what you're trying to do;
>
> are you trying to make an app? learn how memory works in c++? learn how
> memory is used in javascript? Why your app uses 1gb of memory?
>
>
>
>
> On Monday, 10 September 2018 22:10:54 UTC+1, dan Med wrote:
>>
>> How big is the offset from buffer to data ?
>> const void* Data
>> ()
>> const { return buffer_
>> 
>> ->
>> 
>> Data
>> ();
>> }
>>
>> sorry for spamming emails, i will try to condensate more
>>
>> Il giorno lun 10 set 2018 alle ore 23:07 dan Med 
>> ha scritto:
>>
>>> Cause i saw the code but didn't find how it handles all the possible
>>> javascript i might write into a script file
>>>
>>> Il giorno lun 10 set 2018 alle ore 23:06 dan Med 
>>> ha scritto:
>>>
 But after using it for a little while, I have found v8 in general is
 pretty simple. It provides an interface to C 

Re: [v8-users] Arraybuffer

2018-09-10 Thread dan Med
How big is the offset from buffer to data ?
const void* Data
()
const { return buffer_

->

Data
();
}

sorry for spamming emails, i will try to condensate more

Il giorno lun 10 set 2018 alle ore 23:07 dan Med 
ha scritto:

> Cause i saw the code but didn't find how it handles all the possible
> javascript i might write into a script file
>
> Il giorno lun 10 set 2018 alle ore 23:06 dan Med 
> ha scritto:
>
>> But after using it for a little while, I have found v8 in general is
>> pretty simple. It provides an interface to C functions and memory. This is
>> kinda what it's for.
>>
>> so how can i see the memory management ?
>>
>>
>> Il giorno lun 10 set 2018 alle ore 23:06 dan Med 
>> ha scritto:
>>
>>> So, the hole length of this raw memory is set to be Data ? And to use it
>>> i should create a view on top of it like with typedarrays?
>>>
>>>
>>> So to call arraybuffer::append i should first, try to make the typed
>>> array bigger that action will call the arraybuffer::append  ?  i didn't ask
>>> how memcpy work, i didn't get the Data() thing, in the class that's all.
>>>
>>> Il giorno lun 10 set 2018 alle ore 22:55 @soylentgraham <
>>> gra...@grahamreeves.com> ha scritto:
>>>
 > How can i understand the structure in memory of an arraybuffer and how 
 > big is the data field which is pointed by this void pointerIt has no 
 > structure. It is just a series of linear bytes, raw memory, allocated by 
 > the memory allocator. (If you implement your own memory allocator you 
 > can catch when this happens)It's just the data(buffer) for an array.
 > How are they represented in memoryIt IS memory. It's nothing more 
 > (it's an array of bytes)
 > How big is the data field ?If by "field", you mean, the data buffer... 
 > it's Capacity 
 > 
 >  (capacity is how much it can fit) in length. But not how much is being 
 > used. (bytes_used)
 If you're curious about when memory grows, reallocates, is written to, 
 accessed... it might be worth setting up your environment so you can debug 
 it by stepping through the code as it executes. You can watch memory, 
 (this would show what memcpy changes) see the values passed around, track 
 when memory gets allocated etc.
 Your questions are a mix of very broad, ("How does v8 work") and very 
 specific programming questions (what is memcpy() doing)Broad questions are 
 very hard to answer in general. ("How does a car work")

 I agree, simply browsing the code doesn't give a good overview of say, how 
 the javascript compiler works, or how memory is utilised. (How it is 
 allocated is very simple, on the C/++ side it doesn't implement any memory 
 management, and the array buffer/view is a view of the C-side memory)But 
 after using it for a little while, I have found v8 in general is pretty 
 simple. It provides an interface to C functions and memory. This is kinda 
 what it's for.
 But the point of v8 is that it does a lot of that for you. I don't REALLY 
 need to know how the memory is tracked on the javascript side, it just 
 works (if I'm using the API correctly)Then again, if you NEED to know how 
 it works for a specific purpose (very restricted memory, fixing a bug), we 
 can help you a lot more easily by answering a very specific question. ("My 
 car's low-oil light is blinking, where do I fill it up")
 If you're just curious as to how the entire v8 engine works... that's a 
 massive ask. A lot of people work on it, and there is a lot of work and 
 topics involved.Your best bet is reading the (limited) documentation on 
 the wiki, and read the blog posts https://v8project.blogspot.com/ which go 
 into quite a lot of detail on each post topic.I've not seen any real 
 general overview (the 

Re: [v8-users] Arraybuffer

2018-09-10 Thread dan Med
Cause i saw the code but didn't find how it handles all the possible
javascript i might write into a script file

Il giorno lun 10 set 2018 alle ore 23:06 dan Med 
ha scritto:

> But after using it for a little while, I have found v8 in general is
> pretty simple. It provides an interface to C functions and memory. This is
> kinda what it's for.
>
> so how can i see the memory management ?
>
>
> Il giorno lun 10 set 2018 alle ore 23:06 dan Med 
> ha scritto:
>
>> So, the hole length of this raw memory is set to be Data ? And to use it
>> i should create a view on top of it like with typedarrays?
>>
>>
>> So to call arraybuffer::append i should first, try to make the typed
>> array bigger that action will call the arraybuffer::append  ?  i didn't ask
>> how memcpy work, i didn't get the Data() thing, in the class that's all.
>>
>> Il giorno lun 10 set 2018 alle ore 22:55 @soylentgraham <
>> gra...@grahamreeves.com> ha scritto:
>>
>>> > How can i understand the structure in memory of an arraybuffer and how 
>>> > big is the data field which is pointed by this void pointerIt has no 
>>> > structure. It is just a series of linear bytes, raw memory, allocated by 
>>> > the memory allocator. (If you implement your own memory allocator you can 
>>> > catch when this happens)It's just the data(buffer) for an array.
>>> > How are they represented in memoryIt IS memory. It's nothing more 
>>> > (it's an array of bytes)
>>> > How big is the data field ?If by "field", you mean, the data buffer... 
>>> > it's Capacity 
>>> > 
>>> >  (capacity is how much it can fit) in length. But not how much is being 
>>> > used. (bytes_used)
>>> If you're curious about when memory grows, reallocates, is written to, 
>>> accessed... it might be worth setting up your environment so you can debug 
>>> it by stepping through the code as it executes. You can watch memory, (this 
>>> would show what memcpy changes) see the values passed around, track when 
>>> memory gets allocated etc.
>>> Your questions are a mix of very broad, ("How does v8 work") and very 
>>> specific programming questions (what is memcpy() doing)Broad questions are 
>>> very hard to answer in general. ("How does a car work")
>>>
>>> I agree, simply browsing the code doesn't give a good overview of say, how 
>>> the javascript compiler works, or how memory is utilised. (How it is 
>>> allocated is very simple, on the C/++ side it doesn't implement any memory 
>>> management, and the array buffer/view is a view of the C-side memory)But 
>>> after using it for a little while, I have found v8 in general is pretty 
>>> simple. It provides an interface to C functions and memory. This is kinda 
>>> what it's for.
>>> But the point of v8 is that it does a lot of that for you. I don't REALLY 
>>> need to know how the memory is tracked on the javascript side, it just 
>>> works (if I'm using the API correctly)Then again, if you NEED to know how 
>>> it works for a specific purpose (very restricted memory, fixing a bug), we 
>>> can help you a lot more easily by answering a very specific question. ("My 
>>> car's low-oil light is blinking, where do I fill it up")
>>> If you're just curious as to how the entire v8 engine works... that's a 
>>> massive ask. A lot of people work on it, and there is a lot of work and 
>>> topics involved.Your best bet is reading the (limited) documentation on the 
>>> wiki, and read the blog posts https://v8project.blogspot.com/ which go into 
>>> quite a lot of detail on each post topic.I've not seen any real general 
>>> overview (the wiki itself says it's out of date) so, stepping through all 
>>> the code as it executes is probably your best bet.
>>>
>>>
>>> On Monday, 10 September 2018 21:25:37 UTC+1, dan Med wrote:

 in this snippet for example

 namespace WTF 
 
  {// A utility class to build an ArrayBuffer instance. Validity must be 
 checked// by isValid() before using an instance.class WTF_EXPORT 
 
  ArrayBufferBuilder 
 

Re: [v8-users] Arraybuffer

2018-09-10 Thread dan Med
But after using it for a little while, I have found v8 in general is pretty
simple. It provides an interface to C functions and memory. This is kinda
what it's for.

so how can i see the memory management ?


Il giorno lun 10 set 2018 alle ore 23:06 dan Med 
ha scritto:

> So, the hole length of this raw memory is set to be Data ? And to use it i
> should create a view on top of it like with typedarrays?
>
>
> So to call arraybuffer::append i should first, try to make the typed array
> bigger that action will call the arraybuffer::append  ?  i didn't ask how
> memcpy work, i didn't get the Data() thing, in the class that's all.
>
> Il giorno lun 10 set 2018 alle ore 22:55 @soylentgraham <
> gra...@grahamreeves.com> ha scritto:
>
>> > How can i understand the structure in memory of an arraybuffer and how big 
>> > is the data field which is pointed by this void pointerIt has no 
>> > structure. It is just a series of linear bytes, raw memory, allocated by 
>> > the memory allocator. (If you implement your own memory allocator you can 
>> > catch when this happens)It's just the data(buffer) for an array.
>> > How are they represented in memoryIt IS memory. It's nothing more 
>> > (it's an array of bytes)
>> > How big is the data field ?If by "field", you mean, the data buffer... 
>> > it's Capacity 
>> > 
>> >  (capacity is how much it can fit) in length. But not how much is being 
>> > used. (bytes_used)
>> If you're curious about when memory grows, reallocates, is written to, 
>> accessed... it might be worth setting up your environment so you can debug 
>> it by stepping through the code as it executes. You can watch memory, (this 
>> would show what memcpy changes) see the values passed around, track when 
>> memory gets allocated etc.
>> Your questions are a mix of very broad, ("How does v8 work") and very 
>> specific programming questions (what is memcpy() doing)Broad questions are 
>> very hard to answer in general. ("How does a car work")
>>
>> I agree, simply browsing the code doesn't give a good overview of say, how 
>> the javascript compiler works, or how memory is utilised. (How it is 
>> allocated is very simple, on the C/++ side it doesn't implement any memory 
>> management, and the array buffer/view is a view of the C-side memory)But 
>> after using it for a little while, I have found v8 in general is pretty 
>> simple. It provides an interface to C functions and memory. This is kinda 
>> what it's for.
>> But the point of v8 is that it does a lot of that for you. I don't REALLY 
>> need to know how the memory is tracked on the javascript side, it just works 
>> (if I'm using the API correctly)Then again, if you NEED to know how it works 
>> for a specific purpose (very restricted memory, fixing a bug), we can help 
>> you a lot more easily by answering a very specific question. ("My car's 
>> low-oil light is blinking, where do I fill it up")
>> If you're just curious as to how the entire v8 engine works... that's a 
>> massive ask. A lot of people work on it, and there is a lot of work and 
>> topics involved.Your best bet is reading the (limited) documentation on the 
>> wiki, and read the blog posts https://v8project.blogspot.com/ which go into 
>> quite a lot of detail on each post topic.I've not seen any real general 
>> overview (the wiki itself says it's out of date) so, stepping through all 
>> the code as it executes is probably your best bet.
>>
>>
>> On Monday, 10 September 2018 21:25:37 UTC+1, dan Med wrote:
>>>
>>> in this snippet for example
>>>
>>> namespace WTF 
>>> 
>>>  {// A utility class to build an ArrayBuffer instance. Validity must be 
>>> checked// by isValid() before using an instance.class WTF_EXPORT 
>>> 
>>>  ArrayBufferBuilder 
>>> 

Re: [v8-users] Arraybuffer

2018-09-10 Thread dan Med
So, the hole length of this raw memory is set to be Data ? And to use it i
should create a view on top of it like with typedarrays?


So to call arraybuffer::append i should first, try to make the typed array
bigger that action will call the arraybuffer::append  ?  i didn't ask how
memcpy work, i didn't get the Data() thing, in the class that's all.

Il giorno lun 10 set 2018 alle ore 22:55 @soylentgraham <
gra...@grahamreeves.com> ha scritto:

> > How can i understand the structure in memory of an arraybuffer and how big 
> > is the data field which is pointed by this void pointerIt has no structure. 
> > It is just a series of linear bytes, raw memory, allocated by the memory 
> > allocator. (If you implement your own memory allocator you can catch when 
> > this happens)It's just the data(buffer) for an array.
> > How are they represented in memoryIt IS memory. It's nothing more (it's 
> > an array of bytes)
> > How big is the data field ?If by "field", you mean, the data buffer... it's 
> > Capacity 
> > 
> >  (capacity is how much it can fit) in length. But not how much is being 
> > used. (bytes_used)
> If you're curious about when memory grows, reallocates, is written to, 
> accessed... it might be worth setting up your environment so you can debug it 
> by stepping through the code as it executes. You can watch memory, (this 
> would show what memcpy changes) see the values passed around, track when 
> memory gets allocated etc.
> Your questions are a mix of very broad, ("How does v8 work") and very 
> specific programming questions (what is memcpy() doing)Broad questions are 
> very hard to answer in general. ("How does a car work")
>
> I agree, simply browsing the code doesn't give a good overview of say, how 
> the javascript compiler works, or how memory is utilised. (How it is 
> allocated is very simple, on the C/++ side it doesn't implement any memory 
> management, and the array buffer/view is a view of the C-side memory)But 
> after using it for a little while, I have found v8 in general is pretty 
> simple. It provides an interface to C functions and memory. This is kinda 
> what it's for.
> But the point of v8 is that it does a lot of that for you. I don't REALLY 
> need to know how the memory is tracked on the javascript side, it just works 
> (if I'm using the API correctly)Then again, if you NEED to know how it works 
> for a specific purpose (very restricted memory, fixing a bug), we can help 
> you a lot more easily by answering a very specific question. ("My car's 
> low-oil light is blinking, where do I fill it up")
> If you're just curious as to how the entire v8 engine works... that's a 
> massive ask. A lot of people work on it, and there is a lot of work and 
> topics involved.Your best bet is reading the (limited) documentation on the 
> wiki, and read the blog posts https://v8project.blogspot.com/ which go into 
> quite a lot of detail on each post topic.I've not seen any real general 
> overview (the wiki itself says it's out of date) so, stepping through all the 
> code as it executes is probably your best bet.
>
>
> On Monday, 10 September 2018 21:25:37 UTC+1, dan Med wrote:
>>
>> in this snippet for example
>>
>> namespace WTF 
>> 
>>  {// A utility class to build an ArrayBuffer instance. Validity must be 
>> checked// by isValid() before using an instance.class WTF_EXPORT 
>> 
>>  ArrayBufferBuilder 
>> 
>>  final {  // Disallow copying since it's expensive and we don't want code to 
>> do it by  // accident.  USING_FAST_MALLOC 
>> 

Re: [v8-users] Arraybuffer

2018-09-10 Thread dan Med
in this snippet for example

namespace WTF 

{// A utility class to build an ArrayBuffer instance. Validity must be
checked// by isValid() before using an instance.class WTF_EXPORT

ArrayBufferBuilder

final {  // Disallow copying since it's expensive and we don't want
code to do it by  // accident.  USING_FAST_MALLOC
(ArrayBufferBuilder
);
public:  // Creates an ArrayBufferBuilder using the default capacity.
ArrayBufferBuilder
();
 ArrayBufferBuilder
(unsigned
capacity 
)
 : bytes_used_
(0),
variable_capacity_
(true)
{buffer_ 

= 

ArrayBuffer 
::Create
(capacity
,
1);  }  bool IsValid
()
const { return buffer_
.get
();
}  // Appending empty data is not allowed.  unsigned Append

Re: [v8-users] Arraybuffer

2018-09-10 Thread Jakob Kummerow
On Mon, Sep 10, 2018 at 12:22 PM dan Med  wrote:

> I don't quite see if this google group is useful or not, everybody keeps
> answering me with superficial things,
>

You said you wanted to read the compiler's source but couldn't find it, so
I told you that it's in src/compiler/. If that was not the answer you
wanted, then try asking a different question?

Please also keep in mind that people's time is limited. The easier/quicker
it is to answer your question, the more likely you are to get an answer.

i don't care about the trminology like tell me which allocator it uses when
> and why or at least if there's something i can read to understand.
> I'm surprised u don't know what a JIT page is, basically if you call a
> function foo() let's say 100 times then v8,had enough time to understand
> the parameters given to that specific function and how to optimize it
> efficently based on it's prediction/observation.
>
> I'm not interested in the terminology of things, (that's just a matter of
> reading the source code ) i'm more in reading how it works when and why..
>

It's great that you want to understand how things work. Terminology is an
important aspect of that though, because it enables communication. If we
use different words for the same thing, we won't understand each other.
Based on your explanation, I'm guessing that by "JIT page" you mean "the
strategy V8 uses to select functions for optimization". The core of that
logic is in MarkCandidatesForOptimization in src/runtime-profiler.cc.


> For example when is ArrayBufferBuilder::Append called ??
>

I don't know; it's not part of V8. But you can use Code Search to find out
where anything is called, just click the function in question to get a list
of call sites:
https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?q=ArrayBufferBuilder=package:chromium=0=61


> And i thing i've looked at the entire v8 source code but didn't find much,
> apart from the array.js file which describes some javascript function, i
> don't understand where's the rest
>


Il giorno lun 10 set 2018 alle ore 20:45 Jakob Kummerow <
> jkumme...@chromium.org> ha scritto:
>
>> On Sun, Sep 9, 2018 at 8:54 AM dan Med  wrote:
>>
>>> Oh and one more thing, i've surfed perhaps the entire source code of v8
>>> at least the interesting parts, but what i came across was just very short
>>> code execpt for some builtins written in javascript i believe, can't find
>>> all of the things i've found on the documentation such as the interpreter
>>>
>>
>> src/interpreter/
>>
>>
>>> and the JIT compilers,
>>>
>>
>> src/compiler/
>>
>>
>>> one more thing i'd like to understand how the memory is handeled like
>>> how can i read about the JIT pages,
>>>
>>
>> What's a JIT page?
>>
>>
>>> or which memory allocator does v8 use
>>>
>>
>> It uses several allocation techniques for different purposes.
>>
>>
>>> and it's garbage collector
>>>
>>
>> src/heap/
>>
>>
>>>
>>> Thank you !
>>>
>>> Il giorno dom 9 set 2018 alle ore 17:51 dan Med 
>>> ha scritto:
>>>
 I don't have understood this part, let me explain it to you.
 This is how i get it tell me if i'm wrong at any part.

 I need to understand how is the structure in memory of the arraybuffer
 how is it represented and if the data of the array are directly stored at
 an offset accessed by buffer_ -> data().


 before the call to expand capacity it does create an array


 the arraybuffer in src /
 third_party /blink
 /renderer
 /
 platform
 
 /wtf
 
 /typed_arrays
 
 /array_buffer_builder.cc
 
  is
 called whenever the renderer  (has to execute some javascript which defines
 arraybuffers)
 First when is arraybuffer::append  called, cause i know that if someone
 need to reallocate a bigger arraybuffer then a new instance will be created
 and filled with the old values if the length in the original array isn't
 has much as the user reqeusted ?

 One more thing is, when this class is called, the arraybuffer is always
 set to the initial length of static const int kDefaultBufferCapacity
 

Re: [v8-users] Arraybuffer

2018-09-10 Thread Jakob Kummerow
On Sun, Sep 9, 2018 at 8:54 AM dan Med  wrote:

> Oh and one more thing, i've surfed perhaps the entire source code of v8 at
> least the interesting parts, but what i came across was just very short
> code execpt for some builtins written in javascript i believe, can't find
> all of the things i've found on the documentation such as the interpreter
>

src/interpreter/


> and the JIT compilers,
>

src/compiler/


> one more thing i'd like to understand how the memory is handeled like how
> can i read about the JIT pages,
>

What's a JIT page?


> or which memory allocator does v8 use
>

It uses several allocation techniques for different purposes.


> and it's garbage collector
>

src/heap/


>
> Thank you !
>
> Il giorno dom 9 set 2018 alle ore 17:51 dan Med 
> ha scritto:
>
>> I don't have understood this part, let me explain it to you.
>> This is how i get it tell me if i'm wrong at any part.
>>
>> I need to understand how is the structure in memory of the arraybuffer
>> how is it represented and if the data of the array are directly stored at
>> an offset accessed by buffer_ -> data().
>>
>>
>> before the call to expand capacity it does create an array
>>
>>
>> the arraybuffer in src /
>> third_party /blink
>> /renderer
>> /
>> platform
>> 
>> /wtf
>> 
>> /typed_arrays
>> 
>> /array_buffer_builder.cc
>> 
>>  is
>> called whenever the renderer  (has to execute some javascript which defines
>> arraybuffers)
>> First when is arraybuffer::append  called, cause i know that if someone
>> need to reallocate a bigger arraybuffer then a new instance will be created
>> and filled with the old values if the length in the original array isn't
>> has much as the user reqeusted ?
>>
>> One more thing is, when this class is called, the arraybuffer is always
>> set to the initial length of static const int kDefaultBufferCapacity
>> 
>> = 32768; if in the javascript i declare an arraybuffer of 20bytes will
>> it allocate of
>> 32768bytes anyway =?
>>
>>
>>
>>
>>
>>
>>
>> Il giorno mar 4 set 2018 alle ore 12:14 Graham Reeves <
>> gra...@grahamreeves.com> ha scritto:
>>
>>> > is std::numeric_limits
>>> 
>>> ::max
>>> ();
>>> referring to the max unsigned int value ? cause the source code won't find
>>> it
>>> Yes, that's the maximum value unsigned (an unsigned int) can be, but
>>> what do you mean by, the source won't find it?
>>>
>>> On Monday, 3 September 2018 19:55:48 UTC+1, dan Med wrote:

 Can someone help me out?

 Il giorno sab 1 set 2018 alle ore 15:30  ha
 scritto:

> array_buffer_builder.cc in src 
> /third_party /blink
> /renderer
> /
> platform
> 
> /wtf
> 
> /typed_arrays
> 
> /array_buffer_builder.cc
> 
>
> the ArrayBufferBuilder
> 
> ::Append
> 

Re: [v8-users] Netwrok v8

2018-09-10 Thread dan Med
Is there any good doc that explains all of these crucial steps, reading the
code is ok but I’d like to have a bigger idea first like how can I get a
fully picture of JIT COMPILERS ???

On Mon, 10 Sep 2018 at 16:02, J Decker  wrote:

>
>
> On Mon, Sep 10, 2018 at 6:05 AM  wrote:
>
>> How does a signle process of the browser handle http and network traffic
>> ?
>>
> Quite well.
> What are you actually seeking?  It calls system libraries that provide
> sockets just like any other app ...
>
>> --
>> --
>> 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 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 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] Netwrok v8

2018-09-10 Thread J Decker
On Mon, Sep 10, 2018 at 6:05 AM  wrote:

> How does a signle process of the browser handle http and network traffic ?
>
Quite well.
What are you actually seeking?  It calls system libraries that provide
sockets just like any other app ...

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