V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
object-access.h
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 #ifndef V8_WASM_OBJECT_ACCESS_H_
6 #define V8_WASM_OBJECT_ACCESS_H_
7 
8 #include "src/globals.h"
9 #include "src/objects/fixed-array.h"
10 #include "src/objects/js-objects.h"
11 #include "src/objects/shared-function-info.h"
12 
13 namespace v8 {
14 namespace internal {
15 namespace wasm {
16 
17 class ObjectAccess : public AllStatic {
18  public:
19  // Convert an offset into an object to an offset into a tagged object.
20  static constexpr int ToTagged(int offset) { return offset - kHeapObjectTag; }
21 
22  // Get the offset into a fixed array for a given {index}.
23  static constexpr int ElementOffsetInTaggedFixedArray(int index) {
24  return ToTagged(FixedArray::OffsetOfElementAt(index));
25  }
26 
27  // Get the offset of the context stored in a {JSFunction} object.
28  static constexpr int ContextOffsetInTaggedJSFunction() {
29  return ToTagged(JSFunction::kContextOffset);
30  }
31 
32  // Get the offset of the shared function info in a {JSFunction} object.
33  static constexpr int SharedFunctionInfoOffsetInTaggedJSFunction() {
34  return ToTagged(JSFunction::kSharedFunctionInfoOffset);
35  }
36 
37  // Get the offset of the formal parameter count in a {SharedFunctionInfo}
38  // object.
39  static constexpr int FormalParameterCountOffsetInSharedFunctionInfo() {
40  return ToTagged(SharedFunctionInfo::kFormalParameterCountOffset);
41  }
42 };
43 
44 } // namespace wasm
45 } // namespace internal
46 } // namespace v8
47 
48 #endif // V8_WASM_OBJECT_ACCESS_H_
Definition: libplatform.h:13