Skip to content

Commit a9c77b4

Browse files
committed
Improve the dumping of literals
* Guard `lit_dump_literals` with `JERRY_ENABLE_LOG` (both in source and in header). * Change `printf`s to `JERRY_DLOG`. * Make `lit_dump_literals` be called in `lit_finalize` (it was dead code). * Remove its duplicate declaration from lit-literal.h JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
1 parent c82caa7 commit a9c77b4

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

jerry-core/lit/lit-literal-storage.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2015 Samsung Electronics Co., Ltd.
1+
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
22
* Copyright 2015-2016 University of Szeged
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -178,6 +178,7 @@ lit_count_literals ()
178178
return num;
179179
} /* lit_count_literals */
180180

181+
#ifdef JERRY_ENABLE_LOG
181182
/**
182183
* Dump the contents of the literal storage.
183184
*/
@@ -187,14 +188,14 @@ lit_dump_literals ()
187188
lit_record_t *rec_p;
188189
size_t i;
189190

190-
printf ("LITERALS:\n");
191+
JERRY_DLOG ("LITERALS:\n");
191192

192193
for (rec_p = lit_storage;
193194
rec_p != NULL;
194195
rec_p = lit_cpointer_decompress (rec_p->next))
195196
{
196-
printf ("%p ", rec_p);
197-
printf ("[%3zu] ", lit_get_literal_size (rec_p));
197+
JERRY_DLOG ("%p ", rec_p);
198+
JERRY_DLOG ("[%3zu] ", lit_get_literal_size (rec_p));
198199

199200
switch (rec_p->type)
200201
{
@@ -206,26 +207,26 @@ lit_dump_literals ()
206207
{
207208
FIXME ("Support proper printing of characters which occupy more than one byte.")
208209

209-
printf ("%c", *str);
210+
JERRY_DLOG ("%c", *str);
210211
}
211212

212-
printf (" : STRING");
213+
JERRY_DLOG (" : STRING");
213214

214215
break;
215216
}
216217
case LIT_RECORD_TYPE_MAGIC_STR:
217218
{
218219
lit_magic_string_id_t id = (lit_magic_string_id_t) ((lit_magic_record_t *) rec_p)->magic_id;
219-
printf ("%s : MAGIC STRING", lit_get_magic_string_utf8 (id));
220-
printf (" [id=%d] ", id);
220+
JERRY_DLOG ("%s : MAGIC STRING", lit_get_magic_string_utf8 (id));
221+
JERRY_DLOG (" [id=%d] ", id);
221222

222223
break;
223224
}
224225
case LIT_RECORD_TYPE_MAGIC_STR_EX:
225226
{
226227
lit_magic_string_ex_id_t id = ((lit_magic_record_t *) rec_p)->magic_id;
227-
printf ("%s : EXT MAGIC STRING", lit_get_magic_string_ex_utf8 (id));
228-
printf (" [id=%d] ", id);
228+
JERRY_DLOG ("%s : EXT MAGIC STRING", lit_get_magic_string_ex_utf8 (id));
229+
JERRY_DLOG (" [id=%d] ", id);
229230

230231
break;
231232
}
@@ -237,7 +238,7 @@ lit_dump_literals ()
237238

238239
if (ecma_number_is_nan (value))
239240
{
240-
printf ("%s : NUMBER", "NaN");
241+
JERRY_DLOG ("%s : NUMBER", "NaN");
241242
}
242243
else
243244
{
@@ -247,7 +248,7 @@ lit_dump_literals ()
247248
lit_utf8_size_t sz = ecma_number_to_utf8_string (value, buff, sizeof (buff));
248249
JERRY_ASSERT (sz <= ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER);
249250

250-
printf ("%s : NUMBER", buff);
251+
JERRY_DLOG ("%s : NUMBER", buff);
251252
}
252253

253254
break;
@@ -258,6 +259,7 @@ lit_dump_literals ()
258259
}
259260
}
260261

261-
printf ("\n");
262+
JERRY_DLOG ("\n");
262263
}
263264
} /* lit_dump_literals */
265+
#endif /* JERRY_ENABLE_LOG */

jerry-core/lit/lit-literal-storage.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2015 Samsung Electronics Co., Ltd.
1+
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
22
* Copyright 2015-2016 University of Szeged
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -93,7 +93,10 @@ extern lit_record_t *lit_free_literal (lit_record_t *);
9393
extern size_t lit_get_literal_size (const lit_record_t *);
9494

9595
extern uint32_t lit_count_literals ();
96+
97+
#ifdef JERRY_ENABLE_LOG
9698
extern void lit_dump_literals ();
99+
#endif /* JERRY_ENABLE_LOG */
97100

98101
#define LIT_RECORD_IS_CHARSET(lit) (((lit_record_t *) lit)->type == LIT_RECORD_TYPE_CHARSET)
99102
#define LIT_RECORD_IS_MAGIC_STR(lit) (((lit_record_t *) lit)->type == LIT_RECORD_TYPE_MAGIC_STR)

jerry-core/lit/lit-literal.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2015 Samsung Electronics Co., Ltd.
1+
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
22
* Copyright 2016 University of Szeged.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -37,6 +37,10 @@ lit_init (void)
3737
void
3838
lit_finalize (void)
3939
{
40+
#ifdef JERRY_ENABLE_LOG
41+
lit_dump_literals ();
42+
#endif /* JERRY_ENABLE_LOG */
43+
4044
while (lit_storage)
4145
{
4246
lit_storage = lit_free_literal (lit_storage);

jerry-core/lit/lit-literal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
extern void lit_init ();
3131
extern void lit_finalize ();
32-
extern void lit_dump_literals ();
3332

3433
extern lit_literal_t lit_create_literal_from_utf8_string (const lit_utf8_byte_t *, lit_utf8_size_t);
3534
extern lit_literal_t lit_find_literal_by_utf8_string (const lit_utf8_byte_t *, lit_utf8_size_t);

0 commit comments

Comments
 (0)