want to port JIT to MIPS - stack/code segment

71 篇文章 0 订阅
42 篇文章 0 订阅

http://marc.info/?l=webkit-dev&m=123572053829137&w=2

want to port JIT to MIPS - stack/code segment


in ARM, we have a rule set called EABI (Embedded Application Binary
Interface). It says the stack must always be word aligned, and must be 2
words (8 bytes) aligned if you call other functions. The WebKit
interpreter callbacks returns either a single pointer (sometimes an int
contains a boolean value) or double pointers. These return values can be
passed through registers, no need to pre-allocate stack space for them.
The functions generated by g++ are also EABI compilant, so we don't need
worry about the stack at all.

I think AssemblerBuffer is only temporary hold the generated machine
instructions. When the compilation phase is done, you need to call
AssemblerBuffer::executableCopy, which allocates a new executable memory
space and that space is aligned by ExecutableAllocator.

Cheers,
Zoltan

> Zoltan,
> thanks a lot! yeah the issue is just JIT related.
> Do I need to take care of stack in JIT code, say before emit asm call I
> align the stack? I guess no need because Mips always aligned to 32bits,
> and the only double functions in webkit return result in registers not
> memory.
> For AssemblerBuffer.h I think it is different because the initial 256bytes
> buffer may be not aligned to 32bit. I'll add __attribute__ ((aligned (4)))
> or 8.
> rgds
> joe


I am not sure I understand your questions. The code blocks are allocated
by mmap() or VirtualAlloc(), thus they are aligned to 4K. Smaller chunks
are aligned by roundUpAllocationSize() function. Now the alignemt is
sizeof(void*) in both x86 and ARM. See ExecutableAllocator.h

The current jit implementations don't store temporary variables on the
stack, they allocate a fixed size buffer after the entry, and only free
that when you leave the jit. This approach is much easier than keep
tracking of the stack.

Cheers,
Zoltan

> gcc handles it well for X86. now on Mips I need to do followings right?
> 1. make sure (re)allocated code buffer aligned to 64bits and gcc malloc()
> only guarantee 32bits
> 2. before any call instruction in JIT code, make sure stack is aligned to
> 64bit also.
> PPC no JIT thus no problem right?
> rgds
> joe

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Traceback (most recent call last): File "/home/a/pycharmproject/clothes_try_on_copy/11/PF-AFN-main/PF-AFN_train/train_PBAFN_stage1.py", line 134, in <module> loss_vgg = criterionVGG(x_all[num], cur_person_clothes.cuda()) File "/home/a/.conda/envs/clothes_try_on_copy1/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "/home/a/pycharmproject/clothes_try_on_copy/11/PF-AFN-main/PF-AFN_train/models/networks.py", line 164, in forward x_vgg, y_vgg = self.vgg(x), self.vgg(y) File "/home/a/.conda/envs/clothes_try_on_copy1/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "/home/a/pycharmproject/clothes_try_on_copy/11/PF-AFN-main/PF-AFN_train/models/networks.py", line 150, in forward h_relu5 = self.slice5(h_relu4) File "/home/a/.conda/envs/clothes_try_on_copy1/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "/home/a/.conda/envs/clothes_try_on_copy1/lib/python3.8/site-packages/torch/nn/modules/container.py", line 119, in forward input = module(input) File "/home/a/.conda/envs/clothes_try_on_copy1/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "/home/a/.conda/envs/clothes_try_on_copy1/lib/python3.8/site-packages/torch/nn/modules/pooling.py", line 162, in forward return F.max_pool2d(input, self.kernel_size, self.stride, File "/home/a/.conda/envs/clothes_try_on_copy1/lib/python3.8/site-packages/torch/_jit_internal.py", line 365, in fn return if_false(*args, **kwargs) File "/home/a/.conda/envs/clothes_try_on_copy1/lib/python3.8/site-packages/torch/nn/functional.py", line 659, in _max_pool2d return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode) RuntimeError: Given input size: (512x2x1). Calculated output size: (512x1x0). Output size is too small 进程已结束,退出代码1
07-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值