• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/execution/isolate.h"
7 #include "src/flags/flags.h"
8 #include "src/handles/handles-inl.h"
9 
10 namespace v8 {
11 namespace internal {
12 namespace wasm {
13 
14 // static
FromFlags()15 WasmFeatures WasmFeatures::FromFlags() {
16   WasmFeatures features = WasmFeatures::None();
17 #define FLAG_REF(feat, ...) \
18   if (FLAG_experimental_wasm_##feat) features.Add(kFeature_##feat);
19   FOREACH_WASM_FEATURE_FLAG(FLAG_REF)
20 #undef FLAG_REF
21 #define NON_FLAG_REF(feat, ...) features.Add(kFeature_##feat);
22   FOREACH_WASM_NON_FLAG_FEATURE(NON_FLAG_REF)
23 #undef NON_FLAG_REF
24   return features;
25 }
26 
27 // static
FromIsolate(Isolate * isolate)28 WasmFeatures WasmFeatures::FromIsolate(Isolate* isolate) {
29   return FromContext(isolate, handle(isolate->context(), isolate));
30 }
31 
32 // static
FromContext(Isolate * isolate,Handle<Context> context)33 WasmFeatures WasmFeatures::FromContext(Isolate* isolate,
34                                        Handle<Context> context) {
35   WasmFeatures features = WasmFeatures::FromFlags();
36   if (isolate->IsWasmSimdEnabled(context)) {
37     features.Add(kFeature_simd);
38   }
39   if (isolate->AreWasmExceptionsEnabled(context)) {
40     features.Add(kFeature_eh);
41   }
42   return features;
43 }
44 
45 }  // namespace wasm
46 }  // namespace internal
47 }  // namespace v8
48