11cb0ef41Sopenharmony_ci// Copyright 2017 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#ifndef V8_COMPILER_PROPERTY_ACCESS_BUILDER_H_ 61cb0ef41Sopenharmony_ci#define V8_COMPILER_PROPERTY_ACCESS_BUILDER_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include "src/base/optional.h" 91cb0ef41Sopenharmony_ci#include "src/codegen/machine-type.h" 101cb0ef41Sopenharmony_ci#include "src/compiler/js-heap-broker.h" 111cb0ef41Sopenharmony_ci#include "src/compiler/node.h" 121cb0ef41Sopenharmony_ci#include "src/handles/handles.h" 131cb0ef41Sopenharmony_ci#include "src/objects/map.h" 141cb0ef41Sopenharmony_ci#include "src/zone/zone-containers.h" 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_cinamespace v8 { 171cb0ef41Sopenharmony_cinamespace internal { 181cb0ef41Sopenharmony_cinamespace compiler { 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ciclass CommonOperatorBuilder; 211cb0ef41Sopenharmony_ciclass CompilationDependencies; 221cb0ef41Sopenharmony_ciclass Graph; 231cb0ef41Sopenharmony_ciclass JSGraph; 241cb0ef41Sopenharmony_ciclass JSHeapBroker; 251cb0ef41Sopenharmony_ciclass PropertyAccessInfo; 261cb0ef41Sopenharmony_ciclass SimplifiedOperatorBuilder; 271cb0ef41Sopenharmony_cistruct FieldAccess; 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ciclass PropertyAccessBuilder { 301cb0ef41Sopenharmony_ci public: 311cb0ef41Sopenharmony_ci PropertyAccessBuilder(JSGraph* jsgraph, JSHeapBroker* broker, 321cb0ef41Sopenharmony_ci CompilationDependencies* dependencies) 331cb0ef41Sopenharmony_ci : jsgraph_(jsgraph), broker_(broker), dependencies_(dependencies) {} 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci // Builds the appropriate string check if the maps are only string 361cb0ef41Sopenharmony_ci // maps. 371cb0ef41Sopenharmony_ci bool TryBuildStringCheck(JSHeapBroker* broker, ZoneVector<MapRef> const& maps, 381cb0ef41Sopenharmony_ci Node** receiver, Effect* effect, Control control); 391cb0ef41Sopenharmony_ci // Builds a number check if all maps are number maps. 401cb0ef41Sopenharmony_ci bool TryBuildNumberCheck(JSHeapBroker* broker, ZoneVector<MapRef> const& maps, 411cb0ef41Sopenharmony_ci Node** receiver, Effect* effect, Control control); 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci void BuildCheckMaps(Node* object, Effect* effect, Control control, 441cb0ef41Sopenharmony_ci ZoneVector<MapRef> const& maps); 451cb0ef41Sopenharmony_ci 461cb0ef41Sopenharmony_ci Node* BuildCheckValue(Node* receiver, Effect* effect, Control control, 471cb0ef41Sopenharmony_ci Handle<HeapObject> value); 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ci // Builds the actual load for data-field and data-constant-field 501cb0ef41Sopenharmony_ci // properties (without heap-object or map checks). 511cb0ef41Sopenharmony_ci Node* BuildLoadDataField(NameRef const& name, 521cb0ef41Sopenharmony_ci PropertyAccessInfo const& access_info, 531cb0ef41Sopenharmony_ci Node* lookup_start_object, Node** effect, 541cb0ef41Sopenharmony_ci Node** control); 551cb0ef41Sopenharmony_ci 561cb0ef41Sopenharmony_ci // Tries to load a constant value from a prototype object in dictionary mode 571cb0ef41Sopenharmony_ci // and constant-folds it. Returns {} if the constant couldn't be safely 581cb0ef41Sopenharmony_ci // retrieved. 591cb0ef41Sopenharmony_ci base::Optional<Node*> FoldLoadDictPrototypeConstant( 601cb0ef41Sopenharmony_ci PropertyAccessInfo const& access_info); 611cb0ef41Sopenharmony_ci 621cb0ef41Sopenharmony_ci static MachineRepresentation ConvertRepresentation( 631cb0ef41Sopenharmony_ci Representation representation); 641cb0ef41Sopenharmony_ci 651cb0ef41Sopenharmony_ci private: 661cb0ef41Sopenharmony_ci JSGraph* jsgraph() const { return jsgraph_; } 671cb0ef41Sopenharmony_ci JSHeapBroker* broker() const { return broker_; } 681cb0ef41Sopenharmony_ci CompilationDependencies* dependencies() const { return dependencies_; } 691cb0ef41Sopenharmony_ci Graph* graph() const; 701cb0ef41Sopenharmony_ci Isolate* isolate() const; 711cb0ef41Sopenharmony_ci CommonOperatorBuilder* common() const; 721cb0ef41Sopenharmony_ci SimplifiedOperatorBuilder* simplified() const; 731cb0ef41Sopenharmony_ci 741cb0ef41Sopenharmony_ci Node* TryFoldLoadConstantDataField(NameRef const& name, 751cb0ef41Sopenharmony_ci PropertyAccessInfo const& access_info, 761cb0ef41Sopenharmony_ci Node* lookup_start_object); 771cb0ef41Sopenharmony_ci // Returns a node with the holder for the property access described by 781cb0ef41Sopenharmony_ci // {access_info}. 791cb0ef41Sopenharmony_ci Node* ResolveHolder(PropertyAccessInfo const& access_info, 801cb0ef41Sopenharmony_ci Node* lookup_start_object); 811cb0ef41Sopenharmony_ci 821cb0ef41Sopenharmony_ci Node* BuildLoadDataField(NameRef const& name, Node* holder, 831cb0ef41Sopenharmony_ci FieldAccess& field_access, bool is_inobject, 841cb0ef41Sopenharmony_ci Node** effect, Node** control); 851cb0ef41Sopenharmony_ci 861cb0ef41Sopenharmony_ci JSGraph* jsgraph_; 871cb0ef41Sopenharmony_ci JSHeapBroker* broker_; 881cb0ef41Sopenharmony_ci CompilationDependencies* dependencies_; 891cb0ef41Sopenharmony_ci}; 901cb0ef41Sopenharmony_ci 911cb0ef41Sopenharmony_cibool HasOnlyStringMaps(JSHeapBroker* broker, ZoneVector<MapRef> const& maps); 921cb0ef41Sopenharmony_ci 931cb0ef41Sopenharmony_ci} // namespace compiler 941cb0ef41Sopenharmony_ci} // namespace internal 951cb0ef41Sopenharmony_ci} // namespace v8 961cb0ef41Sopenharmony_ci 971cb0ef41Sopenharmony_ci#endif // V8_COMPILER_PROPERTY_ACCESS_BUILDER_H_ 98