node-v8.11.3:Failed to flush the instruction cache

参考 https://android.googlesource.com/platform/bionic/+/1e980b6/libc/arch-mips/bionic/cacheflush.c
改用 gcc 的 __builtin___clear_cache 代替了。
不过这东西没返回值,是不是真的能有作用就不知道了。
 
----------
 
修改源代码,输出了 errno 看了一下,居然是 1 ??errno 的 1 是没有 root 权限吧?这个 cacheflush 不是 userland 吗?
 
----------------------
 
刷新缓存失败?这是什么原因?用 syscall 直接调用系统的 __NR_cacheflush 。但是返回消息显示失败了。之前 nodejs 似乎编译没问题,这里是新添加的内容?
  g++ -pthread -rdynamic -EL -mhard-float -mips64r2 -mabi=64 -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -o /builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot -Wl,--start-group /builddir/build/BUILD/node-v8.11.3/out/Debug/obj.target/mksnapshot/deps/v8/src/snapshot/mksnapshot.o /builddir/build/BUILD/node-v8.11.3/out/Debug/obj.target/deps/v8/src/libv8_base.a /builddir/build/BUILD/node-v8.11.3/out/Debug/obj.target/deps/v8/src/libv8_builtins_setup.a /builddir/build/BUILD/node-v8.11.3/out/Debug/obj.target/deps/v8/src/libv8_libbase.a /builddir/build/BUILD/node-v8.11.3/out/Debug/obj.target/deps/v8/src/libv8_libplatform.a /builddir/build/BUILD/node-v8.11.3/out/Debug/obj.target/deps/v8/src/libv8_nosnapshot.a /builddir/build/BUILD/node-v8.11.3/out/Debug/obj.target/tools/icu/libicui18n.a /builddir/build/BUILD/node-v8.11.3/out/Debug/obj.target/deps/v8/src/libv8_libsampler.a /builddir/build/BUILD/node-v8.11.3/out/Debug/obj.target/tools/icu/libicuucx.a /builddir/build/BUILD/node-v8.11.3/out/Debug/obj.target/tools/icu/libicudata.a /builddir/build/BUILD/node-v8.11.3/out/Debug/obj.target/tools/icu/libicustubdata.a /builddir/build/BUILD/node-v8.11.3/out/Debug/obj.target/deps/v8/src/libv8_builtins_generators.a -lz -lhttp_parser -luv -lnghttp2 -lcrypto -lssl -ldl -lrt -Wl,--end-group
LD_LIBRARY_PATH=/builddir/build/BUILD/node-v8.11.3/out/Debug/lib.host:/builddir/build/BUILD/node-v8.11.3/out/Debug/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../deps/v8/src; mkdir -p /builddir/build/BUILD/node-v8.11.3/out/Debug/obj.target/v8_snapshot/geni; "/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot" --nodebug_code --startup_src "/builddir/build/BUILD/node-v8.11.3/out/Debug/obj.target/v8_snapshot/geni/snapshot.cc" ""


#
# Fatal error in ../deps/v8/src/mips64/cpu-mips64.cc, line 42
# Failed to flush the instruction cache
#

==== C stack trace ===============================

/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(v8::base::debug::StackTrace::StackTrace()+0x2c) [0xaaac0ff184]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(+0x12cbb30) [0xaaabe2bb30]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(V8_Fatal(char const*, int, char const*, ...)+0xd0) [0xaaabe23c08]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(v8::internal::Deoptimizer::TableEntryGenerator::GeneratePrologue()+0) [0xaaab894fd0]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(v8::internal::AssemblerBase::FlushICache(v8::internal::Isolate*, void*, unsigned long)+0x34) [0xaaab1c17b4]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(v8::internal::Code::CopyFrom(v8::internal::CodeDesc const&)+0x4e0) [0xaaab5ae6c8]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(v8::internal::Factory::NewCode(v8::internal::CodeDesc const&, unsigned int, v8::internal::Handle<v8::internal::Object>, bool, int)+0x554) [0xaaab3d2ddc]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(v8::internal::PlatformCodeStub::GenerateCode()+0x140) [0xaaab201808]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(v8::internal::CodeStub::GetCode()+0x188) [0xaaab203ba0]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(v8::internal::MacroAssembler::CallStub(v8::internal::CodeStub*, v8::internal::Condition, v8::internal::Register, v8::internal::Operand const&, v8::internal::BranchDelaySlot)+0x70) [0xaaab8b92c8]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(v8::internal::MacroAssembler::CallRuntime(v8::internal::Runtime::Function const*, int, v8::internal::SaveFPRegsMode, v8::internal::BranchDelaySlot)+0x154) [0xaaab8bb30c]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(+0x149a6e4) [0xaaabffa6e4]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(v8::internal::SetupIsolateDelegate::PopulateWithPlaceholders(v8::internal::Isolate*)+0x70) [0xaaabffa8e8]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(v8::internal::SetupIsolateDelegate::SetupBuiltinsInternal(v8::internal::Isolate*)+0x68) [0xaaabffc770]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(v8::internal::SetupIsolateDelegate::SetupBuiltins(v8::internal::Isolate*, bool)+0x64) [0xaaabe1d7cc]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(v8::internal::Isolate::Init(v8::internal::StartupDeserializer*)+0x17bc) [0xaaab51f1f4]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(v8::SnapshotCreator::SnapshotCreator(long const*, v8::StartupData*)+0x150) [0xaaab146570]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(v8::V8::CreateSnapshotDataBlob(char const*)+0x78) [0xaaab1b25a8]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(main+0x438) [0xaaab143860]
/lib64/libc.so.6(__libc_start_main+0xfc) [0xfff41592dc]
/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot(+0x5e3bc0) [0xaaab143bc0]
/bin/sh: line 1: 8364 Trace/breakpoint trap (core dumped) "/builddir/build/BUILD/node-v8.11.3/out/Debug/mksnapshot" --nodebug_code --startup_src "/builddir/build/BUILD/node-v8.11.3/out/Debug/obj.target/v8_snapshot/geni/snapshot.cc" ""
make[1]: *** [deps/v8/src/v8_snapshot.target.mk:13: /builddir/build/BUILD/node-v8.11.3/out/Debug/obj.target/v8_snapshot/geni/snapshot.cc] Error 133
make: *** [Makefile:92: node_g] Error 2






 
我看了眼这个文件,内容不多:
// Copyright 2012 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// CPU specific code for arm independent of OS goes here.

#include <sys/syscall.h>
#include <unistd.h>

#ifdef __mips
#include <asm/cachectl.h>
#endif // #ifdef __mips

#if V8_TARGET_ARCH_MIPS64

#include "src/assembler.h"
#include "src/macro-assembler.h"

#include "src/simulator.h" // For cache flushing.

namespace v8 {
namespace internal {


void CpuFeatures::FlushICache(void* start, size_t size) {
#if !defined(USE_SIMULATOR)
// Nothing to do, flushing no instructions.
if (size == 0) {
return;
}

#if defined(ANDROID) && !defined(__LP64__)
// Bionic cacheflush can typically run in userland, avoiding kernel call.
char *end = reinterpret_cast<char *>(start) + size;
cacheflush(
reinterpret_cast<intptr_t>(start), reinterpret_cast<intptr_t>(end), 0);
#else // ANDROID
long res; // NOLINT(runtime/int)
// See http://www.linux-mips.org/wiki/Cacheflush_Syscall.
res = syscall(__NR_cacheflush, start, size, ICACHE);
if (res) {
V8_Fatal(__FILE__, __LINE__, "Failed to flush the instruction cache");
}
#endif // ANDROID
#endif // !USE_SIMULATOR.
}

} // namespace internal
} // namespace v8

#endif // V8_TARGET_ARCH_MIPS64



已邀请:

flygoatfree

赞同来自:

没记错的话。。这个syscall是假的。。。不如插一句asm。。sync来的爽快。

要回复问题请先登录注册