Skip to content

Commit

Permalink
feat:临时提交,优化代码结构
Browse files Browse the repository at this point in the history
  • Loading branch information
Knight-ZXW committed May 11, 2024
1 parent be994ae commit 9eb3929
Show file tree
Hide file tree
Showing 24 changed files with 651 additions and 476 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ class MainFragment : Fragment() {
binding.btnTestGetThreadCpuTime.setOnClickListener {

val nativePeer = ArtThread.getNativePeer(Looper.getMainLooper().thread)
val frames = Sliver.nativeGetMethodStackTrace(nativePeer);
val prettyMethods = Sliver.prettyMethods(frames)
Log.e("zxw","methods is "+prettyMethods)


val mainThreadCpuMicroTime = ArtThread.getCpuMicroTime(nativePeer)
Log.d("zxw","主线程CpuMicroTime "+mainThreadCpuMicroTime)

val frames = Sliver.nativeGetMethodStackTrace(nativePeer);
val prettyMethods = Sliver.prettyMethods(frames)
Log.e("zxw","methods is "+prettyMethods)


}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.knightboost.appoptimizeframework
import android.annotation.SuppressLint
import android.app.Application
import android.content.Context
import android.os.Build
import android.util.Log
import com.bytedance.shadowhook.ShadowHook
import com.knightboost.appoptimizeframework.tests.retrofit.BilibiliService
Expand Down
6 changes: 2 additions & 4 deletions kbArt/src/main/cpp/android_14_debuggable_bug_fixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <chrono>

#include "cstddef"
#include "art.h"
#include "art_runtime.h"
#include "class_linker.h"
#include "object.h"
#include "class.h"
Expand All @@ -28,7 +28,7 @@ void fix(){
if (api_level == 34){
auto start = std::chrono::steady_clock::now();
FixClassVisitor visitor;
void *class_linker = reinterpret_cast<PartialRuntimeTiramisu *>(ArtHelper::partialRuntime)->class_linker_;
void *class_linker =ArtRuntime::Get()->GetClassLinker();
VisitClasses(class_linker,&visitor);
auto end = std::chrono::steady_clock::now();
LOGI("Android14BugFixer","clear memory shared methods cost %lld us",
Expand All @@ -38,7 +38,5 @@ void fix(){
extern "C"
JNIEXPORT void JNICALL
Java_com_knightboost_artvm_Android14DebuggableBugFixer_fix(JNIEnv *env, jclass clazz) {
ArtHelper::init(env);

fix();
}
190 changes: 0 additions & 190 deletions kbArt/src/main/cpp/art/art.cpp

This file was deleted.

15 changes: 8 additions & 7 deletions kbArt/src/main/cpp/art/art_method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Created by Administrator on 2024/4/24.
//
#include "art_method.h"
#include "cxx_helper.h"
uint32_t ArtMethod::GetAccessFlags() const {
return access_flags_.load(std::memory_order_relaxed);
return 0;
return MemberOf<uint32_t>(art_method_ptr_, offset_->access_flags_offset_);
}
bool ArtMethod::IsMemorySharedMethod() {
return IsMemorySharedMethod(GetAccessFlags());
Expand Down Expand Up @@ -39,8 +39,9 @@ std::string ArtMethod::PrettyMethod(bool withSignature) {
return _PrettyMethod(this, withSignature);

}
constexpr size_t ArtMethod::PtrSizedFieldsOffset(PointerSize pointer_size) {
// Round up to pointer size for padding field. Tested in art_method.cc.
return RoundUp(offsetof(ArtMethod, hotness_count_) + sizeof(hotness_count_),
static_cast<size_t>(pointer_size));
}
//constexpr size_t ArtMethod::PtrSizedFieldsOffset(PointerSize pointer_size) {
// // Round up to pointer size for padding field. Tested in art_method.cc.
// return RoundUp(offsetof(ArtMethod, hotness_count_) + sizeof(hotness_count_),
// static_cast<size_t>(pointer_size));
//}

Loading

0 comments on commit 9eb3929

Please sign in to comment.