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_INSTRUCTION_STREAM_H_
6 #define V8_INSTRUCTION_STREAM_H_
7 
8 #include "src/base/macros.h"
9 #include "src/globals.h"
10 
11 namespace v8 {
12 namespace internal {
13 
14 class Code;
15 class Isolate;
16 
17 // Wraps an off-heap instruction stream.
18 // TODO(jgruber,v8:6666): Remove this class.
19 class InstructionStream final : public AllStatic {
20  public:
21   // Returns true, iff the given pc points into an off-heap instruction stream.
22   static bool PcIsOffHeap(Isolate* isolate, Address pc);
23 
24   // Returns the corresponding Code object if it exists, and nullptr otherwise.
25   static Code* TryLookupCode(Isolate* isolate, Address address);
26 
27   // During snapshot creation, we first create an executable off-heap area
28   // containing all off-heap code. The area is guaranteed to be contiguous.
29   // Note that this only applies when building the snapshot, e.g. for
30   // mksnapshot. Otherwise, off-heap code is embedded directly into the binary.
31   static void CreateOffHeapInstructionStream(Isolate* isolate, uint8_t** data,
32                                              uint32_t* size);
33   static void FreeOffHeapInstructionStream(uint8_t* data, uint32_t size);
34 };
35 
36 }  // namespace internal
37 }  // namespace v8
38 
39 #endif  // V8_INSTRUCTION_STREAM_H_
40