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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 char* result = new char[len]; | 760 char* result = new char[len]; |
761 strncpy(result, msg, len); | 761 strncpy(result, msg, len); |
762 result[len - 1] = 0; | 762 result[len - 1] = 0; |
763 error_msg.Reset(result); | 763 error_msg.Reset(result); |
764 } | 764 } |
765 }; | 765 }; |
766 | 766 |
767 ModuleResult DecodeWasmModule(Isolate* isolate, Zone* zone, | 767 ModuleResult DecodeWasmModule(Isolate* isolate, Zone* zone, |
768 const byte* module_start, const byte* module_end, | 768 const byte* module_start, const byte* module_end, |
769 bool verify_functions, ModuleOrigin origin) { | 769 bool verify_functions, ModuleOrigin origin) { |
| 770 size_t decode_memory_start = zone->allocation_size(); |
| 771 HistogramTimerScope wasm_decode_module_time_scope( |
| 772 isolate->counters()->wasm_decode_module_time()); |
770 size_t size = module_end - module_start; | 773 size_t size = module_end - module_start; |
771 if (module_start > module_end) return ModuleError("start > end"); | 774 if (module_start > module_end) return ModuleError("start > end"); |
772 if (size >= kMaxModuleSize) return ModuleError("size > maximum module size"); | 775 if (size >= kMaxModuleSize) return ModuleError("size > maximum module size"); |
| 776 // TODO(bradnelson): Improve histogram handling of size_t. |
| 777 isolate->counters()->wasm_module_size_bytes()->AddSample( |
| 778 static_cast<int>(size)); |
773 WasmModule* module = new WasmModule(); | 779 WasmModule* module = new WasmModule(); |
774 ModuleDecoder decoder(zone, module_start, module_end, origin); | 780 ModuleDecoder decoder(zone, module_start, module_end, origin); |
775 return decoder.DecodeModule(module, verify_functions); | 781 ModuleResult result = decoder.DecodeModule(module, verify_functions); |
| 782 // TODO(bradnelson): Improve histogram handling of size_t. |
| 783 isolate->counters()->wasm_decode_peak_memory_bytes()->AddSample( |
| 784 static_cast<int>(zone->allocation_size() - decode_memory_start)); |
| 785 return result; |
776 } | 786 } |
777 | 787 |
778 | |
779 FunctionSig* DecodeWasmSignatureForTesting(Zone* zone, const byte* start, | 788 FunctionSig* DecodeWasmSignatureForTesting(Zone* zone, const byte* start, |
780 const byte* end) { | 789 const byte* end) { |
781 ModuleDecoder decoder(zone, start, end, kWasmOrigin); | 790 ModuleDecoder decoder(zone, start, end, kWasmOrigin); |
782 return decoder.DecodeFunctionSignature(start); | 791 return decoder.DecodeFunctionSignature(start); |
783 } | 792 } |
784 | 793 |
785 | 794 |
786 FunctionResult DecodeWasmFunction(Isolate* isolate, Zone* zone, | 795 FunctionResult DecodeWasmFunction(Isolate* isolate, Zone* zone, |
787 ModuleEnv* module_env, | 796 ModuleEnv* module_env, |
788 const byte* function_start, | 797 const byte* function_start, |
789 const byte* function_end) { | 798 const byte* function_end) { |
| 799 HistogramTimerScope wasm_decode_function_time_scope( |
| 800 isolate->counters()->wasm_decode_function_time()); |
790 size_t size = function_end - function_start; | 801 size_t size = function_end - function_start; |
791 if (function_start > function_end) return FunctionError("start > end"); | 802 if (function_start > function_end) return FunctionError("start > end"); |
792 if (size > kMaxFunctionSize) | 803 if (size > kMaxFunctionSize) |
793 return FunctionError("size > maximum function size"); | 804 return FunctionError("size > maximum function size"); |
| 805 isolate->counters()->wasm_function_size_bytes()->AddSample( |
| 806 static_cast<int>(size)); |
794 WasmFunction* function = new WasmFunction(); | 807 WasmFunction* function = new WasmFunction(); |
795 ModuleDecoder decoder(zone, function_start, function_end, kWasmOrigin); | 808 ModuleDecoder decoder(zone, function_start, function_end, kWasmOrigin); |
796 return decoder.DecodeSingleFunction(module_env, function); | 809 return decoder.DecodeSingleFunction(module_env, function); |
797 } | 810 } |
798 } // namespace wasm | 811 } // namespace wasm |
799 } // namespace internal | 812 } // namespace internal |
800 } // namespace v8 | 813 } // namespace v8 |
OLD | NEW |