Rework storing the line/column/bytecode info (#4707)
This information is stored in a separate memory block instead of being part of the byte code. Snapshot does not supported. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -113,9 +113,6 @@ typedef struct vm_frame_ctx_t
|
||||
struct vm_frame_ctx_t *prev_context_p; /**< previous context */
|
||||
ecma_value_t this_binding; /**< this binding */
|
||||
ecma_value_t block_result; /**< block result */
|
||||
#if JERRY_LINE_INFO
|
||||
uint32_t current_line; /**< currently executed line */
|
||||
#endif /* JERRY_LINE_INFO */
|
||||
uint16_t context_depth; /**< current context depth */
|
||||
uint8_t status_flags; /**< combination of vm_frame_ctx_flags_t bits */
|
||||
uint8_t call_operation; /**< perform a call or construct operation */
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-line-info.h"
|
||||
#include "jcontext.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "vm.h"
|
||||
@@ -75,7 +76,8 @@ vm_get_backtrace (uint32_t max_depth) /**< maximum backtrace depth, 0 = unlimite
|
||||
|
||||
while (context_p != NULL)
|
||||
{
|
||||
ecma_value_t resource_name = ecma_get_resource_name (context_p->shared_p->bytecode_header_p);
|
||||
const ecma_compiled_code_t *bytecode_header_p = context_p->shared_p->bytecode_header_p;
|
||||
ecma_value_t resource_name = ecma_get_resource_name (bytecode_header_p);
|
||||
ecma_string_t *str_p = ecma_get_string_from_value (resource_name);
|
||||
ecma_stringbuilder_t builder = ecma_stringbuilder_create ();
|
||||
|
||||
@@ -89,9 +91,27 @@ vm_get_backtrace (uint32_t max_depth) /**< maximum backtrace depth, 0 = unlimite
|
||||
ecma_stringbuilder_append_byte (&builder, LIT_CHAR_COLON);
|
||||
}
|
||||
|
||||
ecma_string_t *line_str_p = ecma_new_ecma_string_from_uint32 (context_p->current_line);
|
||||
ecma_stringbuilder_append (&builder, line_str_p);
|
||||
ecma_deref_ecma_string (line_str_p);
|
||||
if (bytecode_header_p->status_flags & CBC_CODE_FLAGS_HAS_LINE_INFO)
|
||||
{
|
||||
jerry_backtrace_location_t location;
|
||||
ecma_line_info_get (ecma_compiled_code_get_line_info (bytecode_header_p),
|
||||
(uint32_t) (context_p->byte_code_p - context_p->byte_code_start_p),
|
||||
&location);
|
||||
|
||||
ecma_string_t *line_str_p = ecma_new_ecma_string_from_uint32 (location.line);
|
||||
ecma_stringbuilder_append (&builder, line_str_p);
|
||||
ecma_deref_ecma_string (line_str_p);
|
||||
|
||||
ecma_stringbuilder_append_byte (&builder, LIT_CHAR_COLON);
|
||||
|
||||
line_str_p = ecma_new_ecma_string_from_uint32 (location.column);
|
||||
ecma_stringbuilder_append (&builder, line_str_p);
|
||||
ecma_deref_ecma_string (line_str_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_stringbuilder_append_raw (&builder, (const lit_utf8_byte_t *)"1:1", 3);
|
||||
}
|
||||
|
||||
ecma_string_t *builder_str_p = ecma_stringbuilder_finalize (&builder);
|
||||
ecma_fast_array_set_property (array_p, index, ecma_make_string_value (builder_str_p));
|
||||
|
||||
@@ -4629,23 +4629,6 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
continue;
|
||||
}
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
#if JERRY_LINE_INFO
|
||||
case VM_OC_LINE:
|
||||
{
|
||||
uint32_t value = 0;
|
||||
uint8_t byte;
|
||||
|
||||
do
|
||||
{
|
||||
byte = *byte_code_p++;
|
||||
value = (value << 7) | (byte & CBC_LOWER_SEVEN_BIT_MASK);
|
||||
}
|
||||
while (byte & CBC_HIGHEST_BIT_MASK);
|
||||
|
||||
frame_ctx_p->current_line = value;
|
||||
continue;
|
||||
}
|
||||
#endif /* JERRY_LINE_INFO */
|
||||
case VM_OC_NONE:
|
||||
default:
|
||||
{
|
||||
@@ -5112,9 +5095,6 @@ vm_init_exec (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
|
||||
frame_ctx_p->prev_context_p = JERRY_CONTEXT (vm_top_context_p);
|
||||
frame_ctx_p->block_result = ECMA_VALUE_UNDEFINED;
|
||||
#if JERRY_LINE_INFO
|
||||
frame_ctx_p->current_line = 0;
|
||||
#endif /* JERRY_LINE_INFO */
|
||||
frame_ctx_p->context_depth = 0;
|
||||
frame_ctx_p->status_flags = (uint8_t) ((shared_p->status_flags & VM_FRAME_CTX_DIRECT_EVAL)
|
||||
| (bytecode_header_p->status_flags & VM_FRAME_CTX_IS_STRICT));
|
||||
|
||||
@@ -234,9 +234,6 @@ typedef enum
|
||||
VM_OC_BREAKPOINT_ENABLED, /**< enabled breakpoint for debugger */
|
||||
VM_OC_BREAKPOINT_DISABLED, /**< disabled breakpoint for debugger */
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
#if JERRY_LINE_INFO
|
||||
VM_OC_LINE, /**< line number of the next statement */
|
||||
#endif /* JERRY_LINE_INFO */
|
||||
#if JERRY_ESNEXT
|
||||
VM_OC_CHECK_VAR, /**< check redeclared vars in the global scope */
|
||||
VM_OC_CHECK_LET, /**< check redeclared lets in the global scope */
|
||||
@@ -319,9 +316,6 @@ typedef enum
|
||||
VM_OC_BREAKPOINT_ENABLED = VM_OC_NONE, /**< enabled breakpoint for debugger is unused */
|
||||
VM_OC_BREAKPOINT_DISABLED = VM_OC_NONE, /**< disabled breakpoint for debugger is unused */
|
||||
#endif /* !JERRY_DEBUGGER */
|
||||
#if !JERRY_LINE_INFO
|
||||
VM_OC_LINE = VM_OC_NONE, /**< line number of the next statement is unused */
|
||||
#endif /* !JERRY_LINE_INFO */
|
||||
#if !JERRY_ESNEXT
|
||||
VM_OC_EXT_VAR_EVAL = VM_OC_NONE, /**< variable and function evaluation for
|
||||
* functions with separate argument context */
|
||||
|
||||
Reference in New Issue
Block a user