blob: 14a7e3b6a6f13b007f255e4290c8be829b82975a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/wasm/wasm-init-expr.h"
#include "src/wasm/wasm-features.h"
#include "src/wasm/wasm-module.h"
namespace v8 {
namespace internal {
namespace wasm {
ValueType WasmInitExpr::type(const WasmModule* module,
const WasmFeatures& enabled_features) const {
switch (kind()) {
case kNone:
return kWasmBottom;
case kGlobalGet:
return immediate().index < module->globals.size()
? module->globals[immediate().index].type
: kWasmBottom;
case kI32Const:
return kWasmI32;
case kI64Const:
return kWasmI64;
case kF32Const:
return kWasmF32;
case kF64Const:
return kWasmF64;
case kS128Const:
return kWasmS128;
case kRefFuncConst: {
uint32_t heap_type = enabled_features.has_typed_funcref()
? module->functions[immediate().index].sig_index
: HeapType::kFunc;
return ValueType::Ref(heap_type, kNonNullable);
}
case kRefNullConst:
return ValueType::Ref(immediate().heap_type, kNullable);
case kStructNewWithRtt:
case kArrayInit:
return ValueType::Ref(immediate().index, kNonNullable);
case kRttCanon:
return ValueType::Rtt(immediate().heap_type, 0);
case kRttSub:
case kRttFreshSub: {
ValueType operand_type = operands()[0].type(module, enabled_features);
if (!operand_type.is_rtt()) return kWasmBottom;
if (operand_type.has_depth()) {
return ValueType::Rtt(immediate().heap_type, operand_type.depth() + 1);
} else {
return ValueType::Rtt(immediate().heap_type);
}
}
}
}
} // namespace wasm
} // namespace internal
} // namespace v8
|