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/flags.h" | 9 #include "src/flags.h" |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 offset = (offset + size - 1) & ~(size - 1); // align | 773 offset = (offset + size - 1) & ~(size - 1); // align |
774 global.offset = offset; | 774 global.offset = offset; |
775 offset += size; | 775 offset += size; |
776 } | 776 } |
777 module->globals_size = offset; | 777 module->globals_size = offset; |
778 } | 778 } |
779 | 779 |
780 // Verifies the body (code) of a given function. | 780 // Verifies the body (code) of a given function. |
781 void VerifyFunctionBody(uint32_t func_num, ModuleBytesEnv* menv, | 781 void VerifyFunctionBody(uint32_t func_num, ModuleBytesEnv* menv, |
782 WasmFunction* function) { | 782 WasmFunction* function) { |
| 783 WasmFunctionName func_name(function, |
| 784 menv->wire_bytes.GetNameOrNull(function)); |
783 if (FLAG_trace_wasm_decoder || FLAG_trace_wasm_decode_time) { | 785 if (FLAG_trace_wasm_decoder || FLAG_trace_wasm_decode_time) { |
784 OFStream os(stdout); | 786 OFStream os(stdout); |
785 os << "Verifying WASM function " << WasmFunctionName(function, menv) | 787 os << "Verifying WASM function " << func_name << std::endl; |
786 << std::endl; | |
787 } | 788 } |
788 FunctionBody body = {function->sig, start_, | 789 FunctionBody body = {function->sig, start_, |
789 start_ + function->code_start_offset, | 790 start_ + function->code_start_offset, |
790 start_ + function->code_end_offset}; | 791 start_ + function->code_end_offset}; |
791 DecodeResult result = | 792 DecodeResult result = VerifyWasmCode( |
792 VerifyWasmCode(module_zone->allocator(), | 793 module_zone->allocator(), |
793 menv == nullptr ? nullptr : menv->module, body); | 794 menv == nullptr ? nullptr : menv->module_env.module, body); |
794 if (result.failed()) { | 795 if (result.failed()) { |
795 // Wrap the error message from the function decoder. | 796 // Wrap the error message from the function decoder. |
796 std::ostringstream str; | 797 std::ostringstream str; |
797 str << "in function " << WasmFunctionName(function, menv) << ": "; | 798 str << "in function " << func_name << ": "; |
798 str << result; | 799 str << result; |
799 std::string strval = str.str(); | 800 std::string strval = str.str(); |
800 const char* raw = strval.c_str(); | 801 const char* raw = strval.c_str(); |
801 size_t len = strlen(raw); | 802 size_t len = strlen(raw); |
802 char* buffer = new char[len]; | 803 char* buffer = new char[len]; |
803 strncpy(buffer, raw, len); | 804 strncpy(buffer, raw, len); |
804 buffer[len - 1] = 0; | 805 buffer[len - 1] = 0; |
805 | 806 |
806 // Copy error code and location. | 807 // Copy error code and location. |
807 result_.MoveFrom(result); | 808 result_.MoveFrom(result); |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 table.push_back(std::move(func_asm_offsets)); | 1257 table.push_back(std::move(func_asm_offsets)); |
1257 } | 1258 } |
1258 if (decoder.more()) decoder.error("unexpected additional bytes"); | 1259 if (decoder.more()) decoder.error("unexpected additional bytes"); |
1259 | 1260 |
1260 return decoder.toResult(std::move(table)); | 1261 return decoder.toResult(std::move(table)); |
1261 } | 1262 } |
1262 | 1263 |
1263 } // namespace wasm | 1264 } // namespace wasm |
1264 } // namespace internal | 1265 } // namespace internal |
1265 } // namespace v8 | 1266 } // namespace v8 |
OLD | NEW |