-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
> > # 内存地址相关 #560
Comments
JERRY_ASSERT ((uintptr_t) JERRY_HEAP_CONTEXT (area) % JMEM_ALIGNMENT == 0); 上面这句应该只是要求jerry_global_heap.area为8字节对齐把?没有要求jerry_global_heap为8字节对齐把?分析area关键是这两个宏: #define JMEM_HEAP_GET_OFFSET_FROM_ADDR(p) ((uint32_t) ((uint8_t *) (p) - JERRY_HEAP_CONTEXT (area)))
#define JMEM_HEAP_GET_ADDR_FROM_OFFSET(u) ((jmem_heap_free_t *) (JERRY_HEAP_CONTEXT (area) + (u))) 看这两个宏的读写操作赋值结果area的类型都是 |
为了保证jerry_global_heap.area可以是8字节对齐,必须是 jerry_global_heap是8字节对齐,对吧 另外下面的宏 (jmem_heap_free_t *)的作用是将jerry_global_heap.area指向的类型转为jmem_heap_free_t,它的地址是不变,并不是对jerry_global_heap.area地址对齐有什么约束 |
我觉得你理解错我的意思了,我的意思是对area的操作基本都是通过JMEM_HEAP_GET_OFFSET_FROM_ADDR和JMEM_HEAP_GET_ADDR_FROM_OFFSET这两个宏进行的。那么我们可以看看jerryscript通过调用这两个宏往area塞入了什么数据。全局搜索这两个宏发现,只往area塞入了jmem_heap_free_t类型的数据,没有别的类型数据。所以area里面只有jmem_heap_free_t为结构单元的数据 |
因为的它的存储结构是jmem_heap_free_t,刚好是8字节吧,(建议关注:#535 这个帖子,以后解读基本以那个为主)
Originally posted by @cisen in #479 (comment)
分析了下觉得和jmem_heap_free_t 8字节没关系。
与JerryScript中ecma的结构有关。
具体分析如下: jerry_global_heap是我们分配的堆的起始地址,以创建object为例子,jerry_global_heap的8字节对齐,决定了后面分配的ecma_object_point8字节对齐。(ecma_object_point 必须8字节对齐,因为ecma_object_point 转成ecma_data时,通过ecma_pointer_to_ecma_value直接(将指针地址转为值)强转得到的,后面3bit必须为000, 官网中已说明ecma_value后面的3bit需要用于标志type)
The text was updated successfully, but these errors were encountered: