how v8 encodes pointers in memory - google-chrome

V8 version 10.7.0 (candidate)
I have created an array of elements from several objects
enter image description here
with v8 builtin functions, use "%DebugPrint" to get pointer to array object
enter image description here
I look in memory for the address of the array object "0x000001BE0010BC5D",
enter image description here
and I see that the first address corresponds to the map of the object
the map address is encrypted
I would love to know how to decode the address manually

It's not encrypted, it's compressed. So it helps to print 32-bit values in your disassembler; in this case that'd be 0x002c3b51 for the array's map (lower half of the 64-bit value that you printed). Since all objects live on the same heap, you can manually decompress that address by adding the same upper-32-bits prefix that the array's address has, i.e. 0x000001be. So the map's full address is 0x000001be002c3b51 (as you can already see in your second screenshot).
The upper half of that first 64-bit value is the compressed version of the array's second field, to its "properties" backing store.
Side note: please learn how to post code as code, not as screenshots.

Related

StorageProvider: What is populating and what does PopulationPolicy do?

I'm reading up on Cloud file storage, and ran across the PopulationPolicy property under Storage.Provider.StorageProviderSyncRootInfo, but I'm not sure what this does. The definition that msdn provided to just cut off. Under the Fields section, AlwaysFull sounds similar to how the first part of HydrationPolicyModifier's ValidationRequired field works ("it guarantees that the data returned by the sync provider is always persisted to the disk prior to it being returned to the user application"). I believe that hydration fills the placeholder object with the correct data from the cloud (correct me), but I'm confused about what populate does.
What is populating?
What does changing the PopulationPolicy to Full and AlwaysFull do?
Population is about files and folders (placeholders), not their content (Hydration).
If you don't use AlwaysFull (so the only valid value left is Full), the platform will call your engine back with CF_CALLBACK_TYPE_FETCH_PLACEHOLDERS, otherwise this type of callback will not be used.

Method GetInfo in WebSerial API? Is there another way to get device infos?

I'm using the Web Serial API to connect two different scales. They send the weight data in different ways, so I'm trying to get the serialport metadata from them (vendorId etc) because I want to detect which scale is connected. The "getInfo()" method does not work because it is undefined in the Serialport Object.
[Exposed=(DedicatedWorker,Window), SecureContext]
interface SerialPortInfo {
maplike<DOMString, DOMString?>;
};
This is the interface for the metadata but I don't even know, how to use it.
My sources: https://wicg.github.io/serial/#dom-serialportinfo
The method is declared a little strangely in that version of the specification. You can treat the return value as a plan object. If the port is a USB device then it will have usbVendorId and usbProductId properties which are the metadata you are interested in.

In HDL file /<path>/<to>/<chip>.hdl Line <xx>, Can't connect part's output pin to gate's input pin: load <chip>.hdl

SPOILER ALERT: Contains a brief code snippet from Memory.hdl (project 5).
I am receiving the error listed in the title of this question, yet I am certain that it is not related to connecting an internal part's output pin to the chip's input pin.
Here's the code which is creating the error. There's no other code in the program so far.
CHIP Memory {
IN in[16], load, address[15];
OUT out[16];
PARTS:
DMux(in=load,sel=address[14],a=load_ram,b=load_other);
}
What is going on?!
Solution: Remove the underscore characters from your pin names.
The hardware simulator is producing the wrong error message. The issue is that the underscore character (_) is not a valid character for pin names. So when the hardware simulator sees a=load_ram it parses it as a=load ram. Since load is the name of an input pin for Memory, that explains why you are seeing that error.
http://nand2tetris-questions-and-answers-forum.32033.n3.nabble.com/Cannot-connect-part-s-output-pin-to-gate-s-input-pin-tp4025858p4025859.html

Read contents of Initialization range and SegmentBase indexRange in a DASH stream

I have been trying to understand how DASH works, mainly the MPD and how a remote client boots-up to play a stream. Of many parameters in the MPD, the Initialization range and SegmentBase indexRange seems to be of much interest. If I understand it right, these values give the base URL and the mappings to key-frames that must be retrieved if the client seeks/rewinds a video.
My question is if these values can be seen before I actually play a video. For example, can I use a tool like youtube-dl to download these byte-ranges and decode them in a way that is human readable?
Much appreciated.
-Jamie
I'm also starting to look into DASH so take my answer with a grain of salt.
The SegmentBase is used when you have a single segment in a representation. For multiple segments there's SegmentList and SegmentTemplate. You can find more in this MPEG-DASH overview.
For MPEG-DASH the SegmentBase indexRange attribute points to the location of the sidx box (Segment Index Box). The box contains information about the sub-segments and random access points for seeking etc. There's more info in this Quick Tutorial on MPEG-DASH.
In the case of WebM-DASH the segment index corresponds to the Cues element.
The Initialization range attribute points to the initialization segment.
If the server supports it you could issue HTTP Range requests to get the data but you'll need to parse it.
There's a Node.js ISO BMFF parser here: iso-bmff-parser-stream and the DASH-IF reference client implementation in JavaScript can be found at: dash.js.
For WebM the Cues can be read using mkvinfo, as reported by #jamie.

How do I implement a "find nearest" type functionality?

HI,
I was wondering if anyone had any ideas about how to implement functionality where given an array of locations ( for e.g. branches) it will list the nearest one or list all withing a 5 mile radius etc?
When you say "locations", what do you mean exactly? Street addresses? GPS coordinates?
If you have GPS coordinates (or can convert an address to coords), you can always calculate the Euclidean distance or the (more accurate) great-circle distance between two points. Caculate the distance between the current location and each potential destination, then sort the list by shortest distance.
You didn't mention if you were using the Google Maps API, but here's some additional info in case you are. You can store two points as objects of type GLatLng and use object1.distanceFrom(object2) to calculate this. You can also create a GLatLngBounds object representing a rectangular region on the map and use GLatLngBounds.containsLatLng(latlng:GLatLng) to see if a geographical point lies within that region.
Edit: What typically happens in the case you mention below is when a user enters a post code, the "current location" is taken to be the geographic center of that post code (you would probably have to get this info from the authority who assigns post codes in your area). If you are in the UK, this site has a free list of postcodes and their coordinates. Searching for a postal code in Google Maps will take you to the center of that postcode; if you need to build your own list of post codes and coordinates, you can probably create a script that will iterate through all valid post codes and use Google maps to look them up and turn them into GPS coordinates.
To turn an address into coordinates, you want to do what is called geocoding. Google Maps has an API for this, and there are other resources that can provide you this functionality. For some examples, try this page. What resource you use largely depends on where you are, as most of this information is localized. You didn't mention much about your project (platform, language, etc), but at the bottom of that page is a section called "Geocoding Helper Libraries" that may have the functionality you need rolled into a pre-built package. In particular the GeoKit library (Ruby language) has a handful of examples on the front page of their website, including several that look like they do exactly what you are wanting to do.
EDIT: I got the following code from the code generator at WebRPC:
/**
* Copyright WebRPC
* available under the GNU GENERAL PUBLIC LICENSE Version 2, June 1991
* http://www.gnu.org/licenses/gpl.txt
*/
public class Client
{
public static void Main(string[] args)
{
// make the call
XPathDocument doc = new XPathDocument(#"http://maps.google.com/maps/geo?q=New+York&output=xml&key=ABQIAAAAuXdMTY5VIU1FvkgOOP1dNBTsILMTMKRV-aJhd94IQkaJhVJ0YBS2qNSZGm8TaefqbXBT6lUXeMZ6tA");
// print the outputs
XPathNavigator nav = doc.CreateNavigator();
XPathNodeIterator coord = nav.Select( "/kml/Response/Placemark/Point/coordinates" );
while ( coord.MoveNext() )
System.Console.WriteLine( coord.Current );
XPathNodeIterator accuracy = nav.Select( "/kml/Response/Placemark/AddressDetails/#Accuracy" );
while ( accuracy.MoveNext() )
System.Console.WriteLine( accuracy.Current );
}
}
You should be able to modify this C# code to suit your needs. Specifically, in the call to new XPathDocument, change the part of the string that reads ?q=New+York to whatever address or postal code you need (for example, using ?q=1060+West+Addison%2C+Chicago%2C+IL will retrieve information for Wrigley Field in Chicago, or using ?q=LS11+0ES%2C+UK will get info for a postal code in Leeds). To format an address from a regular text string, change spaces to '+' and turn all other non-alphanumeric characters into their ASCII equivalent (such as '%2C' for a comma).
The next few lines retrieve the information from the server and parse it in various ways. Of interest here is the field /kml/Response/Placemark/Point/coordinates in the returned data. This string will contain your latitude and longitude coordinates for the location you specified above.
Now, this should give you enough information to create a C# function that is able to turn an address or post code into a pair of coordinates. The hard part is done, but two steps remain. First, you will want to use this to generate coordinates for each address in your database (store these in the database with the addresses for best results). Now, when a user enters an address, call your C# function again to generate a set of coordinates for her location. Now that you have coordinates for everything, you can find the distance between two coordinates by using one of the two distance-calculating functions I linked to at the top of the post. Run down your list of branches, calculate the distance from the user to each, and sort that list to find the branches with the shortest distance values.