Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: src/wasm/signature-map.h

Issue 2403093002: [wasm] Canonicalize function signature indices for matching in indirect calls. (Closed)
Patch Set: Add TODO for myself Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 #ifndef V8_WASM_SIGNATURE_MAP_H_
6 #define V8_WASM_SIGNATURE_MAP_H_
7
8 #include <map>
9
10 #include "src/signature.h"
11 #include "src/wasm/wasm-opcodes.h"
12
13 namespace v8 {
14 namespace internal {
15 namespace wasm {
16
17 // A signature map canonicalizes signatures into a range of indices so that
18 // two different {FunctionSig} instances with the same contents map to the
19 // same index.
20 class SignatureMap {
21 public:
22 // Gets the index for a signature, assigning a new index if necessary.
23 uint32_t Get(FunctionSig* sig);
24
25 // Gets the index for a signature, returning {-1} if not found.
26 int32_t Find(FunctionSig* sig) const;
27
28 private:
29 struct CompareFunctionSigs {
30 bool operator()(FunctionSig* a, FunctionSig* b) const;
31 };
32 uint32_t next_;
33 std::map<FunctionSig*, uint32_t, CompareFunctionSigs> map_;
Clemens Hammacher 2016/10/10 17:35:02 Depending on the size of the map, an std::unordere
titzer 2016/10/10 17:45:21 I've added a TODO here (since it was much easier t
34 };
35
36 } // namespace wasm
37 } // namespace internal
38 } // namespace v8
39
40 #endif // V8_WASM_SIGNATURE_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698