Commit 9fad5990 authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

[maglev] Implement LoadNamedGeneric IR

Bug: v8:7700
Change-Id: I117f0ed7df60eff145b0ecd509ffa7debc137038
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3494239Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79315}
parent 487f840e
......@@ -127,8 +127,9 @@ void MaglevGraphBuilder::VisitLdaNamedProperty() {
}
}
ValueNode* context = GetContext();
compiler::NameRef name = GetRefOperand<Name>(1);
SetAccumulator(AddNewNode<LoadNamedGeneric>({object}, name));
SetAccumulator(AddNewNode<LoadNamedGeneric>({context, object}, name));
MarkPossibleSideEffect();
}
void MaglevGraphBuilder::VisitLdaNamedPropertyFromSuper() { UNREACHABLE(); }
......
......@@ -590,12 +590,21 @@ void LoadField::PrintParams(std::ostream& os,
void LoadNamedGeneric::AllocateVreg(MaglevVregAllocationState* vreg_state,
const ProcessingState& state) {
UseRegister(object_input());
DefineAsRegister(vreg_state, this);
using D = LoadNoFeedbackDescriptor;
UseFixed(context(), kContextRegister);
UseFixed(object_input(), D::GetRegisterParameter(D::kReceiver));
DefineAsFixed(vreg_state, this, kReturnRegister0);
}
void LoadNamedGeneric::GenerateCode(MaglevCodeGenState* code_gen_state,
const ProcessingState& state) {
UNREACHABLE();
using D = LoadNoFeedbackDescriptor;
const int ic_kind = static_cast<int>(FeedbackSlotKind::kLoadProperty);
DCHECK_EQ(ToRegister(context()), kContextRegister);
DCHECK_EQ(ToRegister(object_input()), D::GetRegisterParameter(D::kReceiver));
__ Move(D::GetRegisterParameter(D::kName), name().object());
__ Move(D::GetRegisterParameter(D::kICKind),
Immediate(Smi::FromInt(ic_kind)));
__ CallBuiltin(Builtin::kLoadIC_NoFeedback);
}
void LoadNamedGeneric::PrintParams(std::ostream& os,
MaglevGraphLabeller* graph_labeller) const {
......
......@@ -881,8 +881,8 @@ class LoadGlobal : public FixedInputValueNodeT<1, LoadGlobal> {
const compiler::NameRef name_;
};
class LoadNamedGeneric : public FixedInputValueNodeT<1, LoadNamedGeneric> {
using Base = FixedInputValueNodeT<1, LoadNamedGeneric>;
class LoadNamedGeneric : public FixedInputValueNodeT<2, LoadNamedGeneric> {
using Base = FixedInputValueNodeT<2, LoadNamedGeneric>;
public:
explicit LoadNamedGeneric(size_t input_count, const compiler::NameRef& name)
......@@ -893,7 +893,9 @@ class LoadNamedGeneric : public FixedInputValueNodeT<1, LoadNamedGeneric> {
compiler::NameRef name() const { return name_; }
static constexpr int kObjectIndex = 0;
static constexpr int kContextIndex = 0;
static constexpr int kObjectIndex = 1;
Input& context() { return input(kContextIndex); }
Input& object_input() { return input(kObjectIndex); }
void AllocateVreg(MaglevVregAllocationState*, const ProcessingState&);
......
// Copyright 2022 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
function f(x) {
return x.a;
}
function Foo(a) {
this.a = a;
}
function Goo(a) {
this.a = a;
}
%PrepareFunctionForOptimization(f);
var o1 = new Foo(42);
var o2 = new Goo(4.2);
assertEquals(f(o1), 42);
assertEquals(f(o2), 4.2);
%OptimizeMaglevOnNextCall(f);
assertEquals(f(o1), 42);
assertEquals(f(o2), 4.2);
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