OLD | NEW |
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 #include "src/signature.h" | 5 #include "src/signature.h" |
6 | 6 |
7 #include "src/handles.h" | 7 #include "src/handles.h" |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
10 | 10 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 } | 189 } |
190 e->signature_index_ = mb->AddSignature(sig.Build()); | 190 e->signature_index_ = mb->AddSignature(sig.Build()); |
191 e->name_.insert(e->name_.begin(), name_.begin(), name_.end()); | 191 e->name_.insert(e->name_.begin(), name_.begin(), name_.end()); |
192 return e; | 192 return e; |
193 } | 193 } |
194 | 194 |
195 | 195 |
196 void WasmFunctionBuilder::IndexVars(WasmFunctionEncoder* e, | 196 void WasmFunctionBuilder::IndexVars(WasmFunctionEncoder* e, |
197 uint16_t* var_index) const { | 197 uint16_t* var_index) const { |
198 uint16_t param = 0; | 198 uint16_t param = 0; |
199 uint16_t int32 = 0; | 199 uint16_t i32 = 0; |
200 uint16_t int64 = 0; | 200 uint16_t i64 = 0; |
201 uint16_t float32 = 0; | 201 uint16_t f32 = 0; |
202 uint16_t float64 = 0; | 202 uint16_t f64 = 0; |
203 for (size_t i = 0; i < locals_.size(); i++) { | 203 for (size_t i = 0; i < locals_.size(); i++) { |
204 if (locals_.at(i).param_) { | 204 if (locals_.at(i).param_) { |
205 param++; | 205 param++; |
206 } else if (locals_.at(i).type_ == kAstI32) { | 206 } else if (locals_.at(i).type_ == kAstI32) { |
207 int32++; | 207 i32++; |
208 } else if (locals_.at(i).type_ == kAstI64) { | 208 } else if (locals_.at(i).type_ == kAstI64) { |
209 int64++; | 209 i64++; |
210 } else if (locals_.at(i).type_ == kAstF32) { | 210 } else if (locals_.at(i).type_ == kAstF32) { |
211 float32++; | 211 f32++; |
212 } else if (locals_.at(i).type_ == kAstF64) { | 212 } else if (locals_.at(i).type_ == kAstF64) { |
213 float64++; | 213 f64++; |
214 } | 214 } |
215 } | 215 } |
216 e->local_int32_count_ = int32; | 216 e->local_i32_count_ = i32; |
217 e->local_int64_count_ = int64; | 217 e->local_i64_count_ = i64; |
218 e->local_float32_count_ = float32; | 218 e->local_f32_count_ = f32; |
219 e->local_float64_count_ = float64; | 219 e->local_f64_count_ = f64; |
220 float64 = param + int32 + int64 + float32; | 220 f64 = param + i32 + i64 + f32; |
221 float32 = param + int32 + int64; | 221 f32 = param + i32 + i64; |
222 int64 = param + int32; | 222 i64 = param + i32; |
223 int32 = param; | 223 i32 = param; |
224 param = 0; | 224 param = 0; |
225 for (size_t i = 0; i < locals_.size(); i++) { | 225 for (size_t i = 0; i < locals_.size(); i++) { |
226 if (locals_.at(i).param_) { | 226 if (locals_.at(i).param_) { |
227 e->params_.push_back(locals_.at(i).type_); | 227 e->params_.push_back(locals_.at(i).type_); |
228 var_index[i] = param++; | 228 var_index[i] = param++; |
229 } else if (locals_.at(i).type_ == kAstI32) { | 229 } else if (locals_.at(i).type_ == kAstI32) { |
230 var_index[i] = int32++; | 230 var_index[i] = i32++; |
231 } else if (locals_.at(i).type_ == kAstI64) { | 231 } else if (locals_.at(i).type_ == kAstI64) { |
232 var_index[i] = int64++; | 232 var_index[i] = i64++; |
233 } else if (locals_.at(i).type_ == kAstF32) { | 233 } else if (locals_.at(i).type_ == kAstF32) { |
234 var_index[i] = float32++; | 234 var_index[i] = f32++; |
235 } else if (locals_.at(i).type_ == kAstF64) { | 235 } else if (locals_.at(i).type_ == kAstF64) { |
236 var_index[i] = float64++; | 236 var_index[i] = f64++; |
237 } | 237 } |
238 } | 238 } |
239 } | 239 } |
240 | 240 |
241 | 241 |
242 WasmFunctionEncoder::WasmFunctionEncoder(Zone* zone, LocalType return_type, | 242 WasmFunctionEncoder::WasmFunctionEncoder(Zone* zone, LocalType return_type, |
243 bool exported, bool external) | 243 bool exported, bool external) |
244 : params_(zone), | 244 : params_(zone), |
245 exported_(exported), | 245 exported_(exported), |
246 external_(external), | 246 external_(external), |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 EmitUint16(header, signature_index_); | 278 EmitUint16(header, signature_index_); |
279 | 279 |
280 if (HasName()) { | 280 if (HasName()) { |
281 uint32_t name_offset = static_cast<uint32_t>(*body - buffer); | 281 uint32_t name_offset = static_cast<uint32_t>(*body - buffer); |
282 EmitUint32(header, name_offset); | 282 EmitUint32(header, name_offset); |
283 std::memcpy(*body, &name_[0], name_.size()); | 283 std::memcpy(*body, &name_[0], name_.size()); |
284 (*body) += name_.size(); | 284 (*body) += name_.size(); |
285 } | 285 } |
286 | 286 |
287 if (HasLocals()) { | 287 if (HasLocals()) { |
288 EmitUint16(header, local_int32_count_); | 288 EmitUint16(header, local_i32_count_); |
289 EmitUint16(header, local_int64_count_); | 289 EmitUint16(header, local_i64_count_); |
290 EmitUint16(header, local_float32_count_); | 290 EmitUint16(header, local_f32_count_); |
291 EmitUint16(header, local_float64_count_); | 291 EmitUint16(header, local_f64_count_); |
292 } | 292 } |
293 | 293 |
294 if (!external_) { | 294 if (!external_) { |
295 EmitUint16(header, static_cast<uint16_t>(body_.size())); | 295 EmitUint16(header, static_cast<uint16_t>(body_.size())); |
296 if (body_.size() > 0) { | 296 if (body_.size() > 0) { |
297 std::memcpy(*header, &body_[0], body_.size()); | 297 std::memcpy(*header, &body_[0], body_.size()); |
298 (*header) += body_.size(); | 298 (*header) += body_.size(); |
299 } | 299 } |
300 } | 300 } |
301 } | 301 } |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 next = next | 0x80; | 577 next = next | 0x80; |
578 } | 578 } |
579 output.push_back(next); | 579 output.push_back(next); |
580 shift += 7; | 580 shift += 7; |
581 } while ((next & 0x80) != 0); | 581 } while ((next & 0x80) != 0); |
582 return output; | 582 return output; |
583 } | 583 } |
584 } // namespace wasm | 584 } // namespace wasm |
585 } // namespace internal | 585 } // namespace internal |
586 } // namespace v8 | 586 } // namespace v8 |
OLD | NEW |