This is a good question.
While an object represents functions and data that are theoretically located in the same place, most implementations share it. The way you do this is that the code is split and stored in the RO segment. Then, the object in the RW area has the ability to refer to this code in the RO area. The combination of code and data is used conceptually only by the human programmer and type controller to ensure that you do not violate the rules and principles.
Typically, Java / C # is similar to a language, so each object has a tag identifying the type of object. The object itself is simply a structure containing all the fields laid out in a given order. You can then use this tag to search for the function that you want to call in the RO zone. The function in the RO area is changed to get an additional parameter called this or "I" through which the contents of the specified object can be reached. When a method needs to refer to fields, it knows a predefined order, so it can perform this correlation. Note that some tricks are needed to solve inheritance, but this is the essence of the idea.
A Python / Ruby language usually makes the object a hash table, where the method is a pointer to code in the RO area (provided that the language is compiled and does not run through the bytecode interpreter). The function call is made by searching the contents of the hash table and the subsequent code pointer. Fields are also viewed in the same hash table.
Given these basics, most implementations do tricks to avoid where the pointer is used to find the function to call. They try to figure out and narrow down a possible call to one function. Then they can replace the search with a direct call to the right function, a much faster solution.
tl version; dr: language semantics considers fields and methods as part of an object. The implementation divided them into RO and RW segments. As such, OS support is not required.
I GIVE CRAP ANSWERS
source share