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

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

Issue 2783183002: Stream DoubleLiteral (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
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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_BINARY_FLOWGRAPH_H_ 5 #ifndef RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_
6 #define RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ 6 #define RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_
7 7
8 #if !defined(DART_PRECOMPILED_RUNTIME) 8 #if !defined(DART_PRECOMPILED_RUNTIME)
9 9
10 #include <map> 10 #include <map>
11 11
12 #include "vm/kernel.h" 12 #include "vm/kernel.h"
13 #include "vm/kernel_binary.h" 13 #include "vm/kernel_binary.h"
14 #include "vm/kernel_to_il.h" 14 #include "vm/kernel_to_il.h"
15 #include "vm/object.h" 15 #include "vm/object.h"
16 16
17 namespace dart { 17 namespace dart {
18 namespace kernel { 18 namespace kernel {
19 19
20 class StreamingConstantEvaluator {
21 public:
22 StreamingConstantEvaluator(StreamingFlowGraphBuilder* builder,
23 Zone* zone,
24 TranslationHelper* h,
25 DartTypeTranslator* type_translator);
26
27 virtual ~StreamingConstantEvaluator() {}
28
29 Instance& EvaluateExpression();
30 void EvaluateDoubleLiteral();
31
32 private:
33 bool GetCachedConstant(intptr_t kernel_offset, Instance* value);
34 void CacheConstantValue(intptr_t kernel_offset, const Instance& value);
35
36 StreamingFlowGraphBuilder* builder_;
37 Isolate* isolate_;
38 Zone* zone_;
39 TranslationHelper& translation_helper_;
40 // DartTypeTranslator& type_translator_;
41
42 Script& script_;
43 Instance& result_;
44 };
45
20 class StreamingFlowGraphBuilder { 46 class StreamingFlowGraphBuilder {
21 public: 47 public:
22 StreamingFlowGraphBuilder(FlowGraphBuilder* flowGraph_builder, 48 StreamingFlowGraphBuilder(FlowGraphBuilder* flow_graph_builder,
23 const uint8_t* buffer, 49 const uint8_t* buffer,
24 intptr_t buffer_length) 50 intptr_t buffer_length)
25 : flow_graph_builder_(flowGraph_builder), 51 : flow_graph_builder_(flow_graph_builder),
52 translation_helper_(flow_graph_builder->translation_helper_),
53 zone_(flow_graph_builder->zone_),
26 reader_(new kernel::Reader(buffer, buffer_length)), 54 reader_(new kernel::Reader(buffer, buffer_length)),
55 constant_evaluator_(this,
56 flow_graph_builder->zone_,
Kevin Millikin (Google) 2017/03/31 12:23:41 You should be able to use zone_ and &translation_h
57 &flow_graph_builder->translation_helper_,
58 &flow_graph_builder->type_translator_),
27 string_table_offsets_(NULL), 59 string_table_offsets_(NULL),
28 string_table_size_(-1), 60 string_table_size_(-1),
29 string_table_entries_read_(0) {} 61 string_table_entries_read_(0) {}
30 62
31 virtual ~StreamingFlowGraphBuilder() { 63 virtual ~StreamingFlowGraphBuilder() {
32 delete reader_; 64 delete reader_;
33 if (string_table_offsets_ != NULL) { 65 if (string_table_offsets_ != NULL) {
34 delete[] string_table_offsets_; 66 delete[] string_table_offsets_;
35 } 67 }
36 } 68 }
37 69
38 Fragment BuildAt(intptr_t kernel_offset); 70 Fragment BuildAt(intptr_t kernel_offset);
39 71
40 private: 72 private:
41 intptr_t GetStringTableOffset(intptr_t index); 73 intptr_t GetStringTableOffset(intptr_t index);
42 74
75 intptr_t ReaderOffset();
76 void SetOffset(intptr_t offset);
77 void SkipBytes(intptr_t skip);
43 uint32_t ReadUInt(); 78 uint32_t ReadUInt();
44 intptr_t ReadListLength(); 79 intptr_t ReadListLength();
45 TokenPosition ReadPosition(bool record = true); 80 TokenPosition ReadPosition(bool record = true);
81 Tag ReadTag(uint8_t* payload = NULL);
46 82
47 CatchBlock* catch_block(); 83 CatchBlock* catch_block();
48 ScopeBuildingResult* scopes(); 84 ScopeBuildingResult* scopes();
85 ParsedFunction* parsed_function();
86
87 dart::String& DartSymbol(intptr_t str_index);
88 dart::String& DartString(intptr_t str_index);
49 89
50 Fragment DebugStepCheck(TokenPosition position); 90 Fragment DebugStepCheck(TokenPosition position);
51 Fragment LoadLocal(LocalVariable* variable); 91 Fragment LoadLocal(LocalVariable* variable);
52 Fragment PushArgument(); 92 Fragment PushArgument();
53 Fragment RethrowException(TokenPosition position, int catch_try_index); 93 Fragment RethrowException(TokenPosition position, int catch_try_index);
54 Fragment ThrowNoSuchMethodError(); 94 Fragment ThrowNoSuchMethodError();
55 Fragment Constant(const Object& value); 95 Fragment Constant(const Object& value);
56 Fragment IntConstant(int64_t value); 96 Fragment IntConstant(int64_t value);
57 97
58 Fragment BuildInvalidExpression(); 98 Fragment BuildInvalidExpression();
59 Fragment BuildThisExpression(); 99 Fragment BuildThisExpression();
60 Fragment BuildRethrow(); 100 Fragment BuildRethrow();
61 Fragment BuildStringLiteral(); 101 Fragment BuildStringLiteral();
62 Fragment BuildIntLiteral(uint8_t payload); 102 Fragment BuildIntLiteral(uint8_t payload);
63 Fragment BuildIntLiteral(bool is_negative); 103 Fragment BuildIntLiteral(bool is_negative);
104 Fragment BuildDoubleLiteral();
64 Fragment BuildBoolLiteral(bool value); 105 Fragment BuildBoolLiteral(bool value);
65 Fragment BuildNullLiteral(); 106 Fragment BuildNullLiteral();
66 107
67 FlowGraphBuilder* flow_graph_builder_; 108 FlowGraphBuilder* flow_graph_builder_;
109 TranslationHelper& translation_helper_;
110 Zone* zone_;
68 kernel::Reader* reader_; 111 kernel::Reader* reader_;
112 StreamingConstantEvaluator constant_evaluator_;
69 intptr_t* string_table_offsets_; 113 intptr_t* string_table_offsets_;
70 intptr_t string_table_size_; 114 intptr_t string_table_size_;
71 intptr_t string_table_entries_read_; 115 intptr_t string_table_entries_read_;
116
117 friend class StreamingConstantEvaluator;
72 }; 118 };
73 119
74 } // namespace kernel 120 } // namespace kernel
75 } // namespace dart 121 } // namespace dart
76 122
77 #endif // !defined(DART_PRECOMPILED_RUNTIME) 123 #endif // !defined(DART_PRECOMPILED_RUNTIME)
78 #endif // RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ 124 #endif // RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/kernel_binary_flowgraph.cc » ('j') | runtime/vm/kernel_binary_flowgraph.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698