Skip to content

Commit 3d8075c

Browse files
committed
Compact Byte Code parser and executor for Jerry.
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected] JerryScript-DCO-1.0-Signed-off-by: Tamas Gergely [email protected] JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély [email protected] JerryScript-DCO-1.0-Signed-off-by: Roland Takacs [email protected] JerryScript-DCO-1.0-Signed-off-by: István Kádár [email protected] JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg [email protected]
1 parent eda775a commit 3d8075c

File tree

92 files changed

+17109
-20195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+17109
-20195
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 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
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -271,7 +271,7 @@ project (Jerry CXX C ASM)
271271
endmacro()
272272

273273
add_jerry_compile_warnings(all extra format-nonliteral init-self conversion sign-conversion format-security missing-declarations)
274-
add_jerry_compile_flags(-pedantic -Wno-stack-protector -Wno-attributes -Wfatal-errors)
274+
add_jerry_compile_flags(-pedantic -Wno-stack-protector -Wno-attributes)
275275
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
276276
add_jerry_compile_warnings(logical-op)
277277
else()

jerry-core/CMakeLists.txt

Lines changed: 3 additions & 2 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
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -31,7 +31,8 @@ project (JerryCore CXX C ASM)
3131
OUTPUT_STRIP_TRAILING_WHITESPACE)
3232

3333
set(DEFINES_JERRY
34-
JERRY_ENABLE_SNAPSHOT
34+
JERRY_ENABLE_SNAPSHOT_SAVE
35+
JERRY_ENABLE_SNAPSHOT_EXEC
3536
JERRY_BUILD_DATE="${JERRY_BUILD_DATE}"
3637
JERRY_COMMIT_HASH="${JERRY_GIT_COMMIT}"
3738
JERRY_BRANCH_NAME="${JERRY_GIT_BRANCH}")

jerry-core/ecma/base/ecma-gc.cpp

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
1+
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
3232
#include "jrt.h"
3333
#include "jrt-libc-includes.h"
3434
#include "jrt-bit-fields.h"
35+
#include "vm-defines.h"
3536
#include "vm-stack.h"
3637

3738
#define JERRY_INTERNAL
@@ -335,13 +336,11 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
335336
JERRY_UNREACHABLE ();
336337
}
337338

338-
case ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS: /* a collection of strings */
339339
case ECMA_INTERNAL_PROPERTY_PRIMITIVE_STRING_VALUE: /* compressed pointer to a ecma_string_t */
340340
case ECMA_INTERNAL_PROPERTY_PRIMITIVE_NUMBER_VALUE: /* compressed pointer to a ecma_number_t */
341341
case ECMA_INTERNAL_PROPERTY_PRIMITIVE_BOOLEAN_VALUE: /* a simple boolean value */
342342
case ECMA_INTERNAL_PROPERTY_CLASS: /* an enum */
343343
case ECMA_INTERNAL_PROPERTY_CODE_BYTECODE: /* compressed pointer to a bytecode array */
344-
case ECMA_INTERNAL_PROPERTY_CODE_FLAGS_AND_OFFSET: /* an integer */
345344
case ECMA_INTERNAL_PROPERTY_NATIVE_CODE: /* an external pointer */
346345
case ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE: /* an external pointer */
347346
case ECMA_INTERNAL_PROPERTY_FREE_CALLBACK: /* an object's native free callback */
@@ -484,25 +483,6 @@ ecma_gc_run (void)
484483
}
485484
}
486485

487-
/* if some object is referenced from a register variable (i.e. it is root),
488-
* start recursive marking traverse from the object */
489-
for (vm_stack_frame_t *frame_iter_p = vm_stack_get_top_frame ();
490-
frame_iter_p != NULL;
491-
frame_iter_p = frame_iter_p->prev_frame_p)
492-
{
493-
for (uint32_t reg_index = 0; reg_index < frame_iter_p->regs_number; reg_index++)
494-
{
495-
ecma_value_t reg_value = vm_stack_frame_get_reg_value (frame_iter_p, VM_REG_FIRST + reg_index);
496-
497-
if (ecma_is_value_object (reg_value))
498-
{
499-
ecma_object_t *obj_p = ecma_get_object_from_value (reg_value);
500-
501-
ecma_gc_set_object_visited (obj_p, true);
502-
}
503-
}
504-
}
505-
506486
bool marked_anything_during_current_iteration = false;
507487

508488
do

jerry-core/ecma/base/ecma-globals.h

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
1+
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -82,6 +82,7 @@ typedef enum
8282
but are stored directly in the array's property list
8383
(used for array elements with non-default attribute values) */
8484
ECMA_SIMPLE_VALUE_ARRAY_HOLE, /**< array hole, used for initialization of an array literal */
85+
ECMA_SIMPLE_VALUE_REGISTER_REF, /**< register reference, a special "base" value for vm */
8586
ECMA_SIMPLE_VALUE__COUNT /** count of simple ecma-values */
8687
} ecma_simple_value_t;
8788

@@ -170,21 +171,12 @@ typedef uint32_t ecma_completion_value_t;
170171
#define ECMA_COMPLETION_VALUE_VALUE_POS (0)
171172
#define ECMA_COMPLETION_VALUE_VALUE_WIDTH (ECMA_VALUE_SIZE)
172173

173-
/**
174-
* Break / continue jump target
175-
*/
176-
#define ECMA_COMPLETION_VALUE_TARGET_POS (0)
177-
#define ECMA_COMPLETION_VALUE_TARGET_WIDTH ((uint32_t) sizeof (vm_instr_counter_t) * JERRY_BITSINBYTE)
178-
179174
/**
180175
* Type (ecma_completion_type_t)
181176
*/
182-
#define ECMA_COMPLETION_VALUE_TYPE_POS (JERRY_MAX (JERRY_ALIGNUP (ECMA_COMPLETION_VALUE_VALUE_POS + \
177+
#define ECMA_COMPLETION_VALUE_TYPE_POS (JERRY_ALIGNUP (ECMA_COMPLETION_VALUE_VALUE_POS + \
183178
ECMA_COMPLETION_VALUE_VALUE_WIDTH, \
184-
JERRY_BITSINBYTE), \
185-
JERRY_ALIGNUP (ECMA_COMPLETION_VALUE_TARGET_POS + \
186-
ECMA_COMPLETION_VALUE_TARGET_WIDTH, \
187-
JERRY_BITSINBYTE)))
179+
JERRY_BITSINBYTE))
188180
#define ECMA_COMPLETION_VALUE_TYPE_WIDTH (8)
189181

190182
/**
@@ -218,12 +210,9 @@ typedef enum
218210
ECMA_INTERNAL_PROPERTY_SCOPE, /**< [[Scope]] */
219211
ECMA_INTERNAL_PROPERTY_PARAMETERS_MAP, /**< [[ParametersMap]] */
220212
ECMA_INTERNAL_PROPERTY_CODE_BYTECODE, /**< first part of [[Code]] - compressed pointer to bytecode array */
221-
ECMA_INTERNAL_PROPERTY_CODE_FLAGS_AND_OFFSET, /**< second part of [[Code]] - offset in bytecode array and code flags
222-
* (see also: ecma_pack_code_internal_property_value) */
223213
ECMA_INTERNAL_PROPERTY_NATIVE_CODE, /**< native handler location descriptor */
224214
ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE, /**< native handle associated with an object */
225215
ECMA_INTERNAL_PROPERTY_FREE_CALLBACK, /**< object's native free callback */
226-
ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS, /**< [[FormalParameters]] */
227216
ECMA_INTERNAL_PROPERTY_PRIMITIVE_STRING_VALUE, /**< [[Primitive value]] for String objects */
228217
ECMA_INTERNAL_PROPERTY_PRIMITIVE_NUMBER_VALUE, /**< [[Primitive value]] for Number objects */
229218
ECMA_INTERNAL_PROPERTY_PRIMITIVE_BOOLEAN_VALUE, /**< [[Primitive value]] for Boolean objects */
@@ -837,6 +826,22 @@ typedef struct ecma_string_t
837826
*/
838827
typedef uintptr_t ecma_external_pointer_t;
839828

829+
/**
830+
* Compiled byte code data.
831+
*/
832+
typedef struct
833+
{
834+
uint16_t status_flags; /**< various status flags */
835+
} ecma_compiled_code_t;
836+
837+
/**
838+
* Shift value for byte code reference counting.
839+
* The last 10 bit of the first uint16_t value
840+
* of compact byte code or regexp byte code
841+
* is reserved for reference counting.
842+
*/
843+
#define ECMA_BYTECODE_REF_SHIFT 6
844+
840845
/**
841846
* @}
842847
*/

jerry-core/ecma/base/ecma-helpers-string.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
1+
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
2020
* @{
2121
*/
2222

23-
#include "bytecode-data.h"
2423
#include "ecma-alloc.h"
2524
#include "ecma-gc.h"
2625
#include "ecma-globals.h"
@@ -29,9 +28,10 @@
2928
#include "jrt.h"
3029
#include "jrt-libc-includes.h"
3130
#include "lit-char-helpers.h"
31+
#include "lit-literal.h"
3232
#include "lit-magic-strings.h"
33-
#include "vm.h"
3433
#include "rcs-records.h"
34+
#include "vm.h"
3535

3636
/**
3737
* Maximum length of strings' concatenation

jerry-core/ecma/base/ecma-helpers-value.cpp

Lines changed: 3 additions & 63 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
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -26,16 +26,16 @@
2626
#include "ecma-helpers.h"
2727
#include "jrt.h"
2828
#include "jrt-bit-fields.h"
29+
#include "vm-defines.h"
2930

3031
JERRY_STATIC_ASSERT (sizeof (ecma_value_t) * JERRY_BITSINBYTE >= ECMA_VALUE_SIZE);
31-
JERRY_STATIC_ASSERT (sizeof (ecma_completion_value_t) * JERRY_BITSINBYTE >= ECMA_COMPLETION_VALUE_SIZE);
3232

3333
/**
3434
* Get type field of ecma-value
3535
*
3636
* @return type field
3737
*/
38-
static ecma_type_t __attr_pure___
38+
ecma_type_t __attr_pure___
3939
ecma_get_value_type_field (ecma_value_t value) /**< ecma-value */
4040
{
4141
return (ecma_type_t) jrt_extract_bit_field (value,
@@ -474,19 +474,6 @@ ecma_get_completion_value_value_field (ecma_completion_value_t completion_value)
474474
ECMA_COMPLETION_VALUE_VALUE_WIDTH);
475475
} /* ecma_get_completion_value_value_field */
476476

477-
/**
478-
* Get target of break / continue completion value
479-
*
480-
* @return instruction counter
481-
*/
482-
static vm_instr_counter_t
483-
ecma_get_completion_value_target (ecma_completion_value_t completion_value) /**< completion value */
484-
{
485-
return (vm_instr_counter_t) jrt_extract_bit_field (completion_value,
486-
ECMA_COMPLETION_VALUE_TARGET_POS,
487-
ECMA_COMPLETION_VALUE_TARGET_WIDTH);
488-
} /* ecma_get_completion_value_target */
489-
490477
/**
491478
* Set type field of completion value
492479
*
@@ -519,21 +506,6 @@ ecma_set_completion_value_value_field (ecma_completion_value_t completion_value,
519506
ECMA_COMPLETION_VALUE_VALUE_WIDTH);
520507
} /* ecma_set_completion_value_value_field */
521508

522-
/**
523-
* Set target of break / continue completion value
524-
*
525-
* @return completion value with updated field
526-
*/
527-
static ecma_completion_value_t __attr_const___
528-
ecma_set_completion_value_target (ecma_completion_value_t completion_value, /**< completion value
529-
* to set field in */
530-
vm_instr_counter_t target) /**< break / continue target */
531-
{
532-
return (ecma_completion_value_t) jrt_set_bit_field_value (completion_value,
533-
target,
534-
ECMA_COMPLETION_VALUE_TARGET_POS,
535-
ECMA_COMPLETION_VALUE_TARGET_WIDTH);
536-
} /* ecma_set_completion_value_target */
537509

538510
/**
539511
* Normal, throw, return, exit and meta completion values constructor
@@ -652,24 +624,6 @@ ecma_make_meta_completion_value (void)
652624
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY));
653625
} /* ecma_make_meta_completion_value */
654626

655-
/**
656-
* Break / continue completion values constructor
657-
*
658-
* @return completion value
659-
*/
660-
ecma_completion_value_t __attr_const___
661-
ecma_make_jump_completion_value (vm_instr_counter_t target) /**< target break / continue */
662-
{
663-
ecma_completion_value_t completion_value = 0;
664-
665-
completion_value = ecma_set_completion_value_type_field (completion_value,
666-
ECMA_COMPLETION_TYPE_JUMP);
667-
completion_value = ecma_set_completion_value_target (completion_value,
668-
target);
669-
670-
return completion_value;
671-
} /* ecma_make_jump_completion_value */
672-
673627
/**
674628
* Get ecma-value from specified completion value
675629
*
@@ -722,20 +676,6 @@ ecma_get_object_from_completion_value (ecma_completion_value_t completion_value)
722676
return ecma_get_object_from_value (ecma_get_completion_value_value (completion_value));
723677
} /* ecma_get_object_from_completion_value */
724678

725-
/**
726-
* Get break / continue target from completion value
727-
*
728-
* @return instruction counter
729-
*/
730-
vm_instr_counter_t
731-
ecma_get_jump_target_from_completion_value (ecma_completion_value_t completion_value) /**< completion
732-
* value */
733-
{
734-
JERRY_ASSERT (ecma_get_completion_value_type_field (completion_value) == ECMA_COMPLETION_TYPE_JUMP);
735-
736-
return ecma_get_completion_value_target (completion_value);
737-
} /* ecma_get_jump_target_from_completion_value */
738-
739679
/**
740680
* Copy ecma-completion value.
741681
*

0 commit comments

Comments
 (0)