1 // Copyright 2018 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/wasm/wasm-features.h"
6 #include "src/flags.h"
7 #include "src/handles-inl.h"
8 #include "src/isolate.h"
9
10 namespace v8 {
11 namespace internal {
12 namespace wasm {
13
14 #define COMMA ,
15 #define SPACE
16 #define DO_UNION(feat, desc, val) dst->feat |= src.feat;
17 #define FLAG_REF(feat, desc, val) FLAG_experimental_wasm_##feat
18
UnionFeaturesInto(WasmFeatures * dst,const WasmFeatures & src)19 void UnionFeaturesInto(WasmFeatures* dst, const WasmFeatures& src) {
20 FOREACH_WASM_FEATURE(DO_UNION, SPACE);
21 }
22
WasmFeaturesFromFlags()23 WasmFeatures WasmFeaturesFromFlags() {
24 return WasmFeatures{FOREACH_WASM_FEATURE(FLAG_REF, COMMA)};
25 }
26
WasmFeaturesFromIsolate(Isolate * isolate)27 WasmFeatures WasmFeaturesFromIsolate(Isolate* isolate) {
28 WasmFeatures features = WasmFeaturesFromFlags();
29 features.threads |=
30 isolate->AreWasmThreadsEnabled(handle(isolate->context(), isolate));
31 return features;
32 }
33
34 #undef DO_UNION
35 #undef FLAG_REF
36 #undef SPACE
37 #undef COMMA
38 } // namespace wasm
39 } // namespace internal
40 } // namespace v8
41