v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
map-inference.h
Go to the documentation of this file.
1// Copyright 2019 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_COMPILER_MAP_INFERENCE_H_
6#define V8_COMPILER_MAP_INFERENCE_H_
7
10#include "src/objects/map.h"
11
12namespace v8 {
13namespace internal {
14
15namespace compiler {
16
17class CompilationDependencies;
18struct FeedbackSource;
19class JSGraph;
20class JSHeapBroker;
21class Node;
22
23// The MapInference class provides access to the "inferred" maps of an
24// {object}. This information can be either "reliable", meaning that the object
25// is guaranteed to have one of these maps at runtime, or "unreliable", meaning
26// that the object is guaranteed to have HAD one of these maps.
27//
28// The MapInference class does not expose whether or not the information is
29// reliable. A client is expected to eventually make the information reliable by
30// calling one of several methods that will either insert map checks, or record
31// stability dependencies (or do nothing if the information was already
32// reliable).
34 public:
35 MapInference(JSHeapBroker* broker, Node* object, Effect effect);
36
37 // The destructor checks that the information has been made reliable (if
38 // necessary) and force-crashes if not.
40
41 // Is there any information at all?
43
44 // These queries don't require a guard.
45 //
47 // Here, {type} must not be a String type.
50
51 // These queries require a guard. (Even instance types are generally not
52 // reliable because of how the representation of a string can change.)
55 std::function<bool(InstanceType)> f);
56 V8_WARN_UNUSED_RESULT bool Is(MapRef expected_map);
57
58 // These methods provide a guard.
59 //
60 // Returns true iff maps were already reliable or stability dependencies were
61 // successfully recorded.
63 CompilationDependencies* dependencies);
64 // Records stability dependencies if possible, otherwise it inserts map
65 // checks. Does nothing if maps were already reliable. Returns true iff
66 // dependencies were taken.
68 JSGraph* jsgraph, Effect* effect,
69 Control control,
70 const FeedbackSource& feedback);
71 // Inserts map checks even if maps were already reliable.
72 void InsertMapChecks(JSGraph* jsgraph, Effect* effect, Control control,
73 const FeedbackSource& feedback);
74
75 // Internally marks the maps as reliable (thus bypassing the safety check) and
76 // returns the NoChange reduction. USE THIS ONLY WHEN RETURNING, e.g.:
77 // if (foo) return inference.NoChange();
79
80 private:
82 Node* const object_;
83
85 enum {
90
91 bool Safe() const;
93 void SetGuarded();
94
96 std::function<bool(InstanceType)> f) const;
98 std::function<bool(InstanceType)> f) const;
100 CompilationDependencies* dependencies, JSGraph* jsgraph, Effect* effect,
101 Control control, const FeedbackSource& feedback);
102};
103
104} // namespace compiler
105} // namespace internal
106} // namespace v8
107
108#endif // V8_COMPILER_MAP_INFERENCE_H_
JSGraph * jsgraph
V8_WARN_UNUSED_RESULT bool Is(MapRef expected_map)
bool RelyOnMapsPreferStability(CompilationDependencies *dependencies, JSGraph *jsgraph, Effect *effect, Control control, const FeedbackSource &feedback)
enum v8::internal::compiler::MapInference::@47 maps_state_
V8_WARN_UNUSED_RESULT bool AllOfInstanceTypesUnsafe(std::function< bool(InstanceType)> f) const
V8_WARN_UNUSED_RESULT bool RelyOnMapsViaStability(CompilationDependencies *dependencies)
V8_WARN_UNUSED_RESULT ZoneRefSet< Map > const & GetMaps()
V8_WARN_UNUSED_RESULT bool AllOfInstanceTypesAre(InstanceType type) const
MapInference(JSHeapBroker *broker, Node *object, Effect effect)
V8_WARN_UNUSED_RESULT Reduction NoChange()
void InsertMapChecks(JSGraph *jsgraph, Effect *effect, Control control, const FeedbackSource &feedback)
V8_WARN_UNUSED_RESULT bool RelyOnMapsHelper(CompilationDependencies *dependencies, JSGraph *jsgraph, Effect *effect, Control control, const FeedbackSource &feedback)
V8_WARN_UNUSED_RESULT bool AnyOfInstanceTypesUnsafe(std::function< bool(InstanceType)> f) const
V8_WARN_UNUSED_RESULT bool HaveMaps() const
V8_WARN_UNUSED_RESULT bool AllOfInstanceTypesAreJSReceiver() const
V8_WARN_UNUSED_RESULT bool AnyOfInstanceTypesAre(InstanceType type) const
V8_WARN_UNUSED_RESULT bool AllOfInstanceTypes(std::function< bool(InstanceType)> f)
JSHeapBroker * broker
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:671