Skip to content

Commit 0c04f09

Browse files
Reduce register pressure by reusing registers, allocated for argument preparation instruction sequence.
Related issue: #186 JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan [email protected]
1 parent b72df5f commit 0c04f09

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

jerry-core/parser/js/opcodes-dumper.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,41 @@ dumper_finish_scope (void)
755755
STACK_DROP (temp_names, 1);
756756
}
757757

758+
/**
759+
* Handle start of argument preparation instruction sequence generation
760+
*
761+
* Note:
762+
* Values of registers, allocated for the code sequence, are not used outside of the sequence,
763+
* so they can be reused, reducing register pressure.
764+
*
765+
* To reuse the registers, counter of register allocator is saved, and restored then,
766+
* after finishing generation of the code sequence, using dumper_finish_varg_code_sequence.
767+
*
768+
* FIXME:
769+
* Implement general register allocation mechanism
770+
*
771+
* See also:
772+
* dumper_finish_varg_code_sequence
773+
*/
774+
void
775+
dumper_start_varg_code_sequence (void)
776+
{
777+
STACK_PUSH (temp_names, temp_name);
778+
} /* dumper_start_varg_code_sequence */
779+
780+
/**
781+
* Handle finish of argument preparation instruction sequence generation
782+
*
783+
* See also:
784+
* dumper_start_varg_code_sequence
785+
*/
786+
void
787+
dumper_finish_varg_code_sequence (void)
788+
{
789+
temp_name = STACK_TOP (temp_names);
790+
STACK_DROP (temp_names, 1);
791+
} /* dumper_finish_varg_code_sequence */
792+
758793
/**
759794
* Check that byte-code operand refers to 'eval' string
760795
*

jerry-core/parser/js/opcodes-dumper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ void dumper_free (void);
5858
void dumper_new_statement (void);
5959
void dumper_new_scope (void);
6060
void dumper_finish_scope (void);
61+
void dumper_start_varg_code_sequence (void);
62+
void dumper_finish_varg_code_sequence (void);
6163

6264
extern bool dumper_is_eval_literal (operand);
6365

jerry-core/parser/js/parser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,8 @@ parse_argument_list (varg_list_type vlt, operand obj, uint8_t *args_count, opera
521521
skip_newlines ();
522522
while (!token_is (close_tt))
523523
{
524+
dumper_start_varg_code_sequence ();
525+
524526
operand op;
525527

526528
if (vlt == VARG_FUNC_DECL
@@ -572,6 +574,8 @@ parse_argument_list (varg_list_type vlt, operand obj, uint8_t *args_count, opera
572574
}
573575

574576
args_num++;
577+
578+
dumper_finish_varg_code_sequence ();
575579
}
576580

577581
if (args_count != NULL)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2015 Samsung Electronics Co., Ltd.
2+
// Copyright 2015 University of Szeged.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
try
17+
{
18+
write.call(eval.constructor(encodeURIComponent.__proto__.__proto__.isPrototypeOf(operation.__proto__.__defineGetter__.call.__proto__.constructor.getOwnPropertyDescriptor.__proto__.bind.__proto__.__defineSetter__(performance.__proto__.toLocaleString.__proto__.bind(Date(Infinity,ReferenceError.__proto__.prototype.toString(),NaN,eval(Function(isNaN.__proto__.call.bind.__proto__.toString.call.constructor.__proto__.toString.__proto__.call(eval.toString.toLocaleString.apply(Boolean.prototype.constructor(ReferenceError.__proto__.prototype),readbuffer.constructor(parseFloat(SyntaxError.__proto__.__proto__())))))),quit.apply.constructor.__proto__(),escape.__proto__.__lookupSetter__.__proto__.__proto__.toString(),SyntaxError.__proto__.apply(parseFloat.constructor(),Math.imul())))))));
19+
assert (false);
20+
}
21+
catch (e)
22+
{
23+
assert (e instanceof ReferenceError);
24+
}

0 commit comments

Comments
 (0)