Commit 15970238 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] [cleanup] Remove origin test methods

This removes the {IsWasm} and {IsAsmJs} methods, which tested a
ModuleOrigin for a specific constant.
These methods do not comply with our naming conventions, and we don't
have such methods for other enums.

Drive-by: Refactor the code which used these methods for better
readability and maintainability.

R=ahaas@chromium.org, kschimpf@chromium.org
BUG=v8:6474

Change-Id: I98eb4dba5420eaa9452ae6f27598ec8b581a0984
Reviewed-on: https://chromium-review.googlesource.com/530229Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45888}
parent 9d23ec9f
......@@ -1224,9 +1224,10 @@ ModuleResult DecodeWasmModuleInternal(Isolate* isolate,
if (is_sync) {
// TODO(karlschimpf): Make this work when asynchronous.
// https://bugs.chromium.org/p/v8/issues/detail?id=6361
(IsWasm(origin) ? isolate->counters()->wasm_wasm_module_size_bytes()
: isolate->counters()->wasm_asm_module_size_bytes())
->AddSample(static_cast<int>(size));
auto counter = origin == kWasmOrigin
? isolate->counters()->wasm_wasm_module_size_bytes()
: isolate->counters()->wasm_asm_module_size_bytes();
counter->AddSample(static_cast<int>(size));
}
// Signatures are stored in zone memory, which have the same lifetime
// as the {module}.
......@@ -1239,11 +1240,12 @@ ModuleResult DecodeWasmModuleInternal(Isolate* isolate,
if (is_sync && result.ok()) {
// TODO(karlschimpf): Make this work when asynchronous.
// https://bugs.chromium.org/p/v8/issues/detail?id=6361
(IsWasm(origin)
? isolate->counters()->wasm_decode_wasm_module_peak_memory_bytes()
: isolate->counters()->wasm_decode_asm_module_peak_memory_bytes())
->AddSample(
static_cast<int>(result.val->signature_zone->allocation_size()));
auto counter =
origin == kWasmOrigin
? isolate->counters()->wasm_decode_wasm_module_peak_memory_bytes()
: isolate->counters()->wasm_decode_asm_module_peak_memory_bytes();
counter->AddSample(
static_cast<int>(result.val->signature_zone->allocation_size()));
}
return result;
}
......@@ -1256,9 +1258,10 @@ ModuleResult DecodeWasmModule(Isolate* isolate, const byte* module_start,
if (is_sync) {
// TODO(karlschimpf): Make this work when asynchronous.
// https://bugs.chromium.org/p/v8/issues/detail?id=6361
HistogramTimerScope wasm_decode_module_time_scope(
IsWasm(origin) ? isolate->counters()->wasm_decode_wasm_module_time()
: isolate->counters()->wasm_decode_asm_module_time());
auto counter = origin == kWasmOrigin
? isolate->counters()->wasm_decode_wasm_module_time()
: isolate->counters()->wasm_decode_asm_module_time();
HistogramTimerScope wasm_decode_module_time_scope(counter);
return DecodeWasmModuleInternal(isolate, module_start, module_end,
verify_functions, origin, true);
}
......@@ -1314,12 +1317,14 @@ FunctionResult DecodeWasmFunction(Isolate* isolate, Zone* zone,
// https://bugs.chromium.org/p/v8/issues/detail?id=6361
size_t size = function_end - function_start;
bool is_wasm = module_env->module_env.is_wasm();
(is_wasm ? isolate->counters()->wasm_wasm_function_size_bytes()
: isolate->counters()->wasm_asm_function_size_bytes())
->AddSample(static_cast<int>(size));
HistogramTimerScope wasm_decode_function_time_scope(
auto size_counter =
is_wasm ? isolate->counters()->wasm_wasm_function_size_bytes()
: isolate->counters()->wasm_asm_function_size_bytes();
size_counter->AddSample(static_cast<int>(size));
auto time_counter =
is_wasm ? isolate->counters()->wasm_decode_wasm_function_time()
: isolate->counters()->wasm_decode_asm_function_time());
: isolate->counters()->wasm_decode_asm_function_time();
HistogramTimerScope wasm_decode_function_time_scope(time_counter);
return DecodeWasmFunctionInternal(isolate, zone, module_env, function_start,
function_end, true);
}
......
......@@ -154,13 +154,6 @@ struct WasmExport {
enum ModuleOrigin : uint8_t { kWasmOrigin, kAsmJsOrigin };
inline bool IsWasm(ModuleOrigin Origin) {
return Origin == ModuleOrigin::kWasmOrigin;
}
inline bool IsAsmJs(ModuleOrigin Origin) {
return Origin == ModuleOrigin::kAsmJsOrigin;
}
struct ModuleWireBytes;
// Static representation of a module.
......@@ -207,8 +200,8 @@ struct V8_EXPORT_PRIVATE WasmModule {
ModuleOrigin get_origin() const { return origin_; }
void set_origin(ModuleOrigin new_value) { origin_ = new_value; }
bool is_wasm() const { return wasm::IsWasm(origin_); }
bool is_asm_js() const { return wasm::IsAsmJs(origin_); }
bool is_wasm() const { return origin_ == kWasmOrigin; }
bool is_asm_js() const { return origin_ == kAsmJsOrigin; }
private:
// TODO(kschimpf) - Encapsulate more fields.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment