From 6cee783cd23fd29050a0e8746cffc6a9d8adeda8 Mon Sep 17 00:00:00 2001 From: Jakob Kummerow Date: Fri, 6 Sep 2019 18:20:29 +0200 Subject: [PATCH] [wasm-c-api] Fix inefficiency in Global::get Getting the type from the internal object avoids a costly allocation. Not doing it this way all along was an oversight. Change-Id: I22197cbb6ab2a68dd0faba78152e7cc2eb473e23 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1790102 Reviewed-by: Andreas Haas Commit-Queue: Jakob Kummerow Cr-Commit-Position: refs/heads/master@{#63613} --- src/wasm/c-api.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/wasm/c-api.cc b/src/wasm/c-api.cc index e812dd7994..356285b5f7 100644 --- a/src/wasm/c-api.cc +++ b/src/wasm/c-api.cc @@ -1692,17 +1692,17 @@ auto Global::type() const -> own { auto Global::get() const -> Val { i::Handle v8_global = impl(this)->v8_object(); - switch (type()->content()->kind()) { - case I32: + switch (v8_global->type()) { + case i::wasm::kWasmI32: return Val(v8_global->GetI32()); - case I64: + case i::wasm::kWasmI64: return Val(v8_global->GetI64()); - case F32: + case i::wasm::kWasmF32: return Val(v8_global->GetF32()); - case F64: + case i::wasm::kWasmF64: return Val(v8_global->GetF64()); - case ANYREF: - case FUNCREF: { + case i::wasm::kWasmAnyRef: + case i::wasm::kWasmFuncRef: { StoreImpl* store = impl(this)->store(); i::HandleScope scope(store->i_isolate()); return Val(V8RefValueToWasm(store, v8_global->GetRef()));