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

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

Issue 2929853003: Fix use of history timers in background threads. (Closed)
Patch Set: Fix nits. Created 3 years, 6 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
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 #include "src/wasm/function-body-decoder-impl.h" 6 #include "src/wasm/function-body-decoder-impl.h"
7 7
8 #include "src/base/functional.h" 8 #include "src/base/functional.h"
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/counters.h" 10 #include "src/counters.h"
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 // FunctionSig stores the return types first. 1213 // FunctionSig stores the return types first.
1214 ValueType* buffer = zone->NewArray<ValueType>(param_count + return_count); 1214 ValueType* buffer = zone->NewArray<ValueType>(param_count + return_count);
1215 uint32_t b = 0; 1215 uint32_t b = 0;
1216 for (uint32_t i = 0; i < return_count; ++i) buffer[b++] = returns[i]; 1216 for (uint32_t i = 0; i < return_count; ++i) buffer[b++] = returns[i];
1217 for (uint32_t i = 0; i < param_count; ++i) buffer[b++] = params[i]; 1217 for (uint32_t i = 0; i < param_count; ++i) buffer[b++] = params[i];
1218 1218
1219 return new (zone) FunctionSig(return_count, param_count, buffer); 1219 return new (zone) FunctionSig(return_count, param_count, buffer);
1220 } 1220 }
1221 }; 1221 };
1222 1222
1223 ModuleResult DecodeWasmModuleInternal(Isolate* isolate, 1223 } // namespace
1224 const byte* module_start, 1224
1225 const byte* module_end, 1225 ModuleResult DecodeWasmModule(Isolate* isolate, const byte* module_start,
1226 bool verify_functions, 1226 const byte* module_end, bool verify_functions,
1227 ModuleOrigin origin, bool is_sync) { 1227 ModuleOrigin origin, bool is_sync) {
1228 TimedHistogramScope wasm_decode_module_time_scope(
1229 IsWasm(origin) ? isolate->counters()->wasm_decode_wasm_module_time()
jochen (gone - plz use gerrit) 2017/06/08 22:15:36 same here
kschimpf 2017/06/09 20:03:36 Good point. This code was massively reorganized (i
1230 : isolate->counters()->wasm_decode_asm_module_time());
1228 size_t size = module_end - module_start; 1231 size_t size = module_end - module_start;
1229 if (module_start > module_end) return ModuleResult::Error("start > end"); 1232 if (module_start > module_end) return ModuleResult::Error("start > end");
1230 if (size >= kV8MaxWasmModuleSize) 1233 if (size >= kV8MaxWasmModuleSize)
1231 return ModuleResult::Error("size > maximum module size: %zu", size); 1234 return ModuleResult::Error("size > maximum module size: %zu", size);
1232 // TODO(bradnelson): Improve histogram handling of size_t. 1235 // TODO(bradnelson): Improve histogram handling of size_t.
1233 if (is_sync) { 1236 if (is_sync) {
1234 // TODO(karlschimpf): Make this work when asynchronous. 1237 // TODO(karlschimpf): Make this work when asynchronous.
1235 // https://bugs.chromium.org/p/v8/issues/detail?id=6361 1238 // https://bugs.chromium.org/p/v8/issues/detail?id=6361
1236 (IsWasm(origin) ? isolate->counters()->wasm_wasm_module_size_bytes() 1239 (IsWasm(origin) ? isolate->counters()->wasm_wasm_module_size_bytes()
1237 : isolate->counters()->wasm_asm_module_size_bytes()) 1240 : isolate->counters()->wasm_asm_module_size_bytes())
(...skipping 12 matching lines...) Expand all
1250 // https://bugs.chromium.org/p/v8/issues/detail?id=6361 1253 // https://bugs.chromium.org/p/v8/issues/detail?id=6361
1251 (IsWasm(origin) 1254 (IsWasm(origin)
1252 ? isolate->counters()->wasm_decode_wasm_module_peak_memory_bytes() 1255 ? isolate->counters()->wasm_decode_wasm_module_peak_memory_bytes()
1253 : isolate->counters()->wasm_decode_asm_module_peak_memory_bytes()) 1256 : isolate->counters()->wasm_decode_asm_module_peak_memory_bytes())
1254 ->AddSample( 1257 ->AddSample(
1255 static_cast<int>(result.val->signature_zone->allocation_size())); 1258 static_cast<int>(result.val->signature_zone->allocation_size()));
1256 } 1259 }
1257 return result; 1260 return result;
1258 } 1261 }
1259 1262
1260 } // namespace
1261
1262 ModuleResult DecodeWasmModule(Isolate* isolate, const byte* module_start,
1263 const byte* module_end, bool verify_functions,
1264 ModuleOrigin origin, bool is_sync) {
1265 if (is_sync) {
1266 // TODO(karlschimpf): Make this work when asynchronous.
1267 // https://bugs.chromium.org/p/v8/issues/detail?id=6361
1268 HistogramTimerScope wasm_decode_module_time_scope(
1269 IsWasm(origin) ? isolate->counters()->wasm_decode_wasm_module_time()
1270 : isolate->counters()->wasm_decode_asm_module_time());
1271 return DecodeWasmModuleInternal(isolate, module_start, module_end,
1272 verify_functions, origin, true);
1273 }
1274 return DecodeWasmModuleInternal(isolate, module_start, module_end,
1275 verify_functions, origin, false);
1276 }
1277
1278 FunctionSig* DecodeWasmSignatureForTesting(Zone* zone, const byte* start, 1263 FunctionSig* DecodeWasmSignatureForTesting(Zone* zone, const byte* start,
1279 const byte* end) { 1264 const byte* end) {
1280 ModuleDecoder decoder(start, end, kWasmOrigin); 1265 ModuleDecoder decoder(start, end, kWasmOrigin);
1281 return decoder.DecodeFunctionSignature(zone, start); 1266 return decoder.DecodeFunctionSignature(zone, start);
1282 } 1267 }
1283 1268
1284 WasmInitExpr DecodeWasmInitExprForTesting(const byte* start, const byte* end) { 1269 WasmInitExpr DecodeWasmInitExprForTesting(const byte* start, const byte* end) {
1285 AccountingAllocator allocator; 1270 AccountingAllocator allocator;
1286 ModuleDecoder decoder(start, end, kWasmOrigin); 1271 ModuleDecoder decoder(start, end, kWasmOrigin);
1287 return decoder.DecodeInitExpr(start); 1272 return decoder.DecodeInitExpr(start);
1288 } 1273 }
1289 1274
1290 namespace { 1275 FunctionResult DecodeWasmFunction(Isolate* isolate, Zone* zone,
1291 1276 ModuleBytesEnv* module_env,
1292 FunctionResult DecodeWasmFunctionInternal(Isolate* isolate, Zone* zone, 1277 const byte* function_start,
1293 ModuleBytesEnv* module_env, 1278 const byte* function_end, bool is_sync) {
1294 const byte* function_start,
1295 const byte* function_end,
1296 bool is_sync) {
1297 size_t size = function_end - function_start; 1279 size_t size = function_end - function_start;
1280 bool is_wasm = module_env->module_env.is_wasm();
1281 (is_wasm ? isolate->counters()->wasm_wasm_function_size_bytes()
1282 : isolate->counters()->wasm_asm_function_size_bytes())
1283 ->AddSample(static_cast<int>(size));
1284 TimedHistogramScope wasm_decode_function_time_scope(
1285 is_wasm ? isolate->counters()->wasm_decode_wasm_function_time()
1286 : isolate->counters()->wasm_decode_asm_function_time());
1298 if (function_start > function_end) 1287 if (function_start > function_end)
1299 return FunctionResult::Error("start > end"); 1288 return FunctionResult::Error("start > end");
1300 if (size > kV8MaxWasmFunctionSize) 1289 if (size > kV8MaxWasmFunctionSize)
1301 return FunctionResult::Error("size > maximum function size: %zu", size); 1290 return FunctionResult::Error("size > maximum function size: %zu", size);
1302 if (is_sync) { 1291 if (is_sync) {
1303 // TODO(karlschimpf): Make this work when asynchronous. 1292 // TODO(karlschimpf): Make this work when asynchronous.
1304 // https://bugs.chromium.org/p/v8/issues/detail?id=6361 1293 // https://bugs.chromium.org/p/v8/issues/detail?id=6361
1305 bool is_wasm = module_env->module_env.is_wasm(); 1294 bool is_wasm = module_env->module_env.is_wasm();
1306 (is_wasm ? isolate->counters()->wasm_wasm_function_size_bytes() 1295 (is_wasm ? isolate->counters()->wasm_wasm_function_size_bytes()
1307 : isolate->counters()->wasm_asm_function_size_bytes()) 1296 : isolate->counters()->wasm_asm_function_size_bytes())
1308 ->AddSample(static_cast<int>(size)); 1297 ->AddSample(static_cast<int>(size));
1309 } 1298 }
1310 ModuleDecoder decoder(function_start, function_end, kWasmOrigin); 1299 ModuleDecoder decoder(function_start, function_end, kWasmOrigin);
1311 return decoder.DecodeSingleFunction( 1300 return decoder.DecodeSingleFunction(
1312 zone, module_env, std::unique_ptr<WasmFunction>(new WasmFunction())); 1301 zone, module_env, std::unique_ptr<WasmFunction>(new WasmFunction()));
1313 } 1302 }
1314 1303
1315 } // namespace
1316
1317 FunctionResult DecodeWasmFunction(Isolate* isolate, Zone* zone,
1318 ModuleBytesEnv* module_env,
1319 const byte* function_start,
1320 const byte* function_end, bool is_sync) {
1321 if (is_sync) {
1322 // TODO(karlschimpf): Make this work when asynchronous.
1323 // https://bugs.chromium.org/p/v8/issues/detail?id=6361
1324 size_t size = function_end - function_start;
1325 bool is_wasm = module_env->module_env.is_wasm();
1326 (is_wasm ? isolate->counters()->wasm_wasm_function_size_bytes()
1327 : isolate->counters()->wasm_asm_function_size_bytes())
1328 ->AddSample(static_cast<int>(size));
1329 HistogramTimerScope wasm_decode_function_time_scope(
1330 is_wasm ? isolate->counters()->wasm_decode_wasm_function_time()
1331 : isolate->counters()->wasm_decode_asm_function_time());
1332 return DecodeWasmFunctionInternal(isolate, zone, module_env, function_start,
1333 function_end, true);
1334 }
1335 return DecodeWasmFunctionInternal(isolate, zone, module_env, function_start,
1336 function_end, false);
1337 }
1338
1339 AsmJsOffsetsResult DecodeAsmJsOffsets(const byte* tables_start, 1304 AsmJsOffsetsResult DecodeAsmJsOffsets(const byte* tables_start,
1340 const byte* tables_end) { 1305 const byte* tables_end) {
1341 AsmJsOffsets table; 1306 AsmJsOffsets table;
1342 1307
1343 Decoder decoder(tables_start, tables_end); 1308 Decoder decoder(tables_start, tables_end);
1344 uint32_t functions_count = decoder.consume_u32v("functions count"); 1309 uint32_t functions_count = decoder.consume_u32v("functions count");
1345 // Reserve space for the entries, taking care of invalid input. 1310 // Reserve space for the entries, taking care of invalid input.
1346 if (functions_count < static_cast<unsigned>(tables_end - tables_start)) { 1311 if (functions_count < static_cast<unsigned>(tables_end - tables_start)) {
1347 table.reserve(functions_count); 1312 table.reserve(functions_count);
1348 } 1313 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 result.push_back({section_start, name_offset, name_length, payload_offset, 1377 result.push_back({section_start, name_offset, name_length, payload_offset,
1413 payload_length, section_length}); 1378 payload_length, section_length});
1414 } 1379 }
1415 1380
1416 return result; 1381 return result;
1417 } 1382 }
1418 1383
1419 } // namespace wasm 1384 } // namespace wasm
1420 } // namespace internal 1385 } // namespace internal
1421 } // namespace v8 1386 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698