Skip to content

Instantly share code, notes, and snippets.

@ewencp
Created December 10, 2011 02:16
Show Gist options
  • Select an option

  • Save ewencp/1454309 to your computer and use it in GitHub Desktop.

Select an option

Save ewencp/1454309 to your computer and use it in GitHub Desktop.
v8::Object::Set(obj, key, value)
v8::Object* => v8::internal::JSObject** (MAKE_OPEN_HANDLE api.h, this is the external -> internal mapping, that same file also seems to have a macro for internal -> external mapping)
v8::internal::SetProperty(i::Object obj, i::Object key, i::Object val, flags)
implemented handles.cc:268
CALL_HEAP_FUNCTION(isolate, i::Object::SetProperty())
=> JSObject inherits from JSReceiver
JSReceiver::SetProperty objects.cc:1964 -> objects.cc:2619
=> JSObject::SetPropertyForResult
=> SetNormalizedProperty ( for normal, non-global, etc)
=> JSObject::properties_dictionary() => JSObject::properties()
defined in objects_inl.h:1183 by macro ACCESSORS
These are the macros that actually access the data:
ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset)
#define ACCESSORS(holder, name, type, offset) \
type* holder::name() { return type::cast(READ_FIELD(this, offset)); } \
void holder::set_##name(type* value, WriteBarrierMode mode) { \
WRITE_FIELD(this, offset, value); \
CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \
}
#define READ_FIELD(p, offset) \
(*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)))
#define FIELD_ADDR(p, offset) \
(reinterpret_cast<byte*>(p) + offset - kHeapObjectTag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment