v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
well-known-imports.cc
Go to the documentation of this file.
1// Copyright 2023 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
6
7namespace v8::internal::wasm {
8
10 switch (wki) {
11 // Generic:
13 return "uninstantiated";
15 return "generic";
17 return "LinkError";
18
19 // DataView methods:
21 return "DataView.getBigInt64";
23 return "DataView.getBigUint64";
25 return "DataView.getFloat32";
27 return "DataView.getFloat64";
29 return "DataView.getInt8";
31 return "DataView.getInt16";
33 return "DataView.getInt32";
35 return "DataView.getUint8";
37 return "DataView.getUint16";
39 return "DataView.getUint32";
41 return "DataView.setBigInt64";
43 return "DataView.setBigUint64";
45 return "DataView.setFloat32";
47 return "DataView.setFloat64";
49 return "DataView.setInt8";
51 return "DataView.setInt16";
53 return "DataView.setInt32";
55 return "DataView.setUint8";
57 return "DataView.setUint16";
59 return "DataView.setUint32";
61 return "DataView.byteLength";
62
63 // Math functions.
65 return "Math.acos";
67 return "Math.asin";
69 return "Math.atan";
71 return "Math.atan2";
73 return "Math.cos";
75 return "Math.sin";
77 return "Math.tan";
79 return "Math.exp";
81 return "Math.log";
83 return "Math.pow";
85 return "Math.sqrt";
86
87 // String-related functions:
89 return "DoubleToString";
91 return "IntToString";
93 return "ParseFloat";
96 return "String.indexOf";
98 return "String.toLocaleLowerCase";
101 return "String.toLowerCase";
102
103 // JS String Builtins:
105 return "js-string:cast";
107 return "js-string:charCodeAt";
109 return "js-string:codePointAt";
111 return "js-string:compare";
113 return "js-string:concat";
115 return "js-string:equals";
117 return "js-string:fromCharCode";
119 return "js-string:fromCodePoint";
121 return "text-decoder:decodeStringFromUTF8Array";
123 return "js-string:fromCharCodeArray";
125 return "text-encoder:encodeStringIntoUTF8Array";
127 return "text-encoder:encodeStringToUTF8Array";
129 return "js-string:length";
131 return "text-encoder:measureStringAsUTF8";
133 return "js-string:substring";
135 return "js-string:test";
137 return "js-string:intoCharCodeArray";
138
139 // Fast API Call:
141 return "fast API call";
142 }
143}
144
147 DCHECK_EQ(entries.size(), static_cast<size_t>(size_));
148 for (size_t i = 0; i < entries.size(); i++) {
149 WellKnownImport entry = entries[i];
151 WellKnownImport old = statuses_[i].load(std::memory_order_relaxed);
152 if (old == WellKnownImport::kGeneric) continue;
153 if (old == entry) continue;
155 statuses_[i].store(entry, std::memory_order_relaxed);
156 } else {
157 // To avoid having to clear Turbofan code multiple times, we give up
158 // entirely once the first problem occurs.
159 // This is a heuristic; we could also choose to make finer-grained
160 // decisions and only set {statuses_[i] = kGeneric}. We expect that
161 // this case won't ever happen for production modules, so guarding
162 // against pathological cases seems more important than being lenient
163 // towards almost-well-behaved modules.
164 for (size_t j = 0; j < entries.size(); j++) {
166 std::memory_order_relaxed);
167 }
169 }
170 }
171 return UpdateResult::kOK;
172}
173
176 DCHECK_EQ(entries.size(), static_cast<size_t>(size_));
177 for (size_t i = 0; i < entries.size(); i++) {
179 statuses_[i].load(std::memory_order_relaxed));
180 statuses_[i].store(entries[i], std::memory_order_relaxed);
181 }
182}
183
184} // namespace v8::internal::wasm
V8_WARN_UNUSED_RESULT UpdateResult Update(base::Vector< WellKnownImport > entries)
std::unique_ptr< std::atomic< WellKnownImport >[]> statuses_
const int size_
Definition assembler.cc:132
ZoneVector< Entry > entries
const char * WellKnownImportName(WellKnownImport wki)
#define DCHECK(condition)
Definition logging.h:482
#define DCHECK_EQ(v1, v2)
Definition logging.h:485