Convert Smi to Operand.Immediate in ARM64 backend?

16 views
Skip to first unread message

Thomson Tan

unread,
Apr 20, 2018, 9:12:45 PM4/20/18
to v8-users
The ARM64 backend could convert Smi to Operand by assigning tagged Smi to immediate filed in Operand class, as below code snippet. Then the immediate field is tagged Smi value, would it cause problem when encoding this operand?

// src\arm64\assember-arm64-inl.h

template<>

struct ImmediateInitializer<Smi*> {

  static inline int64_t immediate_for(Smi* t) {;

    return reinterpret_cast<int64_t>(t);

  }

};



Ben Noordhuis

unread,
Apr 21, 2018, 4:27:44 AM4/21/18
to v8-users
On Sat, Apr 21, 2018 at 2:58 AM, Thomson Tan <lil...@gmail.com> wrote:
> The ARM64 backend could convert Smi to Operand by assigning tagged Smi to
> immediate filed in Operand class, as below code snippet. Then the immediate
> field is tagged Smi value, would it cause problem when encoding this
> operand?
>
> // src\arm64\assember-arm64-inl.h
> template<>
> struct ImmediateInitializer<Smi*> {
> static const bool kIsIntType = false;
> static inline RelocInfo::Mode rmode_for(Smi* t) { return RelocInfo::NONE;
> }
> static inline int64_t immediate_for(Smi* t) {;
> return reinterpret_cast<int64_t>(t);
> }
> };

No, If I understand your question correctly.

Smis are not heap objects and don't need additional bookkeeping.
That's unlike embedded object pointers, those need to be made visible
to the garbage collector.

Thomson Tan

unread,
Apr 22, 2018, 1:49:28 AM4/22/18
to v8-users
Thanks. I meant whether Smi should be untagged to the real int value (without tag) when assigning to Operand immediate field. 

Ben Noordhuis

unread,
Apr 22, 2018, 8:13:58 AM4/22/18
to v8-users
On Sun, Apr 22, 2018 at 7:49 AM, Thomson Tan <lil...@gmail.com> wrote:
> Thanks. I meant whether Smi should be untagged to the real int value
> (without tag) when assigning to Operand immediate field.

Ah, like that. No, most of the time you don't need to untag. Smi +
Smi = Smi (barring overflow.)
Reply all
Reply to author
Forward
0 new messages