[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 <ahaas@chromium.org> Commit-Queue: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#63613}
This commit is contained in:
parent
8703ac3a42
commit
6cee783cd2
@ -1692,17 +1692,17 @@ auto Global::type() const -> own<GlobalType> {
|
||||
|
||||
auto Global::get() const -> Val {
|
||||
i::Handle<i::WasmGlobalObject> 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()));
|
||||
|
Loading…
Reference in New Issue
Block a user