diff options
author | Myles Borins <mylesborins@google.com> | 2018-04-10 21:39:51 -0400 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2018-04-16 16:02:46 -0700 |
commit | 9daebb48d6f0ca63e72197a69e46c8ab43bc5d02 (patch) | |
tree | 8605276308c8b4e3597516961266bae1af57557a /deps/v8/src/mips | |
parent | 7d2814e7903155e61f244ae70721da1531cbcaec (diff) | |
download | node-new-9daebb48d6f0ca63e72197a69e46c8ab43bc5d02.tar.gz |
deps: update V8 to 6.6.346.23
PR-URL: https://github.com/nodejs/node/pull/19201
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/v8/src/mips')
-rw-r--r-- | deps/v8/src/mips/OWNERS | 1 | ||||
-rw-r--r-- | deps/v8/src/mips/assembler-mips-inl.h | 22 | ||||
-rw-r--r-- | deps/v8/src/mips/assembler-mips.cc | 42 | ||||
-rw-r--r-- | deps/v8/src/mips/assembler-mips.h | 24 | ||||
-rw-r--r-- | deps/v8/src/mips/codegen-mips.cc | 8 | ||||
-rw-r--r-- | deps/v8/src/mips/constants-mips.h | 6 | ||||
-rw-r--r-- | deps/v8/src/mips/cpu-mips.cc | 4 | ||||
-rw-r--r-- | deps/v8/src/mips/disasm-mips.cc | 1 | ||||
-rw-r--r-- | deps/v8/src/mips/frame-constants-mips.h | 6 | ||||
-rw-r--r-- | deps/v8/src/mips/interface-descriptors-mips.cc | 6 | ||||
-rw-r--r-- | deps/v8/src/mips/macro-assembler-mips.cc | 150 | ||||
-rw-r--r-- | deps/v8/src/mips/macro-assembler-mips.h | 24 | ||||
-rw-r--r-- | deps/v8/src/mips/simulator-mips.cc | 16 | ||||
-rw-r--r-- | deps/v8/src/mips/simulator-mips.h | 17 |
14 files changed, 210 insertions, 117 deletions
diff --git a/deps/v8/src/mips/OWNERS b/deps/v8/src/mips/OWNERS index 978563cab5..4ce9d7f91d 100644 --- a/deps/v8/src/mips/OWNERS +++ b/deps/v8/src/mips/OWNERS @@ -1,2 +1,3 @@ ivica.bogosavljevic@mips.com Miran.Karic@mips.com +sreten.kovacevic@mips.com
\ No newline at end of file diff --git a/deps/v8/src/mips/assembler-mips-inl.h b/deps/v8/src/mips/assembler-mips-inl.h index 803c16b829..a5e2335852 100644 --- a/deps/v8/src/mips/assembler-mips-inl.h +++ b/deps/v8/src/mips/assembler-mips-inl.h @@ -46,8 +46,7 @@ namespace v8 { namespace internal { - -bool CpuFeatures::SupportsCrankshaft() { return IsSupported(FPU); } +bool CpuFeatures::SupportsOptimizer() { return IsSupported(FPU); } bool CpuFeatures::SupportsWasmSimd128() { return IsSupported(MIPS_SIMD); } @@ -126,16 +125,14 @@ Address Assembler::target_address_from_return_address(Address pc) { } void Assembler::deserialization_set_special_target_at( - Isolate* isolate, Address instruction_payload, Code* code, Address target) { + Address instruction_payload, Code* code, Address target) { if (IsMipsArchVariant(kMips32r6)) { // On R6 the address location is shifted by one instruction set_target_address_at( - isolate, instruction_payload - (kInstructionsFor32BitConstant - 1) * kInstrSize, code ? code->constant_pool() : nullptr, target); } else { set_target_address_at( - isolate, instruction_payload - kInstructionsFor32BitConstant * kInstrSize, code ? code->constant_pool() : nullptr, target); } @@ -172,9 +169,8 @@ void Assembler::set_target_internal_reference_encoded_at(Address pc, // after complete deserialization, no need to flush on each reference. } - void Assembler::deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, RelocInfo::Mode mode) { + Address pc, Address target, RelocInfo::Mode mode) { if (mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { DCHECK(IsLui(instr_at(pc))); set_target_internal_reference_encoded_at(pc, target); @@ -200,7 +196,7 @@ void RelocInfo::set_target_object(HeapObject* target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); - Assembler::set_target_address_at(target->GetIsolate(), pc_, constant_pool_, + Assembler::set_target_address_at(pc_, constant_pool_, reinterpret_cast<Address>(target), icache_flush_mode); if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != nullptr) { @@ -250,15 +246,15 @@ Address RelocInfo::target_runtime_entry(Assembler* origin) { return target_address(); } -void RelocInfo::set_target_runtime_entry(Isolate* isolate, Address target, +void RelocInfo::set_target_runtime_entry(Address target, WriteBarrierMode write_barrier_mode, ICacheFlushMode icache_flush_mode) { DCHECK(IsRuntimeEntry(rmode_)); if (target_address() != target) - set_target_address(isolate, target, write_barrier_mode, icache_flush_mode); + set_target_address(target, write_barrier_mode, icache_flush_mode); } -void RelocInfo::WipeOut(Isolate* isolate) { +void RelocInfo::WipeOut() { DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)); @@ -267,12 +263,12 @@ void RelocInfo::WipeOut(Isolate* isolate) { } else if (IsInternalReferenceEncoded(rmode_)) { Assembler::set_target_internal_reference_encoded_at(pc_, nullptr); } else { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, nullptr); + Assembler::set_target_address_at(pc_, constant_pool_, nullptr); } } template <typename ObjectVisitor> -void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) { +void RelocInfo::Visit(ObjectVisitor* visitor) { RelocInfo::Mode mode = rmode(); if (mode == RelocInfo::EMBEDDED_OBJECT) { visitor->VisitEmbeddedPointer(host(), this); diff --git a/deps/v8/src/mips/assembler-mips.cc b/deps/v8/src/mips/assembler-mips.cc index bd540346c0..a39c06eaa2 100644 --- a/deps/v8/src/mips/assembler-mips.cc +++ b/deps/v8/src/mips/assembler-mips.cc @@ -79,6 +79,9 @@ void CpuFeatures::ProbeImpl(bool cross_compile) { #if defined(_MIPS_ARCH_MIPS32R6) // FP64 mode is implied on r6. supported_ |= 1u << FP64FPU; +#if defined(_MIPS_MSA) + supported_ |= 1u << MIPS_SIMD; +#endif #endif #if defined(FPU_MODE_FP64) supported_ |= 1u << FP64FPU; @@ -91,8 +94,14 @@ void CpuFeatures::ProbeImpl(bool cross_compile) { if (cpu.is_fp64_mode()) supported_ |= 1u << FP64FPU; #elif defined(FPU_MODE_FP64) supported_ |= 1u << FP64FPU; +#if defined(_MIPS_ARCH_MIPS32R6) +#if defined(_MIPS_MSA) + supported_ |= 1u << MIPS_SIMD; +#else if (cpu.has_msa()) supported_ |= 1u << MIPS_SIMD; #endif +#endif +#endif #if defined(_MIPS_ARCH_MIPS32RX) if (cpu.architecture() == 6) { supported_ |= 1u << MIPSr6; @@ -200,22 +209,20 @@ uint32_t RelocInfo::embedded_size() const { Assembler::target_address_at(pc_, constant_pool_)); } -void RelocInfo::set_embedded_address(Isolate* isolate, Address address, +void RelocInfo::set_embedded_address(Address address, ICacheFlushMode flush_mode) { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, address, - flush_mode); + Assembler::set_target_address_at(pc_, constant_pool_, address, flush_mode); } -void RelocInfo::set_embedded_size(Isolate* isolate, uint32_t size, - ICacheFlushMode flush_mode) { - Assembler::set_target_address_at(isolate, pc_, constant_pool_, +void RelocInfo::set_embedded_size(uint32_t size, ICacheFlushMode flush_mode) { + Assembler::set_target_address_at(pc_, constant_pool_, reinterpret_cast<Address>(size), flush_mode); } -void RelocInfo::set_js_to_wasm_address(Isolate* isolate, Address address, +void RelocInfo::set_js_to_wasm_address(Address address, ICacheFlushMode icache_flush_mode) { DCHECK_EQ(rmode_, JS_TO_WASM_CALL); - set_embedded_address(isolate, address, icache_flush_mode); + set_embedded_address(address, icache_flush_mode); } Address RelocInfo::js_to_wasm_address() const { @@ -272,8 +279,7 @@ void Assembler::AllocateAndInstallRequestedHeapObjects(Isolate* isolate) { break; } Address pc = buffer_ + request.offset(); - set_target_value_at(isolate, pc, - reinterpret_cast<uint32_t>(object.location())); + set_target_value_at(pc, reinterpret_cast<uint32_t>(object.location())); } } @@ -2492,15 +2498,6 @@ void Assembler::cfc1(Register rt, FPUControlRegister fs) { } -void Assembler::DoubleAsTwoUInt32(double d, uint32_t* lo, uint32_t* hi) { - uint64_t i; - memcpy(&i, &d, 8); - - *lo = i & 0xFFFFFFFF; - *hi = i >> 32; -} - - void Assembler::movn_s(FPURegister fd, FPURegister fs, Register rt) { DCHECK(!IsMipsArchVariant(kMips32r6)); GenInstrRegister(COP1, S, rt, fs, fd, MOVN_C); @@ -3889,11 +3886,8 @@ void Assembler::QuietNaN(HeapObject* object) { // There is an optimization below, which emits a nop when the address // fits in just 16 bits. This is unlikely to help, and should be benchmarked, // and possibly removed. -void Assembler::set_target_value_at(Isolate* isolate, Address pc, - uint32_t target, +void Assembler::set_target_value_at(Address pc, uint32_t target, ICacheFlushMode icache_flush_mode) { - DCHECK_IMPLIES(isolate == nullptr, icache_flush_mode == SKIP_ICACHE_FLUSH); - Instr instr2 = instr_at(pc + kInstrSize); uint32_t rt_code = GetRtField(instr2); uint32_t* p = reinterpret_cast<uint32_t*>(pc); @@ -3924,7 +3918,7 @@ void Assembler::set_target_value_at(Isolate* isolate, Address pc, } if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - Assembler::FlushICache(isolate, pc, 2 * sizeof(int32_t)); + Assembler::FlushICache(pc, 2 * sizeof(int32_t)); } } diff --git a/deps/v8/src/mips/assembler-mips.h b/deps/v8/src/mips/assembler-mips.h index 4c68e730b3..a5d608898f 100644 --- a/deps/v8/src/mips/assembler-mips.h +++ b/deps/v8/src/mips/assembler-mips.h @@ -388,7 +388,7 @@ class Operand BASE_EMBEDDED { public: // Immediate. INLINE(explicit Operand(int32_t immediate, - RelocInfo::Mode rmode = RelocInfo::NONE32)) + RelocInfo::Mode rmode = RelocInfo::NONE)) : rm_(no_reg), rmode_(rmode) { value_.immediate = immediate; } @@ -400,8 +400,7 @@ class Operand BASE_EMBEDDED { INLINE(explicit Operand(Object** opp)); INLINE(explicit Operand(Context** cpp)); explicit Operand(Handle<HeapObject> handle); - INLINE(explicit Operand(Smi* value)) - : rm_(no_reg), rmode_(RelocInfo::NONE32) { + INLINE(explicit Operand(Smi* value)) : rm_(no_reg), rmode_(RelocInfo::NONE) { value_.immediate = reinterpret_cast<intptr_t>(value); } @@ -568,9 +567,9 @@ class Assembler : public AssemblerBase { // The isolate argument is unused (and may be nullptr) when skipping flushing. static Address target_address_at(Address pc); INLINE(static void set_target_address_at) - (Isolate* isolate, Address pc, Address target, + (Address pc, Address target, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED) { - set_target_value_at(isolate, pc, reinterpret_cast<uint32_t>(target), + set_target_value_at(pc, reinterpret_cast<uint32_t>(target), icache_flush_mode); } // On MIPS there is no Constant Pool so we skip that parameter. @@ -578,13 +577,13 @@ class Assembler : public AssemblerBase { return target_address_at(pc); } INLINE(static void set_target_address_at( - Isolate* isolate, Address pc, Address constant_pool, Address target, + Address pc, Address constant_pool, Address target, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED)) { - set_target_address_at(isolate, pc, target, icache_flush_mode); + set_target_address_at(pc, target, icache_flush_mode); } static void set_target_value_at( - Isolate* isolate, Address pc, uint32_t target, + Address pc, uint32_t target, ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); // Return the code target address at a call site from the return address @@ -597,12 +596,11 @@ class Assembler : public AssemblerBase { // This is for calls and branches within generated code. The serializer // has already deserialized the lui/ori instructions etc. inline static void deserialization_set_special_target_at( - Isolate* isolate, Address instruction_payload, Code* code, - Address target); + Address instruction_payload, Code* code, Address target); // This sets the internal reference at the pc. inline static void deserialization_set_target_internal_reference_at( - Isolate* isolate, Address pc, Address target, + Address pc, Address target, RelocInfo::Mode mode = RelocInfo::INTERNAL_REFERENCE); // Size of an instruction. @@ -1893,8 +1891,6 @@ class Assembler : public AssemblerBase { return internal_trampoline_exception_; } - void DoubleAsTwoUInt32(double d, uint32_t* lo, uint32_t* hi); - bool is_trampoline_emitted() const { return trampoline_emitted_; } @@ -2235,4 +2231,4 @@ class UseScratchRegisterScope { } // namespace internal } // namespace v8 -#endif // V8_ARM_ASSEMBLER_MIPS_H_ +#endif // V8_MIPS_ASSEMBLER_MIPS_H_ diff --git a/deps/v8/src/mips/codegen-mips.cc b/deps/v8/src/mips/codegen-mips.cc index c07422ff5f..b2e52745ed 100644 --- a/deps/v8/src/mips/codegen-mips.cc +++ b/deps/v8/src/mips/codegen-mips.cc @@ -541,9 +541,9 @@ MemCopyUint8Function CreateMemCopyUint8Function(Isolate* isolate, } CodeDesc desc; masm.GetCode(isolate, &desc); - DCHECK(!RelocInfo::RequiresRelocation(isolate, desc)); + DCHECK(!RelocInfo::RequiresRelocation(desc)); - Assembler::FlushICache(isolate, buffer, allocated); + Assembler::FlushICache(buffer, allocated); CHECK(SetPermissions(buffer, allocated, PageAllocator::kReadExecute)); return FUNCTION_CAST<MemCopyUint8Function>(buffer); #endif @@ -568,9 +568,9 @@ UnaryMathFunctionWithIsolate CreateSqrtFunction(Isolate* isolate) { CodeDesc desc; masm.GetCode(isolate, &desc); - DCHECK(!RelocInfo::RequiresRelocation(isolate, desc)); + DCHECK(!RelocInfo::RequiresRelocation(desc)); - Assembler::FlushICache(isolate, buffer, allocated); + Assembler::FlushICache(buffer, allocated); CHECK(SetPermissions(buffer, allocated, PageAllocator::kReadExecute)); return FUNCTION_CAST<UnaryMathFunctionWithIsolate>(buffer); #endif diff --git a/deps/v8/src/mips/constants-mips.h b/deps/v8/src/mips/constants-mips.h index 565fcd9a68..496c715e81 100644 --- a/deps/v8/src/mips/constants-mips.h +++ b/deps/v8/src/mips/constants-mips.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef V8_MIPS_CONSTANTS_H_ -#define V8_MIPS_CONSTANTS_H_ +#ifndef V8_MIPS_CONSTANTS_MIPS_H_ +#define V8_MIPS_CONSTANTS_MIPS_H_ #include "src/globals.h" // UNIMPLEMENTED_ macro for MIPS. #ifdef DEBUG @@ -1931,4 +1931,4 @@ bool InstructionGetters<T>::IsForbiddenAfterBranchInstr(Instr instr) { } // namespace internal } // namespace v8 -#endif // #ifndef V8_MIPS_CONSTANTS_H_ +#endif // V8_MIPS_CONSTANTS_MIPS_H_ diff --git a/deps/v8/src/mips/cpu-mips.cc b/deps/v8/src/mips/cpu-mips.cc index 1199365b7d..2e71817bd8 100644 --- a/deps/v8/src/mips/cpu-mips.cc +++ b/deps/v8/src/mips/cpu-mips.cc @@ -38,9 +38,7 @@ void CpuFeatures::FlushICache(void* start, size_t size) { int res; // 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"); - } + if (res) FATAL("Failed to flush the instruction cache"); #endif // ANDROID #endif // !USE_SIMULATOR. } diff --git a/deps/v8/src/mips/disasm-mips.cc b/deps/v8/src/mips/disasm-mips.cc index f27bdc9b68..d2f8ebb0ee 100644 --- a/deps/v8/src/mips/disasm-mips.cc +++ b/deps/v8/src/mips/disasm-mips.cc @@ -917,6 +917,7 @@ int Decoder::FormatOption(Instruction* instr, const char* format) { PrintMsaImmElm(instr); return 4; } + UNREACHABLE(); } case 'r': { // 'r: registers. return FormatRegister(instr, format); diff --git a/deps/v8/src/mips/frame-constants-mips.h b/deps/v8/src/mips/frame-constants-mips.h index 344453794a..6d7e471b09 100644 --- a/deps/v8/src/mips/frame-constants-mips.h +++ b/deps/v8/src/mips/frame-constants-mips.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef V8_MIPS_FRAMES_MIPS_H_ -#define V8_MIPS_FRAMES_MIPS_H_ +#ifndef V8_MIPS_FRAME_CONSTANTS_MIPS_H_ +#define V8_MIPS_FRAME_CONSTANTS_MIPS_H_ namespace v8 { namespace internal { @@ -49,4 +49,4 @@ class JavaScriptFrameConstants : public AllStatic { } // namespace internal } // namespace v8 -#endif +#endif // V8_MIPS_FRAME_CONSTANTS_MIPS_H_ diff --git a/deps/v8/src/mips/interface-descriptors-mips.cc b/deps/v8/src/mips/interface-descriptors-mips.cc index 795fdc4af8..a23f8f0fd4 100644 --- a/deps/v8/src/mips/interface-descriptors-mips.cc +++ b/deps/v8/src/mips/interface-descriptors-mips.cc @@ -68,12 +68,6 @@ const Register GrowArrayElementsDescriptor::ObjectRegister() { return a0; } const Register GrowArrayElementsDescriptor::KeyRegister() { return a3; } -void FastNewClosureDescriptor::InitializePlatformSpecific( - CallInterfaceDescriptorData* data) { - Register registers[] = {a1, a2, a3}; - data->InitializePlatformSpecific(arraysize(registers), registers, nullptr); -} - // static const Register TypeConversionDescriptor::ArgumentRegister() { return a0; } diff --git a/deps/v8/src/mips/macro-assembler-mips.cc b/deps/v8/src/mips/macro-assembler-mips.cc index 5c89467cd8..84cf23c832 100644 --- a/deps/v8/src/mips/macro-assembler-mips.cc +++ b/deps/v8/src/mips/macro-assembler-mips.cc @@ -14,6 +14,7 @@ #include "src/debug/debug.h" #include "src/external-reference-table.h" #include "src/frames-inl.h" +#include "src/instruction-stream.h" #include "src/mips/assembler-mips-inl.h" #include "src/mips/macro-assembler-mips.h" #include "src/register-configuration.h" @@ -1162,6 +1163,7 @@ void TurboAssembler::Usdc1(FPURegister fd, const MemOperand& rs, void TurboAssembler::Ldc1(FPURegister fd, const MemOperand& src) { // Workaround for non-8-byte alignment of HeapNumber, convert 64-bit // load to two 32-bit loads. + BlockTrampolinePoolScope block_trampoline_pool(this); DCHECK(Register::kMantissaOffset <= 4 && Register::kExponentOffset <= 4); MemOperand tmp = src; AdjustBaseAndOffset(tmp, OffsetAccessType::TWO_ACCESSES); @@ -1185,6 +1187,7 @@ void TurboAssembler::Ldc1(FPURegister fd, const MemOperand& src) { void TurboAssembler::Sdc1(FPURegister fd, const MemOperand& src) { // Workaround for non-8-byte alignment of HeapNumber, convert 64-bit // store to two 32-bit stores. + BlockTrampolinePoolScope block_trampoline_pool(this); DCHECK(Register::kMantissaOffset <= 4 && Register::kExponentOffset <= 4); MemOperand tmp = src; AdjustBaseAndOffset(tmp, OffsetAccessType::TWO_ACCESSES); @@ -2170,23 +2173,22 @@ void TurboAssembler::FmoveLow(FPURegister dst, Register src_low) { } } -void TurboAssembler::Move(FPURegister dst, float imm) { +void TurboAssembler::Move(FPURegister dst, uint32_t src) { UseScratchRegisterScope temps(this); Register scratch = temps.Acquire(); - li(scratch, Operand(bit_cast<int32_t>(imm))); + li(scratch, Operand(static_cast<int32_t>(src))); mtc1(scratch, dst); } -void TurboAssembler::Move(FPURegister dst, double imm) { - int64_t imm_bits = bit_cast<int64_t>(imm); +void TurboAssembler::Move(FPURegister dst, uint64_t src) { // Handle special values first. - if (imm_bits == bit_cast<int64_t>(0.0) && has_double_zero_reg_set_) { + if (src == bit_cast<uint64_t>(0.0) && has_double_zero_reg_set_) { mov_d(dst, kDoubleRegZero); - } else if (imm_bits == bit_cast<int64_t>(-0.0) && has_double_zero_reg_set_) { + } else if (src == bit_cast<uint64_t>(-0.0) && has_double_zero_reg_set_) { Neg_d(dst, kDoubleRegZero); } else { - uint32_t lo, hi; - DoubleAsTwoUInt32(imm, &lo, &hi); + uint32_t lo = src & 0xFFFFFFFF; + uint32_t hi = src >> 32; // Move the low part of the double into the lower of the corresponding FPU // register of FPU register pair. if (lo != 0) { @@ -2308,6 +2310,79 @@ void TurboAssembler::Clz(Register rd, Register rs) { } } +void TurboAssembler::Ctz(Register rd, Register rs) { + if (IsMipsArchVariant(kMips32r6)) { + // We don't have an instruction to count the number of trailing zeroes. + // Start by flipping the bits end-for-end so we can count the number of + // leading zeroes instead. + Ror(rd, rs, 16); + wsbh(rd, rd); + bitswap(rd, rd); + Clz(rd, rd); + } else { + // Convert trailing zeroes to trailing ones, and bits to their left + // to zeroes. + UseScratchRegisterScope temps(this); + Register scratch = temps.Acquire(); + Addu(scratch, rs, -1); + Xor(rd, scratch, rs); + And(rd, rd, scratch); + // Count number of leading zeroes. + Clz(rd, rd); + // Subtract number of leading zeroes from 32 to get number of trailing + // ones. Remember that the trailing ones were formerly trailing zeroes. + li(scratch, 32); + Subu(rd, scratch, rd); + } +} + +void TurboAssembler::Popcnt(Register rd, Register rs) { + // https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel + // + // A generalization of the best bit counting method to integers of + // bit-widths up to 128 (parameterized by type T) is this: + // + // v = v - ((v >> 1) & (T)~(T)0/3); // temp + // v = (v & (T)~(T)0/15*3) + ((v >> 2) & (T)~(T)0/15*3); // temp + // v = (v + (v >> 4)) & (T)~(T)0/255*15; // temp + // c = (T)(v * ((T)~(T)0/255)) >> (sizeof(T) - 1) * BITS_PER_BYTE; //count + // + // For comparison, for 32-bit quantities, this algorithm can be executed + // using 20 MIPS instructions (the calls to LoadConst32() generate two + // machine instructions each for the values being used in this algorithm). + // A(n unrolled) loop-based algorithm requires 25 instructions. + // + // For 64-bit quantities, this algorithm gets executed twice, (once + // for in_lo, and again for in_hi), but saves a few instructions + // because the mask values only have to be loaded once. Using this + // algorithm the count for a 64-bit operand can be performed in 29 + // instructions compared to a loop-based algorithm which requires 47 + // instructions. + uint32_t B0 = 0x55555555; // (T)~(T)0/3 + uint32_t B1 = 0x33333333; // (T)~(T)0/15*3 + uint32_t B2 = 0x0F0F0F0F; // (T)~(T)0/255*15 + uint32_t value = 0x01010101; // (T)~(T)0/255 + uint32_t shift = 24; // (sizeof(T) - 1) * BITS_PER_BYTE + UseScratchRegisterScope temps(this); + Register scratch = temps.Acquire(); + Register scratch2 = t8; + srl(scratch, rs, 1); + li(scratch2, B0); + And(scratch, scratch, scratch2); + Subu(scratch, rs, scratch); + li(scratch2, B1); + And(rd, scratch, scratch2); + srl(scratch, scratch, 2); + And(scratch, scratch, scratch2); + Addu(scratch, rd, scratch); + srl(rd, scratch, 4); + Addu(rd, rd, scratch); + li(scratch2, B2); + And(rd, rd, scratch2); + li(scratch, value); + Mul(rd, rd, scratch); + srl(rd, rd, shift); +} void MacroAssembler::EmitFPUTruncate(FPURoundingMode rounding_mode, Register result, @@ -3991,12 +4066,27 @@ void MacroAssembler::InvokePrologue(const ParameterCount& expected, void MacroAssembler::CheckDebugHook(Register fun, Register new_target, const ParameterCount& expected, const ParameterCount& actual) { - Label skip_hook; + Label skip_hook, call_hook; + ExternalReference debug_is_active = + ExternalReference::debug_is_active_address(isolate()); + li(t0, Operand(debug_is_active)); + lb(t0, MemOperand(t0)); + Branch(&skip_hook, eq, t0, Operand(zero_reg)); + ExternalReference debug_hook_active = ExternalReference::debug_hook_on_function_call_address(isolate()); li(t0, Operand(debug_hook_active)); lb(t0, MemOperand(t0)); + Branch(&call_hook, ne, t0, Operand(zero_reg)); + + lw(t0, FieldMemOperand(fun, JSFunction::kSharedFunctionInfoOffset)); + lw(t0, FieldMemOperand(t0, SharedFunctionInfo::kDebugInfoOffset)); + JumpIfSmi(t0, &skip_hook); + lw(t0, FieldMemOperand(t0, DebugInfo::kFlagsOffset)); + And(t0, t0, Operand(Smi::FromInt(DebugInfo::kBreakAtEntry))); Branch(&skip_hook, eq, t0, Operand(zero_reg)); + + bind(&call_hook); { FrameScope frame(this, has_frame() ? StackFrame::NONE : StackFrame::INTERNAL); @@ -4054,13 +4144,15 @@ void MacroAssembler::InvokeFunctionCode(Register function, Register new_target, // We call indirectly through the code field in the function to // allow recompilation to take effect without changing any of the // call sites. - Register code = t0; + Register code = kJavaScriptCallCodeStartRegister; lw(code, FieldMemOperand(function, JSFunction::kCodeOffset)); if (flag == CALL_FUNCTION) { - Call(code, Code::kHeaderSize - kHeapObjectTag); + Addu(code, code, Code::kHeaderSize - kHeapObjectTag); + Call(code); } else { DCHECK(flag == JUMP_FUNCTION); - Jump(code, Code::kHeaderSize - kHeapObjectTag); + Addu(code, code, Code::kHeaderSize - kHeapObjectTag); + Jump(code); } // Continue here if InvokePrologue does handle the invocation due to // mismatched parameter counts. @@ -4105,14 +4197,6 @@ void MacroAssembler::InvokeFunction(Register function, InvokeFunctionCode(a1, no_reg, expected, actual, flag); } -void MacroAssembler::InvokeFunction(Handle<JSFunction> function, - const ParameterCount& expected, - const ParameterCount& actual, - InvokeFlag flag) { - li(a1, function); - InvokeFunction(a1, expected, actual, flag); -} - // --------------------------------------------------------------------------- // Support functions. @@ -4467,6 +4551,12 @@ void MacroAssembler::JumpToExternalReference(const ExternalReference& builtin, bd); } +void MacroAssembler::JumpToInstructionStream(const InstructionStream* stream) { + int32_t bytes_address = reinterpret_cast<int32_t>(stream->bytes()); + li(kOffHeapTrampolineRegister, Operand(bytes_address, RelocInfo::NONE)); + Jump(kOffHeapTrampolineRegister); +} + void MacroAssembler::IncrementCounter(StatsCounter* counter, int value, Register scratch1, Register scratch2) { DCHECK_GT(value, 0); @@ -5274,6 +5364,26 @@ bool AreAliased(Register reg1, Register reg2, Register reg3, Register reg4, return n_of_valid_regs != n_of_non_aliasing_regs; } +void TurboAssembler::ComputeCodeStartAddress(Register dst) { + // This push on ra and the pop below together ensure that we restore the + // register ra, which is needed while computing the code start address. + push(ra); + + // The bal instruction puts the address of the current instruction into + // the return address (ra) register, which we can use later on. + Label current; + bal(¤t); + nop(); + int pc = pc_offset(); + bind(¤t); + li(dst, pc); + subu(dst, ra, dst); + + pop(ra); // Restore ra +} + +void TurboAssembler::ResetSpeculationPoisonRegister() { UNREACHABLE(); } + } // namespace internal } // namespace v8 diff --git a/deps/v8/src/mips/macro-assembler-mips.h b/deps/v8/src/mips/macro-assembler-mips.h index 8c70eb54a3..37d2c59270 100644 --- a/deps/v8/src/mips/macro-assembler-mips.h +++ b/deps/v8/src/mips/macro-assembler-mips.h @@ -19,12 +19,15 @@ constexpr Register kReturnRegister2 = a0; constexpr Register kJSFunctionRegister = a1; constexpr Register kContextRegister = s7; constexpr Register kAllocateSizeRegister = a0; +constexpr Register kSpeculationPoisonRegister = t3; constexpr Register kInterpreterAccumulatorRegister = v0; constexpr Register kInterpreterBytecodeOffsetRegister = t4; constexpr Register kInterpreterBytecodeArrayRegister = t5; constexpr Register kInterpreterDispatchTableRegister = t6; constexpr Register kJavaScriptCallArgCountRegister = a0; +constexpr Register kJavaScriptCallCodeStartRegister = a2; constexpr Register kJavaScriptCallNewTargetRegister = a3; +constexpr Register kOffHeapTrampolineRegister = at; constexpr Register kRuntimeCallFunctionRegister = a1; constexpr Register kRuntimeCallArgCountRegister = a0; @@ -559,6 +562,8 @@ class TurboAssembler : public Assembler { void Movf(Register rd, Register rs, uint16_t cc = 0); void Clz(Register rd, Register rs); + void Ctz(Register rd, Register rs); + void Popcnt(Register rd, Register rs); // Int64Lowering instructions void AddPair(Register dst_low, Register dst_high, Register left_low, @@ -731,8 +736,10 @@ class TurboAssembler : public Assembler { Mthc1(src_high, dst); } - void Move(FPURegister dst, float imm); - void Move(FPURegister dst, double imm); + void Move(FPURegister dst, float imm) { Move(dst, bit_cast<uint32_t>(imm)); } + void Move(FPURegister dst, double imm) { Move(dst, bit_cast<uint64_t>(imm)); } + void Move(FPURegister dst, uint32_t src); + void Move(FPURegister dst, uint64_t src); // ------------------------------------------------------------------------- // Overflow handling functions. @@ -844,6 +851,12 @@ class TurboAssembler : public Assembler { BranchF64(bd, target, nan, cc, cmp1, cmp2); } + // Compute the start of the generated instruction stream from the current PC. + // This is an alternative to embedding the {CodeObject} handle as a reference. + void ComputeCodeStartAddress(Register dst); + + void ResetSpeculationPoisonRegister(); + protected: void BranchLong(Label* L, BranchDelaySlot bdslot); @@ -1023,10 +1036,6 @@ class MacroAssembler : public TurboAssembler { void InvokeFunction(Register function, const ParameterCount& expected, const ParameterCount& actual, InvokeFlag flag); - void InvokeFunction(Handle<JSFunction> function, - const ParameterCount& expected, - const ParameterCount& actual, InvokeFlag flag); - // Frame restart support. void MaybeDropFrames(); @@ -1089,6 +1098,9 @@ const Operand& rt = Operand(zero_reg), BranchDelaySlot bd = PROTECT BranchDelaySlot bd = PROTECT, bool builtin_exit_frame = false); + // Generates a trampoline to jump to the off-heap instruction stream. + void JumpToInstructionStream(const InstructionStream* stream); + // ------------------------------------------------------------------------- // StatsCounter support. diff --git a/deps/v8/src/mips/simulator-mips.cc b/deps/v8/src/mips/simulator-mips.cc index 4994418ef5..b55273eba5 100644 --- a/deps/v8/src/mips/simulator-mips.cc +++ b/deps/v8/src/mips/simulator-mips.cc @@ -783,8 +783,7 @@ void MipsDebugger::Debug() { #undef XSTR } - -static bool ICacheMatch(void* one, void* two) { +bool Simulator::ICacheMatch(void* one, void* two) { DCHECK_EQ(reinterpret_cast<intptr_t>(one) & CachePage::kPageMask, 0); DCHECK_EQ(reinterpret_cast<intptr_t>(two) & CachePage::kPageMask, 0); return one == two; @@ -883,11 +882,6 @@ void Simulator::CheckICache(base::CustomMatcherHashMap* i_cache, Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { - i_cache_ = isolate_->simulator_i_cache(); - if (i_cache_ == nullptr) { - i_cache_ = new base::CustomMatcherHashMap(&ICacheMatch); - isolate_->set_simulator_i_cache(i_cache_); - } // Set up simulator support first. Some of this information is needed to // setup the architecture state. stack_ = reinterpret_cast<char*>(malloc(stack_size_)); @@ -2539,8 +2533,7 @@ void Simulator::PrintStopInfo(uint32_t code) { void Simulator::SignalException(Exception e) { - V8_Fatal(__FILE__, __LINE__, "Error: Exception %i raised.", - static_cast<int>(e)); + FATAL("Error: Exception %i raised.", static_cast<int>(e)); } // Min/Max template functions for Double and Single arguments. @@ -5690,7 +5683,8 @@ void Simulator::DecodeTypeMsa3RF() { case MSUB_Q: case MADDR_Q: case MSUBR_Q: - get_msa_register(wd_reg(), &wd); // fall-through + get_msa_register(wd_reg(), &wd); + V8_FALLTHROUGH; case MUL_Q: case MULR_Q: switch (DecodeMsaDataFormat()) { @@ -6912,7 +6906,7 @@ void Simulator::DecodeTypeJump() { // Executes the current instruction. void Simulator::InstructionDecode(Instruction* instr) { if (v8::internal::FLAG_check_icache) { - CheckICache(isolate_->simulator_i_cache(), instr); + CheckICache(i_cache(), instr); } pc_modified_ = false; v8::internal::EmbeddedVector<char, 256> buffer; diff --git a/deps/v8/src/mips/simulator-mips.h b/deps/v8/src/mips/simulator-mips.h index 0c417becd5..ffd2c46740 100644 --- a/deps/v8/src/mips/simulator-mips.h +++ b/deps/v8/src/mips/simulator-mips.h @@ -258,6 +258,7 @@ class Simulator : public SimulatorBase { static void SetRedirectInstruction(Instruction* instruction); // ICache checking. + static bool ICacheMatch(void* one, void* two); static void FlushICache(base::CustomMatcherHashMap* i_cache, void* start, size_t size); @@ -450,10 +451,10 @@ class Simulator : public SimulatorBase { Instruction* instr_after_compact_branch = reinterpret_cast<Instruction*>(current_pc + Instruction::kInstrSize); if (instr_after_compact_branch->IsForbiddenAfterBranch()) { - V8_Fatal(__FILE__, __LINE__, - "Error: Unexpected instruction 0x%08x immediately after a " - "compact branch instruction.", - *reinterpret_cast<uint32_t*>(instr_after_compact_branch)); + FATAL( + "Error: Unexpected instruction 0x%08x immediately after a " + "compact branch instruction.", + *reinterpret_cast<uint32_t*>(instr_after_compact_branch)); } } @@ -480,9 +481,8 @@ class Simulator : public SimulatorBase { } if (instr->IsForbiddenInBranchDelay()) { - V8_Fatal(__FILE__, __LINE__, - "Eror:Unexpected %i opcode in a branch delay slot.", - instr->OpcodeValue()); + FATAL("Eror:Unexpected %i opcode in a branch delay slot.", + instr->OpcodeValue()); } InstructionDecode(instr); SNPrintF(trace_buf_, " "); @@ -538,9 +538,6 @@ class Simulator : public SimulatorBase { // Debugger input. char* last_debugger_input_; - // Icache simulation. - base::CustomMatcherHashMap* i_cache_; - v8::internal::Isolate* isolate_; // Registered breakpoints. |