11cb0ef41Sopenharmony_ci// Copyright 2012 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_CODEGEN_CODE_FACTORY_H_ 61cb0ef41Sopenharmony_ci#define V8_CODEGEN_CODE_FACTORY_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include "src/codegen/callable.h" 91cb0ef41Sopenharmony_ci#include "src/codegen/interface-descriptors.h" 101cb0ef41Sopenharmony_ci#include "src/common/globals.h" 111cb0ef41Sopenharmony_ci#include "src/objects/type-hints.h" 121cb0ef41Sopenharmony_ci#include "src/utils/allocation.h" 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_cinamespace v8 { 151cb0ef41Sopenharmony_cinamespace internal { 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci// For ArrayNoArgumentConstructor and ArraySingleArgumentConstructor. 181cb0ef41Sopenharmony_cienum AllocationSiteOverrideMode { 191cb0ef41Sopenharmony_ci DONT_OVERRIDE, 201cb0ef41Sopenharmony_ci DISABLE_ALLOCATION_SITES, 211cb0ef41Sopenharmony_ci}; 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ciclass V8_EXPORT_PRIVATE CodeFactory final { 241cb0ef41Sopenharmony_ci public: 251cb0ef41Sopenharmony_ci // CEntry has var-args semantics (all the arguments are passed on the 261cb0ef41Sopenharmony_ci // stack and the arguments count is passed via register) which currently 271cb0ef41Sopenharmony_ci // can't be expressed in CallInterfaceDescriptor. Therefore only the code 281cb0ef41Sopenharmony_ci // is exported here. 291cb0ef41Sopenharmony_ci static Handle<CodeT> RuntimeCEntry(Isolate* isolate, int result_size = 1); 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci static Handle<CodeT> CEntry( 321cb0ef41Sopenharmony_ci Isolate* isolate, int result_size = 1, 331cb0ef41Sopenharmony_ci SaveFPRegsMode save_doubles = SaveFPRegsMode::kIgnore, 341cb0ef41Sopenharmony_ci ArgvMode argv_mode = ArgvMode::kStack, bool builtin_exit_frame = false); 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci // Initial states for ICs. 371cb0ef41Sopenharmony_ci static Callable LoadGlobalIC(Isolate* isolate, TypeofMode typeof_mode); 381cb0ef41Sopenharmony_ci static Callable LoadGlobalICInOptimizedCode(Isolate* isolate, 391cb0ef41Sopenharmony_ci TypeofMode typeof_mode); 401cb0ef41Sopenharmony_ci static Callable DefineNamedOwnIC(Isolate* isolate); 411cb0ef41Sopenharmony_ci static Callable DefineNamedOwnICInOptimizedCode(Isolate* isolate); 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci static Callable ResumeGenerator(Isolate* isolate); 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci static Callable ApiGetter(Isolate* isolate); 461cb0ef41Sopenharmony_ci static Callable CallApiCallback(Isolate* isolate); 471cb0ef41Sopenharmony_ci 481cb0ef41Sopenharmony_ci static Callable NonPrimitiveToPrimitive( 491cb0ef41Sopenharmony_ci Isolate* isolate, ToPrimitiveHint hint = ToPrimitiveHint::kDefault); 501cb0ef41Sopenharmony_ci static Callable OrdinaryToPrimitive(Isolate* isolate, 511cb0ef41Sopenharmony_ci OrdinaryToPrimitiveHint hint); 521cb0ef41Sopenharmony_ci 531cb0ef41Sopenharmony_ci static Callable StringAdd(Isolate* isolate, 541cb0ef41Sopenharmony_ci StringAddFlags flags = STRING_ADD_CHECK_NONE); 551cb0ef41Sopenharmony_ci 561cb0ef41Sopenharmony_ci static Callable FastNewFunctionContext(Isolate* isolate, 571cb0ef41Sopenharmony_ci ScopeType scope_type); 581cb0ef41Sopenharmony_ci 591cb0ef41Sopenharmony_ci static Callable Call(Isolate* isolate, 601cb0ef41Sopenharmony_ci ConvertReceiverMode mode = ConvertReceiverMode::kAny); 611cb0ef41Sopenharmony_ci static Callable Call_WithFeedback(Isolate* isolate, ConvertReceiverMode mode); 621cb0ef41Sopenharmony_ci static Callable CallWithArrayLike(Isolate* isolate); 631cb0ef41Sopenharmony_ci static Callable CallWithSpread(Isolate* isolate); 641cb0ef41Sopenharmony_ci static Callable CallFunction( 651cb0ef41Sopenharmony_ci Isolate* isolate, ConvertReceiverMode mode = ConvertReceiverMode::kAny); 661cb0ef41Sopenharmony_ci static Callable CallVarargs(Isolate* isolate); 671cb0ef41Sopenharmony_ci static Callable CallForwardVarargs(Isolate* isolate); 681cb0ef41Sopenharmony_ci static Callable CallFunctionForwardVarargs(Isolate* isolate); 691cb0ef41Sopenharmony_ci static Callable Construct(Isolate* isolate); 701cb0ef41Sopenharmony_ci static Callable ConstructWithSpread(Isolate* isolate); 711cb0ef41Sopenharmony_ci static Callable ConstructFunction(Isolate* isolate); 721cb0ef41Sopenharmony_ci static Callable ConstructVarargs(Isolate* isolate); 731cb0ef41Sopenharmony_ci static Callable ConstructForwardVarargs(Isolate* isolate); 741cb0ef41Sopenharmony_ci static Callable ConstructFunctionForwardVarargs(Isolate* isolate); 751cb0ef41Sopenharmony_ci 761cb0ef41Sopenharmony_ci static Callable InterpreterPushArgsThenCall(Isolate* isolate, 771cb0ef41Sopenharmony_ci ConvertReceiverMode receiver_mode, 781cb0ef41Sopenharmony_ci InterpreterPushArgsMode mode); 791cb0ef41Sopenharmony_ci static Callable InterpreterPushArgsThenConstruct( 801cb0ef41Sopenharmony_ci Isolate* isolate, InterpreterPushArgsMode mode); 811cb0ef41Sopenharmony_ci static Callable InterpreterCEntry(Isolate* isolate, int result_size = 1); 821cb0ef41Sopenharmony_ci static Callable InterpreterOnStackReplacement(Isolate* isolate); 831cb0ef41Sopenharmony_ci static Callable InterpreterOnStackReplacement_ToBaseline(Isolate* isolate); 841cb0ef41Sopenharmony_ci 851cb0ef41Sopenharmony_ci static Callable ArrayNoArgumentConstructor( 861cb0ef41Sopenharmony_ci Isolate* isolate, ElementsKind kind, 871cb0ef41Sopenharmony_ci AllocationSiteOverrideMode override_mode); 881cb0ef41Sopenharmony_ci static Callable ArraySingleArgumentConstructor( 891cb0ef41Sopenharmony_ci Isolate* isolate, ElementsKind kind, 901cb0ef41Sopenharmony_ci AllocationSiteOverrideMode override_mode); 911cb0ef41Sopenharmony_ci 921cb0ef41Sopenharmony_ci#ifdef V8_IS_TSAN 931cb0ef41Sopenharmony_ci static Builtin GetTSANStoreStub(SaveFPRegsMode fp_mode, int size, 941cb0ef41Sopenharmony_ci std::memory_order order); 951cb0ef41Sopenharmony_ci static Builtin GetTSANRelaxedLoadStub(SaveFPRegsMode fp_mode, int size); 961cb0ef41Sopenharmony_ci#endif // V8_IS_TSAN 971cb0ef41Sopenharmony_ci}; 981cb0ef41Sopenharmony_ci 991cb0ef41Sopenharmony_ci} // namespace internal 1001cb0ef41Sopenharmony_ci} // namespace v8 1011cb0ef41Sopenharmony_ci 1021cb0ef41Sopenharmony_ci#endif // V8_CODEGEN_CODE_FACTORY_H_ 103