Commit a0d944ae authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[Refactoring] Remove {external_reference_redirector} from the isolate

In a recent CL (https://crrev.com/c/1012039) I removed the only valid
use case of {external_reference_redirector}. In this CL I remove the
remaining uses, which are more or less checks if there is a simulator
or not.


R=​mstarzinger@chromium.org

Change-Id: I96203b7b112d57bb3feb9d6863b036747b1963f0
Reviewed-on: https://chromium-review.googlesource.com/1014126
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52649}
parent 013cf15d
......@@ -194,14 +194,6 @@ ExternalReference::runtime_function_table_address_for_unittests(
return runtime_function_table_address(isolate);
}
void ExternalReference::set_redirector(
Isolate* isolate, ExternalReferenceRedirector* redirector) {
// We can't stack them.
DCHECK_NULL(isolate->external_reference_redirector());
isolate->set_external_reference_redirector(
reinterpret_cast<ExternalReferenceRedirectorPointer*>(redirector));
}
// static
Address ExternalReference::Redirect(Address address, Type type) {
#ifdef USE_SIMULATOR
......
......@@ -276,11 +276,6 @@ class ExternalReference BASE_EMBEDDED {
Address address() const { return address_; }
// This lets you register a function that rewrites all external references.
// Used by the ARM simulator to catch calls to external references.
static void set_redirector(Isolate* isolate,
ExternalReferenceRedirector* redirector);
private:
explicit ExternalReference(void* address)
: address_(reinterpret_cast<Address>(address)) {}
......
......@@ -3017,11 +3017,6 @@ bool Isolate::Init(StartupDeserializer* des) {
// Enable logging before setting up the heap
logger_->SetUp(this);
// Initialize other runtime facilities
#if defined(USE_SIMULATOR)
Simulator::Initialize(this);
#endif
{ // NOLINT
// Ensure that the thread has a valid stack guard. The v8::Locker object
// will ensure this too, but we don't have to use lockers if we are only
......
......@@ -105,11 +105,6 @@ class UnicodeCache;
template <StateTag Tag> class VMState;
// 'void function pointer', used to roundtrip the
// ExternalReference::ExternalReferenceRedirector since we can not include
// assembler.h, where it is defined, here.
typedef void* ExternalReferenceRedirectorPointer();
namespace interpreter {
class Interpreter;
}
......@@ -417,8 +412,6 @@ typedef std::vector<HeapObject*> DebugObjectCache;
V(ExtensionCallback, wasm_module_callback, &NoExtension) \
V(ExtensionCallback, wasm_instance_callback, &NoExtension) \
V(ApiImplementationCallback, wasm_compile_streaming_callback, nullptr) \
V(ExternalReferenceRedirectorPointer*, external_reference_redirector, \
nullptr) \
/* State for Relocatable. */ \
V(Relocatable*, relocatable_top, nullptr) \
V(DebugObjectCache*, string_stream_debug_object_cache, nullptr) \
......
......@@ -159,31 +159,29 @@ const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
return &(kIntrinsicFunctions[static_cast<int>(id)]);
}
const Runtime::Function* Runtime::RuntimeFunctionTable(Isolate* isolate) {
if (isolate->external_reference_redirector()) {
// When running with the simulator we need to provide a table which has
// redirected runtime entry addresses.
if (!isolate->runtime_state()->redirected_intrinsic_functions()) {
size_t function_count = arraysize(kIntrinsicFunctions);
Function* redirected_functions = new Function[function_count];
memcpy(redirected_functions, kIntrinsicFunctions,
sizeof(kIntrinsicFunctions));
for (size_t i = 0; i < function_count; i++) {
ExternalReference redirected_entry(static_cast<Runtime::FunctionId>(i),
isolate);
redirected_functions[i].entry = redirected_entry.address();
}
isolate->runtime_state()->set_redirected_intrinsic_functions(
redirected_functions);
#ifdef USE_SIMULATOR
// When running with the simulator we need to provide a table which has
// redirected runtime entry addresses.
if (!isolate->runtime_state()->redirected_intrinsic_functions()) {
size_t function_count = arraysize(kIntrinsicFunctions);
Function* redirected_functions = new Function[function_count];
memcpy(redirected_functions, kIntrinsicFunctions,
sizeof(kIntrinsicFunctions));
for (size_t i = 0; i < function_count; i++) {
ExternalReference redirected_entry(static_cast<Runtime::FunctionId>(i),
isolate);
redirected_functions[i].entry = redirected_entry.address();
}
return isolate->runtime_state()->redirected_intrinsic_functions();
} else {
return kIntrinsicFunctions;
isolate->runtime_state()->set_redirected_intrinsic_functions(
redirected_functions);
}
}
return isolate->runtime_state()->redirected_intrinsic_functions();
#else
return kIntrinsicFunctions;
#endif
}
std::ostream& operator<<(std::ostream& os, Runtime::FunctionId id) {
return os << Runtime::FunctionForId(id)->name;
......
......@@ -58,11 +58,6 @@ void SimulatorBase::GlobalTearDown() {
i_cache_ = nullptr;
}
// static
void SimulatorBase::Initialize(Isolate* isolate) {
ExternalReference::set_redirector(isolate, &RedirectExternalReference);
}
// static
Address SimulatorBase::RedirectExternalReference(Address external_function,
ExternalReference::Type type) {
......
......@@ -25,9 +25,6 @@ class SimulatorBase {
static void InitializeOncePerProcess();
static void GlobalTearDown();
// Call on isolate initialization.
static void Initialize(Isolate* isolate);
static base::Mutex* redirection_mutex() { return redirection_mutex_; }
static Redirection* redirection() { return redirection_; }
static void set_redirection(Redirection* r) { redirection_ = r; }
......
......@@ -169,6 +169,7 @@ HeapObject* Deserializer<AllocatorT>::PostProcessNewObject(HeapObject* obj,
DCHECK(CanBeDeferred(obj));
}
}
if (obj->IsAllocationSite()) {
// Allocation sites are present in the snapshot, and must be linked into
// a list at deserialization time.
......@@ -190,13 +191,13 @@ HeapObject* Deserializer<AllocatorT>::PostProcessNewObject(HeapObject* obj,
new_code_objects_.push_back(Code::cast(obj));
}
} else if (obj->IsAccessorInfo()) {
if (isolate_->external_reference_redirector()) {
accessor_infos_.push_back(AccessorInfo::cast(obj));
}
#ifdef USE_SIMULATOR
accessor_infos_.push_back(AccessorInfo::cast(obj));
#endif
} else if (obj->IsCallHandlerInfo()) {
if (isolate_->external_reference_redirector()) {
call_handler_infos_.push_back(CallHandlerInfo::cast(obj));
}
#ifdef USE_SIMULATOR
call_handler_infos_.push_back(CallHandlerInfo::cast(obj));
#endif
} else if (obj->IsExternalString()) {
if (obj->map() == isolate_->heap()->native_source_string_map()) {
ExternalOneByteString* string = ExternalOneByteString::cast(obj);
......
......@@ -46,15 +46,18 @@ void StartupSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
if (SerializeBackReference(obj, how_to_code, where_to_point, skip)) return;
FlushSkip(skip);
bool use_simulator = false;
#ifdef USE_SIMULATOR
use_simulator = true;
#endif
if (isolate()->external_reference_redirector() && obj->IsAccessorInfo()) {
if (use_simulator && obj->IsAccessorInfo()) {
// Wipe external reference redirects in the accessor info.
AccessorInfo* info = AccessorInfo::cast(obj);
Address original_address = Foreign::cast(info->getter())->foreign_address();
Foreign::cast(info->js_getter())->set_foreign_address(original_address);
accessor_infos_.push_back(info);
} else if (isolate()->external_reference_redirector() &&
obj->IsCallHandlerInfo()) {
} else if (use_simulator && obj->IsCallHandlerInfo()) {
CallHandlerInfo* info = CallHandlerInfo::cast(obj);
Address original_address =
Foreign::cast(info->callback())->foreign_address();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment