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

Side by Side Diff: src/wasm/encoder.h

Issue 1750153002: Replace __init__ function in asm-wasm-builder with the start function section (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_WASM_ENCODER_H_ 5 #ifndef V8_WASM_ENCODER_H_
6 #define V8_WASM_ENCODER_H_ 6 #define V8_WASM_ENCODER_H_
7 7
8 #include "src/signature.h" 8 #include "src/signature.h"
9 #include "src/zone-containers.h" 9 #include "src/zone-containers.h"
10 10
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 WasmModuleIndex* WriteTo(Zone* zone) const; 113 WasmModuleIndex* WriteTo(Zone* zone) const;
114 114
115 private: 115 private:
116 friend class WasmModuleBuilder; 116 friend class WasmModuleBuilder;
117 explicit WasmModuleWriter(Zone* zone); 117 explicit WasmModuleWriter(Zone* zone);
118 ZoneVector<WasmFunctionEncoder*> functions_; 118 ZoneVector<WasmFunctionEncoder*> functions_;
119 ZoneVector<WasmDataSegmentEncoder*> data_segments_; 119 ZoneVector<WasmDataSegmentEncoder*> data_segments_;
120 ZoneVector<FunctionSig*> signatures_; 120 ZoneVector<FunctionSig*> signatures_;
121 ZoneVector<uint16_t> indirect_functions_; 121 ZoneVector<uint16_t> indirect_functions_;
122 ZoneVector<std::pair<MachineType, bool>> globals_; 122 ZoneVector<std::pair<MachineType, bool>> globals_;
123 bool has_start_function_;
titzer 2016/03/01 02:09:33 Just make me an int with a value -1 indicating no
aseemgarg 2016/03/01 02:37:34 Done.
124 uint16_t start_function_index_;
123 }; 125 };
124 126
125 class WasmModuleBuilder : public ZoneObject { 127 class WasmModuleBuilder : public ZoneObject {
126 public: 128 public:
127 explicit WasmModuleBuilder(Zone* zone); 129 explicit WasmModuleBuilder(Zone* zone);
128 uint16_t AddFunction(); 130 uint16_t AddFunction();
129 uint32_t AddGlobal(MachineType type, bool exported); 131 uint32_t AddGlobal(MachineType type, bool exported);
130 WasmFunctionBuilder* FunctionAt(size_t index); 132 WasmFunctionBuilder* FunctionAt(size_t index);
131 void AddDataSegment(WasmDataSegmentEncoder* data); 133 void AddDataSegment(WasmDataSegmentEncoder* data);
132 uint16_t AddSignature(FunctionSig* sig); 134 uint16_t AddSignature(FunctionSig* sig);
133 void AddIndirectFunction(uint16_t index); 135 void AddIndirectFunction(uint16_t index);
136 void MarkStartFunction(uint16_t index);
134 WasmModuleWriter* Build(Zone* zone); 137 WasmModuleWriter* Build(Zone* zone);
135 138
136 struct CompareFunctionSigs { 139 struct CompareFunctionSigs {
137 bool operator()(FunctionSig* a, FunctionSig* b) const; 140 bool operator()(FunctionSig* a, FunctionSig* b) const;
138 }; 141 };
139 typedef ZoneMap<FunctionSig*, uint16_t, CompareFunctionSigs> SignatureMap; 142 typedef ZoneMap<FunctionSig*, uint16_t, CompareFunctionSigs> SignatureMap;
140 143
141 private: 144 private:
142 Zone* zone_; 145 Zone* zone_;
143 ZoneVector<FunctionSig*> signatures_; 146 ZoneVector<FunctionSig*> signatures_;
144 ZoneVector<WasmFunctionBuilder*> functions_; 147 ZoneVector<WasmFunctionBuilder*> functions_;
145 ZoneVector<WasmDataSegmentEncoder*> data_segments_; 148 ZoneVector<WasmDataSegmentEncoder*> data_segments_;
146 ZoneVector<uint16_t> indirect_functions_; 149 ZoneVector<uint16_t> indirect_functions_;
147 ZoneVector<std::pair<MachineType, bool>> globals_; 150 ZoneVector<std::pair<MachineType, bool>> globals_;
148 SignatureMap signature_map_; 151 SignatureMap signature_map_;
152 bool has_start_function_;
153 uint16_t start_function_index_;
149 }; 154 };
150 155
151 std::vector<uint8_t> UnsignedLEB128From(uint32_t result); 156 std::vector<uint8_t> UnsignedLEB128From(uint32_t result);
152 } // namespace wasm 157 } // namespace wasm
153 } // namespace internal 158 } // namespace internal
154 } // namespace v8 159 } // namespace v8
155 160
156 #endif // V8_WASM_ENCODER_H_ 161 #endif // V8_WASM_ENCODER_H_
OLDNEW
« no previous file with comments | « src/wasm/asm-wasm-builder.cc ('k') | src/wasm/encoder.cc » ('j') | src/wasm/encoder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698