-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjerryscript.patch
222 lines (202 loc) · 8.06 KB
/
jerryscript.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
diff --git a/jerry-core/parser/js/js-parser.c b/jerry-core/parser/js/js-parser.c
index b55baed5..bd6b41da 100644
--- a/jerry-core/parser/js/js-parser.c
+++ b/jerry-core/parser/js/js-parser.c
@@ -3356,12 +3356,9 @@ parser_parse_script (void *source_p, /**< source code */
return bytecode_p;
#else /* !JERRY_PARSER */
- JERRY_UNUSED (arg_list_p);
- JERRY_UNUSED (arg_list_size);
JERRY_UNUSED (source_p);
- JERRY_UNUSED (source_size);
JERRY_UNUSED (parse_opts);
- JERRY_UNUSED (resource_name);
+ JERRY_UNUSED (options_p);
ecma_raise_syntax_error (ECMA_ERR_PARSER_NOT_SUPPORTED);
return NULL;
diff --git a/jerry-core/ecma/operations/ecma-eval.c b/jerry-core/ecma/operations/ecma-eval.c
index e4a2d734..cd544844 100644
--- a/jerry-core/ecma/operations/ecma-eval.c
+++ b/jerry-core/ecma/operations/ecma-eval.c
@@ -94,8 +94,7 @@ ecma_op_eval_chars_buffer (void *source_p, /**< source code */
return vm_run_eval (bytecode_p, parse_opts);
#else /* !JERRY_PARSER */
- JERRY_UNUSED (code_p);
- JERRY_UNUSED (code_buffer_size);
+ JERRY_UNUSED (source_p);
JERRY_UNUSED (parse_opts);
return ecma_raise_syntax_error (ECMA_ERR_PARSER_NOT_SUPPORTED);
diff --git a/jerry-core/ecma/base/ecma-helpers.c b/jerry-core/ecma/base/ecma-helpers.c
index bd25d9d3..cce169bb 100644
--- a/jerry-core/ecma/base/ecma-helpers.c
+++ b/jerry-core/ecma/base/ecma-helpers.c
@@ -1626,11 +1626,13 @@ ecma_script_get_from_value (ecma_value_t value) /**< compiled code */
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
+#if JERRY_PARSER
if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_SCRIPT)
{
bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
break;
}
+#endif
#if JERRY_MODULE_SYSTEM
if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_MODULE)
diff --git a/jerry-core/api/jerryscript.c b/jerry-core/api/jerryscript.c
index 13e3fd65..32444cd6 100644
--- a/jerry-core/api/jerryscript.c
+++ b/jerry-core/api/jerryscript.c
@@ -564,10 +564,12 @@ jerry_run (const jerry_value_t func_val) /**< function to run */
ecma_object_t *object_p = ecma_get_object_from_value (func_val);
+#if JERRY_PARSER
if (!ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_SCRIPT))
{
return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG));
}
+#endif
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
diff --git a/jerry-core/jmem/jmem-heap.c b/jerry-core/jmem/jmem-heap.c
index 152909a6..200f61d7 100644
--- a/jerry-core/jmem/jmem-heap.c
+++ b/jerry-core/jmem/jmem-heap.c
@@ -734,6 +734,7 @@ jmem_heap_get_stats (jmem_heap_stats_t *out_heap_stats_p) /**< [out] heap stats
void
jmem_heap_stats_print (void)
{
+#if 0
jmem_heap_stats_t *heap_stats = &JERRY_CONTEXT (jmem_heap_stats);
JERRY_DEBUG_MSG ("Heap stats:\n");
@@ -764,6 +765,7 @@ jmem_heap_stats_print (void)
heap_stats->peak_object_bytes,
heap_stats->property_bytes,
heap_stats->peak_property_bytes);
+#endif
} /* jmem_heap_stats_print */
/**
diff --git a/jerry-core/jrt/jrt.h b/jerry-core/jrt/jrt.h
index ffd4bde3..dc0ee760 100644
--- a/jerry-core/jrt/jrt.h
+++ b/jerry-core/jrt/jrt.h
@@ -24,6 +24,12 @@
#include "config.h"
#include "jrt-types.h"
+#ifdef SMING_ARCH
+#include <FakePgmSpace.h>
+#else
+#define _F(x) x
+#endif
+
/*
* Constants
*/
@@ -78,14 +84,14 @@ void JERRY_ATTR_NORETURN jerry_unreachable (const char *file, const char *functi
{ \
if (JERRY_UNLIKELY (!(x))) \
{ \
- jerry_assert_fail (#x, __FILE__, __func__, __LINE__); \
+ jerry_assert_fail (_F(#x), _F(__FILE__), __func__, __LINE__); \
} \
} while (0)
#define JERRY_UNREACHABLE() \
do \
{ \
- jerry_unreachable (__FILE__, __func__, __LINE__); \
+ jerry_unreachable (_F(__FILE__), __func__, __LINE__); \
} while (0)
#else /* JERRY_NDEBUG */
#define JERRY_ASSERT(x) \
@@ -120,10 +126,10 @@ void JERRY_ATTR_NORETURN jerry_fatal (jerry_fatal_code_t code);
* Logging
*/
#if JERRY_LOGGING
-#define JERRY_ERROR_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_ERROR, __VA_ARGS__)
-#define JERRY_WARNING_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_WARNING, __VA_ARGS__)
-#define JERRY_DEBUG_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_DEBUG, __VA_ARGS__)
-#define JERRY_TRACE_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_TRACE, __VA_ARGS__)
+#define JERRY_ERROR_MSG(fmt, ...) jerry_port_log (JERRY_LOG_LEVEL_ERROR, _F(fmt), ##__VA_ARGS__)
+#define JERRY_WARNING_MSG(fmt, ...) jerry_port_log (JERRY_LOG_LEVEL_WARNING, _F(fmt), ##__VA_ARGS__)
+#define JERRY_DEBUG_MSG(fmt, ...) jerry_port_log (JERRY_LOG_LEVEL_DEBUG, _F(fmt), ##__VA_ARGS__)
+#define JERRY_TRACE_MSG(fmt, ...) jerry_port_log (JERRY_LOG_LEVEL_TRACE, _F(fmt), ##__VA_ARGS__)
#else /* !JERRY_LOGGING */
#define JERRY_ERROR_MSG(...) \
do \
diff --git a/jerry-core/api/jerry-snapshot.c b/jerry-core/api/jerry-snapshot.c
index 19ec199f..fd578b2a 100644
--- a/jerry-core/api/jerry-snapshot.c
+++ b/jerry-core/api/jerry-snapshot.c
@@ -33,6 +33,7 @@
#if JERRY_SNAPSHOT_SAVE || JERRY_SNAPSHOT_EXEC
+#if JERRY_SNAPSHOT_SAVE
/**
* Create an error object
*
@@ -49,6 +50,7 @@ jerry_create_error_from_id (jerry_error_t error_type, /**< type of error */
{
return jerry_create_error (error_type, (jerry_char_t *) ecma_get_error_utf8 (msg));
} /* jerry_create_error_from_id */
+#endif
/**
* Get snapshot configuration flags.
diff --git a/jerry-core/vm/vm.c b/jerry-core/vm/vm.c
index 13cbd7ec..28748935 100644
--- a/jerry-core/vm/vm.c
+++ b/jerry-core/vm/vm.c
@@ -41,6 +41,12 @@
#include "opcodes.h"
#include "vm-stack.h"
+#ifdef SMING_ARCH
+#include <jerry_port_vm.h>
+#else
+#define jerry_port_watchdog_poll() true
+#endif
+
/** \addtogroup vm Virtual machine
* @{
*
@@ -1023,7 +1029,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
while (true)
{
/* Internal loop for byte code execution. */
- while (true)
+ while (jerry_port_watchdog_poll())
{
const uint8_t *byte_code_start_p = byte_code_p;
uint8_t opcode = *byte_code_p++;
diff --git a/jerry-core/include/jerryscript-port.h b/jerry-core/include/jerryscript-port.h
index 91bb3fe3..1f0f1d35 100644
--- a/jerry-core/include/jerryscript-port.h
+++ b/jerry-core/include/jerryscript-port.h
@@ -48,7 +48,8 @@ typedef enum
ERR_REF_COUNT_LIMIT = 12,
ERR_DISABLED_BYTE_CODE = 13,
ERR_UNTERMINATED_GC_LOOPS = 14,
- ERR_FAILED_INTERNAL_ASSERTION = 120
+ ERR_FAILED_INTERNAL_ASSERTION = 120,
+ ERR_WATCHDOG_TIMEOUT = 150, // Custom Sming code
} jerry_fatal_code_t;
/**
diff --git a/jerry-core/jrt/jrt-fatals.c b/jerry-core/jrt/jrt-fatals.c
index 36c02277..94d0934f 100644
--- a/jerry-core/jrt/jrt-fatals.c
+++ b/jerry-core/jrt/jrt-fatals.c
@@ -29,7 +29,7 @@
void JERRY_ATTR_NORETURN
jerry_fatal (jerry_fatal_code_t code) /**< status code */
{
-#ifndef JERRY_NDEBUG
+#if 0
switch (code)
{
case ERR_OUT_OF_MEMORY:
diff --git a/jerry-core/ecma/base/ecma-helpers-string.c b/jerry-core/ecma/base/ecma-helpers-string.c
index 12770f36..5ab67df2 100644
--- a/jerry-core/ecma/base/ecma-helpers-string.c
+++ b/jerry-core/ecma/base/ecma-helpers-string.c
@@ -1835,7 +1835,7 @@ ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /**< ecma-st
const ecma_string_t *string2_p) /**< ecma-string */
{
const lit_utf8_byte_t *utf8_string1_p, *utf8_string2_p;
- lit_utf8_size_t string1_size_and_length[2], string2_size_and_length[2];
+ lit_utf8_size_t string1_size_and_length[2]={0}, string2_size_and_length[2]={0};
utf8_string1_p = ecma_compare_get_string_chars (string1_p, string1_size_and_length);
utf8_string2_p = ecma_compare_get_string_chars (string2_p, string2_size_and_length);