Skip to content

Commit a315642

Browse files
committed
Update jerryscript to 3.0.0
1 parent f355d30 commit a315642

File tree

11 files changed

+92
-132
lines changed

11 files changed

+92
-132
lines changed

jerryscript

Submodule jerryscript updated 1394 files

jerryscript.patch

Lines changed: 48 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/jerry-core/parser/js/js-parser.c b/jerry-core/parser/js/js-parser.c
2-
index b55baed5..bd6b41da 100644
2+
index 8f241b6a..2734b2c5 100644
33
--- a/jerry-core/parser/js/js-parser.c
44
+++ b/jerry-core/parser/js/js-parser.c
5-
@@ -3356,12 +3356,9 @@ parser_parse_script (void *source_p, /**< source code */
5+
@@ -3360,12 +3360,8 @@ parser_parse_script (void *source_p, /**< source code */
66

77
return bytecode_p;
88
#else /* !JERRY_PARSER */
@@ -11,30 +11,15 @@ index b55baed5..bd6b41da 100644
1111
JERRY_UNUSED (source_p);
1212
- JERRY_UNUSED (source_size);
1313
JERRY_UNUSED (parse_opts);
14-
- JERRY_UNUSED (resource_name);
15-
+ JERRY_UNUSED (options_p);
14+
- JERRY_UNUSED (source_name);
1615

1716
ecma_raise_syntax_error (ECMA_ERR_PARSER_NOT_SUPPORTED);
1817
return NULL;
19-
diff --git a/jerry-core/ecma/operations/ecma-eval.c b/jerry-core/ecma/operations/ecma-eval.c
20-
index e4a2d734..cd544844 100644
21-
--- a/jerry-core/ecma/operations/ecma-eval.c
22-
+++ b/jerry-core/ecma/operations/ecma-eval.c
23-
@@ -94,8 +94,7 @@ ecma_op_eval_chars_buffer (void *source_p, /**< source code */
24-
25-
return vm_run_eval (bytecode_p, parse_opts);
26-
#else /* !JERRY_PARSER */
27-
- JERRY_UNUSED (code_p);
28-
- JERRY_UNUSED (code_buffer_size);
29-
+ JERRY_UNUSED (source_p);
30-
JERRY_UNUSED (parse_opts);
31-
32-
return ecma_raise_syntax_error (ECMA_ERR_PARSER_NOT_SUPPORTED);
3318
diff --git a/jerry-core/ecma/base/ecma-helpers.c b/jerry-core/ecma/base/ecma-helpers.c
34-
index bd25d9d3..cce169bb 100644
19+
index c51be10d..151ec37a 100644
3520
--- a/jerry-core/ecma/base/ecma-helpers.c
3621
+++ b/jerry-core/ecma/base/ecma-helpers.c
37-
@@ -1626,11 +1626,13 @@ ecma_script_get_from_value (ecma_value_t value) /**< compiled code */
22+
@@ -1616,11 +1616,13 @@ ecma_script_get_from_value (ecma_value_t value) /**< compiled code */
3823
{
3924
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
4025

@@ -49,47 +34,47 @@ index bd25d9d3..cce169bb 100644
4934
#if JERRY_MODULE_SYSTEM
5035
if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_MODULE)
5136
diff --git a/jerry-core/api/jerryscript.c b/jerry-core/api/jerryscript.c
52-
index 13e3fd65..32444cd6 100644
37+
index d8174b92..1ceb0373 100644
5338
--- a/jerry-core/api/jerryscript.c
5439
+++ b/jerry-core/api/jerryscript.c
55-
@@ -564,10 +564,12 @@ jerry_run (const jerry_value_t func_val) /**< function to run */
40+
@@ -534,10 +534,12 @@ jerry_run (const jerry_value_t script) /**< script or module to run */
5641

57-
ecma_object_t *object_p = ecma_get_object_from_value (func_val);
42+
ecma_object_t *object_p = ecma_get_object_from_value (script);
5843

5944
+#if JERRY_PARSER
6045
if (!ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_SCRIPT))
6146
{
62-
return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG));
47+
return jerry_throw_sz (JERRY_ERROR_TYPE, ecma_get_error_msg (ECMA_ERR_WRONG_ARGS_MSG));
6348
}
6449
+#endif
6550

6651
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
6752

6853
diff --git a/jerry-core/jmem/jmem-heap.c b/jerry-core/jmem/jmem-heap.c
69-
index 152909a6..200f61d7 100644
54+
index b7e60849..c3177506 100644
7055
--- a/jerry-core/jmem/jmem-heap.c
7156
+++ b/jerry-core/jmem/jmem-heap.c
72-
@@ -734,6 +734,7 @@ jmem_heap_get_stats (jmem_heap_stats_t *out_heap_stats_p) /**< [out] heap stats
57+
@@ -744,6 +744,7 @@ jmem_heap_get_stats (jmem_heap_stats_t *out_heap_stats_p) /**< [out] heap stats
7358
void
7459
jmem_heap_stats_print (void)
7560
{
7661
+#if 0
7762
jmem_heap_stats_t *heap_stats = &JERRY_CONTEXT (jmem_heap_stats);
7863

7964
JERRY_DEBUG_MSG ("Heap stats:\n");
80-
@@ -764,6 +765,7 @@ jmem_heap_stats_print (void)
81-
heap_stats->peak_object_bytes,
82-
heap_stats->property_bytes,
83-
heap_stats->peak_property_bytes);
65+
@@ -762,6 +763,7 @@ jmem_heap_stats_print (void)
66+
JERRY_DEBUG_MSG (" Peak allocated object data = %u bytes\n", (unsigned) heap_stats->peak_object_bytes);
67+
JERRY_DEBUG_MSG (" Allocated property data = %u bytes\n", (unsigned) heap_stats->property_bytes);
68+
JERRY_DEBUG_MSG (" Peak allocated property data = %u bytes\n", (unsigned) heap_stats->peak_property_bytes);
8469
+#endif
8570
} /* jmem_heap_stats_print */
8671

8772
/**
8873
diff --git a/jerry-core/jrt/jrt.h b/jerry-core/jrt/jrt.h
89-
index ffd4bde3..dc0ee760 100644
74+
index 2c1f308d..8a760809 100644
9075
--- a/jerry-core/jrt/jrt.h
9176
+++ b/jerry-core/jrt/jrt.h
92-
@@ -24,6 +24,12 @@
77+
@@ -25,6 +25,12 @@
9378
#include "config.h"
9479
#include "jrt-types.h"
9580

@@ -102,7 +87,7 @@ index ffd4bde3..dc0ee760 100644
10287
/*
10388
* Constants
10489
*/
105-
@@ -78,14 +84,14 @@ void JERRY_ATTR_NORETURN jerry_unreachable (const char *file, const char *functi
90+
@@ -79,14 +85,14 @@ void JERRY_ATTR_NORETURN jerry_unreachable (const char *file, const char *functi
10691
{ \
10792
if (JERRY_UNLIKELY (!(x))) \
10893
{ \
@@ -119,43 +104,23 @@ index ffd4bde3..dc0ee760 100644
119104
} while (0)
120105
#else /* JERRY_NDEBUG */
121106
#define JERRY_ASSERT(x) \
122-
@@ -120,10 +126,10 @@ void JERRY_ATTR_NORETURN jerry_fatal (jerry_fatal_code_t code);
107+
@@ -124,10 +130,10 @@ void jerry_jrt_set_log_level (jerry_log_level_t level);
123108
* Logging
124109
*/
125110
#if JERRY_LOGGING
126-
-#define JERRY_ERROR_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_ERROR, __VA_ARGS__)
127-
-#define JERRY_WARNING_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_WARNING, __VA_ARGS__)
128-
-#define JERRY_DEBUG_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_DEBUG, __VA_ARGS__)
129-
-#define JERRY_TRACE_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_TRACE, __VA_ARGS__)
130-
+#define JERRY_ERROR_MSG(fmt, ...) jerry_port_log (JERRY_LOG_LEVEL_ERROR, _F(fmt), ##__VA_ARGS__)
131-
+#define JERRY_WARNING_MSG(fmt, ...) jerry_port_log (JERRY_LOG_LEVEL_WARNING, _F(fmt), ##__VA_ARGS__)
132-
+#define JERRY_DEBUG_MSG(fmt, ...) jerry_port_log (JERRY_LOG_LEVEL_DEBUG, _F(fmt), ##__VA_ARGS__)
133-
+#define JERRY_TRACE_MSG(fmt, ...) jerry_port_log (JERRY_LOG_LEVEL_TRACE, _F(fmt), ##__VA_ARGS__)
111+
-#define JERRY_ERROR_MSG(...) jerry_log (JERRY_LOG_LEVEL_ERROR, __VA_ARGS__)
112+
-#define JERRY_WARNING_MSG(...) jerry_log (JERRY_LOG_LEVEL_WARNING, __VA_ARGS__)
113+
-#define JERRY_DEBUG_MSG(...) jerry_log (JERRY_LOG_LEVEL_DEBUG, __VA_ARGS__)
114+
-#define JERRY_TRACE_MSG(...) jerry_log (JERRY_LOG_LEVEL_TRACE, __VA_ARGS__)
115+
+#define JERRY_ERROR_MSG(fmt, ...) jerry_log (JERRY_LOG_LEVEL_ERROR, _F(fmt), ##__VA_ARGS__)
116+
+#define JERRY_WARNING_MSG(fmt, ...) jerry_log (JERRY_LOG_LEVEL_WARNING, _F(fmt), ##__VA_ARGS__)
117+
+#define JERRY_DEBUG_MSG(fmt, ...) jerry_log (JERRY_LOG_LEVEL_DEBUG, _F(fmt), ##__VA_ARGS__)
118+
+#define JERRY_TRACE_MSG(fmt, ...) jerry_log (JERRY_LOG_LEVEL_TRACE, _F(fmt), ##__VA_ARGS__)
134119
#else /* !JERRY_LOGGING */
135120
#define JERRY_ERROR_MSG(...) \
136121
do \
137-
diff --git a/jerry-core/api/jerry-snapshot.c b/jerry-core/api/jerry-snapshot.c
138-
index 19ec199f..fd578b2a 100644
139-
--- a/jerry-core/api/jerry-snapshot.c
140-
+++ b/jerry-core/api/jerry-snapshot.c
141-
@@ -33,6 +33,7 @@
142-
143-
#if JERRY_SNAPSHOT_SAVE || JERRY_SNAPSHOT_EXEC
144-
145-
+#if JERRY_SNAPSHOT_SAVE
146-
/**
147-
* Create an error object
148-
*
149-
@@ -49,6 +50,7 @@ jerry_create_error_from_id (jerry_error_t error_type, /**< type of error */
150-
{
151-
return jerry_create_error (error_type, (jerry_char_t *) ecma_get_error_utf8 (msg));
152-
} /* jerry_create_error_from_id */
153-
+#endif
154-
155-
/**
156-
* Get snapshot configuration flags.
157122
diff --git a/jerry-core/vm/vm.c b/jerry-core/vm/vm.c
158-
index 13cbd7ec..28748935 100644
123+
index b6e1e88f..2ab657fe 100644
159124
--- a/jerry-core/vm/vm.c
160125
+++ b/jerry-core/vm/vm.c
161126
@@ -41,6 +41,12 @@
@@ -171,7 +136,7 @@ index 13cbd7ec..28748935 100644
171136
/** \addtogroup vm Virtual machine
172137
* @{
173138
*
174-
@@ -1023,7 +1029,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
139+
@@ -1018,7 +1024,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
175140
while (true)
176141
{
177142
/* Internal loop for byte code execution. */
@@ -181,21 +146,21 @@ index 13cbd7ec..28748935 100644
181146
const uint8_t *byte_code_start_p = byte_code_p;
182147
uint8_t opcode = *byte_code_p++;
183148
diff --git a/jerry-core/include/jerryscript-port.h b/jerry-core/include/jerryscript-port.h
184-
index 91bb3fe3..1f0f1d35 100644
149+
index e3187371..c522ec04 100644
185150
--- a/jerry-core/include/jerryscript-port.h
186151
+++ b/jerry-core/include/jerryscript-port.h
187-
@@ -48,7 +48,8 @@ typedef enum
188-
ERR_REF_COUNT_LIMIT = 12,
189-
ERR_DISABLED_BYTE_CODE = 13,
190-
ERR_UNTERMINATED_GC_LOOPS = 14,
191-
- ERR_FAILED_INTERNAL_ASSERTION = 120
192-
+ ERR_FAILED_INTERNAL_ASSERTION = 120,
193-
+ ERR_WATCHDOG_TIMEOUT = 150, // Custom Sming code
152+
@@ -46,7 +46,8 @@ typedef enum
153+
JERRY_FATAL_REF_COUNT_LIMIT = 12, /**< Reference count limit reached */
154+
JERRY_FATAL_DISABLED_BYTE_CODE = 13, /**< Executed disabled instruction */
155+
JERRY_FATAL_UNTERMINATED_GC_LOOPS = 14, /**< Garbage collection loop limit reached */
156+
- JERRY_FATAL_FAILED_ASSERTION = 120 /**< Assertion failed */
157+
+ JERRY_FATAL_FAILED_ASSERTION = 120, /**< Assertion failed */
158+
+ JERRY_FATAL_WATCHDOG_TIMEOUT = 150, /**< Custom Sming code */
194159
} jerry_fatal_code_t;
195160

196161
/**
197162
diff --git a/jerry-core/jrt/jrt-fatals.c b/jerry-core/jrt/jrt-fatals.c
198-
index 36c02277..94d0934f 100644
163+
index c2e09488..53e5e3fc 100644
199164
--- a/jerry-core/jrt/jrt-fatals.c
200165
+++ b/jerry-core/jrt/jrt-fatals.c
201166
@@ -29,7 +29,7 @@
@@ -206,17 +171,13 @@ index 36c02277..94d0934f 100644
206171
+#if 0
207172
switch (code)
208173
{
209-
case ERR_OUT_OF_MEMORY:
210-
diff --git a/jerry-core/ecma/base/ecma-helpers-string.c b/jerry-core/ecma/base/ecma-helpers-string.c
211-
index 12770f36..5ab67df2 100644
212-
--- a/jerry-core/ecma/base/ecma-helpers-string.c
213-
+++ b/jerry-core/ecma/base/ecma-helpers-string.c
214-
@@ -1835,7 +1835,7 @@ ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /**< ecma-st
215-
const ecma_string_t *string2_p) /**< ecma-string */
216-
{
217-
const lit_utf8_byte_t *utf8_string1_p, *utf8_string2_p;
218-
- lit_utf8_size_t string1_size_and_length[2], string2_size_and_length[2];
219-
+ lit_utf8_size_t string1_size_and_length[2]={0}, string2_size_and_length[2]={0};
220-
221-
utf8_string1_p = ecma_compare_get_string_chars (string1_p, string1_size_and_length);
222-
utf8_string2_p = ecma_compare_get_string_chars (string2_p, string2_size_and_length);
174+
case JERRY_FATAL_OUT_OF_MEMORY:
175+
diff --git a/.gitignore b/.gitignore
176+
index 3bb753c2..473e03e4 100644
177+
--- a/.gitignore
178+
+++ b/.gitignore
179+
@@ -39,3 +39,4 @@ docs/doxygen
180+
# Tests
181+
tests/test262/
182+
.vs
183+
+out/

src/Context.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ Context::Context() : Context(JERRY_GLOBAL_HEAP_SIZE * 1024)
2222

2323
Context::Context(size_t heapSize)
2424
{
25-
auto ctx = jerry_create_context(std::max(heapSize, size_t(1024U)), alloc, this);
26-
context.reset(reinterpret_cast<uint8_t*>(ctx));
25+
context = std::make_unique<uint8_t[]>(std::max(heapSize, size_t(1024U)));
2726
}
2827

2928
void* Context::alloc(size_t size, void* param)

src/Debug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Jerryscript
1515
bool printHeap()
1616
{
1717
jerry_heap_stats_t stats;
18-
if(!jerry_get_memory_stats(&stats)) {
18+
if(!jerry_heap_stats(&stats)) {
1919
m_printf(_F("[JS] Heap stats disabled"));
2020
return false;
2121
}

src/Types.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ Value::Value(unsigned value) : value(ecma_make_uint32_value(value))
101101

102102
size_t Value::readString(unsigned offset, char* buffer, size_t length) const
103103
{
104-
return jerry_substring_to_char_buffer(value, offset, offset + length, reinterpret_cast<jerry_char_t*>(buffer),
105-
length);
104+
jerry_value_t substr = jerry_string_substr(value, offset, offset + length);
105+
return jerry_string_to_buffer(substr, JERRY_ENCODING_UTF8, reinterpret_cast<jerry_char_t*>(buffer), length);
106106
}
107107

108108
String Value::subString(unsigned offset, size_t length) const
@@ -127,20 +127,20 @@ Value::operator String() const
127127
return nullptr;
128128
}
129129

130-
jerry_size_t sz = jerry_get_string_size(strval.get());
130+
jerry_size_t sz = jerry_string_size(strval.get(), JERRY_ENCODING_UTF8);
131131
String s;
132132
if(!s.setLength(sz)) {
133133
return nullptr;
134134
}
135135

136-
jerry_string_to_char_buffer(strval.get(), reinterpret_cast<jerry_char_t*>(s.begin()), sz);
136+
jerry_string_to_buffer(strval.get(), JERRY_ENCODING_UTF8, reinterpret_cast<jerry_char_t*>(s.begin()), sz);
137137

138138
return s;
139139
}
140140

141141
Array Object::keys() const
142142
{
143-
return OwnedValue{jerry_get_object_keys(get())};
143+
return OwnedValue{jerry_object_keys(get())};
144144
}
145145

146146
Callable Object::getFunction(const String& name)
@@ -200,7 +200,7 @@ Value Object::runFunction(const String& name, std::initializer_list<Value> args)
200200

201201
Value Error::message() const
202202
{
203-
Object value = OwnedValue{jerry_get_value_from_error(get(), false)};
203+
Object value = OwnedValue{jerry_throw_value(get(), false)};
204204
return value[F("message")];
205205
}
206206

@@ -229,14 +229,13 @@ Object Value::toObject() const
229229
Value Callable::call(const Object& thisValue, const Value& arg)
230230
{
231231
jerry_port_watchdog_reset();
232-
return OwnedValue{jerry_call_function(get(), thisValue.get(), &const_cast<Value&>(arg).get(), 1)};
232+
return OwnedValue{jerry_call(get(), thisValue.get(), &const_cast<Value&>(arg).get(), 1)};
233233
}
234234

235235
Value Callable::call(const Object& thisValue, std::initializer_list<Value> args)
236236
{
237237
jerry_port_watchdog_reset();
238-
return OwnedValue{
239-
jerry_call_function(get(), thisValue.get(), args.size() ? &args.begin()->get() : nullptr, args.size())};
238+
return OwnedValue{jerry_call(get(), thisValue.get(), args.size() ? &args.begin()->get() : nullptr, args.size())};
240239
}
241240

242241
} // namespace Jerryscript

src/include/Jerryscript/Debug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ using HeapStats = jerry_heap_stats_t;
1717

1818
inline bool getHeapStats(HeapStats& stats)
1919
{
20-
return jerry_get_memory_stats(&stats);
20+
return jerry_heap_stats(&stats);
2121
}
2222

2323
size_t getHeapUsed();

src/include/Jerryscript/Except.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "Types.h"
1414
#include <csetjmp>
15+
#include <jerryscript-port.h>
1516

1617
namespace Jerryscript
1718
{

0 commit comments

Comments
 (0)