Remove intrinsics (native_call opcode).

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan 2015-07-30 16:18:07 +03:00
parent 72d4c07bdc
commit f7781bb7bc
7 changed files with 1 additions and 241 deletions

View File

@ -18,7 +18,6 @@
#include "serializer.h"
#include "stack.h"
#include "jsp-early-error.h"
#include "opcodes-native-call.h"
static idx_t temp_name, max_temp_name;
@ -221,43 +220,6 @@ tmp_operand (void)
return ret;
}
static uint8_t
name_to_native_call_id (operand obj)
{
if (obj.type != OPERAND_LITERAL)
{
return OPCODE_NATIVE_CALL__COUNT;
}
if (lit_literal_equal_type_cstr (lit_get_literal_by_cp (obj.data.lit_id), "LEDToggle"))
{
return OPCODE_NATIVE_CALL_LED_TOGGLE;
}
else if (lit_literal_equal_type_cstr (lit_get_literal_by_cp (obj.data.lit_id), "LEDOn"))
{
return OPCODE_NATIVE_CALL_LED_ON;
}
else if (lit_literal_equal_type_cstr (lit_get_literal_by_cp (obj.data.lit_id), "LEDOff"))
{
return OPCODE_NATIVE_CALL_LED_OFF;
}
else if (lit_literal_equal_type_cstr (lit_get_literal_by_cp (obj.data.lit_id), "LEDOnce"))
{
return OPCODE_NATIVE_CALL_LED_ONCE;
}
else if (lit_literal_equal_type_cstr (lit_get_literal_by_cp (obj.data.lit_id), "wait"))
{
return OPCODE_NATIVE_CALL_WAIT;
}
return OPCODE_NATIVE_CALL__COUNT;
}
static bool
is_native_call (operand obj)
{
return name_to_native_call_id (obj) < OPCODE_NATIVE_CALL__COUNT;
}
static op_meta
create_op_meta_for_res_and_obj (vm_instr_t (*getop) (idx_t, idx_t, idx_t), operand *res, operand *obj)
{
@ -331,29 +293,6 @@ create_op_meta_for_obj (vm_instr_t (*getop) (idx_t, idx_t), operand *obj)
return res;
}
static op_meta
create_op_meta_for_native_call (operand res, operand obj)
{
JERRY_ASSERT (is_native_call (obj));
op_meta ret;
switch (res.type)
{
case OPERAND_TMP:
{
const vm_instr_t instr = getop_native_call (res.data.uid, name_to_native_call_id (obj), INVALID_VALUE);
ret = create_op_meta_000 (instr);
break;
}
case OPERAND_LITERAL:
{
const vm_instr_t instr = getop_native_call (LITERAL_TO_REWRITE, name_to_native_call_id (obj), INVALID_VALUE);
ret = create_op_meta_100 (instr, res.data.lit_id);
break;
}
}
return ret;
}
static op_meta
create_op_meta_for_vlt (varg_list_type vlt, operand *res, operand *obj)
{
@ -365,14 +304,7 @@ create_op_meta_for_vlt (varg_list_type vlt, operand *res, operand *obj)
case VARG_CALL_EXPR:
{
JERRY_ASSERT (obj != NULL);
if (is_native_call (*obj))
{
ret = create_op_meta_for_native_call (*res, *obj);
}
else
{
ret = create_op_meta_for_res_and_obj (getop_call_n, res, obj);
}
ret = create_op_meta_for_res_and_obj (getop_call_n, res, obj);
break;
}
case VARG_FUNC_DECL:
@ -1121,7 +1053,6 @@ rewrite_varg_header_set_args_count (uint8_t args_count)
case VM_OP_FUNC_EXPR_N:
case VM_OP_CONSTRUCT_N:
case VM_OP_CALL_N:
case VM_OP_NATIVE_CALL:
{
const operand res = tmp_operand ();
om.op.data.func_expr_n.arg_list = args_count;

View File

@ -21,7 +21,6 @@
#include "jsp-mm.h"
#include "opcodes.h"
#include "opcodes-dumper.h"
#include "opcodes-native-call.h"
#include "parser.h"
#include "re-parser.h"
#include "scopes-tree.h"

View File

@ -260,7 +260,6 @@ generate_instr (scopes_tree tree, vm_instr_counter_t instr_pos, lit_id_hash_tabl
break;
}
case VM_OP_CALL_N:
case VM_OP_NATIVE_CALL:
case VM_OP_CONSTRUCT_N:
case VM_OP_FUNC_EXPR_N:
case VM_OP_DELETE_VAR:
@ -399,7 +398,6 @@ count_new_literals_in_instr (scopes_tree tree, vm_instr_counter_t instr_pos)
break;
}
case VM_OP_CALL_N:
case VM_OP_NATIVE_CALL:
case VM_OP_CONSTRUCT_N:
case VM_OP_FUNC_EXPR_N:
case VM_OP_DELETE_VAR:

View File

@ -1,93 +0,0 @@
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
* Copyright 2015 University of Szeged.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "opcodes-ecma-support.h"
#include "jrt.h"
#include "vm.h"
#include "opcodes.h"
#include "opcodes-native-call.h"
#include "jrt-libc-includes.h"
/**
* 'Native call' opcode handler.
*/
ecma_completion_value_t
opfunc_native_call (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx __attr_unused___ = instr.data.native_call.lhs;
const idx_t native_call_id_idx = instr.data.native_call.name;
const idx_t args_number = instr.data.native_call.arg_list;
const vm_instr_counter_t __attr_unused___ lit_oc = frame_ctx_p->pos;
JERRY_ASSERT (native_call_id_idx < OPCODE_NATIVE_CALL__COUNT);
frame_ctx_p->pos++;
JERRY_STATIC_ASSERT (OPCODE_NATIVE_CALL__COUNT < (1u << (sizeof (native_call_id_idx) * JERRY_BITSINBYTE)));
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
MEM_DEFINE_LOCAL_ARRAY (arg_values, args_number, ecma_value_t);
ecma_length_t args_read;
ecma_completion_value_t get_arg_completion = fill_varg_list (frame_ctx_p,
args_number,
arg_values,
&args_read);
if (ecma_is_completion_value_empty (get_arg_completion))
{
JERRY_ASSERT (args_read == args_number);
switch ((opcode_native_call_t)native_call_id_idx)
{
case OPCODE_NATIVE_CALL_LED_TOGGLE:
case OPCODE_NATIVE_CALL_LED_ON:
case OPCODE_NATIVE_CALL_LED_OFF:
case OPCODE_NATIVE_CALL_LED_ONCE:
case OPCODE_NATIVE_CALL_WAIT:
{
JERRY_UNIMPLEMENTED ("Device operations are not implemented.");
}
case OPCODE_NATIVE_CALL__COUNT:
{
JERRY_UNREACHABLE ();
}
}
}
else
{
JERRY_ASSERT (!ecma_is_completion_value_normal (get_arg_completion));
ret_value = get_arg_completion;
}
for (ecma_length_t arg_index = 0;
arg_index < args_read;
arg_index++)
{
ecma_free_value (arg_values[arg_index], true);
}
MEM_FINALIZE_LOCAL_ARRAY (arg_values);
return ret_value;
} /* opfunc_native_call */

View File

@ -1,32 +0,0 @@
/* Copyright 2014 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OPCODES_NATIVE_CALL_H
#define OPCODES_NATIVE_CALL_H
/**
* Identifier of a native call
*/
typedef enum
{
OPCODE_NATIVE_CALL_LED_TOGGLE,
OPCODE_NATIVE_CALL_LED_ON,
OPCODE_NATIVE_CALL_LED_OFF,
OPCODE_NATIVE_CALL_LED_ONCE,
OPCODE_NATIVE_CALL_WAIT,
OPCODE_NATIVE_CALL__COUNT
} opcode_native_call_t;
#endif /* !OPCODES_NATIVE_CALL_H */

View File

@ -19,7 +19,6 @@
#include "pretty-printer.h"
#include "jrt-libc-includes.h"
#include "lexer.h"
#include "opcodes-native-call.h"
#include "ecma-helpers.h"
#include "ecma-globals.h"
#include "serializer.h"
@ -279,28 +278,6 @@ pp_op_meta (const vm_instr_t *instrs_p,
break;
}
case VM_OP_NATIVE_CALL:
{
if (opm.op.data.native_call.arg_list == 0)
{
printf ("%s = ", VAR (1));
switch (opm.op.data.native_call.name)
{
case OPCODE_NATIVE_CALL_LED_TOGGLE: printf ("LEDToggle ();"); break;
case OPCODE_NATIVE_CALL_LED_ON: printf ("LEDOn ();"); break;
case OPCODE_NATIVE_CALL_LED_OFF: printf ("LEDOff ();"); break;
case OPCODE_NATIVE_CALL_LED_ONCE: printf ("LEDOnce ();"); break;
case OPCODE_NATIVE_CALL_WAIT: printf ("wait ();"); break;
default: JERRY_UNREACHABLE ();
}
}
else
{
vargs_num = opm.op.data.native_call.arg_list;
seen_vargs = 0;
}
break;
}
case VM_OP_CONSTRUCT_N:
{
if (opm.op.data.construct_n.arg_list == 0)
@ -403,7 +380,6 @@ pp_op_meta (const vm_instr_t *instrs_p,
switch (serializer_get_instr (instrs_p, start).op_idx)
{
case VM_OP_CALL_N:
case VM_OP_NATIVE_CALL:
case VM_OP_CONSTRUCT_N:
case VM_OP_FUNC_DECL_N:
case VM_OP_FUNC_EXPR_N:
@ -423,20 +399,6 @@ pp_op_meta (const vm_instr_t *instrs_p,
pp_printf ("%s = %s (", start_op, NULL, start, 1);
break;
}
case VM_OP_NATIVE_CALL:
{
pp_printf ("%s = ", start_op, NULL, start, 1);
switch (start_op.data.native_call.name)
{
case OPCODE_NATIVE_CALL_LED_TOGGLE: printf ("LEDToggle ("); break;
case OPCODE_NATIVE_CALL_LED_ON: printf ("LEDOn ("); break;
case OPCODE_NATIVE_CALL_LED_OFF: printf ("LEDOff ("); break;
case OPCODE_NATIVE_CALL_LED_ONCE: printf ("LEDOnce ("); break;
case OPCODE_NATIVE_CALL_WAIT: printf ("wait ("); break;
default: JERRY_UNREACHABLE ();
}
break;
}
case VM_OP_CONSTRUCT_N:
{
pp_printf ("%s = new %s (", start_op, NULL, start, 1);

View File

@ -38,11 +38,6 @@ VM_OP_3 (call_n, CALL_N,
function_var_idx, VM_OP_ARG_TYPE_VARIABLE,
arg_list, VM_OP_ARG_TYPE_INTEGER_CONST)
VM_OP_3 (native_call, NATIVE_CALL,
lhs, VM_OP_ARG_TYPE_VARIABLE,
name, VM_OP_ARG_TYPE_INTEGER_CONST,
arg_list, VM_OP_ARG_TYPE_INTEGER_CONST)
VM_OP_3 (construct_n, CONSTRUCT_N,
lhs, VM_OP_ARG_TYPE_VARIABLE,
name_lit_idx, VM_OP_ARG_TYPE_VARIABLE,