Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: runtime/vm/kernel.h

Issue 2792333002: Add Kernel AST nodes for Vector and Closure primitives in VM (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/kernel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_KERNEL_H_ 5 #ifndef RUNTIME_VM_KERNEL_H_
6 #define RUNTIME_VM_KERNEL_H_ 6 #define RUNTIME_VM_KERNEL_H_
7 7
8 #if !defined(DART_PRECOMPILED_RUNTIME) 8 #if !defined(DART_PRECOMPILED_RUNTIME)
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/allocation.h" 10 #include "vm/allocation.h"
11 #include "vm/globals.h" 11 #include "vm/globals.h"
12 #include "vm/growable_array.h" 12 #include "vm/growable_array.h"
13 #include "vm/token_position.h" 13 #include "vm/token_position.h"
14 14
15 15
16 #define KERNEL_NODES_DO(M) \ 16 #define KERNEL_NODES_DO(M) \
17 M(Name) \ 17 M(Name) \
18 M(DartType) \ 18 M(DartType) \
19 M(InvalidType) \ 19 M(InvalidType) \
20 M(DynamicType) \ 20 M(DynamicType) \
21 M(VoidType) \ 21 M(VoidType) \
22 M(InterfaceType) \ 22 M(InterfaceType) \
23 M(FunctionType) \ 23 M(FunctionType) \
24 M(TypeParameterType) 24 M(TypeParameterType) \
25 M(VectorType)
25 26
26 #define KERNEL_TREE_NODES_DO(M) \ 27 #define KERNEL_TREE_NODES_DO(M) \
27 M(Library) \ 28 M(Library) \
28 M(Class) \ 29 M(Class) \
29 M(NormalClass) \ 30 M(NormalClass) \
30 M(MixinClass) \ 31 M(MixinClass) \
31 M(Member) \ 32 M(Member) \
32 M(Field) \ 33 M(Field) \
33 M(Constructor) \ 34 M(Constructor) \
34 M(Procedure) \ 35 M(Procedure) \
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 M(TypeLiteral) \ 73 M(TypeLiteral) \
73 M(ThisExpression) \ 74 M(ThisExpression) \
74 M(Rethrow) \ 75 M(Rethrow) \
75 M(Throw) \ 76 M(Throw) \
76 M(ListLiteral) \ 77 M(ListLiteral) \
77 M(MapLiteral) \ 78 M(MapLiteral) \
78 M(MapEntry) \ 79 M(MapEntry) \
79 M(AwaitExpression) \ 80 M(AwaitExpression) \
80 M(FunctionExpression) \ 81 M(FunctionExpression) \
81 M(Let) \ 82 M(Let) \
83 M(VectorCreation) \
84 M(VectorGet) \
85 M(VectorSet) \
86 M(VectorCopy) \
87 M(ClosureCreation) \
82 M(Statement) \ 88 M(Statement) \
83 M(InvalidStatement) \ 89 M(InvalidStatement) \
84 M(ExpressionStatement) \ 90 M(ExpressionStatement) \
85 M(Block) \ 91 M(Block) \
86 M(EmptyStatement) \ 92 M(EmptyStatement) \
87 M(AssertStatement) \ 93 M(AssertStatement) \
88 M(LabeledStatement) \ 94 M(LabeledStatement) \
89 M(BreakStatement) \ 95 M(BreakStatement) \
90 M(WhileStatement) \ 96 M(WhileStatement) \
91 M(DoStatement) \ 97 M(DoStatement) \
(...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 1927
1922 Child<VariableDeclaration> variable_; 1928 Child<VariableDeclaration> variable_;
1923 Child<Expression> body_; 1929 Child<Expression> body_;
1924 TokenPosition position_; 1930 TokenPosition position_;
1925 TokenPosition end_position_; 1931 TokenPosition end_position_;
1926 1932
1927 DISALLOW_COPY_AND_ASSIGN(Let); 1933 DISALLOW_COPY_AND_ASSIGN(Let);
1928 }; 1934 };
1929 1935
1930 1936
1937 class VectorCreation : public Expression {
1938 public:
1939 static VectorCreation* ReadFrom(Reader* reader);
1940
1941 virtual ~VectorCreation();
1942
1943 DEFINE_CASTING_OPERATIONS(VectorCreation);
1944
1945 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
1946 virtual void VisitChildren(Visitor* visitor);
1947
1948 int64_t value() { return value_; }
1949 TokenPosition position() { return position_; }
1950 TokenPosition end_position() { return end_position_; }
1951
1952 private:
1953 VectorCreation()
1954 : position_(TokenPosition::kNoSource),
1955 end_position_(TokenPosition::kNoSource) {}
1956
1957 int64_t value_;
Kevin Millikin (Google) 2017/04/04 11:29:33 Use intptr_t, here and elsewhere.
Dmitry Stefantsov 2017/04/04 12:51:13 Done.
1958 TokenPosition position_;
Kevin Millikin (Google) 2017/04/04 11:29:34 This does not need a token position or an end toke
Dmitry Stefantsov 2017/04/04 12:51:13 No, I guess not. Thanks! Done.
1959 TokenPosition end_position_;
1960
1961 DISALLOW_COPY_AND_ASSIGN(VectorCreation);
1962 };
1963
1964
1965 class VectorGet : public Expression {
1966 public:
1967 static VectorGet* ReadFrom(Reader* reader);
1968
1969 virtual ~VectorGet();
1970
1971 DEFINE_CASTING_OPERATIONS(VectorGet);
1972
1973 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
1974 virtual void VisitChildren(Visitor* visitor);
1975
1976 Expression* vector_expression() { return vector_expression_; }
1977 int64_t index() { return index_; }
1978 TokenPosition position() { return position_; }
1979 TokenPosition end_position() { return end_position_; }
1980
1981 private:
1982 VectorGet()
1983 : position_(TokenPosition::kNoSource),
1984 end_position_(TokenPosition::kNoSource) {}
1985
1986 Child<Expression> vector_expression_;
Kevin Millikin (Google) 2017/04/04 11:29:33 Is it the case that this is always a VariableGet,
Dmitry Stefantsov 2017/04/04 12:51:13 Actually, it's not always VariableGet. In case of
1987 int64_t index_;
Kevin Millikin (Google) 2017/04/04 11:29:34 intptr_t
Dmitry Stefantsov 2017/04/04 12:51:13 Done.
1988 TokenPosition position_;
Kevin Millikin (Google) 2017/04/04 11:29:34 We don't need these token positions.
Dmitry Stefantsov 2017/04/04 12:51:13 I guess we may want these, because they replace va
1989 TokenPosition end_position_;
1990
1991 DISALLOW_COPY_AND_ASSIGN(VectorGet);
1992 };
1993
1994
1995 class VectorSet : public Expression {
1996 public:
1997 static VectorSet* ReadFrom(Reader* reader);
1998
1999 virtual ~VectorSet();
2000
2001 DEFINE_CASTING_OPERATIONS(VectorSet);
2002
2003 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
2004 virtual void VisitChildren(Visitor* visitor);
2005
2006 Expression* vector_expression() { return vector_expression_; }
2007 int64_t index() { return index_; }
2008 Expression* value() { return value_; }
2009 TokenPosition position() { return position_; }
2010 TokenPosition end_position() { return end_position_; }
2011
2012 private:
2013 VectorSet()
2014 : position_(TokenPosition::kNoSource),
2015 end_position_(TokenPosition::kNoSource) {}
2016
2017 Child<Expression> vector_expression_;
2018 int64_t index_;
Kevin Millikin (Google) 2017/04/04 11:29:33 intptr_t
Dmitry Stefantsov 2017/04/04 12:51:13 Done.
2019 Child<Expression> value_;
2020 TokenPosition position_;
Kevin Millikin (Google) 2017/04/04 11:29:34 I guess this will need a position and possibly two
Dmitry Stefantsov 2017/04/04 12:51:13 Agree. Done.
2021 TokenPosition end_position_;
2022
2023 DISALLOW_COPY_AND_ASSIGN(VectorSet);
2024 };
2025
2026
2027 class VectorCopy : public Expression {
2028 public:
2029 static VectorCopy* ReadFrom(Reader* reader);
2030
2031 virtual ~VectorCopy();
2032
2033 DEFINE_CASTING_OPERATIONS(VectorCopy);
2034
2035 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
2036 virtual void VisitChildren(Visitor* visitor);
2037
2038 Expression* vector_expression() { return vector_expression_; }
2039 TokenPosition position() { return position_; }
2040 TokenPosition end_position() { return end_position_; }
2041
2042 private:
2043 VectorCopy()
2044 : position_(TokenPosition::kNoSource),
2045 end_position_(TokenPosition::kNoSource) {}
2046
2047 Child<Expression> vector_expression_;
2048 TokenPosition position_;
Kevin Millikin (Google) 2017/04/04 11:29:34 We shouldn't need these positions.
Dmitry Stefantsov 2017/04/04 12:51:13 Agree. Done.
2049 TokenPosition end_position_;
2050
2051 DISALLOW_COPY_AND_ASSIGN(VectorCopy);
2052 };
2053
2054
2055 class ClosureCreation : public Expression {
2056 public:
2057 static ClosureCreation* ReadFrom(Reader* reader);
2058
2059 virtual ~ClosureCreation();
2060
2061 DEFINE_CASTING_OPERATIONS(ClosureCreation);
2062
2063 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
2064 virtual void VisitChildren(Visitor* visitor);
2065
2066 CanonicalName* top_level_function_reference() {
Kevin Millikin (Google) 2017/04/04 11:29:33 For consistency, we don't usually put _reference i
Dmitry Stefantsov 2017/04/04 12:51:13 Somehow I've missed this convention. Thanks! Fixed
2067 return top_level_function_reference_;
2068 }
2069 Expression* context_vector() { return context_vector_; }
2070 FunctionType* function_type() { return function_type_; }
2071 TokenPosition position() { return position_; }
2072 TokenPosition end_position() { return end_position_; }
2073
2074 private:
2075 ClosureCreation()
2076 : position_(TokenPosition::kNoSource),
2077 end_position_(TokenPosition::kNoSource) {}
2078
2079 Ref<CanonicalName> top_level_function_reference_; // Procedure.
2080 Child<Expression> context_vector_;
2081 Child<FunctionType> function_type_;
2082 TokenPosition position_;
Kevin Millikin (Google) 2017/04/04 11:29:34 I don't think we need these positions.
Dmitry Stefantsov 2017/04/04 12:51:13 Done.
2083 TokenPosition end_position_;
2084
2085 DISALLOW_COPY_AND_ASSIGN(ClosureCreation);
2086 };
2087
2088
1931 class Statement : public TreeNode { 2089 class Statement : public TreeNode {
1932 public: 2090 public:
1933 static Statement* ReadFrom(Reader* reader); 2091 static Statement* ReadFrom(Reader* reader);
1934 2092
1935 virtual ~Statement(); 2093 virtual ~Statement();
1936 2094
1937 DEFINE_CASTING_OPERATIONS(Statement); 2095 DEFINE_CASTING_OPERATIONS(Statement);
1938 2096
1939 virtual void AcceptTreeVisitor(TreeVisitor* visitor); 2097 virtual void AcceptTreeVisitor(TreeVisitor* visitor);
1940 virtual void AcceptStatementVisitor(StatementVisitor* visitor) = 0; 2098 virtual void AcceptStatementVisitor(StatementVisitor* visitor) = 0;
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
2696 2854
2697 private: 2855 private:
2698 TypeParameterType() {} 2856 TypeParameterType() {}
2699 2857
2700 Ref<TypeParameter> parameter_; 2858 Ref<TypeParameter> parameter_;
2701 2859
2702 DISALLOW_COPY_AND_ASSIGN(TypeParameterType); 2860 DISALLOW_COPY_AND_ASSIGN(TypeParameterType);
2703 }; 2861 };
2704 2862
2705 2863
2864 class VectorType : public DartType {
2865 public:
2866 static VectorType* ReadFrom(Reader* reader);
2867
2868 virtual ~VectorType();
2869
2870 DEFINE_CASTING_OPERATIONS(VectorType);
2871
2872 virtual void AcceptDartTypeVisitor(DartTypeVisitor* visitor);
2873 virtual void VisitChildren(Visitor* visitor);
2874
2875 private:
2876 VectorType() {}
2877
2878 DISALLOW_COPY_AND_ASSIGN(VectorType);
2879 };
2880
2881
2706 class TypeParameter : public TreeNode { 2882 class TypeParameter : public TreeNode {
2707 public: 2883 public:
2708 TypeParameter* ReadFrom(Reader* reader); 2884 TypeParameter* ReadFrom(Reader* reader);
2709 2885
2710 virtual ~TypeParameter(); 2886 virtual ~TypeParameter();
2711 2887
2712 DEFINE_CASTING_OPERATIONS(TypeParameter); 2888 DEFINE_CASTING_OPERATIONS(TypeParameter);
2713 2889
2714 virtual void AcceptTreeVisitor(TreeVisitor* visitor); 2890 virtual void AcceptTreeVisitor(TreeVisitor* visitor);
2715 virtual void VisitChildren(Visitor* visitor); 2891 virtual void VisitChildren(Visitor* visitor);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2869 virtual void VisitDoubleLiteral(DoubleLiteral* node) { 3045 virtual void VisitDoubleLiteral(DoubleLiteral* node) {
2870 VisitDefaultBasicLiteral(node); 3046 VisitDefaultBasicLiteral(node);
2871 } 3047 }
2872 virtual void VisitBoolLiteral(BoolLiteral* node) { 3048 virtual void VisitBoolLiteral(BoolLiteral* node) {
2873 VisitDefaultBasicLiteral(node); 3049 VisitDefaultBasicLiteral(node);
2874 } 3050 }
2875 virtual void VisitNullLiteral(NullLiteral* node) { 3051 virtual void VisitNullLiteral(NullLiteral* node) {
2876 VisitDefaultBasicLiteral(node); 3052 VisitDefaultBasicLiteral(node);
2877 } 3053 }
2878 virtual void VisitLet(Let* node) { VisitDefaultExpression(node); } 3054 virtual void VisitLet(Let* node) { VisitDefaultExpression(node); }
3055 virtual void VisitVectorCreation(VectorCreation* node) {
3056 VisitDefaultExpression(node);
3057 }
3058 virtual void VisitVectorGet(VectorGet* node) { VisitDefaultExpression(node); }
3059 virtual void VisitVectorSet(VectorSet* node) { VisitDefaultExpression(node); }
3060 virtual void VisitVectorCopy(VectorCopy* node) {
3061 VisitDefaultExpression(node);
3062 }
3063 virtual void VisitClosureCreation(ClosureCreation* node) {
3064 VisitDefaultExpression(node);
3065 }
2879 }; 3066 };
2880 3067
2881 3068
2882 class StatementVisitor { 3069 class StatementVisitor {
2883 public: 3070 public:
2884 virtual ~StatementVisitor() {} 3071 virtual ~StatementVisitor() {}
2885 3072
2886 virtual void VisitDefaultStatement(Statement* node) = 0; 3073 virtual void VisitDefaultStatement(Statement* node) = 0;
2887 virtual void VisitInvalidStatement(InvalidStatement* node) { 3074 virtual void VisitInvalidStatement(InvalidStatement* node) {
2888 VisitDefaultStatement(node); 3075 VisitDefaultStatement(node);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
3001 virtual void VisitVoidType(VoidType* node) { VisitDefaultDartType(node); } 3188 virtual void VisitVoidType(VoidType* node) { VisitDefaultDartType(node); }
3002 virtual void VisitInterfaceType(InterfaceType* node) { 3189 virtual void VisitInterfaceType(InterfaceType* node) {
3003 VisitDefaultDartType(node); 3190 VisitDefaultDartType(node);
3004 } 3191 }
3005 virtual void VisitFunctionType(FunctionType* node) { 3192 virtual void VisitFunctionType(FunctionType* node) {
3006 VisitDefaultDartType(node); 3193 VisitDefaultDartType(node);
3007 } 3194 }
3008 virtual void VisitTypeParameterType(TypeParameterType* node) { 3195 virtual void VisitTypeParameterType(TypeParameterType* node) {
3009 VisitDefaultDartType(node); 3196 VisitDefaultDartType(node);
3010 } 3197 }
3198 virtual void VisitVectorType(VectorType* node) { VisitDefaultDartType(node); }
3011 }; 3199 };
3012 3200
3013 3201
3014 class TreeVisitor : public ExpressionVisitor, 3202 class TreeVisitor : public ExpressionVisitor,
3015 public StatementVisitor, 3203 public StatementVisitor,
3016 public MemberVisitor, 3204 public MemberVisitor,
3017 public ClassVisitor, 3205 public ClassVisitor,
3018 public InitializerVisitor { 3206 public InitializerVisitor {
3019 public: 3207 public:
3020 virtual ~TreeVisitor() {} 3208 virtual ~TreeVisitor() {}
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
3146 3334
3147 ParsedFunction* ParseStaticFieldInitializer(Zone* zone, 3335 ParsedFunction* ParseStaticFieldInitializer(Zone* zone,
3148 const dart::Field& field); 3336 const dart::Field& field);
3149 3337
3150 } // namespace kernel 3338 } // namespace kernel
3151 3339
3152 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, 3340 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer,
3153 intptr_t buffer_length); 3341 intptr_t buffer_length);
3154 3342
3155 3343
3156
3157 } // namespace dart 3344 } // namespace dart
3158 3345
3159 #endif // !defined(DART_PRECOMPILED_RUNTIME) 3346 #endif // !defined(DART_PRECOMPILED_RUNTIME)
3160 #endif // RUNTIME_VM_KERNEL_H_ 3347 #endif // RUNTIME_VM_KERNEL_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/kernel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698