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

Side by Side Diff: src/wasm/module-decoder.cc

Issue 1952703002: Turn on -Wmissing-field-initializers on Linux. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 #include "src/wasm/module-decoder.h" 5 #include "src/wasm/module-decoder.h"
6 6
7 #include "src/base/functional.h" 7 #include "src/base/functional.h"
8 #include "src/base/platform/platform.h" 8 #include "src/base/platform/platform.h"
9 #include "src/macro-assembler.h" 9 #include "src/macro-assembler.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 FunctionSig* s = consume_sig(); 158 FunctionSig* s = consume_sig();
159 module->signatures.push_back(s); 159 module->signatures.push_back(s);
160 } 160 }
161 break; 161 break;
162 } 162 }
163 case WasmSection::Code::FunctionSignatures: { 163 case WasmSection::Code::FunctionSignatures: {
164 int length; 164 int length;
165 uint32_t functions_count = consume_u32v(&length, "functions count"); 165 uint32_t functions_count = consume_u32v(&length, "functions count");
166 module->functions.reserve(SafeReserve(functions_count)); 166 module->functions.reserve(SafeReserve(functions_count));
167 for (uint32_t i = 0; i < functions_count; i++) { 167 for (uint32_t i = 0; i < functions_count; i++) {
168 module->functions.push_back( 168 module->functions.push_back({nullptr, // sig
169 {nullptr, i, 0, 0, 0, 0, 0, 0, false, false}); 169 i, // func_index
170 0, // sig_index
171 0, // name_offset
172 0, // name_length
173 0, // code_start_offset
174 0, // code_end_offset
175 0, // local_i32_count
176 0, // local_i64_count
177 0, // local_f32_count
178 0, // local_f64_count
179 false, // exported
180 false}); // external
170 WasmFunction* function = &module->functions.back(); 181 WasmFunction* function = &module->functions.back();
171 function->sig_index = consume_sig_index(module, &function->sig); 182 function->sig_index = consume_sig_index(module, &function->sig);
172 } 183 }
173 break; 184 break;
174 } 185 }
175 case WasmSection::Code::FunctionBodies: { 186 case WasmSection::Code::FunctionBodies: {
176 int length; 187 int length;
177 const byte* pos = pc_; 188 const byte* pos = pc_;
178 uint32_t functions_count = consume_u32v(&length, "functions count"); 189 uint32_t functions_count = consume_u32v(&length, "functions count");
179 if (functions_count != module->functions.size()) { 190 if (functions_count != module->functions.size()) {
(...skipping 26 matching lines...) Expand all
206 ModuleEnv menv; 217 ModuleEnv menv;
207 menv.module = module; 218 menv.module = module;
208 menv.instance = nullptr; 219 menv.instance = nullptr;
209 menv.origin = origin_; 220 menv.origin = origin_;
210 // Decode functions. 221 // Decode functions.
211 for (uint32_t i = 0; i < functions_count; i++) { 222 for (uint32_t i = 0; i < functions_count; i++) {
212 if (failed()) break; 223 if (failed()) break;
213 TRACE("DecodeFunction[%d] module+%d\n", i, 224 TRACE("DecodeFunction[%d] module+%d\n", i,
214 static_cast<int>(pc_ - start_)); 225 static_cast<int>(pc_ - start_));
215 226
216 module->functions.push_back( 227 module->functions.push_back({nullptr, // sig
217 {nullptr, i, 0, 0, 0, 0, 0, 0, false, false}); 228 i, // func_index
229 0, // sig_index
230 0, // name_offset
231 0, // name_length
232 0, // code_start_offset
233 0, // code_end_offset
234 0, // local_i32_count
235 0, // local_i64_count
236 0, // local_f32_count
237 0, // local_f64_count
238 false, // exported
239 false}); // external
218 WasmFunction* function = &module->functions.back(); 240 WasmFunction* function = &module->functions.back();
219 DecodeFunctionInModule(module, function, false); 241 DecodeFunctionInModule(module, function, false);
220 } 242 }
221 if (ok() && verify_functions) { 243 if (ok() && verify_functions) {
222 for (uint32_t i = 0; i < functions_count; i++) { 244 for (uint32_t i = 0; i < functions_count; i++) {
223 if (failed()) break; 245 if (failed()) break;
224 WasmFunction* function = &module->functions[i]; 246 WasmFunction* function = &module->functions[i];
225 if (!function->external) { 247 if (!function->external) {
226 VerifyFunctionBody(i, &menv, function); 248 VerifyFunctionBody(i, &menv, function);
227 if (result_.failed()) 249 if (result_.failed())
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 case WasmSection::Code::DataSegments: { 298 case WasmSection::Code::DataSegments: {
277 int length; 299 int length;
278 uint32_t data_segments_count = 300 uint32_t data_segments_count =
279 consume_u32v(&length, "data segments count"); 301 consume_u32v(&length, "data segments count");
280 module->data_segments.reserve(SafeReserve(data_segments_count)); 302 module->data_segments.reserve(SafeReserve(data_segments_count));
281 // Decode data segments. 303 // Decode data segments.
282 for (uint32_t i = 0; i < data_segments_count; i++) { 304 for (uint32_t i = 0; i < data_segments_count; i++) {
283 if (failed()) break; 305 if (failed()) break;
284 TRACE("DecodeDataSegment[%d] module+%d\n", i, 306 TRACE("DecodeDataSegment[%d] module+%d\n", i,
285 static_cast<int>(pc_ - start_)); 307 static_cast<int>(pc_ - start_));
286 module->data_segments.push_back({0, 0, 0}); 308 module->data_segments.push_back({0, // dest_addr
309 0, // source_offset
310 0, // source_size
311 false}); // init
287 WasmDataSegment* segment = &module->data_segments.back(); 312 WasmDataSegment* segment = &module->data_segments.back();
288 DecodeDataSegmentInModule(module, segment); 313 DecodeDataSegmentInModule(module, segment);
289 } 314 }
290 break; 315 break;
291 } 316 }
292 case WasmSection::Code::FunctionTable: { 317 case WasmSection::Code::FunctionTable: {
293 // An indirect function table requires functions first. 318 // An indirect function table requires functions first.
294 CheckForFunctions(module, section); 319 CheckForFunctions(module, section);
295 int length; 320 int length;
296 uint32_t function_table_count = 321 uint32_t function_table_count =
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 int length; 355 int length;
331 uint32_t import_table_count = 356 uint32_t import_table_count =
332 consume_u32v(&length, "import table count"); 357 consume_u32v(&length, "import table count");
333 module->import_table.reserve(SafeReserve(import_table_count)); 358 module->import_table.reserve(SafeReserve(import_table_count));
334 // Decode import table. 359 // Decode import table.
335 for (uint32_t i = 0; i < import_table_count; i++) { 360 for (uint32_t i = 0; i < import_table_count; i++) {
336 if (failed()) break; 361 if (failed()) break;
337 TRACE("DecodeImportTable[%d] module+%d\n", i, 362 TRACE("DecodeImportTable[%d] module+%d\n", i,
338 static_cast<int>(pc_ - start_)); 363 static_cast<int>(pc_ - start_));
339 364
340 module->import_table.push_back({nullptr, 0, 0}); 365 module->import_table.push_back({nullptr, // sig
366 0, // sig_index
367 0, // module_name_offset
368 0, // module_name_length
369 0, // function_name_offset
370 0}); // function_name_length
341 WasmImport* import = &module->import_table.back(); 371 WasmImport* import = &module->import_table.back();
342 372
343 import->sig_index = consume_sig_index(module, &import->sig); 373 import->sig_index = consume_sig_index(module, &import->sig);
344 const byte* pos = pc_; 374 const byte* pos = pc_;
345 import->module_name_offset = consume_string( 375 import->module_name_offset = consume_string(
346 &import->module_name_length, "import module name"); 376 &import->module_name_length, "import module name");
347 if (import->module_name_length == 0) { 377 if (import->module_name_length == 0) {
348 error(pos, "import module name cannot be NULL"); 378 error(pos, "import module name cannot be NULL");
349 } 379 }
350 import->function_name_offset = consume_string( 380 import->function_name_offset = consume_string(
351 &import->function_name_length, "import function name"); 381 &import->function_name_length, "import function name");
352 } 382 }
353 break; 383 break;
354 } 384 }
355 case WasmSection::Code::ExportTable: { 385 case WasmSection::Code::ExportTable: {
356 // Declares an export table. 386 // Declares an export table.
357 CheckForFunctions(module, section); 387 CheckForFunctions(module, section);
358 int length; 388 int length;
359 uint32_t export_table_count = 389 uint32_t export_table_count =
360 consume_u32v(&length, "export table count"); 390 consume_u32v(&length, "export table count");
361 module->export_table.reserve(SafeReserve(export_table_count)); 391 module->export_table.reserve(SafeReserve(export_table_count));
362 // Decode export table. 392 // Decode export table.
363 for (uint32_t i = 0; i < export_table_count; i++) { 393 for (uint32_t i = 0; i < export_table_count; i++) {
364 if (failed()) break; 394 if (failed()) break;
365 TRACE("DecodeExportTable[%d] module+%d\n", i, 395 TRACE("DecodeExportTable[%d] module+%d\n", i,
366 static_cast<int>(pc_ - start_)); 396 static_cast<int>(pc_ - start_));
367 397
368 module->export_table.push_back({0, 0}); 398 module->export_table.push_back({0, // func_index
399 0, // name_offset
400 0}); // name_length
369 WasmExport* exp = &module->export_table.back(); 401 WasmExport* exp = &module->export_table.back();
370 402
371 WasmFunction* func; 403 WasmFunction* func;
372 exp->func_index = consume_func_index(module, &func); 404 exp->func_index = consume_func_index(module, &func);
373 exp->name_offset = consume_string(&exp->name_length, "export name"); 405 exp->name_offset = consume_string(&exp->name_length, "export name");
374 } 406 }
375 break; 407 break;
376 } 408 }
377 case WasmSection::Code::Max: 409 case WasmSection::Code::Max:
378 // Skip unknown sections. 410 // Skip unknown sections.
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 return FunctionError("size > maximum function size"); 841 return FunctionError("size > maximum function size");
810 isolate->counters()->wasm_function_size_bytes()->AddSample( 842 isolate->counters()->wasm_function_size_bytes()->AddSample(
811 static_cast<int>(size)); 843 static_cast<int>(size));
812 WasmFunction* function = new WasmFunction(); 844 WasmFunction* function = new WasmFunction();
813 ModuleDecoder decoder(zone, function_start, function_end, kWasmOrigin); 845 ModuleDecoder decoder(zone, function_start, function_end, kWasmOrigin);
814 return decoder.DecodeSingleFunction(module_env, function); 846 return decoder.DecodeSingleFunction(module_env, function);
815 } 847 }
816 } // namespace wasm 848 } // namespace wasm
817 } // namespace internal 849 } // namespace internal
818 } // namespace v8 850 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698