wasm-features.cc 1.03 KB
Newer Older
1 2 3 4 5 6
// Copyright 2018 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-features.h"
#include "src/flags.h"
7
#include "src/handles-inl.h"
8 9 10 11 12 13 14 15
#include "src/isolate.h"

namespace v8 {
namespace internal {
namespace wasm {

#define COMMA ,
#define SPACE
16
#define DO_UNION(feat, desc, val) dst->feat |= src.feat;
17 18
#define FLAG_REF(feat, desc, val) FLAG_experimental_wasm_##feat

19 20
void UnionFeaturesInto(WasmFeatures* dst, const WasmFeatures& src) {
  FOREACH_WASM_FEATURE(DO_UNION, SPACE);
21 22
}

23
WasmFeatures WasmFeaturesFromFlags() {
24 25 26 27
  return WasmFeatures{FOREACH_WASM_FEATURE(FLAG_REF, COMMA)};
}

WasmFeatures WasmFeaturesFromIsolate(Isolate* isolate) {
28
  WasmFeatures features = WasmFeaturesFromFlags();
29
  features.threads |=
30 31
      isolate->AreWasmThreadsEnabled(handle(isolate->context(), isolate));
  return features;
32 33 34 35 36 37 38 39 40
}

#undef DO_UNION
#undef FLAG_REF
#undef SPACE
#undef COMMA
}  // namespace wasm
}  // namespace internal
}  // namespace v8