Skip to content

Instantly share code, notes, and snippets.

@ihnorton
Last active December 15, 2015 14:29
Show Gist options
  • Select an option

  • Save ihnorton/5275046 to your computer and use it in GitHub Desktop.

Select an option

Save ihnorton/5275046 to your computer and use it in GitHub Desktop.
derefptr
derefptr(thisptr, vtidx) = pointer(Void, unsafe_ref(pointer(Uint64, unsafe_ref(pointer(Uint64,thisptr)))+vtidx*8) )
julia> disassemble(Clang.wrap_cpp.derefptr, (Ptr{Void},Int64))
define i8* @julia_derefptr817(i8*, i64) {
top:
%2 = bitcast i8* %0 to i64*, !dbg !7020, !julia_type !7027
%3 = load i64* %2, !dbg !7020, !julia_type !7028
%4 = inttoptr i64 %3 to i64*, !dbg !7020, !julia_type !7027
%5 = ptrtoint i64* %4 to i64, !dbg !7020, !julia_type !7028
%6 = shl i64 %1, 3, !dbg !7020
%7 = add i64 %5, %6, !dbg !7020, !julia_type !7028
%8 = inttoptr i64 %7 to i64*, !dbg !7020, !julia_type !7027
%9 = load i64* %8, !dbg !7020, !julia_type !7028
%10 = inttoptr i64 %9 to i8*, !dbg !7020, !julia_type !7029
ret i8* %10, !dbg !7020
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment