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 <gra...@grahamreeves.com> 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<length; 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<uint8_t*>(data); > > delete[] data8; > > } > > v8::Isolate::CreateParams create_params; > > create_params.array_buffer_allocator = &mAllocator; > > > > > 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 >> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=80&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523b8F1aEDx%25252F6En%25252FkOKh2zVkvONjtDNg9gr5KG7gT9XeJk%25253D&gsn=Data&ct=xref_usages>() >> const { return buffer_ >> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=94&ct=xref_jump_to_def&gsn=buffer_> >> -> >> <https://cs.chromium.org/chromium/src/base/memory/scoped_refptr.h?l=218&ct=xref_jump_to_def&gsn=-%3E> >> Data >> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer.h?l=225&ct=xref_jump_to_def&gsn=Data>(); >> } >> >> sorry for spamming emails, i will try to condensate more >> >> Il giorno lun 10 set 2018 alle ore 23:07 dan Med <litoki...@gmail.com> >> 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 <litoki...@gmail.com> >>> 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 <litoki...@gmail.com> >>>> 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 memory....It 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 >>>>>> > <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=76&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523kB%25252BJ1WxDvoDqf1c8Tz5Ol3yne4lD03cRpevK2LHMUZk%25253D&gsn=Capacity&ct=xref_usages> >>>>>> > (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 >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=40&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%2523WTF%252523n%252523namespace&gsn=WTF&ct=xref_usages> >>>>>>> {// A utility class to build an ArrayBuffer instance. Validity must be >>>>>>> checked// by isValid() before using an instance.class WTF_EXPORT >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/wtf_export.h?l=46&ct=xref_jump_to_def&gsn=WTF_EXPORT> >>>>>>> ArrayBufferBuilder >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=44&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523ArrayBufferBuilder%25253AWTF%252523c%252523hTnYOn1mFcU%2Bkythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523NyhHD05MjDx8XOe1m%25252BLqXBLvqdjWPsLmDrRvvmR2Ywk%25253D&gsn=ArrayBufferBuilder&ct=xref_usages> >>>>>>> final { // Disallow copying since it's expensive and we don't want >>>>>>> code to do it by // accident. USING_FAST_MALLOC >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/allocator.h?l=146&ct=xref_jump_to_def&gsn=USING_FAST_MALLOC>(ArrayBufferBuilder >>>>>>> >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=44&ct=xref_jump_to_def&gsn=ArrayBufferBuilder>); >>>>>>> public: // Creates an ArrayBufferBuilder using the default capacity. >>>>>>> ArrayBufferBuilder >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=51&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523me5JBk4wDIaIJCK86MiUpy%25252BnGYRZwEr0AvVg3KaU0pw%25253D&gsn=ArrayBufferBuilder&ct=xref_usages>(); >>>>>>> ArrayBufferBuilder >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=53&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523VW0P45Tk9IGjtOqM%25252B9dHdJ64so3WDAfcY1jNBLt0GNY%25253D&gsn=ArrayBufferBuilder&ct=xref_usages>(unsigned >>>>>>> capacity >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=53&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523trfcCH7BPCRWiubGq1QF9bypkCRNYtWGHb2AzglMces%25253D&gsn=capacity&ct=xref_usages>) >>>>>>> : bytes_used_ >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=92&ct=xref_jump_to_def&gsn=bytes_used_>(0), >>>>>>> variable_capacity_ >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=93&ct=xref_jump_to_def&gsn=variable_capacity_>(true) >>>>>>> { buffer_ >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=94&ct=xref_jump_to_def&gsn=buffer_> >>>>>>> = >>>>>>> <https://cs.chromium.org/chromium/src/base/memory/scoped_refptr.h?l=226&ct=xref_jump_to_def&gsn=%3D> >>>>>>> ArrayBuffer >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer.h?l=42&ct=xref_jump_to_def&gsn=ArrayBuffer>::Create >>>>>>> >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer.h?l=125&ct=xref_jump_to_def&gsn=Create>(capacity >>>>>>> >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=53&ct=xref_jump_to_def&gsn=capacity>, >>>>>>> 1); } bool IsValid >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=58&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523Bx72YH%25252BiA4nF5ZIPsFhA9MQpdVCDOCRHSZa0Ksg6Wp4%25253D&gsn=IsValid&ct=xref_usages>() >>>>>>> const { return buffer_ >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=94&ct=xref_jump_to_def&gsn=buffer_>.get >>>>>>> >>>>>>> <https://cs.chromium.org/chromium/src/base/memory/scoped_refptr.h?l=211&ct=xref_jump_to_def&gsn=get>(); >>>>>>> } // Appending empty data is not allowed. unsigned Append >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=61&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523BHKR8BlIFhr03faCJF5mu7RDXZ%25252FPtZDAlnACyKmv1XM%25253D&gsn=Append&ct=xref_usages>(const >>>>>>> char* data >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=61&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%25233VvJP%25252BUI3abzouA4%25252FYSBHt09pw3AiNI9e9QAJGooqYI%25253D&gsn=data&ct=xref_usages>, >>>>>>> unsigned length >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=61&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523xOZXOK9mCrzsbUtqCxdbDuLg939IJhl7gbf0EykKwnY%25253D&gsn=length&ct=xref_usages>); >>>>>>> // Returns the accumulated data as an ArrayBuffer instance. If >>>>>>> needed, // creates a new ArrayBuffer instance and copies contents from >>>>>>> the internal // buffer to it. Otherwise, returns a RefPtr pointing to >>>>>>> the internal // buffer. scoped_refptr >>>>>>> <https://cs.chromium.org/chromium/src/base/memory/scoped_refptr.h?l=167&ct=xref_jump_to_def&gsn=scoped_refptr><ArrayBuffer >>>>>>> >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer.h?l=42&ct=xref_jump_to_def&gsn=ArrayBuffer>> >>>>>>> ToArrayBuffer >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=67&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523JX559OA9Zt0rALNU4DOTOkzcmtws4U5V42xhN0rrbow%25253D&gsn=ToArrayBuffer&ct=xref_usages>(); >>>>>>> // Converts the accumulated data into a String using the default >>>>>>> encoding. String >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/text/wtf_string.h?l=64&ct=xref_jump_to_def&gsn=String> >>>>>>> ToString >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=70&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523VMCyw7t%25252FF0UIo65pz8LTbfX5k5G4pIXrUNQbDNKDjaE%25253D&gsn=ToString&ct=xref_usages>(); >>>>>>> // Number of bytes currently accumulated. unsigned ByteLength >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=73&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523P5Klo%25252BJeJiug%25252FrSAfsaHI8wAnW8h5UBg2%25252BoJByO85kA%25253D&gsn=ByteLength&ct=xref_usages>() >>>>>>> const { return bytes_used_ >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=92&ct=xref_jump_to_def&gsn=bytes_used_>; >>>>>>> } // Number of bytes allocated. unsigned Capacity >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=76&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523kB%25252BJ1WxDvoDqf1c8Tz5Ol3yne4lD03cRpevK2LHMUZk%25253D&gsn=Capacity&ct=xref_usages>() >>>>>>> const { return buffer_ >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=94&ct=xref_jump_to_def&gsn=buffer_>-> >>>>>>> >>>>>>> <https://cs.chromium.org/chromium/src/base/memory/scoped_refptr.h?l=218&ct=xref_jump_to_def&gsn=-%3E>ByteLength >>>>>>> >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer.h?l=249&ct=xref_jump_to_def&gsn=ByteLength>(); >>>>>>> } void ShrinkToFit >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=78&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523WBvAUuWtgva6ffSXIiEGEkt%25252FFFbeCcQcsCz5E%25252FHCKOo%25253D&gsn=ShrinkToFit&ct=xref_usages>(); >>>>>>> const void* Data >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=80&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523b8F1aEDx%25252F6En%25252FkOKh2zVkvONjtDNg9gr5KG7gT9XeJk%25253D&gsn=Data&ct=xref_usages>() >>>>>>> const { return buffer_ >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=94&ct=xref_jump_to_def&gsn=buffer_>-> >>>>>>> >>>>>>> <https://cs.chromium.org/chromium/src/base/memory/scoped_refptr.h?l=218&ct=xref_jump_to_def&gsn=-%3E>Data >>>>>>> >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer.h?l=225&ct=xref_jump_to_def&gsn=Data>(); >>>>>>> } // If set to false, the capacity won't be expanded and when >>>>>>> appended data // overflows, the overflowed part will be dropped. void >>>>>>> SetVariableCapacity >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=84&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%25232ib6USbezkKcLs8hjPaCz4GUGrUHdD%25252BeN%25252FKenERnRLA%25253D&gsn=SetVariableCapacity&ct=xref_usages>(bool >>>>>>> value >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=84&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523vUjrriXMW5FurGjU87jcAlZRQs3b8JSgA4Tt1xrSq7I%25253D&gsn=value&ct=xref_usages>) >>>>>>> { variable_capacity_ >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=93&ct=xref_jump_to_def&gsn=variable_capacity_> >>>>>>> = value >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=84&ct=xref_jump_to_def&gsn=value>; >>>>>>> } private: // Expands the size of m_buffer to size + m_bytesUsed >>>>>>> bytes. Returns true // iff successful. If reallocation is needed, >>>>>>> copies only data in // [0, m_bytesUsed) range. bool ExpandCapacity >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=90&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523szv9AYLlP3J7qhn%25252Fm%25252BJqzPmSgWf45%25252BRVwVxvXDk3WYQ%25253D&gsn=ExpandCapacity&ct=xref_usages>(unsigned >>>>>>> size >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=90&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523mXwymG5xtblCCeS4C9QcnmOwJxql8nYDr2HLqNZVJ8I%25253D&gsn=size&ct=xref_usages>); >>>>>>> unsigned bytes_used_ >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=92&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523x95FyaH%25252BSeW1SF4BFhX9oIq7qgtHy3xzXCMmc37LcL8%25253D&gsn=bytes_used_&ct=xref_usages>; >>>>>>> bool variable_capacity_ >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=93&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523FKWGJXbcZ%25252BRuy6YD7uxQ765XV8Mhciv4FM%25252FF5B3bNvU%25253D&gsn=variable_capacity_&ct=xref_usages>; >>>>>>> scoped_refptr >>>>>>> <https://cs.chromium.org/chromium/src/base/memory/scoped_refptr.h?l=167&ct=xref_jump_to_def&gsn=scoped_refptr><ArrayBuffer >>>>>>> >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer.h?l=42&ct=xref_jump_to_def&gsn=ArrayBuffer>> >>>>>>> buffer_ >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=94&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523aFDjYtlmS2tmLXL2XyJ158HoigBmsAdzguhOSb6XQIw%25253D&gsn=buffer_&ct=xref_usages>; >>>>>>> DISALLOW_COPY_AND_ASSIGN >>>>>>> <https://cs.chromium.org/chromium/src/base/macros.h?l=33&ct=xref_jump_to_def&gsn=DISALLOW_COPY_AND_ASSIGN>(ArrayBufferBuilder >>>>>>> >>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.h?l=96&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.h%2523E6nSXqAY3ipexrHDKPfjzHqWqWIsAlT3EH3KVhT57GQ%25253D&gsn=ArrayBufferBuilder&ct=xref_usages>);};} >>>>>>> // namespace WTF >>>>>>> >>>>>>> >>>>>>> >>>>>>> How can i understand the structure in memory of an arraybuffer and how >>>>>>> big is the data field which is pointed by this void pointerHow are they >>>>>>> represented in memory....How big is the data field ? >>>>>>> >>>>>>> >>>>>>> Il giorno lun 10 set 2018 alle ore 22:19 dan Med < >>>>>>> litoki...@gmail.com> ha scritto: >>>>>>> >>>>>>>> i already did that and btw it is under the WTF/webkit . >>>>>>>> I'm interested how v8 handles javascript into every detail if u can >>>>>>>> guide me... >>>>>>>> Tell me which repository are being used by v8 on the related topic >>>>>>>> that would help me really much. >>>>>>>> >>>>>>>> By when it is called i mean, which javascript code will enable me >>>>>>>> to call that funciton cause if u click u can't go any further than >>>>>>>> that, >>>>>>>> >>>>>>>> Il giorno lun 10 set 2018 alle ore 21:53 Jakob Kummerow < >>>>>>>> jkum...@chromium.org> ha scritto: >>>>>>>> >>>>>>>>> On Mon, Sep 10, 2018 at 12:22 PM dan Med <litoki...@gmail.com> >>>>>>>>> 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&sq=package:chromium&g=0&l=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 < >>>>>>>>>> jkum...@chromium.org> ha scritto: >>>>>>>>>> >>>>>>>>>>> On Sun, Sep 9, 2018 at 8:54 AM dan Med <litoki...@gmail.com> >>>>>>>>>>> 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 < >>>>>>>>>>>> litoki...@gmail.com> 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 <https://cs.chromium.org/chromium/src/> >>>>>>>>>>>>> /third_party >>>>>>>>>>>>> <https://cs.chromium.org/chromium/src/third_party/>/blink >>>>>>>>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/>/ >>>>>>>>>>>>> renderer >>>>>>>>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/> >>>>>>>>>>>>> /platform >>>>>>>>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/> >>>>>>>>>>>>> /wtf >>>>>>>>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/> >>>>>>>>>>>>> /typed_arrays >>>>>>>>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/> >>>>>>>>>>>>> /array_buffer_builder.cc >>>>>>>>>>>>> <https://cs.chromium.org/chromium/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 >>>>>>>>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_builder.cc?l=38&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fthird_party%252Fblink%252Frenderer%252Fplatform%252Fwtf%252Ftyped_arrays%252Farray_buffer_builder.cc%2523YXDT7WTpXCAcuhdyTlkuCzsfCzI%25252BoHLRFAlkbCrkx4g%25253D&gsn=kDefaultBufferCapacity&ct=xref_usages> >>>>>>>>>>>>> = 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 >>>>>>>>>>>>>> <https://cs.chromium.org/chromium/src/buildtools/third_party/libc%2B%2B/trunk/include/limits?l=442&ct=xref_jump_to_def&gsn=numeric_limits> >>>>>>>>>>>>>> <unsigned>::max >>>>>>>>>>>>>> <https://cs.chromium.org/chromium/src/buildtools/third_party/libc%2B%2B/trunk/include/limits?l=450&ct=xref_jump_to_def&gsn=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 <litoki...@gmail.com> >>>>>>>>>>>>>>> ha scritto: >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> array_buffer_builder.cc in src >>>>>>>>>>>>>>>> <https://cs.chromium.org/chromium/src/>/third_party >>>>>>>>>>>>>>>> <https://cs.chromium.org/chromium/src/third_party/>/blink >>>>>>>>>>>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/>/ >>>>>>>>>>>>>>>> renderer >>>>>>>>>>>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/> >>>>>>>>>>>>>>>> /platform >>>>>>>>>>>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/> >>>>>>>>>>>>>>>> /wtf >>>>>>>>>>>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/> >>>>>>>>>>>>>>>> / >>>>>>>>>>>>>>>> <https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/wtf/typed_arrays/> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> -- -- 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.