Skip to content

Commit 62b6deb

Browse files
author
Jianchun Xu
committed
[MERGE chakra-core#193] Type consistency: Use uintptr_t / intptr_t instead of uintptr / intptr
Merge pull request chakra-core#193 from obastemur:fix_ptr_t Fixes chakra-core#168 Replaces all the instances of `intptr`/`uintptr` to `intptr_t`/`uintptr_t`
2 parents f8a38f7 + b534470 commit 62b6deb

21 files changed

Lines changed: 70 additions & 78 deletions

lib/Backend/Lower.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18248,7 +18248,7 @@ Lowerer::GenerateFunctionTypeFromFixedFunctionObject(IR::Instr *insertInstrPt, I
1824818248
IR::AddrOpnd* functionObjAddrOpnd = functionObjOpnd->AsAddrOpnd();
1824918249
// functionTypeRegOpnd = MOV [fixed function address + type offset]
1825018250
functionObjAddrOpnd->m_address;
18251-
functionTypeOpnd = IR::MemRefOpnd::New((void *)((intptr)functionObjAddrOpnd->m_address + Js::RecyclableObject::GetOffsetOfType()), TyMachPtr, this->m_func,
18251+
functionTypeOpnd = IR::MemRefOpnd::New((void *)((intptr_t)functionObjAddrOpnd->m_address + Js::RecyclableObject::GetOffsetOfType()), TyMachPtr, this->m_func,
1825218252
IR::AddrOpndKindDynamicObjectTypeRef);
1825318253
}
1825418254
else
@@ -22026,7 +22026,7 @@ Lowerer::LowerLdEnv(IR::Instr * instr)
2202622026
{
2202722027
Assert(functionObjOpnd->IsAddrOpnd());
2202822028
IR::AddrOpnd* functionObjAddrOpnd = functionObjOpnd->AsAddrOpnd();
22029-
IR::MemRefOpnd* functionEnvMemRefOpnd = IR::MemRefOpnd::New((void *)((intptr)functionObjAddrOpnd->m_address + Js::ScriptFunction::GetOffsetOfEnvironment()),
22029+
IR::MemRefOpnd* functionEnvMemRefOpnd = IR::MemRefOpnd::New((void *)((intptr_t)functionObjAddrOpnd->m_address + Js::ScriptFunction::GetOffsetOfEnvironment()),
2203022030
TyMachPtr, this->m_func, IR::AddrOpndKindDynamicFunctionEnvironmentRef);
2203122031
instr->SetSrc1(functionEnvMemRefOpnd);
2203222032
}

lib/Backend/Opnd.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3255,10 +3255,10 @@ Opnd::GetAddrDescription(__out_ecount(count) wchar_t *const description, const s
32553255
case IR::AddrOpndKindDynamicObjectTypeRef:
32563256
DumpAddress(address, printToConsole, skipMaskedAddress);
32573257
{
3258-
Js::RecyclableObject * dynamicObject = (Js::RecyclableObject *)((intptr)address - Js::RecyclableObject::GetOffsetOfType());
3258+
Js::RecyclableObject * dynamicObject = (Js::RecyclableObject *)((intptr_t)address - Js::RecyclableObject::GetOffsetOfType());
32593259
if (Js::JavascriptFunction::Is(dynamicObject))
32603260
{
3261-
DumpFunctionInfo(&buffer, &n, Js::JavascriptFunction::FromVar((void *)((intptr)address - Js::RecyclableObject::GetOffsetOfType()))->GetFunctionInfo(),
3261+
DumpFunctionInfo(&buffer, &n, Js::JavascriptFunction::FromVar((void *)((intptr_t)address - Js::RecyclableObject::GetOffsetOfType()))->GetFunctionInfo(),
32623262
printToConsole, L"FunctionObjectTypeRef");
32633263
}
32643264
else

lib/Backend/amd64/LinearScanMD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void
103103
LinearScanMD::LegalizeConstantUse(IR::Instr * instr, IR::Opnd * opnd)
104104
{
105105
Assert(opnd->IsAddrOpnd() || opnd->IsIntConstOpnd());
106-
intptr value = opnd->IsAddrOpnd() ? (intptr)opnd->AsAddrOpnd()->m_address : opnd->AsIntConstOpnd()->GetValue();
106+
intptr_t value = opnd->IsAddrOpnd() ? (intptr_t)opnd->AsAddrOpnd()->m_address : opnd->AsIntConstOpnd()->GetValue();
107107
if (value == 0
108108
&& instr->m_opcode == Js::OpCode::MOV
109109
&& !instr->GetDst()->IsRegOpnd()

lib/Backend/i386/LowererMDArch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ LowererMDArch::LowerAsmJsLdElemHelper(IR::Instr * instr, bool isSimdLoad /*= fal
922922
Js::Var* module = (Js::Var*)m_func->m_workItem->GetEntryPoint()->GetModuleAddress();
923923
Js::ArrayBuffer* arrayBuffer = *(Js::ArrayBuffer**)(module + Js::AsmJsModuleMemory::MemoryTableBeginOffset);
924924
Assert(arrayBuffer);
925-
src1->AsIndirOpnd()->SetOffset((uintptr)arrayBuffer->GetBuffer(), true);
925+
src1->AsIndirOpnd()->SetOffset((uintptr_t)arrayBuffer->GetBuffer(), true);
926926
}
927927

928928
if (isSimdLoad)
@@ -998,7 +998,7 @@ LowererMDArch::LowerAsmJsStElemHelper(IR::Instr * instr, bool isSimdStore /*= fa
998998
Js::Var* module = (Js::Var*)m_func->m_workItem->GetEntryPoint()->GetModuleAddress();
999999
Js::ArrayBuffer* arrayBuffer = *(Js::ArrayBuffer**)(module + Js::AsmJsModuleMemory::MemoryTableBeginOffset);
10001000
Assert(arrayBuffer);
1001-
dst->AsIndirOpnd()->SetOffset((uintptr)arrayBuffer->GetBuffer(), true);
1001+
dst->AsIndirOpnd()->SetOffset((uintptr_t)arrayBuffer->GetBuffer(), true);
10021002
}
10031003
return doneLabel;
10041004
}

lib/Runtime/Base/FunctionBody.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ namespace Js
447447
void * nativeAddress;
448448
ptrdiff_t codeSize;
449449
bool isAsmJsFunction; // true if entrypoint is for asmjs function
450-
uintptr mModuleAddress; //asm Module address
450+
uintptr_t mModuleAddress; //asm Module address
451451

452452
#ifdef FIELD_ACCESS_STATS
453453
FieldAccessStatsPtr fieldAccessStats;
@@ -658,14 +658,14 @@ namespace Js
658658
#endif
659659

660660
#ifndef TEMP_DISABLE_ASMJS
661-
void SetModuleAddress(uintptr moduleAddress)
661+
void SetModuleAddress(uintptr_t moduleAddress)
662662
{
663663
Assert(this->GetIsAsmJSFunction());
664664
Assert(moduleAddress);
665665
mModuleAddress = moduleAddress;
666666
}
667667

668-
uintptr GetModuleAddress()const
668+
uintptr_t GetModuleAddress()const
669669
{
670670
Assert(this->GetIsAsmJSFunction());
671671
Assert(mModuleAddress); // module address should not be null

lib/Runtime/Language/InterpreterStackFrame.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,12 +2832,12 @@ namespace Js
28322832
uint homingAreaSize = 0;
28332833
#endif
28342834

2835-
uintptr argAddress = (uintptr)m_inParams;
2835+
uintptr_t argAddress = (uintptr_t)m_inParams;
28362836
for (ArgSlot i = 0; i < argCount; i++)
28372837
{
28382838
#if _M_X64
28392839
// 3rd Argument should be at the end of the homing area.
2840-
Assert(i != 3 || argAddress == (uintptr)m_inParams + homingAreaSize);
2840+
Assert(i != 3 || argAddress == (uintptr_t)m_inParams + homingAreaSize);
28412841
if (i < 3)
28422842
{
28432843
// for x64 we spill the first 3 floating point args below the rest of the arguments on the stack
@@ -2857,7 +2857,7 @@ namespace Js
28572857
// IAT xmm1 spill <- floatSpillAddress for arg1
28582858

28592859
// floats are spilled as xmmwords
2860-
uintptr floatSpillAddress = (uintptr)m_inParams - MachPtr * (15 - 2*i);
2860+
uintptr_t floatSpillAddress = (uintptr_t)m_inParams - MachPtr * (15 - 2*i);
28612861

28622862
if (info->GetArgType(i).isInt())
28632863
{
@@ -2889,7 +2889,7 @@ namespace Js
28892889
// If we have simd arguments, the homing area in m_inParams can be larger than 3 64-bit slots. This is because SIMD values are unboxed there too.
28902890
// After unboxing, the homing area is overwritten by rdx, r8 and r9, and we read/skip 64-bit slots from the homing area (argAddress += MachPtr).
28912891
// After the last argument of the 3 is read, we need to advance argAddress to skip over the possible extra space and to the start of the rest of the arguments.
2892-
argAddress = (uintptr)m_inParams + homingAreaSize;
2892+
argAddress = (uintptr_t)m_inParams + homingAreaSize;
28932893
}
28942894
else
28952895
{

lib/Runtime/Language/JavascriptNativeOperators.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
namespace Js
99
{
1010
#if ENABLE_NATIVE_CODEGEN
11-
void * JavascriptNativeOperators::Op_SwitchStringLookUp(JavascriptString* str, Js::BranchDictionaryWrapper<JavascriptString*>* branchTargets, uintptr funcStart, uintptr funcEnd)
11+
void * JavascriptNativeOperators::Op_SwitchStringLookUp(JavascriptString* str, Js::BranchDictionaryWrapper<JavascriptString*>* branchTargets, uintptr_t funcStart, uintptr_t funcEnd)
1212
{
1313
void* defaultTarget = branchTargets->defaultTarget;
1414
Js::BranchDictionaryWrapper<JavascriptString*>::BranchDictionary& stringDictionary = branchTargets->dictionary;
1515
void* target = stringDictionary.Lookup(str, defaultTarget);
16-
uintptr utarget = (uintptr)target;
16+
uintptr_t utarget = (uintptr_t)target;
1717

1818
if ((utarget - funcStart) > (funcEnd - funcStart))
1919
{

lib/Runtime/Language/JavascriptNativeOperators.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace Js
2929
class JavascriptNativeOperators
3030
{
3131
public:
32-
static void * Op_SwitchStringLookUp(JavascriptString* str, Js::BranchDictionaryWrapper<Js::JavascriptString*>* stringDictionary, uintptr funcStart, uintptr funcEnd);
32+
static void * Op_SwitchStringLookUp(JavascriptString* str, Js::BranchDictionaryWrapper<Js::JavascriptString*>* stringDictionary, uintptr_t funcStart, uintptr_t funcEnd);
3333
};
3434
#endif
3535
};

lib/Runtime/Language/TaggedInt.inl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ namespace Js
2929
#if INT32VAR
3030
__inline bool TaggedInt::Is(Var aValue)
3131
{
32-
bool result = (((uintptr) aValue) >> VarTag_Shift) == AtomTag;
32+
bool result = (((uintptr_t) aValue) >> VarTag_Shift) == AtomTag;
3333
if(result)
3434
{
35-
Assert((uintptr)aValue >> 32 == (AtomTag << 16));
35+
Assert((uintptr_t)aValue >> 32 == (AtomTag << 16));
3636
}
3737
return result;
3838
}
@@ -86,18 +86,18 @@ namespace Js
8686
{
8787
//
8888
// To convert to an var we first cast to uint32 to lose the signedness and then
89-
// extend it to a 64-bit uintptr before OR'ing the 64-bit atom tag.
89+
// extend it to a 64-bit uintptr_t before OR'ing the 64-bit atom tag.
9090
//
9191

9292
AssertMsg(!IsOverflow(nValue), "Ensure no information loss from conversion");
9393

94-
return reinterpret_cast<Var>(((uintptr)(uint32)nValue) | AtomTag_IntPtr);
94+
return reinterpret_cast<Var>(((uintptr_t)(uint32)nValue) | AtomTag_IntPtr);
9595
}
9696

9797
#else
9898
__inline bool TaggedInt::Is(const Var aValue)
9999
{
100-
return (((uintptr) aValue) & AtomTag) == AtomTag_IntPtr;
100+
return (((uintptr_t) aValue) & AtomTag) == AtomTag_IntPtr;
101101
}
102102

103103
__inline bool TaggedInt::IsPair(Var aLeft, Var aRight)
@@ -110,7 +110,7 @@ namespace Js
110110
// short-circuit evaluation.
111111
//
112112

113-
return (((uintptr) aLeft) & ((uintptr) aRight) & AtomTag) == AtomTag_IntPtr;
113+
return (((uintptr_t) aLeft) & ((uintptr_t) aRight) & AtomTag) == AtomTag_IntPtr;
114114
}
115115

116116
__inline int32 TaggedInt::ToInt32(Var aValue)

lib/Runtime/Library/JavascriptFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2004,7 +2004,7 @@ namespace Js
20042004
{
20052005
// some extra checks for asm.js because we have slightly more information that we can validate
20062006
Js::EntryPointInfo* entryPointInfo = (Js::EntryPointInfo*)funcBody->GetDefaultEntryPointInfo();
2007-
uintptr moduleMemory = entryPointInfo->GetModuleAddress();
2007+
uintptr_t moduleMemory = entryPointInfo->GetModuleAddress();
20082008
if (!moduleMemory)
20092009
{
20102010
return EXCEPTION_CONTINUE_SEARCH;

0 commit comments

Comments
 (0)