Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Side by Side Diff: src/wasm/module-decoder.cc

Issue 2424623002: [wasm] Use a Managed<WasmModule> to hold metadata about modules. (Closed)
Patch Set: [wasm] Use a Managed<WasmModule> to hold metadata about modules. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/module-decoder.h ('k') | src/wasm/wasm-js.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 } 1070 }
1071 decoder.consume_bytes(section_iter.payload_length(), "section payload"); 1071 decoder.consume_bytes(section_iter.payload_length(), "section payload");
1072 section_iter.advance(); 1072 section_iter.advance();
1073 } 1073 }
1074 1074
1075 return Vector<const uint8_t>(); 1075 return Vector<const uint8_t>();
1076 } 1076 }
1077 1077
1078 } // namespace 1078 } // namespace
1079 1079
1080 ModuleResult DecodeWasmModule(Isolate* isolate, Zone* zone, 1080 ModuleResult DecodeWasmModule(Isolate* isolate, const byte* module_start,
1081 const byte* module_start, const byte* module_end, 1081 const byte* module_end, bool verify_functions,
1082 bool verify_functions, ModuleOrigin origin) { 1082 ModuleOrigin origin) {
1083 size_t decode_memory_start = zone->allocation_size();
1084 HistogramTimerScope wasm_decode_module_time_scope( 1083 HistogramTimerScope wasm_decode_module_time_scope(
1085 isolate->counters()->wasm_decode_module_time()); 1084 isolate->counters()->wasm_decode_module_time());
1086 size_t size = module_end - module_start; 1085 size_t size = module_end - module_start;
1087 if (module_start > module_end) return ModuleError("start > end"); 1086 if (module_start > module_end) return ModuleError("start > end");
1088 if (size >= kMaxModuleSize) return ModuleError("size > maximum module size"); 1087 if (size >= kMaxModuleSize) return ModuleError("size > maximum module size");
1089 // TODO(bradnelson): Improve histogram handling of size_t. 1088 // TODO(bradnelson): Improve histogram handling of size_t.
1090 isolate->counters()->wasm_module_size_bytes()->AddSample( 1089 isolate->counters()->wasm_module_size_bytes()->AddSample(
1091 static_cast<int>(size)); 1090 static_cast<int>(size));
1092 WasmModule* module = new WasmModule(); 1091 // Signatures are stored in zone memory, which have the same lifetime
1092 // as the {module}.
1093 Zone* zone = new Zone(isolate->allocator(), ZONE_NAME);
1094 WasmModule* module = new WasmModule(zone, module_start);
1093 ModuleDecoder decoder(zone, module_start, module_end, origin); 1095 ModuleDecoder decoder(zone, module_start, module_end, origin);
1094 ModuleResult result = decoder.DecodeModule(module, verify_functions); 1096 ModuleResult result = decoder.DecodeModule(module, verify_functions);
1095 // TODO(bradnelson): Improve histogram handling of size_t. 1097 // TODO(bradnelson): Improve histogram handling of size_t.
1098 // TODO(titzer): this isn't accurate, since it doesn't count the data
1099 // allocated on the C++ heap.
1100 // https://bugs.chromium.org/p/chromium/issues/detail?id=657320
1096 isolate->counters()->wasm_decode_module_peak_memory_bytes()->AddSample( 1101 isolate->counters()->wasm_decode_module_peak_memory_bytes()->AddSample(
1097 static_cast<int>(zone->allocation_size() - decode_memory_start)); 1102 static_cast<int>(zone->allocation_size()));
1098 return result; 1103 return result;
1099 } 1104 }
1100 1105
1101 FunctionSig* DecodeWasmSignatureForTesting(Zone* zone, const byte* start, 1106 FunctionSig* DecodeWasmSignatureForTesting(Zone* zone, const byte* start,
1102 const byte* end) { 1107 const byte* end) {
1103 ModuleDecoder decoder(zone, start, end, kWasmOrigin); 1108 ModuleDecoder decoder(zone, start, end, kWasmOrigin);
1104 return decoder.DecodeFunctionSignature(start); 1109 return decoder.DecodeFunctionSignature(start);
1105 } 1110 }
1106 1111
1107 WasmInitExpr DecodeWasmInitExprForTesting(const byte* start, const byte* end) { 1112 WasmInitExpr DecodeWasmInitExprForTesting(const byte* start, const byte* end) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 table.push_back(std::move(func_asm_offsets)); 1210 table.push_back(std::move(func_asm_offsets));
1206 } 1211 }
1207 if (decoder.more()) decoder.error("unexpected additional bytes"); 1212 if (decoder.more()) decoder.error("unexpected additional bytes");
1208 1213
1209 return decoder.toResult(std::move(table)); 1214 return decoder.toResult(std::move(table));
1210 } 1215 }
1211 1216
1212 } // namespace wasm 1217 } // namespace wasm
1213 } // namespace internal 1218 } // namespace internal
1214 } // namespace v8 1219 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/module-decoder.h ('k') | src/wasm/wasm-js.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698