mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 18:00:31 +00:00
Replace 20 separate Put instructions (5 PutKinds x 4 forms) with 4 unified instructions (PutById, PutByIdWithThis, PutByValue, PutByValueWithThis), each carrying a PutKind field at runtime instead of being a separate opcode. This reduces the number of handler entry points in the dispatch loop and eliminates template instantiations of put_by_property_key and put_by_value that were being duplicated 5x each when inlined by LTO.
39 lines
1,010 B
C++
39 lines
1,010 B
C++
/*
|
|
* Copyright (c) 2025, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
namespace JS::Bytecode {
|
|
|
|
// PutKind indicates how a property is being set.
|
|
// `Normal` is a normal `o.foo = x` or `o[foo] = x` operation.
|
|
// The others are used for object expressions.
|
|
#define JS_ENUMERATE_PUT_KINDS(X) \
|
|
X(Normal) \
|
|
X(Getter) \
|
|
X(Setter) \
|
|
X(Prototype) \
|
|
X(Own) // Always sets an own property, never calls a setter.
|
|
|
|
enum class PutKind {
|
|
#define __JS_ENUMERATE_PUT_KIND(name) name,
|
|
JS_ENUMERATE_PUT_KINDS(__JS_ENUMERATE_PUT_KIND)
|
|
#undef __JS_ENUMERATE_PUT_KIND
|
|
};
|
|
|
|
inline char const* put_kind_to_string(PutKind kind)
|
|
{
|
|
switch (kind) {
|
|
#define __JS_PUT_KIND_TO_STRING(name) \
|
|
case PutKind::name: \
|
|
return #name;
|
|
JS_ENUMERATE_PUT_KINDS(__JS_PUT_KIND_TO_STRING)
|
|
#undef __JS_PUT_KIND_TO_STRING
|
|
}
|
|
VERIFY_NOT_REACHED();
|
|
}
|
|
|
|
}
|