[maglev] Support CreateEmptyObjectLiteral
... with inlined allocation. Bug: v8:7700 Change-Id: I523bc6ed843e87611f83ed39821c389c32ea787e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3804663 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Victor Gomes <victorgomes@chromium.org> Commit-Queue: Leszek Swirski <leszeks@chromium.org> Auto-Submit: Victor Gomes <victorgomes@chromium.org> Cr-Commit-Position: refs/heads/main@{#82169}
This commit is contained in:
parent
8851a27419
commit
21f6c2235a
@ -2063,7 +2063,15 @@ void MaglevGraphBuilder::VisitCreateObjectLiteral() {
|
||||
SetAccumulator(result);
|
||||
}
|
||||
|
||||
MAGLEV_UNIMPLEMENTED_BYTECODE(CreateEmptyObjectLiteral)
|
||||
void MaglevGraphBuilder::VisitCreateEmptyObjectLiteral() {
|
||||
compiler::NativeContextRef native_context = broker()->target_native_context();
|
||||
compiler::MapRef map =
|
||||
native_context.object_function().initial_map(broker()->dependencies());
|
||||
DCHECK(!map.is_dictionary_map());
|
||||
DCHECK(!map.IsInobjectSlackTrackingInProgress());
|
||||
SetAccumulator(AddNewNode<CreateEmptyObjectLiteral>({}, map));
|
||||
}
|
||||
|
||||
MAGLEV_UNIMPLEMENTED_BYTECODE(CloneObject)
|
||||
MAGLEV_UNIMPLEMENTED_BYTECODE(GetTemplateObject)
|
||||
|
||||
|
@ -79,6 +79,7 @@ class MaglevGraphVerifier {
|
||||
case Opcode::kConstant:
|
||||
case Opcode::kConstantGapMove:
|
||||
case Opcode::kCreateEmptyArrayLiteral:
|
||||
case Opcode::kCreateEmptyObjectLiteral:
|
||||
case Opcode::kCreateArrayLiteral:
|
||||
case Opcode::kCreateShallowArrayLiteral:
|
||||
case Opcode::kCreateObjectLiteral:
|
||||
|
@ -923,6 +923,30 @@ void CreateObjectLiteral::GenerateCode(MaglevCodeGenState* code_gen_state,
|
||||
__ CallRuntime(Runtime::kCreateObjectLiteral);
|
||||
}
|
||||
|
||||
void CreateEmptyObjectLiteral::AllocateVreg(
|
||||
MaglevVregAllocationState* vreg_state) {
|
||||
DefineAsRegister(vreg_state, this);
|
||||
}
|
||||
void CreateEmptyObjectLiteral::GenerateCode(MaglevCodeGenState* code_gen_state,
|
||||
const ProcessingState& state) {
|
||||
Register object = ToRegister(result());
|
||||
RegisterSnapshot save_registers = register_snapshot();
|
||||
AllocateRaw(code_gen_state, save_registers, object, map().instance_size());
|
||||
__ Move(kScratchRegister, map().object());
|
||||
__ StoreTaggedField(FieldOperand(object, HeapObject::kMapOffset),
|
||||
kScratchRegister);
|
||||
__ LoadRoot(kScratchRegister, RootIndex::kEmptyFixedArray);
|
||||
__ StoreTaggedField(FieldOperand(object, JSObject::kPropertiesOrHashOffset),
|
||||
kScratchRegister);
|
||||
__ StoreTaggedField(FieldOperand(object, JSObject::kElementsOffset),
|
||||
kScratchRegister);
|
||||
__ LoadRoot(kScratchRegister, RootIndex::kUndefinedValue);
|
||||
for (int i = 0; i < map().GetInObjectProperties(); i++) {
|
||||
int offset = map().GetInObjectPropertyOffset(i);
|
||||
__ StoreTaggedField(FieldOperand(object, offset), kScratchRegister);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateShallowObjectLiteral::AllocateVreg(
|
||||
MaglevVregAllocationState* vreg_state) {
|
||||
DefineAsFixed(vreg_state, this, kReturnRegister0);
|
||||
|
@ -125,6 +125,7 @@ class CompactInterpreterFrameState;
|
||||
V(CreateArrayLiteral) \
|
||||
V(CreateShallowArrayLiteral) \
|
||||
V(CreateObjectLiteral) \
|
||||
V(CreateEmptyObjectLiteral) \
|
||||
V(CreateShallowObjectLiteral) \
|
||||
V(CreateFunctionContext) \
|
||||
V(CreateClosure) \
|
||||
@ -1989,6 +1990,26 @@ class CreateObjectLiteral
|
||||
const int flags_;
|
||||
};
|
||||
|
||||
class CreateEmptyObjectLiteral
|
||||
: public FixedInputValueNodeT<0, CreateEmptyObjectLiteral> {
|
||||
using Base = FixedInputValueNodeT<0, CreateEmptyObjectLiteral>;
|
||||
|
||||
public:
|
||||
explicit CreateEmptyObjectLiteral(uint64_t bitfield, compiler::MapRef& map)
|
||||
: Base(bitfield), map_(map) {}
|
||||
|
||||
static constexpr OpProperties kProperties = OpProperties::DeferredCall();
|
||||
|
||||
compiler::MapRef map() { return map_; }
|
||||
|
||||
void AllocateVreg(MaglevVregAllocationState*);
|
||||
void GenerateCode(MaglevCodeGenState*, const ProcessingState&);
|
||||
void PrintParams(std::ostream&, MaglevGraphLabeller*) const {}
|
||||
|
||||
private:
|
||||
const compiler::MapRef map_;
|
||||
};
|
||||
|
||||
class CreateShallowObjectLiteral
|
||||
: public FixedInputValueNodeT<0, CreateShallowObjectLiteral> {
|
||||
using Base = FixedInputValueNodeT<0, CreateShallowObjectLiteral>;
|
||||
|
Loading…
Reference in New Issue
Block a user