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/macro-assembler.h" | 5 #include "src/macro-assembler.h" |
6 #include "src/objects.h" | 6 #include "src/objects.h" |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/wasm/decoder.h" | 9 #include "src/wasm/decoder.h" |
10 #include "src/wasm/module-decoder.h" | 10 #include "src/wasm/module-decoder.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 error(sigpos, "invalid signature index"); | 227 error(sigpos, "invalid signature index"); |
228 } else { | 228 } else { |
229 import->sig = module->signatures->at(import->sig_index); | 229 import->sig = module->signatures->at(import->sig_index); |
230 } | 230 } |
231 import->module_name_offset = consume_string("import module name"); | 231 import->module_name_offset = consume_string("import module name"); |
232 import->function_name_offset = | 232 import->function_name_offset = |
233 consume_string("import function name"); | 233 consume_string("import function name"); |
234 } | 234 } |
235 break; | 235 break; |
236 } | 236 } |
237 case kDeclWLL: { | 237 default: |
238 // Reserved for experimentation by the Web Low-level Language project | 238 // All other sections are ignored and skipped. Known experimental |
239 // which is augmenting the binary encoding with source code meta | 239 // sections: 0x11 WLL https://github.com/JSStats/wll |
240 // information. This section does not affect the semantics of the code | 240 uint32_t section_size = consume_u32("section size"); |
241 // and can be ignored by the runtime. https://github.com/JSStats/wll | |
242 int length = 0; | |
243 uint32_t section_size = consume_u32v(&length, "section size"); | |
244 if (pc_ + section_size > limit_ || pc_ + section_size < pc_) { | 241 if (pc_ + section_size > limit_ || pc_ + section_size < pc_) { |
245 error(pc_ - length, "invalid section size"); | 242 error(pc_ - 4, "invalid section size"); |
246 break; | 243 break; |
247 } | 244 } |
248 pc_ += section_size; | 245 pc_ += section_size; |
249 break; | 246 break; |
250 } | |
251 default: | |
252 error(pc_ - 1, nullptr, "unrecognized section 0x%02x", section); | |
253 break; | |
254 } | 247 } |
255 } | 248 } |
256 | 249 |
257 return toResult(module); | 250 return toResult(module); |
258 } | 251 } |
259 | 252 |
260 uint32_t SafeReserve(uint32_t count) { | 253 uint32_t SafeReserve(uint32_t count) { |
261 // Avoid OOM by only reserving up to a certain size. | 254 // Avoid OOM by only reserving up to a certain size. |
262 const uint32_t kMaxReserve = 20000; | 255 const uint32_t kMaxReserve = 20000; |
263 return count < kMaxReserve ? count : kMaxReserve; | 256 return count < kMaxReserve ? count : kMaxReserve; |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 if (function_start > function_end) return FunctionError("start > end"); | 600 if (function_start > function_end) return FunctionError("start > end"); |
608 if (size > kMaxFunctionSize) | 601 if (size > kMaxFunctionSize) |
609 return FunctionError("size > maximum function size"); | 602 return FunctionError("size > maximum function size"); |
610 WasmFunction* function = new WasmFunction(); | 603 WasmFunction* function = new WasmFunction(); |
611 ModuleDecoder decoder(zone, function_start, function_end, false); | 604 ModuleDecoder decoder(zone, function_start, function_end, false); |
612 return decoder.DecodeSingleFunction(module_env, function); | 605 return decoder.DecodeSingleFunction(module_env, function); |
613 } | 606 } |
614 } // namespace wasm | 607 } // namespace wasm |
615 } // namespace internal | 608 } // namespace internal |
616 } // namespace v8 | 609 } // namespace v8 |
OLD | NEW |