Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
* lots of progress for JIT of mulle-objc
Browse files Browse the repository at this point in the history
  • Loading branch information
mulle-nat committed Jul 31, 2018
1 parent e73d831 commit a475fc6
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 19 deletions.
6 changes: 6 additions & 0 deletions include/lldb/Target/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -3130,6 +3130,12 @@ class Process : public std::enable_shared_from_this<Process>,

enum { eCanJITDontKnow = 0, eCanJITYes, eCanJITNo } m_can_jit;

// @mulle-lldb@ avoid failed threadplan calling formatters that execute a threadplan again >
public:
bool isThreadPlanLocked( void);
protected:
// @mulle-lldb@ avoid failed threadplan calling formatters that execute a threadplan again <

size_t RemoveBreakpointOpcodesFromBuffer(lldb::addr_t addr, size_t size,
uint8_t *buf) const;

Expand Down
4 changes: 2 additions & 2 deletions source/Expression/ExpressionSourceCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ bool ExpressionSourceCode::GetText(std::string &text,
/// @mulle-objc@ hack some mulle-objc-runtime stuff into the expression >
/// @mulle-objc@ MUST CHANGE VALUES THIS FOR EACH LLDB RELEASE!!
wrap_stream.Printf("\
static const struct clang_mulle_objc_compiler_info\n\
static const struct mulle_clang_objccompilerinfo\n\
{\n\
unsigned int load_version;\n\
unsigned int runtime_version;\n\
} __mulle_objc_compiler_info =\n\
} __mulle_objc_objccompilerinfo =\n\
{\n\
12, // load version must match \n\
0 // 0 to not emit __load_mulle_objc\n\
Expand Down
10 changes: 9 additions & 1 deletion source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,14 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
VersionTuple(10, 7));
else
/// @mulle-objc@ change to Mulle runtime >
{
m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::Mulle,
VersionTuple(0, 12));
// tagged pointers are not good for JIT, but I don't know exactly why yet
m_compiler->getLangOpts().ObjCDisableTaggedPointers = true;
m_compiler->getLangOpts().CPlusPlus = false;
m_compiler->getLangOpts().CPlusPlus11 = false;
}
/// @mulle-objc@ change to Mulle runtime <

if (process_sp->GetObjCLanguageRuntime()->HasNewLiteralsAndIndexing())
Expand Down Expand Up @@ -902,7 +908,9 @@ lldb_private::Status ClangExpressionParser::PrepareForExecution(
DiagnosticManager install_diagnostics;

if (!dynamic_checkers->Install(install_diagnostics, exe_ctx)) {
if (install_diagnostics.Diagnostics().size())
/// @mulle-lldb@ fix a bug >
if (! install_diagnostics.Diagnostics().size())
/// @mulle-lldb@ fix a bug <
err.SetErrorString("couldn't install checkers, unknown error");
else
err.SetErrorString(install_diagnostics.GetString().c_str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,13 @@ struct BufStruct {
UtilityFunction *MulleObjCRuntimeV1::CreateObjectChecker(const char *name) {
std::unique_ptr<BufStruct> buf(new BufStruct);

#ifndef NDEBUG
int strformatsize = snprintf(&buf->contents[0], sizeof(buf->contents),
"extern \"C\"\n"
"{\n"
#include "mulle-objc-object-checker.inc"
"}",
name);
assert(strformatsize < (int)sizeof(buf->contents));
#endif

Status error;
return GetTargetRef().GetUtilityFunctionForLanguage(
Expand Down Expand Up @@ -406,6 +404,8 @@ lldb::addr_t MulleObjCRuntimeV1::GetISAHashTablePointer( Process *process) {
if (!objc_module_sp)
return LLDB_INVALID_ADDRESS;

if( process->isThreadPlanLocked())
return LLDB_INVALID_ADDRESS;
// that pointer is fluctuating!
return CallDangerousGetClassTableFunction( process);
}
Expand Down Expand Up @@ -435,6 +435,7 @@ void MulleObjCRuntimeV1::UpdateISAToDescriptorMapIfNeeded() {
lldb::addr_t hash_table_ptr = GetISAHashTablePointer( process);
if (hash_table_ptr == LLDB_INVALID_ADDRESS) {
m_isa_to_descriptor_stop_id = UINT32_MAX;
return; // can't do anything
}

// Read the mulle_concurrent_hashtable struct:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"static const \n"
"struct mulle_clang_objccompilerinfo\n"
"{\n"
"unsigned int load_version;\n"
"unsigned int runtime_version;\n"
"} __mulle_objc_objccompilerinfo =\n"
"{\n"
"12, \n"
"0 \n"
"};\n"
"void *__lldb_objc_get_dangerous_class_storage( void)\n"
"{\n"
"extern void *mulle_objc_lldb_get_dangerous_classstorage_pointer( void);\n"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
static const
struct mulle_clang_objccompilerinfo
{
unsigned int load_version;
unsigned int runtime_version;
} __mulle_objc_objccompilerinfo =
{
12, // load version must match
0 // 0 to not emit __load_mulle_objc
};


void *__lldb_objc_get_dangerous_class_storage( void)
{
extern void *mulle_objc_lldb_get_dangerous_classstorage_pointer( void);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
"static const \n"
"struct mulle_clang_objccompilerinfo\n"
"{\n"
"unsigned int load_version;\n"
"unsigned int runtime_version;\n"
"} __mulle_objc_objccompilerinfo =\n"
"{\n"
"12, \n"
"0 \n"
"};\n"
"void *__lldb_objc_find_implementation_for_selector( void *object,\n"
"unsigned int methodid,\n"
"void *cls_or_classid,\n"
"int is_classid,\n"
"int is_meta,\n"
"int debug)\n"
"{\n"
"void *mulle_objc_lldb_lookup_implementation( void *obj,\n"
"extern void *mulle_objc_lldb_lookup_implementation( void *obj,\n"
"unsigned int methodid,\n"
"void *cls_or_classid,\n"
"int is_classid,\n"
Expand All @@ -17,4 +27,4 @@
"is_classid,\n"
"is_meta,\n"
"debug));\n"
"}\n"
"}\n"
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
static const
struct mulle_clang_objccompilerinfo
{
unsigned int load_version;
unsigned int runtime_version;
} __mulle_objc_objccompilerinfo =
{
12, // load version must match
0 // 0 to not emit __load_mulle_objc
};

//
// this file is transformed with make-inc.sh into mulle-objc-lookup.inc
// which is then included into MulleObjCTrampolineHandler.cpp
Expand All @@ -13,12 +24,12 @@ void *__lldb_objc_find_implementation_for_selector( void *object,
int is_meta,
int debug)
{
void *mulle_objc_lldb_lookup_implementation( void *obj,
unsigned int methodid,
void *cls_or_classid,
int is_classid,
int is_meta,
int debug);
extern void *mulle_objc_lldb_lookup_implementation( void *obj,
unsigned int methodid,
void *cls_or_classid,
int is_classid,
int is_meta,
int debug);

return( mulle_objc_lldb_lookup_implementation( object,
methodid,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
"static const \n"
"struct mulle_clang_objccompilerinfo\n"
"{\n"
"unsigned int load_version;\n"
"unsigned int runtime_version;\n"
"} __mulle_objc_objccompilerinfo =\n"
"{\n"
"12, \n"
"0 \n"
"};\n"
"void %s( void *$__lldb_obj, unsigned int $__lldb_sel)\n"
"{\n"
"extern void mulle_objc_lldb_check_object( void *$__lldb_obj, unsigned int $__lldb_sel);\n"
"mulle_objc_lldb_check_object( $__lldb_obj, $__lldb_sel);\n"
"}\n"
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
static const
struct mulle_clang_objccompilerinfo
{
unsigned int load_version;
unsigned int runtime_version;
} __mulle_objc_objccompilerinfo =
{
12, // load version must match
0 // 0 to not emit __load_mulle_objc
};

void %s( void *$__lldb_obj, unsigned int $__lldb_sel)
{
extern void mulle_objc_lldb_check_object( void *$__lldb_obj, unsigned int $__lldb_sel);

mulle_objc_lldb_check_object( $__lldb_obj, $__lldb_sel);
}
9 changes: 5 additions & 4 deletions source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3369,9 +3369,6 @@ bool DWARFASTParserClang::ParseMulleABIParameters( const DWARFDIE &die,
&bit_offset_ptr,
&bitfield_bit_size_ptr,
&is_bitfield_ptr);

fprintf( stderr, "#%d _param.%s found\n", (int) i, name.c_str());

function_param_types.push_back( fieldType);

clang::ParmVarDecl *param_var_decl =
Expand All @@ -3396,6 +3393,8 @@ size_t DWARFASTParserClang::ParseChildParameters(
if (!parent_die)
return 0;

bool skipRemainingParameters = false;

size_t arg_idx = 0;
for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid();
die = die.GetSibling()) {
Expand Down Expand Up @@ -3469,7 +3468,8 @@ size_t DWARFASTParserClang::ParseChildParameters(
}
}

bool skip = false;
bool skip = skipRemainingParameters;

if (skip_artificial) {
if (is_artificial) {
// In order to determine if a C++ member function is
Expand Down Expand Up @@ -3550,6 +3550,7 @@ size_t DWARFASTParserClang::ParseChildParameters(
function_param_types,
function_param_decls,
storage);
skipRemainingParameters = true;
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion source/Symbol/ClangASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8452,7 +8452,7 @@ clang::ObjCMethodDecl *ClangASTContext::AddMethodToObjCObjectType(
for (unsigned param_index = 0; param_index < num_args; ++param_index) {
/// @mulle-objc@ add this for parameter names >
identifier = nullptr;
if( function_param_decls.size() < param_index)
if( param_index < function_param_decls.size())
identifier = function_param_decls[ param_index]->getIdentifier();
/// @mulle-objc@ add this for parameter names <

Expand Down
2 changes: 1 addition & 1 deletion source/Symbol/ClangASTImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ clang::Decl *ClangASTImporter::Minion::Imported(clang::Decl *from,
from_named_decl->printName(name_stream);
name_stream.flush();

log->Printf(" [ClangASTImporter] Imported (%sDecl*)%p, named %s (from "
log->Printf(" [ClangASTImporter] Imported (%sDecl*)%p, named \"%s\" (from "
"(Decl*)%p), metadata 0x%" PRIx64,
from->getDeclKindName(), static_cast<void *>(to),
name_string.c_str(), static_cast<void *>(from), user_id);
Expand Down
10 changes: 10 additions & 0 deletions source/Target/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4873,6 +4873,16 @@ HandleStoppedEvent(Thread &thread, const ThreadPlanSP &thread_plan_sp,
return eExpressionInterrupted;
}

// @mulle-lldb@ avoid failed threadplan calling formatters that execute a threadplan again >
bool Process::isThreadPlanLocked( void)
{
if( ! m_run_thread_plan_lock.try_lock())
return( true);
m_run_thread_plan_lock.unlock();
return( false);
}
// @mulle-lldb@ avoid failed threadplan calling formatters that execute a threadplan again <

ExpressionResults
Process::RunThreadPlan(ExecutionContext &exe_ctx,
lldb::ThreadPlanSP &thread_plan_sp,
Expand Down

0 comments on commit a475fc6

Please sign in to comment.