In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to achieve js engine HeapObject". In daily operation, I believe many people have doubts about how to achieve js engine HeapObject. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to achieve js engine HeapObject". Next, please follow the editor to study!
The object base class of V8 is Object. Let's take a look at his class definition first. Only the important functions are listed below.
/ / Object is the abstract superclass for all classes in the
/ / object hierarchy.
/ / Object does not use any virtual functions to avoid the
/ / allocation of the C++ vtable.
/ / Since Smi and Failure are subclasses of Object no
/ / data members can be present in Object.
Class Object BASE_EMBEDDED {
Public:
/ / Type testing.
Inline bool IsSmi ()
/ / here are some functions that list isXX
/ / Extract the number.
Inline double Number ()
Object* ToObject (); / / ECMA-262 9.9.
Object* ToBoolean (); / / ECMA-262 9.2.
/ / Convert to a JSObject if needed.
/ / global_context is used when creating wrapper object.
Object* ToObject (Context* global_context)
/ / Converts this to a Smi if possible.
/ / Failure is returned otherwise.
Inline Object* ToSmi ()
Void Lookup (String* name, LookupResult* result)
/ / Property access.
Inline Object* GetProperty (String* key)
Inline Object* GetProperty (String* key, PropertyAttributes* attributes)
Object* GetPropertyWithReceiver (Object* receiver
String* key
PropertyAttributes* attributes)
Object* GetProperty (Object* receiver
LookupResult* result
String* key
PropertyAttributes* attributes)
Object* GetPropertyWithCallback (Object* receiver
Object* structure
String* name
Object* holder)
Inline Object* GetElement (uint32_t index)
Object* GetElementWithReceiver (Object* receiver, uint32_t index)
/ / Return the object's prototype (might be Heap::null_value ())
Object* GetPrototype ()
/ / Returns true if this is a JSValue containing a string and the index is
/ / < the length of the string. Used to implement [] on strings.
Inline bool IsStringObjectWithCharacterAt (uint32_t index)
/ / Casting: This cast is only needed to satisfy macros in objects-inl.h.
Static Object* cast (Object* value) {return value;}
/ / Layout description.
Static const int kSize = 0; / / Object does not take up any space.
Private:
/ / prevent objects from being created in the heap
/ *
The grand development is
Object ()
Object (const TypeName&)
Void operator= (const Object&)
, /
DISALLOW_IMPLICIT_CONSTRUCTORS (Object)
}
We see that there is a static property kSize in the class, which is the object that marks the class and the size of the memory bytes that the attribute needs to occupy. Let's take a look at the first class Smi that inherits from Object. Smi means minor plastic surgery. Let's look at his definition.
Class Smi: public Object {
Public:
/ / Returns the integer value.
Inline int value ()
/ / Convert a value to a Smi object.
Static inline Smi* FromInt (int value)
/ / Returns whether value can be represented in a Smi.
Static inline bool IsValid (int value)
/ / Casting.
Static inline Smi* cast (Object* object)
/ / Min and max limits for Smi values.
Static const int kMinValue =-(1 kSmiTagSize
}
Smi* Smi::FromInt (int value) {
ASSERT (Smi::IsValid (value))
/ / kSmiTagSize is a type mark that indicates a minor shaping. The value is 1.kSmiTag is 0
Return reinterpret_cast ((value
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.