• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 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_TORQUE_CSA_GENERATOR_H_
6 #define V8_TORQUE_CSA_GENERATOR_H_
7 
8 #include "src/torque/torque-code-generator.h"
9 
10 namespace v8 {
11 namespace internal {
12 namespace torque {
13 
14 class CSAGenerator : public TorqueCodeGenerator {
15  public:
16   CSAGenerator(const ControlFlowGraph& cfg, std::ostream& out,
17                base::Optional<Builtin::Kind> linkage = base::nullopt)
TorqueCodeGenerator(cfg,out)18       : TorqueCodeGenerator(cfg, out), linkage_(linkage) {}
19   base::Optional<Stack<std::string>> EmitGraph(Stack<std::string> parameters);
20 
21   static constexpr const char* ARGUMENTS_VARIABLE_STRING = "arguments";
22 
23   static void EmitCSAValue(VisitResult result, const Stack<std::string>& values,
24                            std::ostream& out);
25 
26  private:
27   base::Optional<Builtin::Kind> linkage_;
28 
29   void EmitSourcePosition(SourcePosition pos,
30                           bool always_emit = false) override;
31 
32   std::string PreCallableExceptionPreparation(
33       base::Optional<Block*> catch_block);
34   void PostCallableExceptionPreparation(
35       const std::string& catch_name, const Type* return_type,
36       base::Optional<Block*> catch_block, Stack<std::string>* stack,
37       const base::Optional<DefinitionLocation>& exception_object_definition);
38 
39   std::vector<std::string> ProcessArgumentsCommon(
40       const TypeVector& parameter_types,
41       std::vector<std::string> constexpr_arguments, Stack<std::string>* stack);
42 
43   Stack<std::string> EmitBlock(const Block* block);
44 #define EMIT_INSTRUCTION_DECLARATION(T)                                 \
45   void EmitInstruction(const T& instruction, Stack<std::string>* stack) \
46       override;
47   TORQUE_BACKEND_DEPENDENT_INSTRUCTION_LIST(EMIT_INSTRUCTION_DECLARATION)
48 #undef EMIT_INSTRUCTION_DECLARATION
49 };
50 
51 }  // namespace torque
52 }  // namespace internal
53 }  // namespace v8
54 
55 #endif  // V8_TORQUE_CSA_GENERATOR_H_
56