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 ECMA_LIT_STORAGE_H 17 #define ECMA_LIT_STORAGE_H 18 19 #include "ecma-globals.h" 20 #include "jmem.h" 21 #include "lit-globals.h" 22 23 /** \addtogroup ecma ECMA 24 * @{ 25 * 26 * \addtogroup ecmalitstorage Literal storage 27 * @{ 28 */ 29 30 #if ENABLED (JERRY_SNAPSHOT_SAVE) 31 /** 32 * Snapshot literal - offset map 33 */ 34 typedef struct 35 { 36 ecma_value_t literal_id; /**< literal id */ 37 ecma_value_t literal_offset; /**< literal offset */ 38 } lit_mem_to_snapshot_id_map_entry_t; 39 #endif /* ENABLED (JERRY_SNAPSHOT_SAVE) */ 40 41 void ecma_finalize_lit_storage (void); 42 43 ecma_value_t ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, lit_utf8_size_t size); 44 ecma_value_t ecma_find_or_create_literal_number (ecma_number_t number_arg); 45 46 #if ENABLED (JERRY_SNAPSHOT_SAVE) 47 void ecma_save_literals_append_value (ecma_value_t value, ecma_collection_t *lit_pool_p); 48 void ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, 49 ecma_collection_t *lit_pool_p); 50 bool ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, uint32_t *buffer_p, size_t buffer_size, 51 size_t *in_out_buffer_offset_p, lit_mem_to_snapshot_id_map_entry_t **out_map_p, 52 uint32_t *out_map_len_p); 53 #endif /* ENABLED (JERRY_SNAPSHOT_SAVE) */ 54 55 #if ENABLED (JERRY_SNAPSHOT_EXEC) || ENABLED (JERRY_SNAPSHOT_SAVE) 56 ecma_value_t 57 ecma_snapshot_get_literal (const uint8_t *literal_base_p, ecma_value_t literal_value); 58 #endif /* ENABLED (JERRY_SNAPSHOT_EXEC) || ENABLED (JERRY_SNAPSHOT_SAVE) */ 59 60 /** 61 * @} 62 * @} 63 */ 64 65 #endif /* !ECMA_LIT_STORAGE_H */ 66