diff options
author | Michaël Zasso <targos@protonmail.com> | 2019-08-01 08:38:30 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2019-08-01 12:53:56 +0200 |
commit | 2dcc3665abf57c3607cebffdeeca062f5894885d (patch) | |
tree | 4f560748132edcfb4c22d6f967a7e80d23d7ea2c /deps/v8/src/execution/simulator-base.cc | |
parent | 1ee47d550c6de132f06110aa13eceb7551d643b3 (diff) | |
download | android-node-v8-2dcc3665abf57c3607cebffdeeca062f5894885d.tar.gz android-node-v8-2dcc3665abf57c3607cebffdeeca062f5894885d.tar.bz2 android-node-v8-2dcc3665abf57c3607cebffdeeca062f5894885d.zip |
deps: update V8 to 7.6.303.28
PR-URL: https://github.com/nodejs/node/pull/28016
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann (רפאל פלחי) <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Diffstat (limited to 'deps/v8/src/execution/simulator-base.cc')
-rw-r--r-- | deps/v8/src/execution/simulator-base.cc | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/deps/v8/src/execution/simulator-base.cc b/deps/v8/src/execution/simulator-base.cc new file mode 100644 index 0000000000..b26c775917 --- /dev/null +++ b/deps/v8/src/execution/simulator-base.cc @@ -0,0 +1,102 @@ +// Copyright 2017 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. + +#include "src/execution/simulator-base.h" + +#include "src/execution/isolate.h" +#include "src/execution/simulator.h" + +#if defined(USE_SIMULATOR) + +namespace v8 { +namespace internal { + +// static +base::Mutex* SimulatorBase::redirection_mutex_ = nullptr; + +// static +Redirection* SimulatorBase::redirection_ = nullptr; + +// static +base::Mutex* SimulatorBase::i_cache_mutex_ = nullptr; + +// static +base::CustomMatcherHashMap* SimulatorBase::i_cache_ = nullptr; + +// static +void SimulatorBase::InitializeOncePerProcess() { + DCHECK_NULL(redirection_mutex_); + redirection_mutex_ = new base::Mutex(); + + DCHECK_NULL(i_cache_mutex_); + i_cache_mutex_ = new base::Mutex(); + + DCHECK_NULL(i_cache_); + i_cache_ = new base::CustomMatcherHashMap(&Simulator::ICacheMatch); +} + +// static +void SimulatorBase::GlobalTearDown() { + delete redirection_mutex_; + redirection_mutex_ = nullptr; + + Redirection::DeleteChain(redirection_); + redirection_ = nullptr; + + delete i_cache_mutex_; + i_cache_mutex_ = nullptr; + + if (i_cache_ != nullptr) { + for (base::HashMap::Entry* entry = i_cache_->Start(); entry != nullptr; + entry = i_cache_->Next(entry)) { + delete static_cast<CachePage*>(entry->value); + } + } + delete i_cache_; + i_cache_ = nullptr; +} + +// static +Address SimulatorBase::RedirectExternalReference(Address external_function, + ExternalReference::Type type) { + base::MutexGuard lock_guard(Simulator::redirection_mutex()); + Redirection* redirection = Redirection::Get(external_function, type); + return redirection->address_of_instruction(); +} + +Redirection::Redirection(Address external_function, + ExternalReference::Type type) + : external_function_(external_function), type_(type), next_(nullptr) { + next_ = Simulator::redirection(); + base::MutexGuard lock_guard(Simulator::i_cache_mutex()); + Simulator::SetRedirectInstruction( + reinterpret_cast<Instruction*>(address_of_instruction())); + Simulator::FlushICache(Simulator::i_cache(), + reinterpret_cast<void*>(&instruction_), + sizeof(instruction_)); + Simulator::set_redirection(this); +#if ABI_USES_FUNCTION_DESCRIPTORS + function_descriptor_[0] = reinterpret_cast<intptr_t>(&instruction_); + function_descriptor_[1] = 0; + function_descriptor_[2] = 0; +#endif +} + +// static +Redirection* Redirection::Get(Address external_function, + ExternalReference::Type type) { + Redirection* current = Simulator::redirection(); + for (; current != nullptr; current = current->next_) { + if (current->external_function_ == external_function && + current->type_ == type) { + return current; + } + } + return new Redirection(external_function, type); +} + +} // namespace internal +} // namespace v8 + +#endif // defined(USE_SIMULATOR) |