28 switch (node->opcode()) {
29 case IrOpcode::kParameter:
31 case IrOpcode::kJSLoadContext:
33 case IrOpcode::kJSLoadScriptContext:
35 case IrOpcode::kJSStoreContext:
37 case IrOpcode::kJSStoreScriptContext:
39 case IrOpcode::kJSGetImportMeta:
48 DCHECK_EQ(IrOpcode::kParameter, node->opcode());
53 if (
closure().ToHandle(&function)) {
65 DCHECK_EQ(IrOpcode::kJSLoadContext, node->opcode());
69 if (new_depth == access.depth() &&
75 new_depth, access.index(), access.immutable());
82 Node* node,
Node* new_context,
size_t new_depth) {
83 DCHECK_EQ(IrOpcode::kJSLoadScriptContext, node->opcode());
87 if (new_depth == access.depth() &&
102 DCHECK_EQ(IrOpcode::kJSStoreContext, node->opcode());
106 if (new_depth == access.depth() &&
119 Node* node,
Node* new_context,
size_t new_depth) {
120 DCHECK_EQ(IrOpcode::kJSStoreScriptContext, node->opcode());
124 if (new_depth == access.depth() &&
138bool IsContextParameter(
Node* node) {
139 DCHECK_EQ(IrOpcode::kParameter, node->opcode());
149OptionalContextRef GetSpecializationContext(JSHeapBroker*
broker, Node* node,
152 switch (node->opcode()) {
153 case IrOpcode::kHeapConstant: {
162 HeapObjectRef
object =
164 if (
object.IsContext())
return object.AsContext();
167 case IrOpcode::kParameter: {
169 if (maybe_outer.
To(&outer) && IsContextParameter(node) &&
170 *distance >= outer.distance) {
171 *distance -= outer.distance;
179 return OptionalContextRef();
185 DCHECK_EQ(IrOpcode::kJSLoadContext, node->opcode());
188 size_t depth = access.depth();
193 OptionalContextRef maybe_concrete =
194 GetSpecializationContext(
broker(), context, &depth,
outer());
195 if (!maybe_concrete.has_value()) {
210 if (!access.immutable() &&
211 !
broker()->dependencies()->DependOnScriptContextSlotProperty(
221 OptionalObjectRef maybe_value;
222 maybe_value = concrete.
get(
broker(),
static_cast<int>(access.index()));
224 if (!maybe_value.has_value()) {
237 if (maybe_value->IsUndefined() || maybe_value->IsTheHole()) {
249 DCHECK_EQ(IrOpcode::kJSLoadScriptContext, node->opcode());
252 DCHECK(!access.immutable());
253 size_t depth = access.depth();
260 OptionalContextRef maybe_concrete =
261 GetSpecializationContext(
broker(), context, &depth,
outer());
262 if (!maybe_concrete.has_value()) {
278 auto maybe_property =
279 concrete.
object()->GetScriptContextSideProperty(access.index());
280 if (!maybe_property) {
284 auto property = maybe_property.value();
287 OptionalObjectRef maybe_value =
288 concrete.
get(
broker(),
static_cast<int>(access.index()));
289 if (!maybe_value.has_value()) {
297 concrete, access.index(), property,
broker());
304 concrete, access.index(), property,
broker());
313 Node* mutable_heap_number;
314 if (
auto concrete_heap_number =
315 concrete.
get(
broker(),
static_cast<int>(access.index()))) {
316 if (!concrete_heap_number->IsHeapNumber()) {
322 concrete_heap_number->AsHeapNumber(),
broker());
330 concrete, access.index(), property,
broker());
333 mutable_heap_number, effect, control);
338 Node* mutable_heap_number;
339 if (
auto concrete_heap_number =
340 concrete.
get(
broker(),
static_cast<int>(access.index()))) {
341 if (!concrete_heap_number->IsHeapNumber()) {
347 concrete_heap_number->AsHeapNumber(),
broker());
355 concrete, access.index(), property,
broker());
356 Node* double_load = effect =
359 mutable_heap_number, effect, control);
378 DCHECK_EQ(IrOpcode::kJSStoreContext, node->opcode());
381 size_t depth = access.depth();
387 OptionalContextRef maybe_concrete =
388 GetSpecializationContext(
broker(), context, &depth,
outer());
389 if (!maybe_concrete.has_value()) {
411 DCHECK_EQ(IrOpcode::kJSStoreScriptContext, node->opcode());
414 size_t depth = access.depth();
423 OptionalContextRef maybe_concrete =
424 GetSpecializationContext(
broker(), context, &depth,
outer());
425 if (!maybe_concrete.has_value()) {
440 auto maybe_property =
441 concrete.
object()->GetScriptContextSideProperty(access.index());
442 if (!maybe_property) {
446 auto property = maybe_property.value();
449 compiler::OptionalObjectRef constant =
450 concrete.
get(
broker(),
static_cast<int>(access.index()));
451 if (!constant.has_value() ||
452 (constant->IsString() && !constant->IsInternalizedString())) {
457 concrete, access.index(), property,
broker());
463 if (!
v8_flags.script_context_mutable_heap_number) {
468 jsgraph()->ConstantNoHole(concrete,
broker()), value, effect, control);
478 concrete, access.index(), property,
broker());
483 jsgraph()->ConstantNoHole(concrete,
broker()), smi_value, effect,
489 Node* mutable_heap_number;
490 if (
auto concrete_heap_number =
491 concrete.
get(
broker(),
static_cast<int>(access.index()))) {
492 if (!concrete_heap_number->IsHeapNumber()) {
498 concrete_heap_number->AsHeapNumber(),
broker());
506 concrete, access.index(), property,
broker());
512 mutable_heap_number, input_number, effect, control);
517 Node* mutable_heap_number;
518 if (
auto concrete_heap_number =
519 concrete.
get(
broker(),
static_cast<int>(access.index()))) {
520 if (!concrete_heap_number->IsHeapNumber()) {
526 concrete_heap_number->AsHeapNumber(),
broker());
534 concrete, access.index(), property,
broker());
540 mutable_heap_number, input_number, effect, control);
549 jsgraph()->ConstantNoHole(concrete,
broker()), value, effect,
561 size_t depth = std::numeric_limits<size_t>::max();
565 while (c.map(
broker).instance_type() != MODULE_CONTEXT_TYPE) {
567 c = c.previous(
broker, &depth);
573 switch (context->opcode()) {
574 case IrOpcode::kHeapConstant: {
585 if (
object.IsContext()) {
586 return find_context(
object.AsContext());
590 case IrOpcode::kParameter: {
592 if (maybe_context.
To(&outer) && IsContextParameter(context)) {
601 return OptionalContextRef();
606 if (!maybe_context.has_value())
return NoChange();
610 if (!module.has_value())
return NoChange();
611 OptionalObjectRef import_meta =
612 module->AsSourceTextModule().import_meta(broker());
613 if (!import_meta.has_value())
return NoChange();
614 if (!import_meta->IsJSObject()) {
615 DCHECK(import_meta->IsTheHole());
623 return Changed(import_meta_const);
SimplifiedOperatorBuilder * simplified
V8_WARN_UNUSED_RESULT V8_INLINE bool To(T *out) const
static FieldAccess ForContextSlotSmi(size_t index)
static FieldAccess ForHeapNumberValue()
static FieldAccess ForHeapInt32Value()
static FieldAccess ForContextSlot(size_t index)
void ReplaceWithValue(Node *node, Node *value, Node *effect=nullptr, Node *control=nullptr)
static Reduction Replace(Node *node)
bool DependOnScriptContextSlotProperty(ContextRef script_context, size_t index, ContextSidePropertyCell::Property property, JSHeapBroker *broker)
ContextRef previous(JSHeapBroker *broker, size_t *depth) const
OptionalObjectRef get(JSHeapBroker *broker, int index) const
IndirectHandle< Context > object() const
JSGraph * jsgraph() const
Reduction SimplifyJSStoreScriptContext(Node *node, Node *new_context, size_t new_depth)
Reduction ReduceParameter(Node *node)
Reduction ReduceJSLoadContext(Node *node)
MaybeHandle< JSFunction > closure() const
Reduction SimplifyJSLoadContext(Node *node, Node *new_context, size_t new_depth)
Maybe< OuterContext > outer() const
Reduction SimplifyJSLoadScriptContext(Node *node, Node *new_context, size_t new_depth)
Isolate * isolate() const
Reduction ReduceJSGetImportMeta(Node *node)
Reduction ReduceJSLoadScriptContext(Node *node)
Reduction Reduce(Node *node) final
Reduction SimplifyJSStoreContext(Node *node, Node *new_context, size_t new_depth)
JSHeapBroker * broker() const
Reduction ReduceJSStoreScriptContext(Node *node)
Reduction ReduceJSStoreContext(Node *node)
JSHeapBroker *const broker_
JSOperatorBuilder * javascript() const
SimplifiedOperatorBuilder * simplified() const
Isolate * isolate() const
Node * ConstantMutableHeapNumber(HeapNumberRef ref, JSHeapBroker *broker)
Node * ConstantNoHole(ObjectRef ref, JSHeapBroker *broker)
CompilationDependencies * dependencies() const
const Operator * LoadScriptContext(size_t depth, size_t index)
const Operator * StoreContext(size_t depth, size_t index)
const Operator * StoreScriptContext(size_t depth, size_t index)
const Operator * LoadContext(size_t depth, size_t index, bool immutable)
static constexpr int kJSCallClosureParamIndex
static void ChangeOp(Node *node, const Operator *new_op)
static Node * GetEffectInput(Node *node, int index=0)
static Node * GetContextInput(Node *node)
static void ReplaceContextInput(Node *node, Node *context)
static Node * GetValueInput(Node *node, int index)
static Node * GetOuterContext(Node *node, size_t *depth)
static Node * GetControlInput(Node *node, int index=0)
Node * BuildCheckNumberFitsInt32(Node *value, Effect *effect, Control control, FeedbackSource feedback_source=FeedbackSource())
Node * BuildCheckValue(Node *receiver, Effect *effect, Control control, ObjectRef value)
Node * BuildCheckSmi(Node *value, Effect *effect, Control control, FeedbackSource feedback_source=FeedbackSource())
Node * BuildCheckNumber(Node *value, Effect *effect, Control control, FeedbackSource feedback_source=FeedbackSource())
static Reduction Changed(Node *node)
static Reduction NoChange()
const Operator * LoadField(FieldAccess const &)
int ContextParameterIndex_MaybeNonStandardLayout() const
Node * NewNode(const Operator *op, int input_count, Node *const *inputs, bool incomplete=false)
#define TRACE_BROKER_MISSING(broker, x)
Handle< HeapObject > HeapConstantOf(const Operator *op)
int ParameterIndexOf(const Operator *const op)
ref_traits< T >::ref_type MakeRefAssumeMemoryFence(JSHeapBroker *broker, Tagged< T > object)
OptionalContextRef GetModuleContext(JSHeapBroker *broker, Node *node, Maybe< OuterContext > maybe_context)
ContextAccess const & ContextAccessOf(Operator const *op)
ref_traits< T >::ref_type MakeRef(JSHeapBroker *broker, Tagged< T > object)
V8_EXPORT_PRIVATE FlagValues v8_flags
#define DCHECK_LE(v1, v2)
#define CHECK_EQ(lhs, rhs)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
IndirectHandle< Context > context