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 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 isolate->counters()->wasm_module_bytes()->AddSample(static_cast<int>(size)); | |
| 773 WasmModule* module = new WasmModule(); | 777 WasmModule* module = new WasmModule(); |
| 774 ModuleDecoder decoder(zone, module_start, module_end, origin); | 778 ModuleDecoder decoder(zone, module_start, module_end, origin); |
| 775 return decoder.DecodeModule(module, verify_functions); | 779 ModuleResult result = decoder.DecodeModule(module, verify_functions); |
| 780 isolate->counters()->wasm_decode_peak_memory()->AddSample( | |
| 781 static_cast<int>(zone->allocation_size() - decode_memory_start)); | |
|
Mircea Trofin
2016/04/13 17:51:25
Same concern with the loss of precision I expresse
bradnelson
2016/04/14 07:05:22
Added TODO.
| |
| 782 return result; | |
| 776 } | 783 } |
| 777 | 784 |
| 778 | |
| 779 FunctionSig* DecodeWasmSignatureForTesting(Zone* zone, const byte* start, | 785 FunctionSig* DecodeWasmSignatureForTesting(Zone* zone, const byte* start, |
| 780 const byte* end) { | 786 const byte* end) { |
| 781 ModuleDecoder decoder(zone, start, end, kWasmOrigin); | 787 ModuleDecoder decoder(zone, start, end, kWasmOrigin); |
| 782 return decoder.DecodeFunctionSignature(start); | 788 return decoder.DecodeFunctionSignature(start); |
| 783 } | 789 } |
| 784 | 790 |
| 785 | 791 |
| 786 FunctionResult DecodeWasmFunction(Isolate* isolate, Zone* zone, | 792 FunctionResult DecodeWasmFunction(Isolate* isolate, Zone* zone, |
| 787 ModuleEnv* module_env, | 793 ModuleEnv* module_env, |
| 788 const byte* function_start, | 794 const byte* function_start, |
| 789 const byte* function_end) { | 795 const byte* function_end) { |
| 796 HistogramTimerScope wasm_decode_function_time_scope( | |
| 797 isolate->counters()->wasm_decode_function_time()); | |
| 790 size_t size = function_end - function_start; | 798 size_t size = function_end - function_start; |
| 791 if (function_start > function_end) return FunctionError("start > end"); | 799 if (function_start > function_end) return FunctionError("start > end"); |
| 792 if (size > kMaxFunctionSize) | 800 if (size > kMaxFunctionSize) |
| 793 return FunctionError("size > maximum function size"); | 801 return FunctionError("size > maximum function size"); |
| 802 isolate->counters()->wasm_function_bytes()->AddSample(static_cast<int>(size)); | |
| 794 WasmFunction* function = new WasmFunction(); | 803 WasmFunction* function = new WasmFunction(); |
| 795 ModuleDecoder decoder(zone, function_start, function_end, kWasmOrigin); | 804 ModuleDecoder decoder(zone, function_start, function_end, kWasmOrigin); |
| 796 return decoder.DecodeSingleFunction(module_env, function); | 805 return decoder.DecodeSingleFunction(module_env, function); |
| 797 } | 806 } |
| 798 } // namespace wasm | 807 } // namespace wasm |
| 799 } // namespace internal | 808 } // namespace internal |
| 800 } // namespace v8 | 809 } // namespace v8 |
| OLD | NEW |