/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ // Copyright 2012 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# include "jit/arm/Architecture-arm.h" # include "jit/arm/disasm/Disasm-arm.h" # include "jit/IonTypes.h" # include "js/AllocPolicy.h" # include "js/ProfilingFrameIterator.h" # include "threading/Thread.h" # include "vm/MutexIDs.h" # include "wasm/WasmSignalHandlers.h"
namespace js { namespace jit {
class JitActivation; class Simulator; class Redirection; class CachePage; class AutoLockSimulator;
// When the SingleStepCallback is called, the simulator is about to execute // sim->get_pc() and the current machine state represents the completed // execution of the previous pc. using SingleStepCallback = void (*)(void* arg, Simulator* sim, void* pc);
// VFP rounding modes. See ARM DDI 0406B Page A2-29. enum VFPRoundingMode {
SimRN = 0 << 22, // Round to Nearest.
SimRP = 1 << 22, // Round towards Plus Infinity.
SimRM = 2 << 22, // Round towards Minus Infinity.
SimRZ = 3 << 22, // Round towards zero.
// Disassemble some instructions starting at instr and print them // on stdout. Useful for working within GDB after a MOZ_CRASH(), // among other things. // // Typical use within a crashed instruction decoding method is simply: // // call Simulator::disassemble(instr, 1) // // or use one of the more convenient inline methods below. staticvoid disassemble(SimInstruction* instr, size_t n);
// Disassemble one instruction. // "call disasm(instr)" void disasm(SimInstruction* instr);
// Disassemble n instructions starting at instr. // "call disasm(instr, 3)" void disasm(SimInstruction* instr, size_t n);
// Skip backwards m instructions before starting, then disassemble n // instructions. // "call disasm(instr, 3, 7)" void disasm(SimInstruction* instr, size_t m, size_t n);
uintptr_t* addressOfStackLimit();
// Accessors for register state. Reading the pc value adheres to the ARM // architecture specification and is off by a 8 from the currently executing // instruction. void set_register(int reg, int32_t value);
int32_t get_register(int reg) const; double get_double_from_register_pair(int reg); void set_register_pair_from_double(int reg, double* value); void set_dw_register(int dreg, constint* dbl);
// Returns true if pc register contains one of the 'special_values' defined // below (bad_lr, end_sim_pc). bool has_bad_pc() const;
private: enum special_values { // Known bad pc value to ensure that the simulator does not execute // without being properly setup.
bad_lr = -1, // A pc value used to signal the simulator to stop execution. Generally // the lr is set to this value on transition from native C code to // simulated execution, so that the simulator can "return" to the native // C code.
end_sim_pc = -2
};
// ForbidUnaligned means "always fault on unaligned access". // // AllowUnaligned means "allow the unaligned access if other conditions are // met". The "other conditions" vary with the instruction: For all // instructions the base condition is !ARMFlags::HasAlignmentFault(), ie, the // chip is configured to allow unaligned accesses. For instructions like VLD1 // there is an additional constraint that the alignment attribute in the // instruction must be set to "default alignment".
// Handle a wasm interrupt triggered by an async signal handler.
JS::ProfilingFrameIterator::RegisterState registerState();
// Handle any wasm faults, returning true if the fault was handled. // This method is rather hot so inline the normal (no-wasm) case. bool MOZ_ALWAYS_INLINE handleWasmSegFault(int32_t addr, unsigned numBytes) { if (MOZ_LIKELY(!wasm::CodeExists)) { returnfalse;
}
uint8_t* newPC; if (!wasm::MemoryAccessTraps(registerState(), (uint8_t*)addr, numBytes,
&newPC)) { returnfalse;
}
// Executing is handled based on the instruction type. // Both type 0 and type 1 rolled into one. void decodeType01(SimInstruction* instr); void decodeType2(SimInstruction* instr); void decodeType3(SimInstruction* instr); void decodeType4(SimInstruction* instr); void decodeType5(SimInstruction* instr); void decodeType6(SimInstruction* instr); void decodeType7(SimInstruction* instr);
// Support for VFP. void decodeTypeVFP(SimInstruction* instr); void decodeType6CoprocessorIns(SimInstruction* instr); void decodeSpecialCondition(SimInstruction* instr);
// Support for some system functions. void decodeType7CoprocessorIns(SimInstruction* instr);
// Executes one instruction. void instructionDecode(SimInstruction* instr);
public: static int64_t StopSimAt;
// For testing the MoveResolver code, a MoveResolver is set up, and // the VFP registers are loaded with pre-determined values, // then the sequence of code is simulated. In order to test this with the // simulator, the callee-saved registers can't be trashed. This flag // disables that feature. bool skipCalleeSavedRegsCheck;
// Architecture state. // Saturating instructions require a Q flag to indicate saturation. // There is currently no way to read the CPSR directly, and thus read the Q // flag, so this is left unimplemented.
int32_t registers_[16]; bool n_flag_; bool z_flag_; bool c_flag_; bool v_flag_;
// Single-stepping support bool single_stepping_;
SingleStepCallback single_step_callback_; void* single_step_callback_arg_;
// A stop is watched if its code is less than kNumOfWatchedStops. // Only watched stops support enabling/disabling and the counter feature. staticconst uint32_t kNumOfWatchedStops = 256;
// Breakpoint is disabled if bit 31 is set. staticconst uint32_t kStopDisabledBit = 1 << 31;
// A stop is enabled, meaning the simulator will stop when meeting the // instruction, if bit 31 of watched_stops_[code].count is unset. // The value watched_stops_[code].count & ~(1 << 31) indicates how many times // the breakpoint was hit or gone through. struct StopCountAndDesc {
uint32_t count; char* desc;
};
StopCountAndDesc watched_stops_[kNumOfWatchedStops];
// This lock creates a critical section around 'redirection_' and // 'icache_', which are referenced both by the execution engine // and by the off-thread compiler (see Redirection::Get in the cpp file).
Mutex cacheLock_ MOZ_UNANNOTATED;
Redirection* redirection_;
ICacheMap icache_;
public: static ICacheMap& icache() { // Technically we need the lock to access the innards of the // icache, not to take its address, but the latter condition // serves as a useful complement to the former.
singleton_->cacheLock_.assertOwnedByCurrentThread(); return singleton_->icache_;
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.12Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.