Navigation Menu

Skip to content

Commit

Permalink
deps: patch V8 to 9.0.257.13
Browse files Browse the repository at this point in the history
Refs: v8/v8@9.0.257.11...9.0.257.13

PR-URL: #37830
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
targos authored and jasnell committed Mar 22, 2021
1 parent 7120411 commit d639321
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 47 deletions.
2 changes: 1 addition & 1 deletion deps/v8/include/v8-version.h
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 9
#define V8_MINOR_VERSION 0
#define V8_BUILD_NUMBER 257
#define V8_PATCH_LEVEL 11
#define V8_PATCH_LEVEL 13

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
26 changes: 17 additions & 9 deletions deps/v8/src/builtins/mips/builtins-mips.cc
Expand Up @@ -2299,15 +2299,23 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
// Save all parameter registers (see wasm-linkage.h). They might be
// overwritten in the runtime call below. We don't have any callee-saved
// registers in wasm, so no need to store anything else.
constexpr RegList gp_regs = Register::ListOf(a0, a2, a3);
constexpr RegList fp_regs =
DoubleRegister::ListOf(f2, f4, f6, f8, f10, f12, f14);
constexpr int16_t num_to_push = base::bits::CountPopulation(gp_regs) +
base::bits::CountPopulation(fp_regs);
// The number of regs to be pushed before kWasmInstanceRegister should be
// equal to kNumberOfSavedAllParamRegs.
STATIC_ASSERT(num_to_push ==
WasmCompileLazyFrameConstants::kNumberOfSavedAllParamRegs);
RegList gp_regs = 0;
for (Register gp_param_reg : wasm::kGpParamRegisters) {
gp_regs |= gp_param_reg.bit();
}

RegList fp_regs = 0;
for (DoubleRegister fp_param_reg : wasm::kFpParamRegisters) {
fp_regs |= fp_param_reg.bit();
}

CHECK_EQ(NumRegs(gp_regs), arraysize(wasm::kGpParamRegisters));
CHECK_EQ(NumRegs(fp_regs), arraysize(wasm::kFpParamRegisters));
CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs,
NumRegs(gp_regs));
CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedFpParamRegs,
NumRegs(fp_regs));

__ MultiPush(gp_regs);
__ MultiPushFPU(fp_regs);

Expand Down
71 changes: 48 additions & 23 deletions deps/v8/src/builtins/mips64/builtins-mips64.cc
Expand Up @@ -1478,7 +1478,9 @@ void Generate_ContinueToBuiltinHelper(MacroAssembler* masm,
bool with_result) {
const RegisterConfiguration* config(RegisterConfiguration::Default());
int allocatable_register_count = config->num_allocatable_general_registers();
Register scratch = t3;
UseScratchRegisterScope temps(masm);
Register scratch = temps.Acquire();

if (with_result) {
if (java_script_builtin) {
__ mov(scratch, v0);
Expand Down Expand Up @@ -2363,24 +2365,41 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
// Save all parameter registers (see wasm-linkage.h). They might be
// overwritten in the runtime call below. We don't have any callee-saved
// registers in wasm, so no need to store anything else.
constexpr RegList gp_regs =
Register::ListOf(a0, a2, a3, a4, a5, a6, a7);
constexpr RegList fp_regs =
DoubleRegister::ListOf(f2, f4, f6, f8, f10, f12, f14);
constexpr int16_t num_to_push = base::bits::CountPopulation(gp_regs) +
base::bits::CountPopulation(fp_regs);
// The number of regs to be pushed before kWasmInstanceRegister should be
// equal to kNumberOfSavedAllParamRegs.
STATIC_ASSERT(num_to_push ==
WasmCompileLazyFrameConstants::kNumberOfSavedAllParamRegs);
__ MultiPush(gp_regs);
if (CpuFeatures::IsSupported(MIPS_SIMD)) {
__ MultiPushMSA(fp_regs);
} else {
__ MultiPushFPU(fp_regs);
__ Dsubu(sp, sp, base::bits::CountPopulation(fp_regs) * kDoubleSize);
RegList gp_regs = 0;
for (Register gp_param_reg : wasm::kGpParamRegisters) {
gp_regs |= gp_param_reg.bit();
}

RegList fp_regs = 0;
for (DoubleRegister fp_param_reg : wasm::kFpParamRegisters) {
fp_regs |= fp_param_reg.bit();
}

CHECK_EQ(NumRegs(gp_regs), arraysize(wasm::kGpParamRegisters));
CHECK_EQ(NumRegs(fp_regs), arraysize(wasm::kFpParamRegisters));
CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs,
NumRegs(gp_regs));
CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedFpParamRegs,
NumRegs(fp_regs));

__ MultiPush(gp_regs);
// Check if machine has simd enabled, if so push vector registers. If not
// then only push double registers.
Label push_doubles, simd_pushed;
__ li(a1, ExternalReference::supports_wasm_simd_128_address());
// If > 0 then simd is available.
__ Lbu(a1, MemOperand(a1));
__ Branch(&push_doubles, le, a1, Operand(zero_reg));
// Save vector registers.
__ MultiPushMSA(fp_regs);
__ Branch(&simd_pushed);
__ bind(&push_doubles);
__ MultiPushFPU(fp_regs);
// kFixedFrameSizeFromFp is hard coded to include space for Simd
// registers, so we still need to allocate extra (unused) space on the stack
// as if they were saved.
__ Dsubu(sp, sp, base::bits::CountPopulation(fp_regs) * kDoubleSize);
__ bind(&simd_pushed);
// Pass instance and function index as an explicit arguments to the runtime
// function.
__ Push(kWasmInstanceRegister, kWasmCompileLazyFuncIndexRegister);
Expand All @@ -2390,12 +2409,18 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
__ CallRuntime(Runtime::kWasmCompileLazy, 2);

// Restore registers.
if (CpuFeatures::IsSupported(MIPS_SIMD)) {
__ MultiPopMSA(fp_regs);
} else {
__ Daddu(sp, sp, base::bits::CountPopulation(fp_regs) * kDoubleSize);
__ MultiPopFPU(fp_regs);
}
Label pop_doubles, simd_popped;
__ li(a1, ExternalReference::supports_wasm_simd_128_address());
// If > 0 then simd is available.
__ Lbu(a1, MemOperand(a1));
__ Branch(&pop_doubles, le, a1, Operand(zero_reg));
// Pop vector registers.
__ MultiPopMSA(fp_regs);
__ Branch(&simd_popped);
__ bind(&pop_doubles);
__ Daddu(sp, sp, base::bits::CountPopulation(fp_regs) * kDoubleSize);
__ MultiPopFPU(fp_regs);
__ bind(&simd_popped);
__ MultiPop(gp_regs);
}
// Finally, jump to the entrypoint.
Expand Down
4 changes: 2 additions & 2 deletions deps/v8/src/codegen/mips64/register-mips64.h
Expand Up @@ -21,7 +21,7 @@ namespace internal {

#define ALLOCATABLE_GENERAL_REGISTERS(V) \
V(a0) V(a1) V(a2) V(a3) \
V(a4) V(a5) V(a6) V(a7) V(t0) V(t1) V(t2) V(s7) \
V(a4) V(a5) V(a6) V(a7) V(t0) V(t1) V(t2) V(t3) V(s7) \
V(v0) V(v1)

#define DOUBLE_REGISTERS(V) \
Expand Down Expand Up @@ -368,7 +368,7 @@ constexpr Register kReturnRegister2 = a0;
constexpr Register kJSFunctionRegister = a1;
constexpr Register kContextRegister = s7;
constexpr Register kAllocateSizeRegister = a0;
constexpr Register kSpeculationPoisonRegister = a7;
constexpr Register kSpeculationPoisonRegister = t3;
constexpr Register kInterpreterAccumulatorRegister = v0;
constexpr Register kInterpreterBytecodeOffsetRegister = t0;
constexpr Register kInterpreterBytecodeArrayRegister = t1;
Expand Down
58 changes: 49 additions & 9 deletions deps/v8/src/deoptimizer/translated-state.cc
Expand Up @@ -1282,7 +1282,8 @@ Address TranslatedState::DecompressIfNeeded(intptr_t value) {
}
}

TranslatedState::TranslatedState(const JavaScriptFrame* frame) {
TranslatedState::TranslatedState(const JavaScriptFrame* frame)
: purpose_(kFrameInspection) {
int deopt_index = Safepoint::kNoDeoptimizationIndex;
DeoptimizationData data =
static_cast<const OptimizedFrame*>(frame)->GetDeoptimizationData(
Expand Down Expand Up @@ -1672,25 +1673,63 @@ void TranslatedState::EnsureCapturedObjectAllocatedAt(
}

default:
CHECK(map->IsJSObjectMap());
EnsureJSObjectAllocated(slot, map);
TranslatedValue* properties_slot = &(frame->values_[value_index]);
value_index++;
int remaining_children_count = slot->GetChildrenCount() - 1;

TranslatedValue* properties_slot = frame->ValueAt(value_index);
value_index++, remaining_children_count--;
if (properties_slot->kind() == TranslatedValue::kCapturedObject) {
// If we are materializing the property array, make sure we put
// the mutable heap numbers at the right places.
// We are materializing the property array, so make sure we put the
// mutable heap numbers at the right places.
EnsurePropertiesAllocatedAndMarked(properties_slot, map);
EnsureChildrenAllocated(properties_slot->GetChildrenCount(), frame,
&value_index, worklist);
} else {
CHECK_EQ(properties_slot->kind(), TranslatedValue::kTagged);
}
// Make sure all the remaining children (after the map and properties) are
// allocated.
return EnsureChildrenAllocated(slot->GetChildrenCount() - 2, frame,

TranslatedValue* elements_slot = frame->ValueAt(value_index);
value_index++, remaining_children_count--;
if (elements_slot->kind() == TranslatedValue::kCapturedObject ||
!map->IsJSArrayMap()) {
// Handle this case with the other remaining children below.
value_index--, remaining_children_count++;
} else {
CHECK_EQ(elements_slot->kind(), TranslatedValue::kTagged);
elements_slot->GetValue();
if (purpose_ == kFrameInspection) {
// We are materializing a JSArray for the purpose of frame inspection.
// If we were to construct it with the above elements value then an
// actual deopt later on might create another JSArray instance with
// the same elements store. That would violate the key assumption
// behind left-trimming.
elements_slot->ReplaceElementsArrayWithCopy();
}
}

// Make sure all the remaining children (after the map, properties store,
// and possibly elements store) are allocated.
return EnsureChildrenAllocated(remaining_children_count, frame,
&value_index, worklist);
}
UNREACHABLE();
}

void TranslatedValue::ReplaceElementsArrayWithCopy() {
DCHECK_EQ(kind(), TranslatedValue::kTagged);
DCHECK_EQ(materialization_state(), TranslatedValue::kFinished);
auto elements = Handle<FixedArrayBase>::cast(GetValue());
DCHECK(elements->IsFixedArray() || elements->IsFixedDoubleArray());
if (elements->IsFixedDoubleArray()) {
DCHECK(!elements->IsCowArray());
set_storage(isolate()->factory()->CopyFixedDoubleArray(
Handle<FixedDoubleArray>::cast(elements)));
} else if (!elements->IsCowArray()) {
set_storage(isolate()->factory()->CopyFixedArray(
Handle<FixedArray>::cast(elements)));
}
}

void TranslatedState::EnsureChildrenAllocated(int count, TranslatedFrame* frame,
int* value_index,
std::stack<int>* worklist) {
Expand Down Expand Up @@ -1755,6 +1794,7 @@ Handle<ByteArray> TranslatedState::AllocateStorageFor(TranslatedValue* slot) {

void TranslatedState::EnsureJSObjectAllocated(TranslatedValue* slot,
Handle<Map> map) {
CHECK(map->IsJSObjectMap());
CHECK_EQ(map->instance_size(), slot->GetChildrenCount() * kTaggedSize);

Handle<ByteArray> object_storage = AllocateStorageFor(slot);
Expand Down
19 changes: 18 additions & 1 deletion deps/v8/src/deoptimizer/translated-state.h
Expand Up @@ -125,6 +125,8 @@ class TranslatedValue {
return storage_;
}

void ReplaceElementsArrayWithCopy();

Kind kind_;
MaterializationState materialization_state_ = kUninitialized;
TranslatedState* container_; // This is only needed for materialization of
Expand Down Expand Up @@ -335,7 +337,15 @@ class TranslatedFrame {

class TranslatedState {
public:
TranslatedState() = default;
// There are two constructors, each for a different purpose:

// The default constructor is for the purpose of deoptimizing an optimized
// frame (replacing it with one or several unoptimized frames). It is used by
// the Deoptimizer.
TranslatedState() : purpose_(kDeoptimization) {}

// This constructor is for the purpose of merely inspecting an optimized
// frame. It is used by stack trace generation and various debugging features.
explicit TranslatedState(const JavaScriptFrame* frame);

void Prepare(Address stack_frame_pointer);
Expand Down Expand Up @@ -370,6 +380,12 @@ class TranslatedState {
private:
friend TranslatedValue;

// See the description of the constructors for an explanation of the two
// purposes. The only actual difference is that in the kFrameInspection case
// extra work is needed to not violate assumptions made by left-trimming. For
// details, see the code around ReplaceElementsArrayWithCopy.
enum Purpose { kDeoptimization, kFrameInspection };

TranslatedFrame CreateNextTranslatedFrame(TranslationArrayIterator* iterator,
FixedArray literal_array,
Address fp, FILE* trace_file);
Expand Down Expand Up @@ -426,6 +442,7 @@ class TranslatedState {
static Float32 GetFloatSlot(Address fp, int slot_index);
static Float64 GetDoubleSlot(Address fp, int slot_index);

Purpose const purpose_;
std::vector<TranslatedFrame> frames_;
Isolate* isolate_ = nullptr;
Address stack_frame_pointer_ = kNullAddress;
Expand Down
4 changes: 2 additions & 2 deletions deps/v8/test/message/message.status
Expand Up @@ -70,10 +70,10 @@
}],

################################################################################
['arch == ppc64', {
['arch == ppc64 or arch == mips64el or arch == mipsel', {
# Tests that require Simd enabled.
'wasm-trace-memory': [SKIP],
}],
}], # arch == ppc64 or arch == mips64el or arch == mipsel


]
25 changes: 25 additions & 0 deletions deps/v8/test/mjsunit/compiler/regress-1182647.js
@@ -0,0 +1,25 @@
// Copyright 2021 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.

// Flags: --allow-natives-syntax --verify-heap

function foo() {
const arr = Array(1000);

function bar() {
try { ({a: p4nda, b: arr.length}); } catch(e) {}
}

for (var i = 0; i < 25; i++) bar();

/p4nda/.test({}); // Deopt here.

arr.shift();
}

%PrepareFunctionForOptimization(foo);
foo();
foo();
%OptimizeFunctionOnNextCall(foo);
foo();
4 changes: 4 additions & 0 deletions deps/v8/tools/testrunner/base_runner.py
Expand Up @@ -653,6 +653,10 @@ def _get_statusfile_variables(self, options):
if self.build_config.arch == 'ppc64':
no_simd_sse = True

if self.build_config.arch == 'mips64el' or \
self.build_config.arch == 'mipsel':
no_simd_sse = not simd_mips

return {
"arch": self.build_config.arch,
"asan": self.build_config.asan,
Expand Down

0 comments on commit d639321

Please sign in to comment.