Chromium Code Reviews| 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/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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 static_cast<int>(pc_ - start_)); | 263 static_cast<int>(pc_ - start_)); |
| 264 module->data_segments.push_back({0, // dest_addr | 264 module->data_segments.push_back({0, // dest_addr |
| 265 0, // source_offset | 265 0, // source_offset |
| 266 0, // source_size | 266 0, // source_size |
| 267 false}); // init | 267 false}); // init |
| 268 WasmDataSegment* segment = &module->data_segments.back(); | 268 WasmDataSegment* segment = &module->data_segments.back(); |
| 269 DecodeDataSegmentInModule(module, segment); | 269 DecodeDataSegmentInModule(module, segment); |
| 270 } | 270 } |
| 271 break; | 271 break; |
| 272 } | 272 } |
| 273 case WasmSection::Code::FunctionTablePad: { | |
| 274 if (!FLAG_wasm_jit_prototype) { | |
| 275 error("FunctionTablePad section without jiting enabled"); | |
| 276 } | |
| 277 // An indirect function table requires functions first. | |
| 278 int length; | |
|
Mircea Trofin
2016/06/21 19:46:14
please initialize length.
| |
| 279 module->indirect_table_size = | |
| 280 consume_u32v(&length, "indirect entry count"); | |
| 281 if (module->indirect_table_size > 0 && | |
| 282 module->indirect_table_size < module->function_table.size()) { | |
| 283 error("more predefined indirect entries than table can hold"); | |
| 284 } | |
| 285 break; | |
| 286 } | |
| 273 case WasmSection::Code::FunctionTable: { | 287 case WasmSection::Code::FunctionTable: { |
| 274 // An indirect function table requires functions first. | 288 // An indirect function table requires functions first. |
| 275 CheckForFunctions(module, section); | 289 CheckForFunctions(module, section); |
| 276 int length; | 290 int length; |
| 277 uint32_t function_table_count = | 291 uint32_t function_table_count = |
| 278 consume_u32v(&length, "function table count"); | 292 consume_u32v(&length, "function table count"); |
| 279 module->function_table.reserve(SafeReserve(function_table_count)); | 293 module->function_table.reserve(SafeReserve(function_table_count)); |
| 280 // Decode function table. | 294 // Decode function table. |
| 281 for (uint32_t i = 0; i < function_table_count; i++) { | 295 for (uint32_t i = 0; i < function_table_count; i++) { |
| 282 if (failed()) break; | 296 if (failed()) break; |
| 283 TRACE("DecodeFunctionTable[%d] module+%d\n", i, | 297 TRACE("DecodeFunctionTable[%d] module+%d\n", i, |
| 284 static_cast<int>(pc_ - start_)); | 298 static_cast<int>(pc_ - start_)); |
| 285 uint16_t index = consume_u32v(&length); | 299 uint16_t index = consume_u32v(&length); |
| 286 if (index >= module->functions.size()) { | 300 if (index >= module->functions.size()) { |
| 287 error(pc_ - 2, "invalid function index"); | 301 error(pc_ - 2, "invalid function index"); |
| 288 break; | 302 break; |
| 289 } | 303 } |
| 290 module->function_table.push_back(index); | 304 module->function_table.push_back(index); |
| 291 } | 305 } |
| 306 if (module->indirect_table_size > 0 && | |
| 307 module->indirect_table_size < module->function_table.size()) { | |
| 308 error("more predefined indirect entries than table can hold"); | |
| 309 } | |
| 292 break; | 310 break; |
| 293 } | 311 } |
| 294 case WasmSection::Code::StartFunction: { | 312 case WasmSection::Code::StartFunction: { |
| 295 // Declares a start function for a module. | 313 // Declares a start function for a module. |
| 296 CheckForFunctions(module, section); | 314 CheckForFunctions(module, section); |
| 297 if (module->start_function_index >= 0) { | 315 if (module->start_function_index >= 0) { |
| 298 error("start function already declared"); | 316 error("start function already declared"); |
| 299 break; | 317 break; |
| 300 } | 318 } |
| 301 WasmFunction* func; | 319 WasmFunction* func; |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 853 decoder.consume_bytes(size); | 871 decoder.consume_bytes(size); |
| 854 } | 872 } |
| 855 if (decoder.more()) decoder.error("unexpected additional bytes"); | 873 if (decoder.more()) decoder.error("unexpected additional bytes"); |
| 856 | 874 |
| 857 return decoder.toResult(std::move(table)); | 875 return decoder.toResult(std::move(table)); |
| 858 } | 876 } |
| 859 | 877 |
| 860 } // namespace wasm | 878 } // namespace wasm |
| 861 } // namespace internal | 879 } // namespace internal |
| 862 } // namespace v8 | 880 } // namespace v8 |
| OLD | NEW |