3434 * @return configuration flags
3535 */
3636static inline uint32_t JERRY_ATTR_ALWAYS_INLINE
37- snapshot_get_global_flags (bool has_regex ) /**< regex literal is present */
37+ snapshot_get_global_flags (bool has_regex , /**< regex literal is present */
38+ bool has_class ) /**< class literal is present */
3839{
3940 JERRY_UNUSED (has_regex );
41+ JERRY_UNUSED (has_class );
4042
4143 uint32_t flags = 0 ;
4244
@@ -45,7 +47,10 @@ snapshot_get_global_flags (bool has_regex) /**< regex literal is present */
4547#endif /* JERRY_CPOINTER_32_BIT */
4648#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
4749 flags |= (has_regex ? JERRY_SNAPSHOT_HAS_REGEX_LITERAL : 0 );
48- #endif /* CONFIG_DISABLE_REGEXP_BUILTIN */
50+ #endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
51+ #ifndef CONFIG_DISABLE_ES2015_CLASS
52+ flags |= (has_class ? JERRY_SNAPSHOT_HAS_CLASS_LITERAL : 0 );
53+ #endif /* !CONFIG_DISABLE_ES2015_CLASS */
4954
5055 return flags ;
5156} /* snapshot_get_global_flags */
@@ -61,8 +66,11 @@ snapshot_check_global_flags (uint32_t global_flags) /**< global flags */
6166#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
6267 global_flags &= (uint32_t ) ~JERRY_SNAPSHOT_HAS_REGEX_LITERAL ;
6368#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
69+ #ifndef CONFIG_DISABLE_ES2015_CLASS
70+ global_flags &= (uint32_t ) ~JERRY_SNAPSHOT_HAS_CLASS_LITERAL ;
71+ #endif /* !CONFIG_DISABLE_ES2015_CLASS */
6472
65- return global_flags == snapshot_get_global_flags (false);
73+ return global_flags == snapshot_get_global_flags (false, false );
6674} /* snapshot_check_global_flags */
6775
6876#endif /* JERRY_ENABLE_SNAPSHOT_SAVE || JERRY_ENABLE_SNAPSHOT_EXEC */
@@ -77,6 +85,7 @@ typedef struct
7785 size_t snapshot_buffer_write_offset ;
7886 ecma_value_t snapshot_error ;
7987 bool regex_found ;
88+ bool class_found ;
8089} snapshot_globals_t ;
8190
8291/** \addtogroup jerrysnapshot Jerry snapshot operations
@@ -154,6 +163,13 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
154163 uint8_t * copied_code_start_p = snapshot_buffer_p + globals_p -> snapshot_buffer_write_offset ;
155164 ecma_compiled_code_t * copied_code_p = (ecma_compiled_code_t * ) copied_code_start_p ;
156165
166+ #ifndef CONFIG_DISABLE_ES2015_CLASS
167+ if (compiled_code_p -> status_flags & CBC_CODE_FLAGS_CONSTRUCTOR )
168+ {
169+ globals_p -> class_found = true;
170+ }
171+ #endif /* !CONFIG_DISABLE_ES2015_CLASS */
172+
157173#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
158174 if (!(compiled_code_p -> status_flags & CBC_CODE_FLAGS_FUNCTION ))
159175 {
@@ -739,6 +755,7 @@ jerry_generate_snapshot_with_args (const jerry_char_t *resource_name_p, /**< scr
739755 globals .snapshot_buffer_write_offset = aligned_header_size ;
740756 globals .snapshot_error = ECMA_VALUE_EMPTY ;
741757 globals .regex_found = false;
758+ globals .class_found = false;
742759
743760 parse_status = parser_parse_script (args_p ,
744761 args_size ,
@@ -769,7 +786,7 @@ jerry_generate_snapshot_with_args (const jerry_char_t *resource_name_p, /**< scr
769786 jerry_snapshot_header_t header ;
770787 header .magic = JERRY_SNAPSHOT_MAGIC ;
771788 header .version = JERRY_SNAPSHOT_VERSION ;
772- header .global_flags = snapshot_get_global_flags (globals .regex_found );
789+ header .global_flags = snapshot_get_global_flags (globals .regex_found , globals . class_found );
773790 header .lit_table_offset = (uint32_t ) globals .snapshot_buffer_write_offset ;
774791 header .number_of_funcs = 1 ;
775792 header .func_offsets [0 ] = aligned_header_size ;
0 commit comments