From 917ebe4a83172149678a6f8d97d0b6195ae4675e Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Mon, 12 Jan 2015 20:52:04 +0300 Subject: [PATCH] Creating ecma-stack frames in run_int_from_pos. --- src/libcoreint/interpreter.c | 9 ++++++++- src/libcoreint/opcodes.h | 4 +++- src/libecmaoperations/ecma-init-finalize.c | 5 ++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/libcoreint/interpreter.c b/src/libcoreint/interpreter.c index 9b3526b35..c5e8c3060 100644 --- a/src/libcoreint/interpreter.c +++ b/src/libcoreint/interpreter.c @@ -1,4 +1,4 @@ -/* Copyright 2014 Samsung Electronics Co., Ltd. +/* Copyright 2014-2015 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ #include "ecma-helpers.h" #include "ecma-lex-env.h" #include "ecma-operations.h" +#include "ecma-stack.h" #include "globals.h" #include "interpreter.h" #include "jerry-libc.h" @@ -461,6 +462,9 @@ run_int_from_pos (opcode_counter_t start_pos, __memset (regs, 0, regs_num * sizeof (ecma_value_t)); JERRY_ASSERT (ecma_is_value_empty (regs[0])); + ecma_stack_frame_t frame; + ecma_stack_add_frame (&frame); + int_data_t int_data; int_data.pos = (opcode_counter_t) (start_pos + 1); int_data.this_binding = this_binding_value; @@ -471,6 +475,7 @@ run_int_from_pos (opcode_counter_t start_pos, int_data.max_reg_num = max_reg_num; int_data.regs_p = regs; int_data.tmp_num_p = ecma_alloc_number (); + int_data.stack_frame_p = &frame; #ifdef MEM_STATS interp_mem_stats_context_enter (&int_data, start_pos); @@ -483,6 +488,8 @@ run_int_from_pos (opcode_counter_t start_pos, || ecma_is_completion_value_return (completion) || ecma_is_completion_value_exit (completion)); + ecma_stack_free_frame (&frame); + ecma_dealloc_number (int_data.tmp_num_p); for (uint32_t reg_index = 0; diff --git a/src/libcoreint/opcodes.h b/src/libcoreint/opcodes.h index a87cafed0..d87f3ae4a 100644 --- a/src/libcoreint/opcodes.h +++ b/src/libcoreint/opcodes.h @@ -1,4 +1,4 @@ -/* Copyright 2014 Samsung Electronics Co., Ltd. +/* Copyright 2014-2015 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #define OPCODES_H #include "ecma-globals.h" +#include "ecma-stack.h" #include "globals.h" /* Maximum opcodes number in bytecode. */ @@ -83,6 +84,7 @@ typedef struct idx_t max_reg_num; /**< maximum idx used for register identification */ ecma_value_t *regs_p; /**< register variables */ ecma_number_t* tmp_num_p; /**< an allocated number (to reduce temporary allocations) */ + ecma_stack_frame_t *stack_frame_p; /**< ecma-stack frame associated with the context */ #ifdef MEM_STATS size_t context_peak_allocated_heap_bytes; diff --git a/src/libecmaoperations/ecma-init-finalize.c b/src/libecmaoperations/ecma-init-finalize.c index f6a43cf32..c11ac2dc7 100644 --- a/src/libecmaoperations/ecma-init-finalize.c +++ b/src/libecmaoperations/ecma-init-finalize.c @@ -1,4 +1,4 @@ -/* Copyright 2014 Samsung Electronics Co., Ltd. +/* Copyright 2014-2015 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ #include "ecma-gc.h" #include "ecma-lcache.h" #include "ecma-operations.h" +#include "ecma-stack.h" #include "mem-allocator.h" /** \addtogroup ecma ECMA @@ -36,6 +37,7 @@ ecma_init (void) ecma_strings_init (); ecma_init_builtins (); ecma_lcache_init (); + ecma_stack_init (); mem_register_a_try_give_memory_back_callback (ecma_try_to_give_back_some_memory); } /* ecma_init */ @@ -48,6 +50,7 @@ ecma_finalize (void) { mem_unregister_a_try_give_memory_back_callback (ecma_try_to_give_back_some_memory); + ecma_stack_finalize (); ecma_finalize_builtins (); ecma_lcache_invalidate_all (); ecma_gc_run (ECMA_GC_GEN_COUNT - 1);