1/* Copyright JS Foundation and other contributors, http://js.foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef JERRY_SNAPSHOT_H
17#define JERRY_SNAPSHOT_H
18
19#include "ecma-globals.h"
20
21/**
22 * Snapshot header
23 */
24typedef struct
25{
26  /* The size of this structure is recommended to be divisible by
27   * uint32_t alignment. Otherwise some bytes after the header are wasted. */
28  uint32_t magic; /**< four byte magic number */
29  uint32_t version; /**< version number */
30  uint32_t global_flags; /**< global configuration and feature flags */
31  uint32_t lit_table_offset; /**< byte offset of the literal table */
32  uint32_t number_of_funcs; /**< number of primary ECMAScript functions */
33  uint32_t func_offsets[1]; /**< function offsets (lowest bit: global(0) or eval(1) context) */
34} jerry_snapshot_header_t;
35
36/**
37 * Jerry snapshot magic marker.
38 */
39#define JERRY_SNAPSHOT_MAGIC (0x5952524Au)
40
41/**
42 * Snapshot configuration flags.
43 */
44typedef enum
45{
46  /* 8 bits are reserved for dynamic features */
47  JERRY_SNAPSHOT_HAS_REGEX_LITERAL = (1u << 0), /**< byte code has regex literal */
48  JERRY_SNAPSHOT_HAS_CLASS_LITERAL = (1u << 1), /**< byte code has class literal */
49  /* 24 bits are reserved for compile time features */
50  JERRY_SNAPSHOT_FOUR_BYTE_CPOINTER = (1u << 8) /**< deprecated, an unused placeholder now */
51} jerry_snapshot_global_flags_t;
52
53#endif /* !JERRY_SNAPSHOT_H */
54