property-access-builder.h 3.05 KB
Newer Older
1 2 3 4 5 6 7 8 9
// Copyright 2017 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.

#ifndef V8_COMPILER_PROPERTY_ACCESS_BUILDER_H_
#define V8_COMPILER_PROPERTY_ACCESS_BUILDER_H_

#include <vector>

10
#include "src/codegen/machine-type.h"
11
#include "src/compiler/js-heap-broker.h"
12
#include "src/handles/handles.h"
13 14 15 16 17 18 19 20
#include "src/objects/map.h"
#include "src/zone/zone-containers.h"

namespace v8 {
namespace internal {
namespace compiler {

class CommonOperatorBuilder;
21
class CompilationDependencies;
22 23
class Graph;
class JSGraph;
24
class JSHeapBroker;
25 26 27 28 29 30
class Node;
class PropertyAccessInfo;
class SimplifiedOperatorBuilder;

class PropertyAccessBuilder {
 public:
31
  PropertyAccessBuilder(JSGraph* jsgraph, JSHeapBroker* broker,
32
                        CompilationDependencies* dependencies)
33
      : jsgraph_(jsgraph), broker_(broker), dependencies_(dependencies) {}
34 35 36

  // Builds the appropriate string check if the maps are only string
  // maps.
37 38 39
  bool TryBuildStringCheck(JSHeapBroker* broker,
                           ZoneVector<Handle<Map>> const& maps, Node** receiver,
                           Node** effect, Node* control);
40
  // Builds a number check if all maps are number maps.
41 42 43
  bool TryBuildNumberCheck(JSHeapBroker* broker,
                           ZoneVector<Handle<Map>> const& maps, Node** receiver,
                           Node** effect, Node* control);
44 45

  void BuildCheckMaps(Node* receiver, Node** effect, Node* control,
46
                      ZoneVector<Handle<Map>> const& receiver_maps);
47 48
  Node* BuildCheckValue(Node* receiver, Node** effect, Node* control,
                        Handle<HeapObject> value);
49 50 51

  // Builds the actual load for data-field and data-constant-field
  // properties (without heap-object or map checks).
52
  Node* BuildLoadDataField(NameRef const& name,
53 54 55
                           PropertyAccessInfo const& access_info,
                           Node* receiver, Node** effect, Node** control);

56 57 58
  static MachineRepresentation ConvertRepresentation(
      Representation representation);

59 60
 private:
  JSGraph* jsgraph() const { return jsgraph_; }
61
  JSHeapBroker* broker() const { return broker_; }
62 63 64 65 66 67
  CompilationDependencies* dependencies() const { return dependencies_; }
  Graph* graph() const;
  Isolate* isolate() const;
  CommonOperatorBuilder* common() const;
  SimplifiedOperatorBuilder* simplified() const;

68
  Node* TryBuildLoadConstantDataField(NameRef const& name,
69 70 71 72 73 74 75
                                      PropertyAccessInfo const& access_info,
                                      Node* receiver);
  // Returns a node with the holder for the property access described by
  // {access_info}.
  Node* ResolveHolder(PropertyAccessInfo const& access_info, Node* receiver);

  JSGraph* jsgraph_;
76
  JSHeapBroker* broker_;
77 78 79
  CompilationDependencies* dependencies_;
};

80 81
bool HasOnlyStringMaps(JSHeapBroker* broker,
                       ZoneVector<Handle<Map>> const& maps);
82

83 84 85 86 87
}  // namespace compiler
}  // namespace internal
}  // namespace v8

#endif  // V8_COMPILER_PROPERTY_ACCESS_BUILDER_H_